derv82 / wifite2

Rewrite of the popular wireless network auditor, "wifite"
GNU General Public License v2.0
6.45k stars 1.32k forks source link

UnicodeEncodeError: 'ascii' codec can't encode character '\xb4' in position 57: ordinal not in range(128) #92

Closed strasharo closed 6 years ago

strasharo commented 6 years ago

Tried to launch wifite2 in a recent ArchLinux which has Python 3.6.5 installed by default:

[root@bbbe wifite2]# python --version
Python 3.6.5
[root@bbbe wifite2]# 

[root@bbbe wifite2]# ./Wifite.py 
Traceback (most recent call last):
  File "./Wifite.py", line 5, in <module>
    wifite.run()
  File "/root/work/wifite2/wifite/wifite.py", line 255, in run
    w.print_banner()
  File "/root/work/wifite2/wifite/wifite.py", line 228, in print_banner
    ''' % Configuration.version)
  File "/root/work/wifite2/wifite/util/color.py", line 49, in pl
    Color.p('%s\n' % text)
  File "/root/work/wifite2/wifite/util/color.py", line 38, in p
    sys.stdout.write(Color.s(text))
UnicodeEncodeError: 'ascii' codec can't encode character '\xb4' in position 57: ordinal not in range(128)
[root@bbbe wifite2]# 

Using python2 instead resolved the issue:

[root@bbbe wifite2]# python2 Wifite.py 
  .               .    
.´  ·  .     .  ·  `.  wifite 2.1.5
:  :  :  (¯)  :  :  :  automated wireless auditor
`.  ·  ` /¯\ ´  ·  .´  https://github.com/derv82/wifite2
  `     /¯¯¯\     ´    

 [+] looking for wireless interfaces
derv82 commented 6 years ago

Looks like \xb4 is the symbol for ´ which isn't supported in ASCII.

I'm guessing there's a router near you with an ESSID that contains ´ ... I haven't found a router that allows non-ASCII characters yet, so I have had a hard time testing this.

I'll try to reproduce locally via unit tests.

derv82 commented 6 years ago

See latest version (2.1.6) which should support non-ASCII symbols in ESSIDs

strasharo commented 6 years ago

Still getting it with the latest code from git:

[root@bbbe wifite2]# git pull
Already up to date.
[root@bbbe wifite2]# ./Wifite.py 
Traceback (most recent call last):
  File "./Wifite.py", line 5, in <module>
    wifite.run()
  File "/root/work/wifite2/wifite/wifite.py", line 255, in run
    w.print_banner()
  File "/root/work/wifite2/wifite/wifite.py", line 228, in print_banner
    ''' % Configuration.version)
  File "/root/work/wifite2/wifite/util/color.py", line 49, in pl
    Color.p('%s\n' % text)
  File "/root/work/wifite2/wifite/util/color.py", line 38, in p
    sys.stdout.write(Color.s(text))
UnicodeEncodeError: 'ascii' codec can't encode character '\xb4' in position 57: ordinal not in range(128)
[root@bbbe wifite2]# python --version
Python 3.6.6
[root@bbbe wifite2]# 
derv82 commented 6 years ago

I'm having a hard time reproducing this...

$sudo python3 -V
Python 3.6.6

$sudo python3 Wifite.py -x
  .               .    
.´  ·  .     .  ·  `.  wifite 2.1.7
:  :  :  (¯)  :  :  :  automated wireless auditor
`.  ·  ` /¯\ ´  ·  .´  https://github.com/derv82/wifite2
  `     /¯¯¯\     ´    

Wifite.py: error: unrecognized arguments: -x

Can you try running wifite with this environment variable first, to see if it fixes the issue?

$ PYTHONIOENCODING=utf-8:surrogateescape ./Wifite.py

Or maybe try just printing the ` character, hopefully will narrow down where the problem is:

python -c 'import sys; sys.stdout.write("\xb4\n")'
strasharo commented 6 years ago

Just updated wifite to the latest from git and an OS update bumped the python version to 3.7.0 and the issue went away. Thanks a lot for your help.