-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·103 lines (93 loc) · 3.13 KB
/
main.cpp
File metadata and controls
executable file
·103 lines (93 loc) · 3.13 KB
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
#include <iostream>
#include <fstream>
#include <boost/filesystem.hpp>
#include "Manager/Manager.h"
using namespace std;
void check_root(){
if(geteuid() != 0){
cout << "You need root permissions to do this." << endl;
exit(0);
}
}
bool file_exists(const boost::filesystem::path path) {
return boost::filesystem::is_regular_file(path);
}
void enable(){
if (file_exists(boost::filesystem::path("/etc/init.d/warpi.sh"))) {
cout << "WarPi should already run at boot" << endl;
exit(0);
}
ofstream warpi("/etc/init.d/warpi.sh");
warpi << "#!/bin/bash\n";
warpi << "screen warpi start\n";
warpi.close();
}
void disable(){
if (!file_exists(boost::filesystem::path("/etc/init.d/warpi.sh"))) {
cout << "WarPi already does not run at boot" << endl;
exit(0);
}
remove("/etc/init.d/warpi.sh");
}
void usage(){
cout << "Usage: ./warpi {option}" << endl;
cout << "\tOptions:" << endl;
cout << "\tstart\t\t-\tStarts the Program" << endl;
cout << "\tenable\t\t-\tEnable running this program at boot" << endl;
cout << "\tdisable\t\t-\tDisable running this program at boot" << endl;
cout << "Got it? Ok. Bye." << endl;
exit(0);
}
vector<string> get_arguments(char **argv, int argc) {
vector<string> arguments;
for (int i = 0; i < argc; i++) {
arguments.push_back(argv[i]);
}
return arguments;
}
int main(int argc, char ** argv) {
check_root();
if (argc != 2) {
usage();
}
vector<string> arguments = get_arguments(argv, argc);
for (unsigned long i = 0; i < arguments.size(); i++) {
if (arguments.at(i) == "start") {
if (!file_exists("/etc/WarPi/config.json")) {
// TODO: Check for --config and use user specified config file
cout << "Need a config file to function properly." << endl;
cout << "Creating the configuration file now. Please edit it to your needs." << endl;
cout << "Config file should be located at: /etc/WarPi/config.json" << endl;
exit(0);
}
Manager *manager = new Manager();
manager->set_do_run(true);
manager->run();
}
if (arguments.at(i) == "enable") {
enable();
}
if (arguments.at(i) == "disable") {
disable();
}
}
}
/*
* TODO:
* Argparsing && Config parsing
* WiFi Authentication (Get IWLib encryption codes(ieee 802.11)) ---> Maybe result->b.mode == IW_AUTH_WPA_ENABLED
*
* Set scanning rate accordingly to moving speed ( eg. walking -> 2 seconds, driving -> 0.2 seconds )
*
* Network Object (eg.: Store information about if connected to network and IP ranges)
* Network Function (eg.: Get Details for above Object, execute scans)
*
* Scanning and Spoofing
*
* WiFi Karma HotSpot (eg.: get most probed ssid -> open hotspot -> scan & poison)
* Number Plate recognition (eg.: libpng -> take picture every x seconds -> openalpr -> plate, coords to db)
*
* Bluetooth (eg.: get near devices, put mac and services to db, act malicious)
* GPS Map (eg.: Tangram Library for rendering)
*
*/