|
|
@ -26,6 +26,9 @@ class Sniffer(Thread): |
|
|
|
self.debug_src = "" |
|
|
|
self.debug_sport = 0 |
|
|
|
|
|
|
|
self.last_ack = 0 |
|
|
|
self.last_seq = 0 |
|
|
|
|
|
|
|
|
|
|
|
def run(self): |
|
|
|
self.socket = conf.L2listen( |
|
|
@ -73,22 +76,44 @@ class Sniffer(Thread): |
|
|
|
self.debug_src = packet[IP].src |
|
|
|
self.debug_sport = tcp_sport |
|
|
|
|
|
|
|
self.last_ack = packet[TCP].ack |
|
|
|
self.last_seq = packet[TCP].seq |
|
|
|
|
|
|
|
self.recv_count += 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_send_payload(): |
|
|
|
|
|
|
|
payload = "BBBBBBBBBBB" |
|
|
|
|
|
|
|
return payload |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def send_debug_packet(sniffer): |
|
|
|
|
|
|
|
debug_port = sniffer.debug_sport |
|
|
|
debug_ip = sniffer.debug_src |
|
|
|
|
|
|
|
send_seq = sniffer.last_ack |
|
|
|
send_ack = sniffer.last_seq |
|
|
|
|
|
|
|
|
|
|
|
if debug_port == 0 or debug_ip == '': |
|
|
|
print("There was no debug source connection to send to") |
|
|
|
return |
|
|
|
|
|
|
|
print("sending debug packet to " + str(debug_ip) + ":" + str(debug_port)) |
|
|
|
|
|
|
|
packet = IP(dst=debug_ip) / TCP(dport=debug_port, sport=server_port, flags='R') |
|
|
|
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: ") |
|
|
|
packet.show() |
|
|
|