From acf56be035703654502c675ec69f8387265ec562 Mon Sep 17 00:00:00 2001 From: Joren Date: Wed, 23 Oct 2024 14:59:01 +0200 Subject: [PATCH] first commit --- README.md | 3 ++ rtspBrute.go | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 README.md create mode 100644 rtspBrute.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..3ee760f --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# RTSP Brute + +Simple program to brute for rtsp connections diff --git a/rtspBrute.go b/rtspBrute.go new file mode 100644 index 0000000..fe03eaf --- /dev/null +++ b/rtspBrute.go @@ -0,0 +1,89 @@ +package main + +import ( + "flag" + "fmt" + "os" + "os/exec" + "bufio" + "strings" + "sync" + "log" +) + +func main() { + targetURL := flag.String("t", "", "Target RTSP server URL (ex. rtsp://127.0.0.1/)") + usernamesFile := flag.String("u", "", "File with usernames") + passwordsFile := flag.String("p", "", "File with passwords") + flag.Parse() + + if *targetURL == "" || *usernamesFile == "" || *passwordsFile == "" { + fmt.Println("Usage: rtspBrute -t -u -p ") + return + } + + usernames, err := readLines(*usernamesFile) + if err != nil { + fmt.Printf("Error reading usernames file: %v\n", err) + return + } + + passwords, err := readLines(*passwordsFile) + if err != nil { + fmt.Printf("Error reading passwords file: %v\n", err) + return + } + + var wg sync.WaitGroup + parts := strings.SplitN(*targetURL, "://", 2) + if len(parts) == 2 { + protocol := parts[0] + ipAndPath := parts[1] + + ffprobePath, ffprobeErr := exec.LookPath("ffprobe") + if ffprobeErr != nil { + log.Println("ffprobe is not found in the PATH or current directory") + return + } + + for _, username := range usernames { + for _, password := range passwords { + modifiedURL := protocol + "://" + username + ":" + password + "@" + ipAndPath + cmd := exec.Command(ffprobePath, "-rtsp_transport", "tcp", modifiedURL) + wg.Add(1) + go func(username, password string) { + defer wg.Done() + + if err := cmd.Run(); err == nil { + fmt.Printf("Login successful: Username: %s, Password: %s\n", username, password) + } + }(username, password) + } + } + } else { + fmt.Printf("Invalid RTSP URL: %s\n", *targetURL) + } + + wg.Wait() +} + +func readLines(filename string) ([]string, error) { + file, err := os.Open(filename) + if err != nil { + return nil, err + } + defer file.Close() + + var lines []string + scanner := bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, strings.TrimSpace(scanner.Text())) + } + + if err := scanner.Err(); err != nil { + return nil, err + } + + return lines, nil +} +