-
Notifications
You must be signed in to change notification settings - Fork 191
/
createDatabase.pl
executable file
·61 lines (55 loc) · 3.29 KB
/
createDatabase.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
#!/usr/bin/perl
use DBI;
use Cwd;
use FindBin qw($Bin);
use lib "$Bin/lib";
use SPF;
my %Variables = SPF::readconfig();
my $dbh = SPF::dbconnect(%Variables);
$Variables{"OS"} = $^O;
$type = $Variables{"DATABASETYPE"};
$dropquery1 = "DROP TABLE IF EXISTS agents";
$dropquery2 = "DROP TABLE IF EXISTS data";
$dropquery3 = "DROP TABLE IF EXISTS modems";
$dropquery4 = "DROP TABLE IF EXISTS remote";
$dropquery5 = "DROP TABLE IF EXISTS client";
if ($type eq "postgres")
{
$createquery1 = "create table agents (id SERIAL NOT NULL PRIMARY KEY, number varchar(12),path varchar(1000), controlkey varchar(7), controlnumber varchar(12), platform varchar(12))"
;
$createquery2 = "create table data (id SERIAL NOT NULL PRIMARY KEY, sms varchar(2000),contacts varchar(1000), picture varchar(100), root varchar(5))";
$createquery3 = "create table modems (id SERIAL NOT NULL PRIMARY KEY, number varchar(12), path varchar(1000), controlkey varchar(7), type varchar(3))";
$createquery4 = "create table remote (id SERIAL NOT NULL PRIMARY KEY, ip varchar(15), exploit varchar(200), vuln varchar(3), agent varchar(3))";
$createquery5 = "create table client (id SERIAL NOT NULL PRIMARY KEY, number varchar(12), exploit varchar(200), vuln varchar(3))";
}
elsif ($type eq "mysql")
{
$createquery1 = "create table agents (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, number varchar(12),path varchar(1000), controlkey varchar(7), controlnumber varchar(12), platform varchar(12))";
$createquery2 = "create table data (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, sms varchar(2000),contacts varchar(1000), picture varchar(100), root varchar(5))";
$createquery3 = "create table modems (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, number varchar(12), path varchar(1000), controlkey varchar(7), type varchar(3))";
$createquery4 = "create table remote (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, ip varchar(15), exploit varchar(200), vuln varchar(3), agent varchar(3))";
$createquery5 = "create table client (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, number varchar(12), exploit varchar(200), vuln varchar(3))";
}
$sql = $dbh->prepare($dropquery1);
$sql->execute;
$sql = $dbh->prepare($dropquery2);
$sql->execute;
$sql = $dbh->prepare($dropquery3);
$sql->execute;
$sql = $dbh->prepare($dropquery4);
$sql->execute;
$sql = $dbh->prepare($dropquery5);
$sql->execute;
$sql = $dbh->prepare($createquery1);
$sql->execute;
$sql = $dbh->prepare($createquery2);
$sql->execute;
$sql = $dbh->prepare($createquery3);
$sql->execute;
$sql = $dbh->prepare($createquery4);
$sql->execute;
$sql = $dbh->prepare($createquery5);
$sql->execute;
#####This sends it back to the main page.
my $url = "menu.pl";
print "Location: $url\n\n";