其他分享
首页 > 其他分享> > Penetration Test - Using_Scripting_in_Pen_Testing(6)

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

image-20201213182356873

QUICK REVIEW

标签:socket,Python,Testing,argv,sys,int,Pen,Penetration,target
来源: https://www.cnblogs.com/keepmoving1113/p/14129499.html