1 /* $Id: xprobe.cc,v 1.7 2004/09/05 07:18:00 mederchik Exp $ */
2 /*
3 ** Copyright (C) 2001 Fyodor Yarochkin <fygrave@tigerteam.net>,
4 ** Ofir Arkin <ofir@sys-security.com>
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
10 **
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software
19 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22 #include "xprobe.h"
23 #include "cmd_opts.h"
24 #include "targets_list.h"
25 #include "config_set.h"
26 #include "xprobe_module.h"
27 #include "xprobe_module_hdlr.h"
28 #include "scan_engine.h"
29 #include "interface_con.h"
30 #include "os_matrix.h"
31 #include "log.h"
32
33 /* globals */
34
35 Cmd_Opts *copts;
36 Targets_List *targets;
37 Config_Set *cfg;
38 Xprobe_Module_Hdlr *xmh;
39 Interface *ui;
40 Scan_Engine *se;
41 OS_Name *oses;
42 XML_Log *xml;
43
main(int argc,char * argv[])44 int main(int argc, char *argv[]) {
45
46 ui = new Interface_Con; // we have only console for now
47 copts = new Cmd_Opts;
48 targets = new Targets_List;
49 xmh = new Xprobe_Module_Hdlr;
50 se = new Scan_Engine;
51 cfg = new Config_Set;
52 oses = new OS_Name;
53 xml = new XML_Log;
54 time_t start = time(NULL);
55
56 ui->msg("%s\n",BANNER);
57 copts->parse(argc, argv);
58
59 /* should we show the route to target */
60 cfg->show_route(copts->show_route());
61 cfg->set_udp_ports(copts->get_udp_ports());
62 cfg->set_tcp_ports(copts->get_tcp_ports());
63 if (copts->do_xml())
64 if (xml->set_logfile(copts->get_logfile()))
65 exit(1);
66 /* targets list */
67 if (targets->init(copts->get_target()) == FAIL) {
68 exit(1);
69 }
70 xml->log(XPROBELOG_XP_SESS_START, "%v%b", VERSION, BANNER);
71 xml->log(XPROBELOG_MSG_RUN, "%c%a%d", argc, argv, start);
72
73 /* config file */
74 xprobe_debug(XPROBE_DEBUG_INIT, "[+] config file is: %s\n", copts->get_configfile());
75
76
77 /* load modules first. register the keywords */
78 xmh->load();
79
80 /* parse config file */
81 if (cfg->read_config(copts->get_configfile()) == FAIL) {
82 exit(1);
83 }
84
85 /* debugging only! */
86 oses->list_oses();
87
88 /* initialize loaded tests */
89 xmh->init();
90 /* for debugging */
91 xmh->print();
92
93 /* scan stuff */
94 se->init();
95 se->run();
96 se->fini();
97
98 /* finite la comedia' */
99
100 xmh->fini();
101 ui->msg("[+] Execution completed.\n");
102 xml->log(XPROBELOG_XP_SESS_END, "FIN");
103 delete oses;
104 delete copts;
105 delete targets;
106 delete cfg;
107 delete xmh;
108 delete se;
109 delete ui;
110 delete xml;
111
112 }
113