Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #36365
    Jay2thaworld
    Participant

    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 optparse

    def 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 str

    Process finished with exit code 1

    #36393
    Diego PérezDiego Pérez
    Moderator

    Hi 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.
    Diego

    #36939
    Jay2thaworld
    Participant

    Thank 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.

    #37009
    Diego PérezDiego Pérez
    Moderator

    Hi!
    Can you share the command used to run your code?
    Let me know.
    Diego

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.