- Python
- JSON
- Virtual Studio Code
Here is the completed code, we import the socket library which is used to specify we are using IPv4 via the "AF_INET" method and "SOCK_STREAM" which specifies it being TCP and that there will be a TCP Handshake:
We create a function which scans the port using the socket variable we created and it checks to see if the socket does not connect using "connect_ex" print that its closed. Else print that its open if it connects:
We will be scanning the ports of this site "www.hackthissite.org" as an example, to get the ip we ping the site in our command prompt:
Now we run the code and follow the input instructions we made, we add the IP which we got from the cmd:
And then we input the port we want to scan to see if its open or closed, in this case we will check port 21 and it appears to be open:
This Concludes This Automation Python Script Project!
NOTE: You can add onto this and make it more complex, or use these methonds to automate other tasks!