Skip to content

Commit

Permalink
rtpbleed: added -o param
Browse files Browse the repository at this point in the history
  • Loading branch information
Pepelux committed Sep 20, 2024
1 parent ced8d61 commit 176e511
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
6 changes: 4 additions & 2 deletions bin/sippts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def main():
s.rtp = rtp
s.auth = auth
elif params[0] == "rtpbleed":
(cmd, ip, start_port, end_port, loops, payload, delay) = params
(cmd, ip, start_port, end_port, loops, payload, delay, ofile) = params

from sippts.rtpbleed import RTPBleed

Expand All @@ -678,8 +678,9 @@ def main():
s.loops = loops
s.payload = payload
s.delay = delay
s.ofile = ofile
elif params[0] == "rtcpbleed":
(cmd, ip, start_port, end_port, delay) = params
(cmd, ip, start_port, end_port, delay, ofile) = params

from sippts.rtcpbleed import RTCPBleed

Expand All @@ -688,6 +689,7 @@ def main():
s.start_port = start_port
s.end_port = end_port
s.delay = delay
s.ofile = ofile
elif params[0] == "rtpbleedflood":
(cmd, ip, port, payload, verbose) = params

Expand Down
30 changes: 26 additions & 4 deletions src/sippts/lib/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
BWHITE = "\033[1;37;20m"
WHITE = "\033[0;37;20m"

local_version = "4.0.14"
local_version = "4.0.15"


def get_sippts_args():
Expand Down Expand Up @@ -2747,6 +2747,16 @@ def get_sippts_args():
"-i", metavar="IP", type=str, help="Target IP address", dest="ipaddr"
)

log = parser_rtpbleed.add_argument_group("Log")
log.add_argument(
"-o",
metavar="FILE",
type=str,
help="Save data into a log file",
dest="ofile",
default="",
)

other = parser_rtpbleed.add_argument_group("Other options")
other.add_argument(
"-s",
Expand Down Expand Up @@ -2817,6 +2827,16 @@ def get_sippts_args():
"-i", metavar="IP", type=str, help="Target IP address", dest="ipaddr"
)

log = parser_rtcpbleed.add_argument_group("Log")
log.add_argument(
"-o",
metavar="FILE",
type=str,
help="Save data into a log file",
dest="ofile",
default="",
)

other = parser_rtcpbleed.add_argument_group("Other options")
other.add_argument(
"-s",
Expand Down Expand Up @@ -3989,10 +4009,11 @@ def get_sippts_args():
SP = SP + 1
if EP % 2 != 0:
EP = EP + 1
LOOPS = args.loops
LOOPS = args.loops
PAYLOAD = args.payload
DELAY = args.delay
return COMMAND, IPADDR, SP, EP, LOOPS, PAYLOAD, DELAY
OFILE = args.ofile
return COMMAND, IPADDR, SP, EP, LOOPS, PAYLOAD, DELAY, OFILE
elif COMMAND == "rtcpbleed":
if args.help == 1:
parser_rtcpbleed.print_help()
Expand All @@ -4014,7 +4035,8 @@ def get_sippts_args():
if EP % 2 == 0:
EP = EP + 1
DELAY = args.delay
return COMMAND, IPADDR, SP, EP, DELAY
OFILE = args.ofile
return COMMAND, IPADDR, SP, EP, DELAY, OFILE
elif COMMAND == "rtpbleedflood":
if args.help == 1:
parser_rtpbleedflood.print_help()
Expand Down
20 changes: 19 additions & 1 deletion src/sippts/rtcpbleed.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self):
self.start_port = "10000"
self.end_port = "20000"
self.delay = "1"
self.ofile = ""

self.c = Color()

Expand All @@ -44,6 +45,10 @@ def start(self):
)
print(self.c.WHITE)

if self.ofile != "":
f = open(self.ofile, "a+")
f.write(f"Target IP: {self.ip}\n")

# Create a UDP socket
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand All @@ -57,7 +62,8 @@ def start(self):
byte_array = bytearray.fromhex(message)
port = self.start_port

while True:
# while True:
while port < self.end_port + 2:
try:
host = (str(self.ip), port)

Expand All @@ -76,16 +82,28 @@ def start(self):
print(
f"{self.c.WHITE}received {str(size)} bytes from target port {str(rport)}"
)

if self.ofile != "":
f.write(f"received {str(size)} bytes from target port {str(rport)}\n")
except:
# No data available
pass
except KeyboardInterrupt:
print(f"{self.c.YELLOW}\nYou pressed Ctrl+C!")
print(self.c.WHITE)
if self.ofile != "":
f.write("\n")
f.close()
exit()
except:
pass

port += 2
if port > self.end_port:
port = self.start_port

print(self.c.WHITE)

if self.ofile != "":
f.write("\n")
f.close()
14 changes: 14 additions & 0 deletions src/sippts/rtpbleed.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self):
self.loops = "4"
self.payload = "0"
self.delay = "50"
self.ofile = ""

self.c = Color()

Expand All @@ -52,6 +53,10 @@ def start(self):
)
print(self.c.WHITE)

if self.ofile != "":
f = open(self.ofile, "a+")
f.write(f"Target IP: {self.ip}\n")

# Create a UDP socket
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand Down Expand Up @@ -117,16 +122,25 @@ def start(self):
print(
f"{self.c.WHITE} [-] SSRC: {ssrc} - Timestamp: {timestamp} - Seq number: {seq}"
)
if self.ofile != "":
f.write(f"received {str(size)} bytes from target port {str(rport)} - loop {str(loop)} - SSRC: {ssrc} - Timestamp: {timestamp} - Seq number: {seq}\n")
except:
# No data available
continue
except KeyboardInterrupt:
print(f"{self.c.YELLOW}\nYou pressed Ctrl+C!")
print(self.c.WHITE)
if self.ofile != "":
f.write("\n")
f.close()
exit()
except:
pass

port += 2

print(self.c.WHITE)

if self.ofile != "":
f.write("\n")
f.close()
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.14
4.0.15

0 comments on commit 176e511

Please sign in to comment.