the-useless-one / pywerview

A (partial) Python rewriting of PowerSploit's PowerView
GNU General Public License v3.0
908 stars 113 forks source link

Encoding error in get-netlocalgroup and get-netshare #5

Closed ThePirateWhoSmellsOfSunflowers closed 8 years ago

ThePirateWhoSmellsOfSunflowers commented 8 years ago

Hi dude !

Because of non ascii characters (maudits français) in the group name or the description, PywerView is not able to diplay them. Same problem in get-netshare. Affected functions : get-netlocalgroup and get-netshare (but maybe in others too)

PywerView

$ ./pywerview.py get-netlocalgroup -w DOMAIN.lan -u administrator -p p@ssw0rd --dc-ip DC.domain.lan --computername COMPUTER01.domain.lan --list-groups

Traceback (most recent call last): File "./pywerview.py", line 285, in print '\n\n'.join(str(x) for x in results) File "./pywerview.py", line 285, in print '\n\n'.join(str(x) for x in results) File "/home/x/tools/pywerview/pywerview/rpcobjects.py", line 50, in str s += '{}: {}{}\n'.format(member[0], ' ' * (max_length - len(member[0])), member[1]) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 56: ordinal not in range(128)

Powerview

PS C:\Users\administrator> Get-NetLocalGroup -ComputerName COMPUTER01.domain.lan -ListGroup

Server Group SID Description

COMPUTER01.domain.lan Administrateurs S-X-X-XX-XXX Les membres du groupe Admi... COMPUTER01.domain.lan Duplicateurs S-X-X-XX-XXX Prend en charge la réplica... COMPUTER01.domain.lan Invités S-X-X-XX-XXX Les membres du groupe Invi... [..]

PywerView

$ ./pywerview.py get-netshare -w DOMAIN.lan -u administrator -p p@ssw0rd --computername COMPUTER01.domain.lan

Traceback (most recent call last): File "./pywerview.py", line 285, in print '\n\n'.join(str(x) for x in results) File "./pywerview.py", line 285, in print '\n\n'.join(str(x) for x in results) File "/home/x/tools/pywerview/pywerview/rpcobjects.py", line 50, in str s += '{}: {}{}\n'.format(member[0], ' ' * (max_length - len(member[0])), member[1]) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 15: ordinal not in range(128)

Powerview

PS C:\Users\administrator> get-netshare -ComputerName COMPUTER01.domain.lan

shi1_netname shi1_type shi1_remark

IPC$ 2147483651 IPC distant SharedDocs 0 print$ 0 Pilotes d'imprimantes ADMIN$ 2147483648 Administration à distance C$ 2147483648 Partage par défaut

(Oh for f*\ sake's Github...)

By the way awesome tool ahah :+1:

"I'm fear of encoding"

the-useless-one commented 8 years ago

Yes, "I'm fear of encoding" too :stuck_out_tongue:, but this commit should fix the issue. The encoding problem was only present when using RPC communications (impacket's LDAP seems to better handle encoding).

I also had to change how results were printed, so I took the opportunity to close #9 too.

Hope this works, if anyone else has a problem, feel free to reopen the issue.

Cheers,

Yannick