From 47f34e486b76976a7f348fd99479858ef650a729 Mon Sep 17 00:00:00 2001 From: David Westgate Date: Thu, 13 Jun 2024 14:05:05 -0700 Subject: [PATCH] update rtp script --- final/scripts/rtp1.py | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 final/scripts/rtp1.py diff --git a/final/scripts/rtp1.py b/final/scripts/rtp1.py new file mode 100644 index 0000000..8024f66 --- /dev/null +++ b/final/scripts/rtp1.py @@ -0,0 +1,65 @@ +import sys +from scapy.all import sniff, send, IP, IPv6, Packet, Raw, Ether, sendp, base64_bytes, hex_bytes,bytes_base64 +from scapy.layers.inet import UDP +from scapy.layers.rtp import RTP, bind_layers +from datetime import datetime + +def invert_byte(byte): + return ~byte & 0xFF + +def modify_packet(packet: Packet): + global modifications + global seen + + + udp: Packet = packet[UDP] + # udp.show() + if RTP in udp: + rtp: Packet = udp[RTP] + # load: bytes = rtp.load + if rtp.payload_type == 96: + print("96") + # payload: bytes = rtp.payload.load + # pretty = bytes_base64(payload) + # print(payload) + # hex: str = payload.hex() + # new_hex = hex[::-1] + # print(hex) + # print() + # print(new_hex) + # print(type(new_payload)) + # rtp.payload = Raw(hex_bytes(new_hex)) + original_payload = bytes(rtp.payload) + new_payload_hex = "deadbeef" # New payload in hex format + new_payload = bytes.fromhex(new_payload_hex) + rtp.payload = Raw(new_payload) + udp.len = len(udp) + udp.chksum = None # Recalculate checksum + # payload[6] = invert_byte(payload[6]) + else: + print('npe') + + + + seen += 1 + sendp(packet, iface=sys.argv[1]) + + +if __name__ == "__main__": + modifications = 0 + seen = 0 + if len(sys.argv) != 2: + print(f"Usage: {sys.argv[0]} ") + sys.exit(1) + + interface = sys.argv[1] + + start_time = datetime.now() + print(f"Script started at: {start_time.strftime('%Y-%m-%d %H:%M:%S')}") + bind_layers(UDP, RTP, sport=6970) + packets = sniff(filter="udp port 6970", iface=interface, timeout=60*1, prn=modify_packet) + + end_time = datetime.now() + print(f"Script ended at: {end_time.strftime('%Y-%m-%d %H:%M:%S')}") + print(f"{modifications} ip(v6) packets modified") + print(f"{seen} total ip(v6) packets seen") \ No newline at end of file