Penetration Test - Using_Scripting_in_Pen_Testing(6)
作者:互联网
Python Scripts
DEMO
portscan.py
import sys, socket
target = sys.argv[1]
minport = int(sys.argv[2])
maxport = int(sys.argv[3])
def porttry(cur_target, port):
try:
s.connect((cur_target, port))
return True
except:
return None
for i in range(minport, maxport+1):
s = socket.socket(2, 1) #socket.AF_INET, socket.SOCK_STREAM
value = porttry(target, i)
if value != None:
print("Port opened on %d" % i)
Run the following command:
sudo python portscan.py 192.168.2.22 20 80
QUICK REVIEW
- Python is another powerful object-oriented language
- Python is a popular language because it's easy to write very powerful programs in just a few lines of code
- Unlike many other languages, Python depends on indentation to define blocks.
标签:socket,Python,Testing,argv,sys,int,Pen,Penetration,target 来源: https://www.cnblogs.com/keepmoving1113/p/14129499.html