|
|
@ -84,7 +84,18 @@ class Sniffer(Thread): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: make this function be able to craft full custom packet including |
|
|
|
# source IP, sport, protocol, flags, payload, etc. |
|
|
|
def craft_send_payload(dip, dest_port): |
|
|
|
|
|
|
|
payload = "" |
|
|
|
send_pkt = IP(dst=dip, src="10.0.0.17") / TCP(dport=dest_port,sport=40404,flags="S") / "AAAAAAAA" |
|
|
|
send_bytes = bytes(send_pkt) |
|
|
|
payload = send_bytes |
|
|
|
|
|
|
|
print("debug send payload: " + str(payload)) |
|
|
|
|
|
|
|
return payload |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -93,7 +104,7 @@ def get_send_payload(): |
|
|
|
|
|
|
|
payload = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" |
|
|
|
|
|
|
|
send_pkt = IP(dst="9.9.9.9", src="10.0.0.161") / ICMP() / "AAAAAAAA" |
|
|
|
send_pkt = IP(dst="9.9.9.9", src="10.0.0.161") / TCP(dport=80,sport=40404,flags="S") / "AAAAAAAA" |
|
|
|
send_bytes = bytes(send_pkt) |
|
|
|
payload = send_bytes |
|
|
|
|
|
|
@ -104,7 +115,8 @@ def get_send_payload(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def send_debug_packet(sniffer): |
|
|
|
|
|
|
|
def send_debug_packet(sniffer, is_custom): |
|
|
|
|
|
|
|
debug_port = sniffer.debug_sport |
|
|
|
debug_ip = sniffer.debug_src |
|
|
@ -118,8 +130,20 @@ def send_debug_packet(sniffer): |
|
|
|
return |
|
|
|
|
|
|
|
print("sending debug packet to " + str(debug_ip) + ":" + str(debug_port)) |
|
|
|
send_payload = "" |
|
|
|
|
|
|
|
if is_custom: |
|
|
|
|
|
|
|
print("\n\nEnter dest ip for packet..") |
|
|
|
dip = input("Enter IP: ") |
|
|
|
print("\n\nEnter dest port for packet..") |
|
|
|
dport = input("Enter port: ") |
|
|
|
send_payload = craft_send_payload(dip, int(dport)) |
|
|
|
|
|
|
|
else: |
|
|
|
send_payload = get_send_payload() |
|
|
|
|
|
|
|
|
|
|
|
send_payload = get_send_payload() |
|
|
|
packet = IP(dst=debug_ip) / TCP(dport=debug_port, sport=server_port, flags='PA', seq=send_seq, ack=send_ack) / send_payload |
|
|
|
send(packet, iface="ens18") |
|
|
|
print("sent debug packet: ") |
|
|
@ -142,8 +166,9 @@ def main(): |
|
|
|
|
|
|
|
print("Enter action to take..") |
|
|
|
print("1. Keep sniffing") |
|
|
|
print("2. Send packet back") |
|
|
|
print("3. Quit") |
|
|
|
print("2. Send test packet back") |
|
|
|
print("3. Craft custom packet to send from genie") |
|
|
|
print("4. Quit") |
|
|
|
|
|
|
|
answer = input("Enter answer: ") |
|
|
|
|
|
|
@ -151,8 +176,10 @@ def main(): |
|
|
|
print("sleeping for sniffer..") |
|
|
|
time.sleep(5) |
|
|
|
elif answer == "2": |
|
|
|
send_debug_packet(sniffer) |
|
|
|
send_debug_packet(sniffer, False) |
|
|
|
elif answer == "3": |
|
|
|
send_debug_packet(sniffer, True) |
|
|
|
elif answer == "4": |
|
|
|
print("ending the sniffer") |
|
|
|
done = True |
|
|
|
|
|
|
|