Thursday, March 8, 2018

Pentest via cellular network (IV): port scanning with Python-nmap


- Layout for this exercise (Smartphone and Raspberry Pi / SIM card / Modem):

1 - Installing Python-Map on the Raspeberry Pi

- python-nmap is a python library which helps in using Nmap port scanner.

- It allows to easilly manipulate nmap scan results and will be a perfect tool for systems administrators who want to automatize scanning task and reports. 

- It also supports nmap script outputs.

- For further information:

- Python-nmap works on top of Nmap, so let's make sure that Nmap is previosly installed:

- Downloading python-nmap:

- Uncompressing:

- Setting up and installing:

2 - Testing python-nmap with Python interactive mode

- Now, let's check its funcionality scanning the port 22 of the localhost Raspberry Pi, invoking python-nmap from Python:

- The SSH port 22 is in "open" status:

3 - Writing a Python script using python-nmap

- This Python script uses python-nmap for scanning, and it is based on the documentation provided by the python-nmap official website:

- Let's notice that the final section of the script just indicates to scan the localhost port 22:

- Running the script the result is successful: