-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathportscan.py
54 lines (46 loc) · 1.47 KB
/
portscan.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
45
46
47
48
49
50
51
52
53
54
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#+--------------------+
#|Creators : |
#|-Drarqua GHS Storm |
#|-Rebel Yell |
#+--------------------+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
import time
import socket
import os
import sys
import string
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
def restart_program():
python = sys.executable
os.execl(python, python, * sys.argv)
curdir = os.getcwd()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
address = raw_input( "Choose your target:" )
start = input( "From port:" )
stop = input( "To port:" )
openportsL = []
def portscan(address, port):
ps = socket.socket()
print ("Searching for open ports")
try:
ps.connect((address, port))
print ("[Port %s is OPEN.]") %(port)
openportsL[1:1] = [port]
return True
except socket.error, msg:
return False
s.close()
print ("Port Scan Started ... It may take time")
for port in range(start, stop):
portscan(address, port)
print ("Port Scann completed")
print ("The open ports are :")
print ( openportsL )
if __name__ == "__main__":
answer = raw_input("Do you want to Portscan again?")
if answer.strip() in "y Y yes Yes YES".split():
restart_program()
else:
os.system(curdir+"\Deq\main.py")
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#