From c44a88b57a016dd9dc4540a1968e10e0e6068cc7 Mon Sep 17 00:00:00 2001 From: Brendan LE GLAUNEC Date: Mon, 31 Oct 2016 10:01:13 +0100 Subject: [PATCH] Add GST RTSP SERVER option --- README.md | 20 ++++++++++++++++++ cameradar_standalone/src/dispatcher.cpp | 22 ++++++++++++++------ cameradar_standalone/src/main.cpp | 6 ++++++ cameradar_standalone/src/tasks/brutelogs.cpp | 2 +- cameradar_standalone/src/tasks/parsing.cpp | 2 +- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b6888fb..1830401 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Of course, you can also call for individual tasks if you plug in a Database to C - [Under the hood](#under-the-hood) - [Contribution](#contribution) - [Next improvements](#next-improvements) +- [Frequently Asked Questions](#frequently-asked-questions) - [License](#license) ## Quick install @@ -222,6 +223,7 @@ If you're still in your console however, you can go even faster by using **vlc i * Needs either to be launched with the -d option or to use an advanced cache manager (DB, file, ...) with data already present * **"-v"** : Display Cameradar's version * **"-h"** : Display this help +* **"--gst-rtsp-server"** : Use this option if the bruteforce does not seem to work (only detects the username but not the path, or the opposite). This option will switch the order of the bruteforce to prioritize path over credentials, which is the way priority is handled for cameras that use GStreamer's RTSP server. ## Under the hood @@ -261,6 +263,24 @@ If you have other cool ideas, feel free to share them with me at [brendan.leglau - [ ] Make a standalone docker image - [ ] Push to DockerHub +## Frequently Asked Questions + +> My camera's credentials are guessed by Cameradar but the RTSP url is not! + +Your camera probably uses GST RTSP Server internally. Try the `--gst-rtsp-server` command-line option, and if it does not work, send me the cameradar output in DEBUG mode (`-l 1`) and I will help you. + +> Cameradar does not detect any camera! + +That means that either your cameras are not streaming in RTSP or that they are not on the subnetwork you are scanning. In most cases, CCTV cameras will be on a private subnetwork. Use the `-s` option to specify your camera's subnetwork. + +> Cameradar detects my cameras, but does not manage to access them at all! + +Maybe your cameras have been configured and the credentials / URL have been changed. Cameradar only guesses using default constructor values. However, you can use your own dictionary in which you just have to add your passwords. To do that, see how the [configuration](#configuration) works. + +> It does not compile + +You probably missed the part with the dependencies! Use the quick docker deployment, it will be easier and will not pollute your machine with useless dependencies! `;)` + ## License Copyright 2016 Etix Labs diff --git a/cameradar_standalone/src/dispatcher.cpp b/cameradar_standalone/src/dispatcher.cpp index 09af577..b8cc3aa 100644 --- a/cameradar_standalone/src/dispatcher.cpp +++ b/cameradar_standalone/src/dispatcher.cpp @@ -17,7 +17,7 @@ namespace etix { namespace cameradar { - using namespace std::chrono_literals; +using namespace std::chrono_literals; // The main loop of the binary void @@ -49,7 +49,7 @@ dispatcher::run() { // Waiting for task to cleanup / force stop command while ((signal_handler::instance().should_stop() not_eq stop_priority::force_stop) and doing_stuff()) { - std::this_thread::sleep_for(30ms); + std::this_thread::sleep_for(30ms); } worker.join(); } @@ -63,8 +63,13 @@ dispatcher::do_stuff() { queue.push_back(new etix::cameradar::parsing(cache, conf, nmap_output)); } if (opts.second.exist("-b")) { - queue.push_back(new etix::cameradar::brutelogs(cache, conf, nmap_output)); - queue.push_back(new etix::cameradar::brutepath(cache, conf, nmap_output)); + if (opts.second.exist("--gst-rtsp-server")) { + queue.push_back(new etix::cameradar::brutepath(cache, conf, nmap_output)); + queue.push_back(new etix::cameradar::brutelogs(cache, conf, nmap_output)); + } else { + queue.push_back(new etix::cameradar::brutelogs(cache, conf, nmap_output)); + queue.push_back(new etix::cameradar::brutepath(cache, conf, nmap_output)); + } } if (opts.second.exist("-t")) { queue.push_back(new etix::cameradar::thumbnail(cache, conf, nmap_output)); @@ -76,8 +81,13 @@ dispatcher::do_stuff() { !opts.second.exist("-g")) { queue.push_back(new etix::cameradar::mapping(cache, conf, nmap_output)); queue.push_back(new etix::cameradar::parsing(cache, conf, nmap_output)); - queue.push_back(new etix::cameradar::brutelogs(cache, conf, nmap_output)); - queue.push_back(new etix::cameradar::brutepath(cache, conf, nmap_output)); + if (opts.second.exist("--gst-rtsp-server")) { + queue.push_back(new etix::cameradar::brutepath(cache, conf, nmap_output)); + queue.push_back(new etix::cameradar::brutelogs(cache, conf, nmap_output)); + } else { + queue.push_back(new etix::cameradar::brutelogs(cache, conf, nmap_output)); + queue.push_back(new etix::cameradar::brutepath(cache, conf, nmap_output)); + } queue.push_back(new etix::cameradar::thumbnail(cache, conf, nmap_output)); queue.push_back(new etix::cameradar::stream_check(cache, conf, nmap_output)); } diff --git a/cameradar_standalone/src/main.cpp b/cameradar_standalone/src/main.cpp index 028eca9..57cbd08 100644 --- a/cameradar_standalone/src/main.cpp +++ b/cameradar_standalone/src/main.cpp @@ -41,6 +41,12 @@ parse_cmdline(int argc, char* argv[]) { opt_parse.optional("-g", "Check if the stream can be opened with GStreamer", false); opt_parse.optional("-v", "Display Cameradar's version", false); opt_parse.optional("-h", "Display this help", false); + opt_parse.optional( + "--gst-rtsp-server", + "Change the order of the bruteforce to match GST RTSP Server's implementation of " + "RTSP. Some cameras and RTSP servers will use this standard instead of the more " + "standard one. For more information, see the README.md file.", + false); opt_parse.execute(); if (opt_parse.exist("-h")) { diff --git a/cameradar_standalone/src/tasks/brutelogs.cpp b/cameradar_standalone/src/tasks/brutelogs.cpp index 2460665..19c3585 100644 --- a/cameradar_standalone/src/tasks/brutelogs.cpp +++ b/cameradar_standalone/src/tasks/brutelogs.cpp @@ -35,7 +35,7 @@ brutelogs::test_ids(const etix::cameradar::stream_model& stream, bool found = false; std::string path = stream.service_name + "://"; if (username != "" || password != "") { path += username + ":" + password + "@"; } - path += stream.address + ":" + std::to_string(stream.port); + path += stream.address + ":" + std::to_string(stream.port) + stream.route; LOG_INFO_("Testing ids : " + path, "brutelogs"); try { if (curl_describe(path, true)) { diff --git a/cameradar_standalone/src/tasks/parsing.cpp b/cameradar_standalone/src/tasks/parsing.cpp index 5ac5da1..fd9a95e 100644 --- a/cameradar_standalone/src/tasks/parsing.cpp +++ b/cameradar_standalone/src/tasks/parsing.cpp @@ -54,7 +54,7 @@ parsing::parse_camera(TiXmlElement* xml_host, std::vector& data) c stream.service_name = "closed"; stream.product = "closed"; } - data.push_back(stream); + if (!stream.state.compare("open")) data.push_back(stream); } }