问题描述
我正在编写一个用于更改MAC地址的程序 (我怀疑这是shell = True创建此循环) 我正在从Udemy课程中学到这一点,在他的程序中他没有使用shell = True。当我尝试它给我一个错误 这是该疑问的链接 FileNotFoundError: [Errno 2] No such file or directory: 'ifconfig'
#! /usr/bin/python3.5
import subprocess
interface = input("Enter Interface of Your Choice: ")
mac_chg = input("Enter New Mac Address: ")
print("[+]Changing Mac ADDRESS of " + interface + " to " + mac_chg)
subprocess.call(["sudo ifconfig",interface,"down"],shell=True)
subprocess.call(["sudo ifconfig","hw","ether",mac_chg],"up"],shell=True)
subprocess.call(["sudo ifconfig"],shell=True)
但这不能提供正确的输出,我无法理解为什么请帮助 终端输出在这里
kali@kali:~/PycharmProjects/hello$ python3 main.py
Enter Interface of Your Choice: eth0
Enter New Mac Address: 00:23:76:23:23:11
[+]Changing Mac ADDRESS of eth0 to 00:23:76:23:23:11
[sudo] password for kali:
eth0: flags=4163<UP,broADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe23:ff90 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:23:ff:90 txqueuelen 1000 (Ethernet)
RX packets 4 bytes 770 (770.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 27 bytes 2313 (2.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 18 bytes 950 (950.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 18 bytes 950 (950.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 18 bytes 950 (950.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 18 bytes 950 (950.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)