Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Port to Python 3 #317

Closed
sbrun opened this issue Sep 20, 2019 · 27 comments
Closed

Port to Python 3 #317

sbrun opened this issue Sep 20, 2019 · 27 comments
Assignees

Comments

@sbrun
Copy link

sbrun commented Sep 20, 2019

Hello,
Python 2.x will no longer be supported by their upstream developers in 2020. Thus Debian developers are actively removing Python 2 support in Debian Testing with the goal of getting rid of Python 2 in Debian 11 (bullseye).
Kali is tracking Debian Testing and is thus affected by this. You should consider to switch crackmapexec to Python 3.

FWIW this is tracked in https://gitlab.com/kalilinux/packages/crackmapexec/issues/1 on the Kali side.

@byt3bl33d3r byt3bl33d3r self-assigned this Sep 20, 2019
@byt3bl33d3r
Copy link
Owner

byt3bl33d3r commented Sep 20, 2019

I am aware, efforts on this have been ongoing for a while I've been getting side tracked with some other projects of mine. Next month (October 2019) will be the official "Port CME to Python3" Month.

@byt3bl33d3r byt3bl33d3r changed the title Should swith to Python 3 Port to Python 3 Sep 20, 2019
@mpgn
Copy link
Contributor

mpgn commented Nov 10, 2019

I was ready to do it, but noticed that pywerview is not ported to python3 so I don't see how it is possible to port CME to python3 :'(

@mpgn
Copy link
Contributor

mpgn commented Nov 10, 2019

Turns out I started to migrate the project to python3 https://github.com/mpgn/CrackMapExec/tree/python3

Of course, I migrate the pywerview to python3 too.

Here is a preview for tonight !

image

@mpgn
Copy link
Contributor

mpgn commented Nov 11, 2019

I'm starting the fire #323 :)

@byt3bl33d3r
Copy link
Owner

Damn, this is crazy. Thanks for the help!

@Reelix
Copy link

Reelix commented Dec 3, 2019

Tried an install on 3.8 - Failed on https://github.com/dlitz/pycrypto - Which hasn't received a commit in the past 6 years and likely never will :p

@mpgn
Copy link
Contributor

mpgn commented Dec 3, 2019

Very strange since CME doesn't use pycrypto anymore 333f1c4 ...

@rhertzog
Copy link

rhertzog commented Jan 16, 2020

Hello, what's the current status for the Python 3 port ? It's getting harder for us (Kali) to keep crackmapexec with Python 2, Debian has already dropped the Python 2 version of impacket.

https://www.dlitz.net/software/pycrypto/ is available for Python 3 in Debian/Kali at least, even if it hasn't changed since a long time, its setup.py indicates Python 3 support. There are a couple of patches in the Debian package though: https://sources.debian.org/src/python-crypto/2.6.1-13/debian/patches/

Anyway I don't think that pycrypto should be a blocker.

@mpgn
Copy link
Contributor

mpgn commented Jan 16, 2020

Hi @rhertzog CME is already ported to python3, we are waiting for the approval of @byt3bl33d3r to merge into the branch python3 of CME.

The project has also the dependency pywerview (python2 project) the-useless-one/pywerview#34 where I'm also waiting for the PR (we don't even need to be on the master branch) - but this part is not a blocker since we can use my fork of their repo.

More info: #323

As for the pycrypto problem, I've tested CME python3 in Kali and I didn't encountered the problem described by Reelix.

@rhertzog
Copy link

@mpgn Do you consider both of your PR as ready? If yes, we can already package your forks in Kali until we have proper upstream releases.

@mpgn
Copy link
Contributor

mpgn commented Jan 18, 2020

Hello @rhertzog

I've contact directly @byt3bl33d3r and he tells me that he has to deal with other issues first. He didn't forget us, he just has more important priorites :)

Do you consider both of your PR as ready? If yes, we can already package your forks in Kali until we have proper upstream releases.

Not an ideal solution because I'm afraid people will still open issue on this github while the issue maybe related to the python3 CME project.
I've hoped the branch be merged even if some features (not related to python3) are missing (gevent over asyncio, only thirdparty with pip) but unfortunately no merge possible I guess.

I've tested to run my PR on latest Kali using this lines and CME is working fine on my side.

git clone --recursive https://github.com/mpgn/CrackMapExec && cd CrackMapExec
git submodule update --recursive
python3 setup.py install
cme

@blshkv
Copy link

blshkv commented Feb 5, 2020

Hi @mpgn , thanks a lot for taking the initiative. I'm having a minor issue with python3, clould you have a look at the following please:

/usr/bin/python3.6 /var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/temp/tmpjti65h7a.py
  File "/usr/lib64/python3.6/site-packages/cme/data/invoke-vnc/vncexec.py", line 235
    print 'Ip addr required for reverse connection'
                                                  ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Ip addr required for reverse connection')?

  File "/usr/lib64/python3.6/site-packages/cme/data/invoke-vnc/gen_buffer.py", line 15
    print res
            ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(res)?

removing /var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/temp/tmpjti65h7a.py
writing byte-compilation script '/var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/temp/tmpe5n5gbs4.py'
/usr/bin/python3.6 /var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/temp/tmpe5n5gbs4.py
  File "/usr/lib64/python3.6/site-packages/cme/data/invoke-vnc/vncexec.py", line 235
    print 'Ip addr required for reverse connection'
                                                  ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Ip addr required for reverse connection')?

  File "/usr/lib64/python3.6/site-packages/cme/data/invoke-vnc/gen_buffer.py", line 15
    print res
            ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(res)?

removing /var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/temp/tmpe5n5gbs4.py
running install_egg_info
Copying crackmapexec.egg-info to /var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/image/_python3.6/usr/lib64/python3.6/site-packages/crackmapexec-5.0.0.dev0-py3.6.egg-info
running install_scripts
Installing cme script to /var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/image/_python3.6/usr/lib/python-exec/python3.6
Installing cmedb script to /var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/image/_python3.6/usr/lib/python-exec/python3.6
Installing crackmapexec script to /var/tmp/portage/net-analyzer/crackmapexec-3.1.5_p20200124/image/_python3.6/usr/lib/python-exec/python3.6
  File "/usr/lib64/python3.6/site-packages/cme/data/invoke-vnc/vncexec.py", line 235
    print 'Ip addr required for reverse connection'
                                                  ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Ip addr required for reverse connection')?

  File "/usr/lib64/python3.6/site-packages/cme/data/invoke-vnc/gen_buffer.py", line 15
    print res
            ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(res)?

 * python3_6: running distutils-r1_run_phase distutils-r1_python_install_all

@blshkv
Copy link

blshkv commented Feb 5, 2020

There is also one more issue with slinky.py module. It requires pylnk package, however it does not support python3.
Update: there is a fork with python3 support: https://github.com/strayge/pylnk/commits/master

@mpgn
Copy link
Contributor

mpgn commented Feb 14, 2020

Hello @blshkv I fix the problem in this commit 6ad9713

@blshkv
Copy link

blshkv commented Feb 15, 2020

@mpgn thanks. Can you also fix a bunch of prints which I posted above? Update: all errors are related to the invoke-vnc external module.

@mpgn
Copy link
Contributor

mpgn commented Feb 15, 2020

PR submitted to the Invoke-vnc project @blshkv :)

@blshkv
Copy link

blshkv commented Feb 17, 2020

@mpgn I have merged all patches, managed to install, start and tested some basic functionality.
Great job!

@mpgn
Copy link
Contributor

mpgn commented Apr 20, 2020

Closing this one since the python3 PR is merged 🖌️

@mpgn mpgn closed this as completed Apr 20, 2020
@blshkv
Copy link

blshkv commented Apr 20, 2020

sorry, I can't find this commit and the merge pull request is still opened

@mpgn
Copy link
Contributor

mpgn commented Apr 20, 2020

can you elaborate ?

@blshkv
Copy link

blshkv commented Apr 20, 2020

I have pulled the latest git version https://github.com/byt3bl33d3r/CrackMapExec.git master, e294a72 commit and still see the same errors as reported. I can still apply the same patch from the pull request

@mpgn
Copy link
Contributor

mpgn commented Apr 20, 2020

I see, I forgot about this one @blshkv but I already take care of the problem. Nevertheless, I cannot do much if no one wants to merge my PR . . .

klsecservices/Invoke-Vnc#2

@mpgn
Copy link
Contributor

mpgn commented Apr 20, 2020

We can use my fork in the meantime :)

@blshkv
Copy link

blshkv commented Apr 20, 2020

Please keep this bug open until someone will find a power to press that damn merge button :-)

@mpgn mpgn reopened this Apr 20, 2020
@byt3bl33d3r
Copy link
Owner

@blshkv Just for my clarity, are you getting errors when packaging CME cause of the VNC script thing?

@blshkv
Copy link

blshkv commented Apr 20, 2020

@byt3bl33d3r hm... I just realized that you have merged #323 pull request yesterday. My apologies, this bug can be closed!

These are remaining external modules:
klsecservices/Invoke-Vnc#2
the-useless-one/pywerview#36

@mpgn
Copy link
Contributor

mpgn commented Apr 21, 2020

This should do the work :)

@mpgn mpgn closed this as completed Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants