- This topic has 3 replies, 2 voices, and was last updated 4 years, 7 months ago by Diego Pérez.
- AuthorPosts
- May 9, 2020 at 9:57 pm #36365Jay2thaworldParticipant
Hi,
I was following along with the video. I entered the code as shown but I am throwing these errors when running. I’ve reviewed countless times and cannot find where I went wrong:
#!/usr/bin/env python
import subprocess
import optparsedef change_mac(interface, new_mac):
print(“[+] Changing MAC Address for ” + interface + ” to ” + new_mac)subprocess.call([“ifconfig”, interface, “down”])
subprocess.call([“ifconfig”, interface, “hw”, “ether”, new_mac])
subprocess.call([“ifconfig”, interface, “up”])
subprocess.call([“ifconfig”, interface])parser = optparse.OptionParser()
parser.add_option(“-i”, “–interface”, dest=”interface”, help=”Interface to change it’s MAC Address”)
parser.add_option(“-m”, “–mac”, dest=”new_mac”, help=”New MAC Address”)(options, arguments) = parser.parse_args()
change_mac(options.interface, options.new_mac)
Here is the error:
/root/PycharmProjects/hello/venv/bin/python /root/PycharmProjects/hello/mac_changer.py
Traceback (most recent call last):
File “/root/PycharmProjects/hello/mac_changer.py”, line 21, in <module>
change_mac(options.interface, options.new_mac)
File “/root/PycharmProjects/hello/mac_changer.py”, line 7, in change_mac
print(“[+] Changing MAC Address for ” + interface + ” to ” + new_mac)
TypeError: can only concatenate str (not “NoneType”) to strProcess finished with exit code 1
May 10, 2020 at 6:32 am #36393Diego PérezModeratorHi Jay!
Can you share the command used to run the script?Also it’s important to run the code directly in kali’s terminal and not in PyCharm.
Let me know.
DiegoMay 15, 2020 at 1:27 pm #36939Jay2thaworldParticipantThank you for your response, I used both Python and Python 3 + the name of the file on my system to run the script. Both resulting in the error, I cannot seem to discover the issues in the two referenced lines.
May 16, 2020 at 7:07 am #37009Diego PérezModeratorHi!
Can you share the command used to run your code?
Let me know.
Diego - AuthorPosts
- You must be logged in to reply to this topic.