the-useless-one / pywerview

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

Fixed trailing \x00 while retrieving local disks #64

Closed Anhydrite closed 7 months ago

Anhydrite commented 7 months ago

Hey, I was playing with NetExec and i figured out that disks contained trailing \x00 at the end of their name as shown in the screenshot. As this is the only place where \x00 is present, i think that might be unexpected.

image

The PR simply consists of adding .rstrip("\x00") when a new disk has been found

ThePirateWhoSmellsOfSunflowers commented 7 months ago

Hello,

I'm sorry but your PR is not working on my testing environment.

$ ./pywerview.py get-localdisks  -w domain.lan  -u adm -p password --computername 10.0.0.1 -l debug
[DEBUG] pywerview_main_logger.LDAPRequester - __init__ : LDAP sign and seal are not supported
[DEBUG] pywerview_main_logger.LDAPRequester - __init__ : TLS channel binding is not supported
Traceback (most recent call last):
  File "/home/xxxxxxxxxx/tools/pywerview/./pywerview.py", line 23, in <module>
    main()
  File "/home/xxxxxxxxxx/tools/pywerview/pywerview/cli/main.py", line 636, in main
    results = args.func(**parsed_args)
  File "/home/xxxxxxxxxx/tools/pywerview/pywerview/cli/helpers.py", line 242, in get_localdisks
    return requester.get_localdisks()
  File "/home/xxxxxxxxxx/tools/pywerview/pywerview/requester.py", line 601, in wrapper
    return f(*args, **kwargs)
  File "/home/xxxxxxxxxx/tools/pywerview/pywerview/functions/net.py", line 746, in get_localdisks
    results.append(rpcobj.Disk(disk.rstrip("\x00")))
AttributeError: 'DISK_INFO' object has no attribute 'rstrip'

Moreover, please, change this behaviour within the object file (rpcobjects.py), not in the function. Thanks

Anhydrite commented 7 months ago

Well ok, my bad on that, pushed too fast. It should be good now !

$ python3 pywerview.py get-localdisks -u vagrant -p vagrant --computername 192.168.56.10 -l debug
[DEBUG] pywerview_main_logger.LDAPRequester - __init__ : LDAP sign and seal are not supported
[DEBUG] pywerview_main_logger.LDAPRequester - __init__ : TLS channel binding is not supported
disk: C:

(I hope commits name doesnt matter)

ThePirateWhoSmellsOfSunflowers commented 7 months ago

Thanks for your contribution! Squashed + merged your commits.

:sunflower: