forked from CSCult/port-scanner-using-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample_port_Scanner.py
44 lines (31 loc) · 1.37 KB
/
Sample_port_Scanner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
@Author : Add Your Name Here
@Created On: Date On Which Projet is Created
@Title: Port Scanner
"""
#!/bin/python3 #Generally used in kali. (#! is shebang.)
# boiler plate of Sample Port Scanner
#It isn't perfect. We can't get everything in very beginning. Its a bad port scanner.
import sys
import socket
from datetime import datetime
#Define our target
if
target = #Translates hostname to IPv4
else:
print("Invalid amount of arguments.")
print("Syntax: python3 scanner.py <ip>")
#Add a pretty banner - Just for fun!!!
print("-" * 70)
print("Scanning target "+target)
print("Time started: "+str(datetime.now()))
print("-" * 70)
try:
for port in range(1,65535): #Depends on how much range you want to put in, if you know which port is open in that ip address... cause its so, lengthy and time taking.
#It returns an error indicator.
print("Checking port {}".format(port)) #It is optional depends on you whether wanna write it or not. Cause this line of code will umm... not gonna break suspense, run it see for yourself. Its fun!!!
if result == 0:
print("Port {} is open".format(port))
except #KeyboardInterrupt
except #hostname could not be resolved
except #couldn't connect to server