-
Notifications
You must be signed in to change notification settings - Fork 0
/
packetshark.py
79 lines (64 loc) · 2.87 KB
/
packetshark.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import socket
print("Write Ip Address")
IPA = input("Ip >")
print("Write Port")
PORTA = int(input("Port >"))
print(f"Ip Is: {IPA} Port Is: {PORTA}")
def Seleksiyon():
while True:
print("Welcome To Yev Group PacketShark")
print("Modes Is TCP and UDP")
kuesciyon = input("Select Mode ->").strip().lower()
if kuesciyon == 'tcp':
print("DPL(DataPacketLoop) or RM(RawMessage) Choose One:")
tcpmodeselection = input("Select Mode -->").strip().lower()
if tcpmodeselection in ['dpl', 'datapacketloop']:
print("Write Loop Number")
tcpdpl = int(input("Write Loop Number --->"))
DPLS = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
DPLS.connect((IPA, PORTA))
for i in range(tcpdpl):
try:
tcpdplpack = b'GET / HTTP/1.1\r\nHost: ' + IPA.encode() + b'\r\n\r\n'
DPLS.sendall(tcpdplpack)
except Exception as e:
print(f"Error: {e}")
response = DPLS.recv(50).decode()
status_line = response.split('\r\n')[0]
status_code = status_line.split(' ')[1]
print(f"HTTPRC: {status_code}")
print(f"{tcpdpl} Packet Sended")
DPLS.close()
elif tcpmodeselection in ['rm', 'rawmessage']:
RMtcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
RMtcp.connect((IPA, PORTA))
print("Raw Message")
rmmsg = input("Message --->")
RMtcp.sendall(rmmsg.encode())
RMtcp.close()
elif kuesciyon == 'udp':
print("DPL(DataPacketLoop) or RM(RawMessage) Choose One:")
udpmodeselection = input("Select Mode -->").strip().lower()
if udpmodeselection in ['dpl', 'datapacketloop']:
print("Write Loop Number")
udpdpl = int(input("Write Loop Number --->"))
UDPLS = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
for x in range(udpdpl):
try:
udpdplpack = b'GET / HTTP/1.1\r\nHost: ' + IPA.encode() + b'\r\n\r\n'
UDPLS.sendto(udpdplpack, (IPA, PORTA))
except Exception as e:
print(f"Error: {e}")
UDPLS.close()
elif udpmodeselection in ['rm', 'rawmessage']:
RMudp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
print("Write Message")
rmumsg = input("Message --->")
RMudp.sendto(rmumsg.encode(), (IPA, PORTA))
RMudp.close()
else:
print("Select A Mode")
else:
print("Select A Mode")
Seleksiyon()
input("Press Enter For Exit")