current position:Home>Writing nmap scanning tool in Python -- multithreaded version

Writing nmap scanning tool in Python -- multithreaded version

2022-01-31 01:49:35 Official account Growth path of Xiaobo test

「 This is my participation 11 The fourth of the yuegengwen challenge 3 God , Check out the activity details :2021 One last more challenge

precondition :

use Python Code a simple nmap Scan tool

Python The basic operation of multithreading in

I learned before python The use of multithreading in , Also learned to pass socket modular , Scan whether a port of the server is open . The port range of the server is 0~65535, If you want to scan all ports , Longer time consuming . Suppose that the timeout length of each port scan is set to 0.5s, Then the time required to scan all ports is :65535*0.5≈9h . therefore , The scanned script needs to be optimized , You can consider using multithreading to execute .

Script before optimization :

Script after adding multithreading :

Script optimization effect :

1、 Scan local open ports , About ten seconds to complete

Problems with scripts :

1、 Create in batch once in the script 65536 Threads , Some computers may not be able to carry

2、 The scanned results are not accurate , Especially when scanning remote servers , The effect is more obvious , It's easier to see the problem

copyright notice
author[Official account Growth path of Xiaobo test],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/01/202201310149335020.html

Random recommended