byt3bl33d3r / CrackMapExec

A swiss army knife for pentesting networks
BSD 2-Clause "Simplified" License
8.46k stars 1.64k forks source link

Username and password unicode support #14

Closed maaaaz closed 9 years ago

maaaaz commented 9 years ago

@byt3bl33d3r,

I faced some unicode errors regarding user names. In the following example, I do have an user named 'Invité' (french for 'guest').

(venvcrackmapexec)root@kali:~/Partage/CrackMapExec# python -i crackmapexec.py -t 2 192.168.11.129 -u admin -p admin --shares --users
[*] 192.168.11.129:445 is running Windows 6.1 Build 7601 (name:WIN-P3B5MV8U1LT) (domain:WIN-P3B5MV8U1LT)
[+] 192.168.11.129:445 Login successful 'WIN-P3B5MV8U1LT\admin:admin'
[+] 192.168.11.129:445 WIN-P3B5MV8U1LT Dumping users (rid:user):
1000: Admin
500: Administrateur
Traceback (most recent call last):
  File "/root/venvcrackmapexec/local/lib/python2.7/site-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "crackmapexec.py", line 2872, in connect
    print_att('{}: {}'.format(user[1], user[0]))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)
<Greenlet at 0xb6754b6cL: connect('192.168.11.129')> failed with UnicodeEncodeError

I have been able to fix it by changing the following code section (line 2872): from

for user in users:
                    print_att('{}: {}'.format(user[1], user[0]))

to

for user in users:
                    print_att(u'{}: {}'.format(user[1], user[0]))

I guess that this lack of unicode support is not limited to this module (dumping usernames). Maybe you could try to find a way to include that support in your lamba print_* functions.

Cheers

byt3bl33d3r commented 9 years ago

@maaaaz thanks, this should be easy to fix, will push a patch later today

byt3bl33d3r commented 9 years ago

@maaaaz this should be fixed now , thanks