【问题标题】:I am currently working on a MAC changer script, I am running into an error我目前正在处理 MAC 转换器脚本,我遇到了一个错误
【发布时间】:2021-09-15 10:23:18
【问题描述】:

这是我的代码:

import subprocess
 
import optparse

parser = optparse.OptionParser()

parser.add_option("-i", "--interface", dest="interface", help="interface to change MAC adress")

parser.add_option("-m", "--mac", dest="mac", help="new mac adress")

(options, arguments) = parser.parse_args()

interface = options.interface

mac = options.mac 

#print("(+) Your mac adress for " + interface + " has been changed to " + mac)

subprocess.call(["sudo ifconfig",interface, "down"])

subprocess.call(["sudo ifconfig",interface, "hw", "ether", mac])

subprocess.call(["sudo ifconfig",interface, "up"])

这是错误:

Traceback (most recent call last):

  File "mac_changer.py", line 10, in <module>
    subprocess.call(["sudo ifconfig",interface, "down"])

  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:

  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,

  File "/usr/lib/python3.8/subprocess.py", line 1639, in _execute_child

    self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not NoneType

我使用的是 Ubuntu 20.04。

【问题讨论】:

    标签: python penetration-testing


    【解决方案1】:

    您似乎没有为interface 赋值,因此它是NoneType。确保使用 -i 调用脚本并指定网络接口。

    【讨论】:

      猜你喜欢
      • 2020-03-15
      • 2022-11-22
      • 2021-05-18
      • 1970-01-01
      • 2020-03-22
      • 1970-01-01
      • 1970-01-01
      • 2020-11-03
      • 2016-12-03
      相关资源
      最近更新 更多