Penetration Testing

Penetration Testing using Python Code

Nowadays, programming is considered as a very important element in the industry especially IT. In this post, I would like to share a brief knowledge about Penetration Testing using Python code which can be useful for other people out there.

Below are the example from the server side program which you can modify based on your server environment:

socket.listen() is normally a method that will ensure that the server will listen mode to the port that been assigned on the python code. The response from the Python code above will prompt to you showing whether the host can listen to the port itself.

Extending the above code to show the connection will be connected to the server. For the msg.encode section, I have use based64 as the encryption connection.

The user can also inside the following code where we will ask the target’s machine so that we using the socket.listen to create socket.

Once we are completed with the code above, we can save it as anything for it to run. For my case, i save it as socket.py and be advise to be using Python3 version.

*Reminder: Python2.7 is not recommended to use if you are using Mac OS.

The objective of the Python code here is to build a simple to use of port scanner from zero. This code also can be able to use within Nmap module where it will reach the goal of getting port scan.

In nmap, the python would be the same function as nmap -vvv <ip address> to gain information about the target’s machine. This activity is very important in early Penetration Testing if they are proceeding with BlackBox Penetration.

Leave a Reply

Your email address will not be published. Required fields are marked *