m57 / piescan

A simple fast port scanner for when you cant use Nmap on a pentest.
BSD 3-Clause "New" or "Revised" License
67 stars 25 forks source link

Port the project from Python 2.7 to Python 3 #7

Closed michaelmcmillan closed 3 years ago

michaelmcmillan commented 3 years ago

Considering Python 2.7 is no longer supported I have ported this project to Python 3. We want to use this port scanner on Azure Runbooks, and they do not support similar tools such as nmap.

I used the built-in 2to3 and reindent tool in Python to carry out the port.

wget https://raw.githubusercontent.com/python/cpython/master/Tools/scripts/reindent.py
python3 reindent.py piescan.py
2to3 piescan.py -w

Test that it worked under Python 3:

sudo python3 piescan.py -sU -t 127.0.0.1 -p 99-100
Password:

          piescan v1.1 -- https://www.twitter.com/@_g0dmode
        ---------------------------------------------------
            A simple, fast, lightweight TCP/UDP scanner

[ 15:19:54 - 29/12/2020 ] Scan started - Host: 127.0.0.1

Port            State           Reason
-----------------------------------------------------
100/udp         closed          ICMP Code 3
99/udp          closed          ICMP Code 3
peterezzo commented 3 years ago

I'm not involved with the project in any way but just some thoughts as I read this. First, all of the py2.6 compatibility code can be removed if you want to go straight python3 - the effect now is to run different code on python 3.6 or higher. You have also left some variables called xxx_todo_changeme in there. And finally if this code was merged as-is it would break python2 support, which is one of the reasons I use this.

m57 commented 3 years ago

I have done this now.