Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to python3 #34

Open
wants to merge 10 commits into
base: master
from
Open

Migration to python3 #34

wants to merge 10 commits into from

Conversation

@mpgn
Copy link

mpgn commented Nov 11, 2019

Hello,

I migrate the project to python3, I didn't have tested all the functions so I set this Pull Request as Draft for now until i'm sure everything is migrated to python3.

@mpgn mpgn mentioned this pull request Nov 11, 2019
30 of 34 tasks complete
@mpgn mpgn marked this pull request as ready for review Nov 12, 2019
@byt3bl33d3r

This comment has been minimized.

Copy link
Contributor

byt3bl33d3r commented Nov 12, 2019

Also @the-useless-one , could we get Pywerview published to Pypi? I'll gladly help if needed :)

Thanks !

@ThePirateWhoSmellsOfSunflowers

This comment has been minimized.

Copy link
Contributor

ThePirateWhoSmellsOfSunflowers commented Nov 13, 2019

I think you forgot to migrate encode('hex') ;) btw, nice PR

Traceback (most recent call last):
  File "pywerview.py", line 24, in <module>
    main()
  File "/xxx/pywerview/pywerview/cli/main.py", line 466, in main
    x = str(x)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 130, in __str__
    member_value = '{}...'.format(member[1].encode('hex')[:100])
LookupError: 'hex' is not a text encoding; use codecs.encode() to handle arbitrary codecs

🌻

@mpgn

This comment has been minimized.

Copy link
Author

mpgn commented Nov 13, 2019

@ThePirateWhoSmellsOfSunflowers can you check again ?

@ThePirateWhoSmellsOfSunflowers

This comment has been minimized.

Copy link
Contributor

ThePirateWhoSmellsOfSunflowers commented Nov 13, 2019

Better but now you forgot a coma 😄

  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 130
    member_value = '{}...'.format(codecs.encode(member[1]'hex')[:100])
                                                             ^
SyntaxError: invalid syntax
@ThePirateWhoSmellsOfSunflowers

This comment has been minimized.

Copy link
Contributor

ThePirateWhoSmellsOfSunflowers commented Nov 13, 2019

🤷‍♂

Traceback (most recent call last):
  File "/usr/lib/python3.6/encodings/hex_codec.py", line 15, in hex_encode
    return (binascii.b2a_hex(input), len(input))
TypeError: a bytes-like object is required, not 'str'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/xxx/pywerview/pywerview/cli/main.py", line 466, in main
    x = str(x)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 130, in __str__
    member_value = '{}...'.format(codecs.encode(member[1],'hex')[:100])
TypeError: encoding with 'hex' codec failed (TypeError: a bytes-like object is required, not 'str')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/encodings/hex_codec.py", line 15, in hex_encode
    return (binascii.b2a_hex(input), len(input))
TypeError: a bytes-like object is required, not 'str'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "pywerview.py", line 24, in <module>
    main()
  File "/xxx/pywerview/pywerview/cli/main.py", line 471, in main
    print(results)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 139, in __repr__
    return str(self)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 130, in __str__
    member_value = '{}...'.format(codecs.encode(member[1],'hex')[:100])
TypeError: encoding with 'hex' codec failed (TypeError: a bytes-like object is required, not 'str')

🌻

@mpgn mpgn force-pushed the mpgn:master branch from ca2d759 to 7a505f5 Nov 13, 2019
@mpgn

This comment has been minimized.

Copy link
Author

mpgn commented Nov 13, 2019

I clean up and remove binascii. Let's try one more time 🗡

@ThePirateWhoSmellsOfSunflowers

This comment has been minimized.

Copy link
Contributor

ThePirateWhoSmellsOfSunflowers commented Nov 13, 2019

Eeeeeeet...non

Traceback (most recent call last):
  File "/xxx/pywerview/pywerview/cli/main.py", line 466, in main
    x = str(x)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 129, in __str__
    member_value = '{}...'.format(codecs.encode(bytes(member[1]),'hex')[:100])
TypeError: string argument without an encoding

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pywerview.py", line 24, in <module>
    main()
  File "/xxx/pywerview/pywerview/cli/main.py", line 471, in main
    print(results)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 138, in __repr__
    return str(self)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 129, in __str__
    member_value = '{}...'.format(codecs.encode(bytes(member[1]),'hex')[:100])
TypeError: string argument without an encoding

🌻

@mpgn

This comment has been minimized.

Copy link
Author

mpgn commented Nov 13, 2019

I do it blindly, not ideal :'(

We will squash this at the end so all the commit will be merged in one aha

@ThePirateWhoSmellsOfSunflowers

This comment has been minimized.

Copy link
Contributor

ThePirateWhoSmellsOfSunflowers commented Nov 13, 2019

Hooray 🎉
Seems to work now, binary attributes are prefixed with a b but I think it's OK since these attributes are not very useful (and striped in the tostring method).

Screenshot from 2019-11-13 17-45-35

Maybe I'll have enough time to test others functions this week.

🌻

@ThePirateWhoSmellsOfSunflowers

This comment has been minimized.

Copy link
Contributor

ThePirateWhoSmellsOfSunflowers commented Nov 14, 2019

Traceback (most recent call last):
  File "/xxx/pywerview/pywerview/cli/main.py", line 466, in main
    x = str(x)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 108, in __str__
    member_value = (',\n' + ' ' * (max_length + 2)).join(codecs.encode(bytes(x, encoding='utf8'),'hex') for x in member[1])
TypeError: sequence item 0: expected str instance, bytes found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pywerview.py", line 24, in <module>
    main()
  File "/xxx/pywerview/pywerview/cli/main.py", line 471, in main
    print(results)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 138, in __repr__
    return str(self)
  File "/xxx/pywerview/pywerview/objects/adobjects.py", line 108, in __str__
    member_value = (',\n' + ' ' * (max_length + 2)).join(codecs.encode(bytes(x, encoding='utf8'),'hex') for x in member[1])
TypeError: sequence item 0: expected str instance, bytes found
@ThePirateWhoSmellsOfSunflowers

This comment has been minimized.

Copy link
Contributor

ThePirateWhoSmellsOfSunflowers commented Nov 14, 2019

The error is gone but now the output is f*cked up because \n are no longer interpreted.

[...]
msmqdigests:                b'c29XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,\n                            c29fYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY55,\n                          
[...]
@mpgn

This comment has been minimized.

Copy link
Author

mpgn commented Nov 14, 2019

let's try this one

@ThePirateWhoSmellsOfSunflowers

This comment has been minimized.

Copy link
Contributor

ThePirateWhoSmellsOfSunflowers commented Nov 14, 2019

Yes, this one is ok ! No more b in front of "binary" strings.

@mpgn

This comment has been minimized.

Copy link
Author

mpgn commented Nov 14, 2019

Yeah, it's better :)

@the-useless-one

This comment has been minimized.

Copy link
Owner

the-useless-one commented Nov 14, 2019

Hi all,

Thanks a lot for contributing to pywerview! As you can see, I don't really take the time to support this project, as my colleagues like to remind me (hi @ThePirateWhoSmellsOfSunflowers ❤️), so i'm glad to see that people still find it useful, and contribute to it :)

@byt3bl33d3r pywerview is in fact published to PyPI, but it's reeeally possible that it's not up to date with the latest additions. I'll try to find some time update everything. Also, I was wondering whether I should rename the functions, as they did in the dev version of PowerView (renaming every Get-Net* to Get-Domain* etc.). What do you think? They can easily create aliases in PowerShell, but it might be messy in Python. I don't really think a lot of users use pywerview's API so there shouldn't be a lot of breaking, but I don't know 🤷‍♂

Cheers,

Y

@mpgn

This comment has been minimized.

Copy link
Author

mpgn commented Dec 3, 2019

Any update on this @the-useless-one ?

@the-useless-one

This comment has been minimized.

Copy link
Owner

the-useless-one commented Dec 4, 2019

Hi @mpgn, @ThePirateWhoSmellsOfSunflowers and I are performing some internal tests later in the month. We'll have the occasion to test your PR, and I'll merge it if everything works properly.

Thanks a lot for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.