Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #59761
    jingjohn77
    Participant

    Error whiile running

    collisions 0\n\n’
    Traceback (most recent call last):
    File “/root/PycharmProjects/macChanger/Macchanger.py”, line 28, in <module>
    mac_address_search_result = re.compile(r”\w\w:\w\w:\w\w:\w\w:\w\w:\w\w”).search(ifconfig_result)
    TypeError: cannot use a string pattern on a bytes-like object

    my code

    import subprocess
    import optparse
    import re

    def get_arguments():
    parser = optparse.OptionParser()
    parser.add_option(“-i”, “–interface”, help=”interface to change its mac addreesses”, dest=”interface”)
    parser.add_option(“-m”, “–mac”, dest=”new_mac”, help=”new mac addreesses”)
    (options, arguments) = parser.parse_args()
    if not options.interface:
    parser.error(“[-] please specify an interface, se –help for more info.”)
    elif not options.new_mac:
    parser.error(“[-] please specify an mac, se –help for more info.”)
    return options

    def change_mac(interface, new_mac):
    subprocess.call([“ifconfig”, interface, “down”])
    subprocess.call([“ifconfig”, interface, “hw”, “ether”, new_mac])
    subprocess.call([“ifconfig”, interface, “up”])

    options=get_arguments()

    #change_mac(options.interface, options.new_mac)

    ifconfig_result = subprocess.check_output([“ifconfig”, options.interface])
    print(ifconfig_result)
    mac_address_search_result = re.search(r”\w\w:\w\w:\w\w:\w\w:\w\w:\w\w”,ifconfig_result)
    print(mac_address_search_result.group(0))

    I followed step by step, what is the issue?

    #59762
    jingjohn77
    Participant

    Oh Wait I got it, i was running python3 sorry never mind

    #59770
    diego
    Moderator

    Hi!

    Cool you got it!
    Diego

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