refactor breeder
This commit is contained in:
parent
844cfc15ff
commit
3379fa02e0
6 changed files with 23 additions and 129 deletions
32
Breeder.cpp
32
Breeder.cpp
|
@ -36,7 +36,6 @@
|
|||
#include "./commons/classPacket.h"
|
||||
#include "./commons/classFlow.h"
|
||||
#include "./commons/libDump.h"
|
||||
#include "./commons/classFlowMatch.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::program_options;
|
||||
|
@ -45,27 +44,38 @@ using namespace libNetwork;
|
|||
int main ( int argc, char **argv ) {
|
||||
options_description desc ( "Breeder - Network TCP Flux Seletor" );
|
||||
desc.add_options()
|
||||
( "help", "prints this" )
|
||||
( "http", "select the http protocol." )
|
||||
( "help,h", "prints this" )
|
||||
( "filters,f", value<string>(), "specifies a list of protocols." )
|
||||
;
|
||||
|
||||
variables_map vm;
|
||||
store ( parse_command_line ( argc, argv, desc ), vm );
|
||||
notify ( vm );
|
||||
|
||||
try {
|
||||
store ( parse_command_line ( argc, argv, desc ), vm );
|
||||
notify ( vm );
|
||||
} catch ( boost::program_options::unknown_option ex1 ) {
|
||||
cerr << "ERROR >> " << ex1.what() << "" << endl;
|
||||
cerr << ">> Try '" << argv[0] << " --help' for more information." << endl;
|
||||
return EXIT_SUCCESS;
|
||||
} catch ( boost::program_options::invalid_command_line_syntax ex2 ) {
|
||||
cerr << "ERROR >> " << ex2.what() << "" << endl;
|
||||
cerr << ">> Try '" << argv[0] << " --help' for more information." << endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if ( vm.count ( "help" ) ) {
|
||||
cout<<desc<<"\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
breederConfig::init();
|
||||
boost::property_tree::ptree config = breederConfig::load();
|
||||
|
||||
cout << config.get<std::string>("global.protocols") << endl;
|
||||
|
||||
// TODO
|
||||
|
||||
classFlowMatch* match = new classFlowMatch("file.txt");
|
||||
cout << config.get<std::string>("global.protocols") << endl;
|
||||
|
||||
|
||||
|
||||
// TODO
|
||||
|
||||
list<std::string> regularexpressions;
|
||||
|
||||
|
|
|
@ -50,5 +50,4 @@ target_link_libraries(pursuer libDump)
|
|||
target_link_libraries(breeder ${Boost_LIBRARIES})
|
||||
target_link_libraries(breeder ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries(breeder libNetwork)
|
||||
target_link_libraries(breeder libDump)
|
||||
target_link_libraries(breeder libMatch)
|
||||
target_link_libraries(breeder libDump)
|
|
@ -2,8 +2,6 @@ project (commons)
|
|||
|
||||
add_library (libNetwork STATIC classMacAddress.h classMacAddress.cpp classPacket.h classPacket.cpp classFlow.h classFlow.cpp)
|
||||
add_library (libDump STATIC libDump.h libDump.cpp)
|
||||
add_library (libMatch STATIC classFlowMatch.h classFlowMatch.cpp)
|
||||
|
||||
target_link_libraries (libNetwork)
|
||||
target_link_libraries (libDump)
|
||||
target_link_libraries (libMatch)
|
|
@ -1,53 +0,0 @@
|
|||
/**
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*
|
||||
* Name : Project Riddle
|
||||
* Author : Andrea Bontempi
|
||||
* Version : 0.1 aplha
|
||||
* Description : Modular Network Sniffer
|
||||
*
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The project Riddle is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this project. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include "classFlowMatch.h"
|
||||
|
||||
classFlowMatch::classFlowMatch ( std::string path ) {
|
||||
|
||||
std::ifstream config;
|
||||
config.open ( path.c_str() );
|
||||
if ( config.is_open() && !config.eof() ) {
|
||||
|
||||
std::string line;
|
||||
|
||||
while ( getline ( config, line ) ) {
|
||||
|
||||
// TODO
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// TODO ERROR
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/**
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*
|
||||
* Name : Project Riddle
|
||||
* Author : Andrea Bontempi
|
||||
* Version : 0.1 aplha
|
||||
* Description : Modular Network Sniffer
|
||||
*
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The project Riddle is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this project. If not, see <http://www.gnu.org/licenses/>.packet
|
||||
*
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CLASSFLOWMATCH_H
|
||||
#define CLASSFLOWMATCH_H
|
||||
|
||||
#include <map>
|
||||
#include "./classFlow.h"
|
||||
|
||||
class classFlowMatch {
|
||||
|
||||
|
||||
private:
|
||||
class matchRules {
|
||||
|
||||
private:
|
||||
std::string regex;
|
||||
int port;
|
||||
|
||||
public:
|
||||
matchRules ( std::string regex_n, int port_n ) {
|
||||
regex = regex_n;
|
||||
port = port_n;
|
||||
}
|
||||
};
|
||||
std::map<std::string, matchRules*> rulesMap;
|
||||
|
||||
public:
|
||||
classFlowMatch ( std::string path );
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CLASSFLOWMATCH_H
|
|
@ -47,7 +47,7 @@ void breederConfig::init()
|
|||
|
||||
boost::property_tree::ptree http;
|
||||
http.put( "description", "..." );
|
||||
http.put( "regexp", "..." );
|
||||
http.put( "regexp", "HTTP/[0-9]\.[0-9]" );
|
||||
http.put( "ports", "80 8080" );
|
||||
|
||||
root.push_back(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue