- This topic has 2 replies, 2 voices, and was last updated 3 years ago by Diego Pérez.
- AuthorPosts
- November 2, 2021 at 4:06 am #59761jingjohn77Participant
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 objectmy code
import subprocess
import optparse
import redef 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 optionsdef 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?
November 2, 2021 at 4:14 am #59762jingjohn77ParticipantOh Wait I got it, i was running python3 sorry never mind
November 2, 2021 at 4:59 pm #59770Diego PérezModeratorHi!
Cool you got it!
Diego - AuthorPosts
- You must be logged in to reply to this topic.