Skip to content

Commit

Permalink
Simple RTSP scanning script
Browse files Browse the repository at this point in the history
  • Loading branch information
robotrapta committed Jan 10, 2024
1 parent 45e115c commit 5d55090
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions api/rtsp_scan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Function to install necessary dependencies
install_dependencies() {
echo "Installing dependencies..."
sudo apt update
sudo apt install -y nmap net-tools
}

# Function to find subnets
find_subnets() {
# This function finds the subnets associated with your physical network interfaces
# It excludes loopback, virtual, and docker interfaces

# List all network interfaces except loopback and docker/virtual interfaces
local interfaces=$(ip -br link | awk '$1 !~ /^lo|docker|veth|br-|virbr/ {print $1}')

# Loop through each interface to find its subnet
for interface in $interfaces; do
# Get the IP address and subnet mask for each interface
ip -4 addr show $interface | grep -oP '(?<=inet\s)\d+(\.\d+){3}/\d+' | while read -r subnet; do
echo "$subnet"
done
done
}


# Function to scan a given subnet
scan_subnet() {
local subnet=$1
echo "Scanning subnet $subnet..."

# Run Nmap with Grepable output, then parse to list hosts with open port 554
nmap -p 554 --open -oG - $subnet | grep '/open/' | awk '{ print $2 }' | while read -r host; do
echo "rtsp://admin:admin@$host:554"
done
}


# Main execution
main() {
#install_dependencies
find_subnets | while read -r subnet; do
scan_subnet "$subnet"
done
}

main

0 comments on commit 5d55090

Please sign in to comment.