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

Python 3.5 UnicodeDecodeError #56

Closed
RomaEcho opened this issue Oct 11, 2015 · 12 comments
Closed

Python 3.5 UnicodeDecodeError #56

RomaEcho opened this issue Oct 11, 2015 · 12 comments

Comments

@RomaEcho
Copy link

Hi, trying to launch spoofmac on python3.5, windows 8.
command spoof-mac -help works correct,
but spoof-mac list :

C:\Python35\Scripts> spoof-mac list
Traceback (most recent call last):
File "C:\Python35\Scripts\spoof-mac.py", line 138, in
sys.exit(main(arguments, root_or_admin))
File "C:\Python35\Scripts\spoof-mac.py", line 76, in main
list_interfaces(args, spoofer)
File "C:\Python35\Scripts\spoof-mac.py", line 56, in list_interfaces
for port, device, address, current_address in spoofer.find_interfaces(targets=targets):
File "c:\python35\lib\site-packages\spoofmac\interface.py", line 185, in find_interfaces
output = self.get_ipconfig_all()
File "c:\python35\lib\site-packages\spoofmac\interface.py", line 149, in get_ipconfig_all
return result.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8d in position 2: ordinal not in range(128)

@thewood
Copy link
Contributor

thewood commented Oct 12, 2015

are you running the script with admin priv?

@feross
Copy link
Owner

feross commented Oct 12, 2015

It appears that that's the issue. Run the script as an admin.

@feross feross closed this as completed Oct 12, 2015
@RomaEcho
Copy link
Author

I definitely launch command prompt with admin priv, dont know what the problem...

@feross
Copy link
Owner

feross commented Oct 16, 2015

Okay, re-opening.

@feross feross reopened this Oct 16, 2015
@pteek
Copy link
Collaborator

pteek commented Nov 6, 2015

2.0.6 is working on my windows 7 system. Will look into this.

@Akarius
Copy link

Akarius commented Jan 12, 2016

Same error here. spoofMAC 2.1.1 with python 2.7.10 on Win7 as admin.
Traceback (most recent call last):
File "spoof-mac.py", line 4, in
import('pkg_resources').run_script('spoofmac==2.1.1', 'spoof-mac.py')
File "build\bdist.win32\egg\pkg_resources__init__.py", line 745, in run_script
File "build\bdist.win32\egg\pkg_resources__init__.py", line 1677, in run_script
File "C:\Python\Python27\lib\site-packages\spoofmac-2.1.1-py2.7.egg\EGG-INFO\scripts\spoof-mac.py", line 138, in

File "C:\Python\Python27\lib\site-packages\spoofmac-2.1.1-py2.7.egg\EGG-INFO\scripts\spoof-mac.py", line 76, in main

File "C:\Python\Python27\lib\site-packages\spoofmac-2.1.1-py2.7.egg\EGG-INFO\scripts\spoof-mac.py", line 56, in list_i
nterfaces

File "build\bdist.win32\egg\spoofmac\interface.py", line 266, in find_interfaces
File "build\bdist.win32\egg\spoofmac\interface.py", line 230, in get_ipconfig_all
UnicodeDecodeError: 'ascii' codec can't decode byte 0x93 in position 46: ordinal not in range(128)

@Akarius
Copy link

Akarius commented Jan 12, 2016

Just checked in code...and I find why.
In the code of interface.py, subprocess.popen is use to get the output of ipconfig /all
My system is in french, there are accented characters in the results and the decode('ascii') fails.

@feross
Copy link
Owner

feross commented Jan 12, 2016

@Akarius Thanks for digging into this. I don't write Python very often, so I don't know how to fix this. If you send a PR, I will merge it and release a new version.

@feross feross closed this as completed Jan 12, 2016
@Akarius
Copy link

Akarius commented Jan 14, 2016

@feross I manage to make "spoof-mac.py list" working by altering the encoding of the output to remove the accented characters. I got no result. The problem is that there are many searches for strings like "Physical Address" and "adapter" in the ipconfig /all output (in interface.py) and these are language-dependants and will only work in english and no other languages. You should add a note about it in the README.md to avoid confusion.
As this project is about spoofing and not getting your MAC address, a solution would be to use netifaces to get infos about the adapter(s) instead of using subprocess with ipconfig. netifaces does a good job for this but is not included in the standard distribution of python, you have to add it (easy_install and pip can do it easily)

@feross
Copy link
Owner

feross commented Feb 7, 2016

@Akarius PR welcome for the doc fix. Also, if you're interested in becoming a maintainer I'll add you.

@Marshall13
Copy link

Marshall13 commented May 22, 2017

image

I have exactly the same problem..Has anyone found a solution?
My system is also French ^^ I do not know if there is a link

@junglist565
Copy link

junglist565 commented Jan 20, 2018

I solved the problem by changing the charset from "ascii" to "latin1" on Windows 10 (my system is italian :D ).
You also have to change the regex in find_interfaces(self, targets=None) method in your language, by comparing the original English output with yours.

In my case it's something like this:

# search for specific adapter gobble through mac address
details = re.findall("Scheda (.*?):[\\n\\r]+(.*?)\\s*Indirizzo fisico[^\\d]+(\\s\\S+)", output, re.DOTALL)

In any case the script seems to work fine, but in facts it doesn't change the MAC of the specified device (by typing ipconfig /all command nothing has changed).

Anyway it works fine on Linux (I never tried on MacOS), but on Windows has some bugs

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

7 participants