byt3bl33d3r / CrackMapExec

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

AttributeError: 'int' object has no attribute 'decode' #34

Closed byt3bl33d3r closed 8 years ago

byt3bl33d3r commented 8 years ago

Originally reported by @maaaaz in #28

I'm also experiencing that bug, which is not directly related to encoding but only type:

$ python crackmapexec_bug.py -d adyolo -u administrator -p "<password>" 192.168.11.136 --sessions
[*] 192.168.11.136:445 is running Windows 6.3 Build 9600 (name:DC01) (domain:adyolo)
[+] 192.168.11.136:445 Login successful adyolo\administrator:<password>
[+] 192.168.11.136:445 DC01 Current active sessions:
sesi502_cltype_name 
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_bug.py", line 2926, in connect
    print "{} {}".format(fname, yellow(session[fname]))
  File "crackmapexec_bug.py", line 87, in yellow
    return colored(text.decode('utf8'), 'yellow', attrs=['bold'])
AttributeError: 'int' object has no attribute 'decode'
<Greenlet at 0xb682bb6cL: connect('192.168.11.136')> failed with AttributeError

I was able to fix it by modifying the following line from:

print "{} {}".format(fname, yellow(session[fname]))

to:

print "{} {}".format(fname, yellow(str(session[fname])))
$ python crackmapexec_bug.py -d adyolo -u administrator -p "<password>" 192.168.11.136 --sessions
[*] 192.168.11.136:445 is running Windows 6.3 Build 9600 (name:DC01) (domain:adyolo)
[+] 192.168.11.136:445 Login successful adyolo\administrator:<password>
[+] 192.168.11.136:445 DC01 Current active sessions:
sesi502_cltype_name 
sesi502_time 0
sesi502_user_flags 0
sesi502_username administrator
sesi502_idle_time 0
sesi502_num_opens 0
sesi502_cname 192.168.11.130
sesi502_transport 
sesi502_cltype_name 
sesi502_time 0
sesi502_user_flags 0
sesi502_username administrator
sesi502_idle_time 0
sesi502_num_opens 1
sesi502_cname 192.168.11.130
sesi502_transport

By the way has the result presentation changed ? Wasn't it with columns before ?

byt3bl33d3r commented 8 years ago

@maaaaz should be fixed now