-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathengine.pl
executable file
·117 lines (108 loc) · 3.34 KB
/
engine.pl
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/perl
use codebase;
# install/uninstall/ sync
my $version = "0.97";
if($ARGV[0] eq "start"){
coldwar::print_out("\tColdWar v$version\n","g");
coldwar::init();
}
elsif($ARGV[0] eq "stop"){
coldwar::engine("stop");
}
elsif($ARGV[0] eq "restart"){
coldwar::print_out("Stopping engine\n","g");
coldwar::engine("stop");
coldwar::print_out("Starting engine\n","g");
coldwar::init();
}
elsif($ARGV[0] eq "status"){
coldwar::engine("status");
}
elsif($ARGV[0] eq "install"){
# eshte 1 her ?
coldwar::print_out("Installing perl modules\n","g");
if(-f "/etc/debian_version"){
# debian based system
system("apt-get -y install make"); # y u no complier ?
system("apt-get -y install libnet-pcap-perl");
system("apt-get -y install libwww-perl");
system("apt-get -y install libdbd-sqlite3-perl");
system("cpan install NetPacket::Ethernet");
system("cpan install NetPacket::IP");
system("cpan install NetPacket::TCP");
system("cpan install LWP::UserAgent");
system("cpan install Time::HiRes");
system("cpan install DBD::SQLite");
system("cpan install JSON");
system("cpan install Proc::Daemon");
system("perl -MCPAN -e 'notest force install Net::Server::PreFork'");
coldwar::print_out("if everything is green its safe to run ./engine.pl start","g");
#system("cpan install Net::Pcap");
}
elsif(-f "/etc/redhat-release"){
# rpm based system
system("cpan NetPacket::Ethernet");
system("cpan NetPacket::IP");
system("cpan NetPacket::TCP");
system("cpan Time::HiRes");
system("cpan LWP::UserAgent");
system("cpan DBD::SQLite");
system("cpan JSON");
system("perl -MCPAN -e 'notest force install Net::Server::PreFork'"); # ??
#system("cpan Net::Server::PreFork");
system("yum -y install perl-Net-Pcap");
system("yum install libpcap");
system("yum install libpcap-devel");
#yum install libpcap-devel # might come in handy
#system("cpan Net::Pcap");
}
else{
print_out("As lame as it seems, we couldnt /are_too_lazy_to detect your OS","g");
print_out("try installing it by hand:\t libnet-pcap-perl","g");
}
system("mkdir /opt/coldwar");
system("cp bandb.sqlite3 /opt/coldwar/");
system("cp coldwar.sh /opt/coldwar/");
system("cp engine.pl /opt/coldwar/");
system("cp config /opt/coldwar/");
system("cp codebase.pm /opt/coldwar/");
system("cp README.md /opt/coldwar/");
coldwar::check_libs();
}
elsif($ARGV[0] eq "uninstall"){
# why ?
}
elsif($ARGV[0] eq "removeip"){
if(coldwar::validate_ip($ARGV[1])){
coldwar::delete_from_iptbl($ARGV[1]);
}
else{
print "Please insert a valid IP\n";
}
}
elsif($ARGV[0] eq "help"){
help();
}
elsif($ARGV[0] eq "check"){
coldwar::print_out("\tColdWar v$version\n","g");
print "Checking teh stuffz \n";
coldwar::check_files();
coldwar::check_ifroot();
coldwar::check_libs();
coldwar::print_out("If everything is green, I think its safe to start it","g");
exit(1);
}
else{
help();
}
sub help{
coldwar::print_out("\tColdWar v$version\n","g");
print "Usage:\n ";
print "./engine.pl start|stop|status|install|uninstall|check\n";
print " start|stop|restart \t they start|stop|restart the engine duuhh (stop also removes the lock file) \n";
print " install|uninstall \t nothing new here \n";
print " removeip IP \t remove ip from iptables/db \n";
print " cleardb \t clears teh db \n";
print " check \t check for all the neccessary stuff \n";
exit(1 );
}