Below is a simple python program in linux to see if a port is open or close.
#!/usr/bin/python
import socket
ip = raw_input("Enter the IP Address: ")
port = input("Enter the Port Number: ")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if sock.connect_ex((ip,port)):
print "Port",port, "is closed"
else:
print "Port",port, "is open"
We will use which python.py to know about the location of python, so we can use it in hash bang.
next we are importing the socket library.
taking as input and port are self explanatory.
SOCKET constants and functions are used to get socket connected to sock variable.
connect_ex will throw an exception if the port is closed , and we are utilizing it to display "the port is closed"
else it will be open.
make it executable and run,...
I am not going into details, as there are many tutorials out there to learn the basics.
CYB3RTR0N
I Blog about Cyber Security including CTF Walkthroughs , cool helpful scripts , sometimes games.
Subscribe to:
Post Comments (Atom)
Scheduled Skype Message in Python
To send a message on Skype at a scheduled time, you can use the schedule library in Python along with the skype4py library to interact wit...
-
Below are the commands , to Decode and Encoded text from Base64 and Rot13. It is a handy and easy technique required in CTFs. Alternative...
-
WALKTHROUGH (spoiler) OF PRINTER HACKING 101 by swafox in Try Hack Me (tryhackme.com) Unit 1 introduction In This section th...
No comments:
Post a Comment