Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac_changer.py #86

Open
shakhboz997 opened this issue Feb 16, 2022 · 1 comment
Open

mac_changer.py #86

shakhboz997 opened this issue Feb 16, 2022 · 1 comment

Comments

@shakhboz997
Copy link

shakhboz997 commented Feb 16, 2022

can you help, where i made a mistake.

b'eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500\n inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255\n inet6 fe80::a00:27ff:fe50:4c14 prefixlen 64 scopeid 0x20\n ether 08:00:27:50:4c:14 txqueuelen 1000 (Ethernet)\n RX packets 8780 bytes 10354741 (9.8 MiB)\n RX errors 0 dropped 0 overruns 0 frame 0\n TX packets 6205 bytes 1055091 (1.0 MiB)\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0\n\n'
Traceback (most recent call last):
File "/root/PycharmProjects/mac_changer/mac_changer.py", line 34, in
current_mac = get_current_mac(options.interface)
File "/root/PycharmProjects/mac_changer/mac_changer.py", line 27, in get_current_mac
mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result)
File "/usr/lib/python3.9/re.py", line 201, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object

@Acetolyne
Copy link

Hi,

Without seeing the whole code I think the issue is you are passing in a byte array ( variable ifconfig_result)
This needs to be a string for re.search to work, then when you get the result mac_address_search_result you will need to get the nth index of it to return a string as it is an object still. so to review
convert ifconfig_result to string
use mac_address_search_result[0] to pass the resulting string of "08:00:27:50:4c:14" in your above example

Hope this helps resolve your issue, if it does resolve your issue please mark this issue as resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants