int main(int argc, char* argv[]) { etix::tool::logger::get_instance("cameradar"); auto args = parse_cmdline(argc, argv); if (not args.first) return EXIT_FAILURE; print_version(); // configure file configuration path auto conf_path = std::string{}; if (not args.second.exist("-c")) { conf_path = etix::cameradar::default_configuration_path; LOG_WARN_("No custom path set, trying to use default path: " + conf_path, "main"); } else { conf_path = args.second["-c"]; } if (not args.second.exist("-l")) { etix::tool::logger::get_instance("cameradar").set_level(etix::tool::loglevel::INFO); LOG_INFO_("No log level set, using log level 2 (ignoring DEBUG)", "main"); } else { try { int level = std::stoi(args.second["-l"]); etix::tool::logger::get_instance("cameradar") .set_level(static_cast<etix::tool::loglevel>(level)); } catch (...) { LOG_ERR_("Invalid log level format, log level should be 1, 2, 4, 5 or 6", "main"); return EXIT_FAILURE; } } // Try to load the configuration auto conf = cmrdr::load(conf_path); if (not conf.first) { return EXIT_FAILURE; } LOG_INFO_("Configuration successfully loaded", "main"); // If one of the path is invalid, exit auto paths_ok = check_storage_path(conf.second.thumbnail_storage_path); if (not paths_ok) { return EXIT_FAILURE; } // Here we should get the cache manager but for now we will juste // make a dumb cache manager auto plug = std::make_shared<etix::cameradar::cache_manager>(conf.second.cache_manager_path, conf.second.cache_manager_name); if (not plug->make_instance()) { LOG_ERR_(std::string("Invalid cache manager "), "cameradar"); return false; } LOG_INFO_("Launching Cameradar, press CTRL+C to gracefully stop", "main"); etix::cameradar::dispatcher disp(conf.second, plug, args); disp.run(); LOG_WARN_("See ya !", "cameradar"); return EXIT_SUCCESS; }
static int validate_nla_stream(uint8_t *buf, size_t buflen) { struct nlattr *cur_attr; int remaining, attr_cnt = 0; cur_attr = (struct nlattr *) buf; remaining = buflen; while (nla_ok(cur_attr, remaining)) { attr_cnt++; cur_attr = nla_next(cur_attr, &remaining); } if (!attr_cnt) { LOG_ERR_("No valid attributes found in the input!\n"); return -EINVAL; } if (remaining) LOG_WARN_("%d invalid bytes at the end detected of the" " input. Skipping these..\n", remaining); LOG_NOTICE_("Found %d attributes in the input stream\n", attr_cnt); return 0; }
//! Tries to discover the right IDs on all RTSP streams in DB //! Uses the ids.json file to try different combinations bool brutelogs::run() const { LOG_INFO_( "Beginning bruteforce of the usernames and passwords task, it may " "take a while.", "brutelogs"); std::vector<etix::cameradar::stream_model> streams = (*cache)->get_streams(); bool doubleskip; size_t found = 0; for (const auto& stream : streams) { doubleskip = false; if (signal_handler::instance().should_stop() != etix::cameradar::stop_priority::running) break; if ((found < streams.size()) && ids_already_found(streams, stream)) { LOG_INFO_(stream.address + " : This camera's ids were already discovered in " "the database. Skipping to " "the next camera.", "brutelogs"); ++found; } else { for (const auto& username : conf.usernames) { if (doubleskip || signal_handler::instance().should_stop() != etix::cameradar::stop_priority::running) break; for (const auto& password : conf.passwords) { if (doubleskip || signal_handler::instance().should_stop() != etix::cameradar::stop_priority::running) break; if (test_ids(stream, password, username)) { ++found; doubleskip = true; } } } } } if (!found) { LOG_WARN_(no_ids_warning_, "brutelogs"); return false; } else LOG_INFO_("Found " + std::to_string(found) + " ids for " + std::to_string(streams.size()) + " cameras", "brutelogs"); return true; }