Created
August 17, 2020 20:58
-
-
Save leeyoungseok/ae95a3df13ad5c65cce35e97da347f4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # Scapy 로 TCP 연결 만들고 HTTP GET 메시지 전송 | |
from scapy.all import * | |
seq = random.randint(1025,65535) | |
sport = random.randint(1025,65535) | |
dport = 80 | |
ip_packet = IP(dst='168.188.126.81') | |
syn_packet = TCP(sport=sport, dport=dport, flags='S', seq=seq) | |
packet = ip_packet/syn_packet | |
synack_response = sr1(packet) | |
next_seq = seq + 1 | |
my_ack = synack_response.seq + 1 | |
ack_packet = TCP(sport=sport, dport=dport, flags='A', seq=next_seq, ack=my_ack) | |
send(ip_packet/ack_packet) | |
payload_packet = TCP(sport=sport, dport=dport, flags='PA', seq=next_seq, ack=my_ack) | |
payload = "GET / HTTP/1.0\r\nHOST: networks.cnu.ac.kr \r\n\r\n" | |
reply, error = sr(ip_packet/payload_packet/payload, multi=1, timeout=1) | |
for r in reply: | |
r[0].show2() | |
r[1].show2() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment