Rename subnet to target to avoid confusion (#70)
This commit is contained in:
committed by
Brendan Le Glaunec
parent
8c6c94cc34
commit
81b7e893dc
@@ -6,7 +6,7 @@
|
||||
"password": "root",
|
||||
"db_name": "cmrdr"
|
||||
},
|
||||
"subnets" : "localhost",
|
||||
"target" : "localhost",
|
||||
"ports" : "554,8554",
|
||||
"rtsp_url_file" : "/cameradar/conf/url.json",
|
||||
"rtsp_ids_file" : "/cameradar/conf/ids.json",
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace cameradar {
|
||||
static const std::string default_configuration_path = "conf/cameradar.conf.json";
|
||||
|
||||
static const std::string default_ports = "554,8554";
|
||||
static const std::string default_subnets = "localhost,168.0.0.0/24";
|
||||
static const std::string default_target = "localhost,168.0.0.0/24";
|
||||
static const std::string default_thumbnail_storage_path = "/tmp";
|
||||
static const std::string default_rtsp_url_file = "conf/url.json";
|
||||
static const std::string default_rtsp_ids_file = "conf/ids.json";
|
||||
@@ -37,7 +37,7 @@ static const std::string default_cache_manager_name = "dumb";
|
||||
|
||||
struct configuration {
|
||||
std::string thumbnail_storage_path;
|
||||
std::string subnets;
|
||||
std::string target;
|
||||
std::string rtsp_url_file;
|
||||
std::string rtsp_ids_file;
|
||||
std::string ports;
|
||||
@@ -51,14 +51,14 @@ struct configuration {
|
||||
|
||||
configuration() = default;
|
||||
configuration(const std::string& thumbnail_storage_path,
|
||||
const std::string& subnets,
|
||||
const std::string& target,
|
||||
const std::string& rtsp_url_file,
|
||||
const std::string& rtsp_ids_file,
|
||||
const std::string& cache_manager_path,
|
||||
const std::string& cache_manager_name,
|
||||
const std::string& ports)
|
||||
: thumbnail_storage_path(thumbnail_storage_path)
|
||||
, subnets(subnets)
|
||||
, target(target)
|
||||
, rtsp_url_file(rtsp_url_file)
|
||||
, rtsp_ids_file(rtsp_ids_file)
|
||||
, ports(ports)
|
||||
|
||||
@@ -136,10 +136,10 @@ serialize(const Json::Value& root) {
|
||||
else
|
||||
ret.second.ports = default_ports;
|
||||
|
||||
if (!root["subnets"].isNull())
|
||||
ret.second.subnets = root["subnets"].asString();
|
||||
if (!root["target"].isNull())
|
||||
ret.second.target = root["target"].asString();
|
||||
else
|
||||
ret.second.subnets = default_subnets;
|
||||
ret.second.target = default_target;
|
||||
|
||||
if (!root["rtsp_ids_file"].isNull())
|
||||
ret.second.rtsp_ids_file = root["rtsp_ids_file"].asString();
|
||||
@@ -229,8 +229,8 @@ load(const std::pair<bool, etix::tool::opt_parse>& args) {
|
||||
conf.first &= conf.second.load_url();
|
||||
conf.first &= conf.second.load_ids();
|
||||
|
||||
if (args.second.exist("-s")) conf.second.subnets = args.second["-s"];
|
||||
if (args.second.exist("-p")) conf.second.ports = args.second["-p"];
|
||||
if (args.second.exist("-s")) conf.second.target = args.second["-s"];
|
||||
if (args.second.exist("-p")) conf.second.target = args.second["-p"];
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ std::pair<bool, etix::tool::opt_parse>
|
||||
parse_cmdline(int argc, char* argv[]) {
|
||||
auto opt_parse = etix::tool::opt_parse{ argc, argv };
|
||||
|
||||
opt_parse.optional("-s", "Set subnets (e.g.: `172.16.0.0/24`)", true);
|
||||
opt_parse.optional("-s", "Set target (e.g.: `172.16.0.0/24`)", true);
|
||||
opt_parse.optional("-p", "Set ports (e.g.: `554,8554`)", true);
|
||||
opt_parse.optional("-c", "Path to the configuration file (-c /path/to/conf)", true);
|
||||
opt_parse.optional("-l", "Set log level (-l 4 will only show warnings and errors)", true);
|
||||
opt_parse.optional("-d", "Launch the discovery tool on the given subnet", false);
|
||||
opt_parse.optional("-d", "Launch the discovery tool on the given target", false);
|
||||
opt_parse.optional("-b", "Launch the bruteforce tool on all discovered devices", false);
|
||||
opt_parse.optional("-t", "Generate thumbnails from detected cameras", false);
|
||||
opt_parse.optional("-g", "Check if the stream can be opened with GStreamer", false);
|
||||
|
||||
@@ -34,16 +34,16 @@ nmap_is_ok() {
|
||||
}
|
||||
|
||||
// Launches and checks the return of the nmap command
|
||||
// Uses the subnets specified in the conf file to launch nmap
|
||||
// Uses the target specified in the conf file to launch nmap
|
||||
bool
|
||||
mapping::run() const {
|
||||
if (nmap_is_ok()) {
|
||||
std::string subnets = this->conf.subnets;
|
||||
std::replace(subnets.begin(), subnets.end(), ',', ' ');
|
||||
std::string target = this->conf.target;
|
||||
std::replace(target.begin(), target.end(), ',', ' ');
|
||||
LOG_INFO_("Nmap 6.0 or greater found", "mapping");
|
||||
LOG_INFO_("Beginning mapping task. This may take a while.", "mapping");
|
||||
std::string cmd =
|
||||
"nmap -T4 -A " + subnets + " -p " + this->conf.ports + " -oX " + nmap_output;
|
||||
"nmap -T4 -A " + target + " -p " + this->conf.ports + " -oX " + nmap_output;
|
||||
LOG_DEBUG_("Launching nmap : " + cmd, "mapping");
|
||||
bool ret = launch_command(cmd);
|
||||
if (ret)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace cameradar {
|
||||
static const std::string no_hosts_found_ =
|
||||
"No hosts were discovered on your network. Please check your internet "
|
||||
"connexion "
|
||||
"and verify that the subnetworks you specified in your configuration file "
|
||||
"and verify that the targetworks you specified in your configuration file "
|
||||
"were "
|
||||
"accessible";
|
||||
|
||||
@@ -79,7 +79,7 @@ parsing::print_detected_cameras(const std::vector<stream_model>& data) const {
|
||||
LOG_WARN_(
|
||||
"Mapping unsuccessful, no rtsp streams were discovered. You "
|
||||
"should try other "
|
||||
"subnetworks",
|
||||
"targetworks",
|
||||
"parsing");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace etix {
|
||||
namespace cameradar {
|
||||
|
||||
// Launches and checks the return of the nmap command
|
||||
// Uses the subnets specified in the conf file to launch nmap
|
||||
// Uses the specified targets in the conf file to launch nmap
|
||||
bool
|
||||
print::run() const {
|
||||
std::vector<stream_model> results = (*cache)->get_valid_streams();
|
||||
|
||||
Reference in New Issue
Block a user