breeder ++

This commit is contained in:
Andrea Bontempi 2012-09-03 12:15:55 +02:00
commit 5bfe3de639
2 changed files with 33 additions and 10 deletions

View file

@ -45,6 +45,7 @@ int main ( int argc, char **argv ) {
options_description desc ( "Breeder - Network TCP Flux Seletor" );
desc.add_options()
( "help,h", "prints this" )
( "list,l", "list the available protocols.")
( "filters,f", value< vector<string> >(), "specifies a list of protocols." )
;
@ -72,20 +73,31 @@ int main ( int argc, char **argv ) {
return EXIT_SUCCESS;
}
if ( !breederConfig::fexists() ) {
breederConfig::init();
}
boost::property_tree::ptree config = breederConfig::load();
vector< string > pavailable = breederConfig::getProtocolsAvailable( config );
if ( vm.count ( "list" ) ) {
std::cerr << "Available protocols:" << std::endl;
for (vector< string >::iterator it = pavailable.begin(); it != pavailable.end(); ++it) {
std::cerr << "* " << *it << "\t" << config.get< string >( *it + ".description" ) << std::endl;
}
return EXIT_SUCCESS;
}
if ( !vm.count ( "filters" ) || vm["filters"].as< vector<string> >().empty() ) {
std::cerr<<"ERROR >> You have not selected any protocol!"<<std::endl;
return EXIT_FAILURE;
}
if( !breederConfig::fexists() ) {
breederConfig::init();
}
boost::property_tree::ptree config = breederConfig::load();
vector< string > pselect = vm["filters"].as< vector< string > >();
vector< string > pavailable = breederConfig::getProtocolsAvailable( config );
list< string > filters = breederTools::protocolsValidation( pselect, pavailable );
if ( filters.empty() ) {

View file

@ -45,25 +45,36 @@ void breederConfig::init()
boost::property_tree::ptree global;
global.put( "threshold", "90" );
global.put( "protocols", "http" );
global.put( "protocols", "http ftp" );
root.push_front(
boost::property_tree::ptree::value_type( "global", global )
);
boost::property_tree::ptree http;
http.put( "description", "The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web." );
http.put( "description", "The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed hypermedia information systems." );
http.put( "regexp_content", "HTTP/[0-9]\\.[0-9]" );
http.put( "regexp_score", "80" );
http.put( "ports_content", "80 8080" );
http.put( "ports_score", "20" );
boost::property_tree::ptree ftp;
ftp.put( "description", "File Transfer Protocol (FTP) is a standard network protocol used to transfer files from one host to another host over a TCP-based network." );
ftp.put( "regexp_content", "USER#.*?#.*?PASS" );
ftp.put( "regexp_score", "20" );
ftp.put( "ports_content", "21" );
ftp.put( "ports_score", "80" );
// TODO Aggiungi protocolli.
root.push_back(
boost::property_tree::ptree::value_type( "http", http )
);
root.push_back(
boost::property_tree::ptree::value_type( "ftp", ftp )
);
boost::property_tree::ini_parser::write_ini( FILECONFIG, root );
}