-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMetaPoisoner.cpp
More file actions
235 lines (204 loc) · 9.47 KB
/
Copy pathMetaPoisoner.cpp
File metadata and controls
235 lines (204 loc) · 9.47 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <ctime>
#include <cmath>
#include <sstream>
#include <memory>
#include <array>
struct DevicePreset {
std::string make;
std::string model;
std::string software;
};
const std::vector<DevicePreset> PRESETS = {
{"Apple", "iPhone 13 Pro", "iOS 15.4.1"},
{"Samsung", "Galaxy S22 Ultra", "Android 12 (Knox 3.8)"},
{"Google", "Pixel 6 Pro", "Android 12 (Build SQ3A)"},
{"Sony", "Alpha 7R IV", "Firmware v1.20"},
{"Canon", "EOS R5", "Canon Ver 1.4.0"}
};
struct PipeDeleter {
void operator()(FILE* p) const {
if (p) pclose(p);
}
};
void print_banner() {
std::cout << R"(
__ __ _ _____ _ _
| \/ | | | | __ \ (_) (_)
| \ / | ___ | |_ __ _ | |__) | ___ _ ___ ___ _ __ _ _ __ __ _
| |\/| |/ _ \| __|/ _` || ___/ / _ \ | |/ __|/ _ \| '_ \| || '_ \ / _` |
| | | | (_) | |_| (_| || | | (_) || |\__ \ (_) | | | | || | | | (_| |
|_| |_|\___/ \__|\__,_||_| \___/ |_||___/\___/|_| |_|_||_| |_|\__, |
__/ |
|___/
)" << '\n';
std::cout << " [ MetaPoisoner - hide meta data ]\n";
std::cout << "--------------------------------------------------------------\n\n";
}
std::string get_input(const std::string& prompt, const std::string& default_val) {
std::cout << "[?] " << prompt << " (Enter для '" << default_val << "'): ";
std::string input;
std::getline(std::cin, input);
return input.empty() ? default_val : input;
}
std::string escape_quotes(const std::string& str) {
std::string sanitized;
for (char c : str) {
if (c == '"') sanitized += "\\\"";
else sanitized += c;
}
return sanitized;
}
std::string exec_command(const char* cmd) {
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, PipeDeleter> pipe(popen(cmd, "r"));
if (!pipe) return "";
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
}
bool fetch_gps_from_osm(const std::string& location, double& out_lat, double& out_lon) {
std::cout << "[*] Запрос координат для локации: " << location << " через OSM API...\n";
std::string url_loc = location;
for (char &c : url_loc) if (c == ' ') c = '+';
std::string cmd = "curl -s -A \"MetaPoisoner/4.0\" \"https://nominatim.openstreetmap.org/search?q=" + url_loc + "&format=json&limit=1\"";
std::string response = exec_command(cmd.c_str());
size_t lat_pos = response.find("\"lat\":\"");
size_t lon_pos = response.find("\"lon\":\"");
if (lat_pos == std::string::npos || lon_pos == std::string::npos) {
return false;
}
lat_pos += 7;
size_t lat_end = response.find("\"", lat_pos);
out_lat = std::stod(response.substr(lat_pos, lat_end - lat_pos));
lon_pos += 7;
size_t lon_end = response.find("\"", lon_pos);
out_lon = std::stod(response.substr(lon_pos, lon_end - lon_pos));
return true;
}
void apply_gps_jitter(double& lat, double& lon) {
double jitter_lat = (((rand() % 400) - 200) / 100000.0);
double jitter_lon = (((rand() % 400) - 200) / 100000.0);
lat += jitter_lat;
lon += jitter_lon;
}
std::string generate_random_date() {
int year = 2016 + rand() % 9;
int month = 1 + rand() % 12;
int day = 1 + rand() % 28;
int hour = rand() % 24;
int min = rand() % 60;
int sec = rand() % 60;
char buf[30];
snprintf(buf, sizeof(buf), "%04d:%02d:%02d %02d:%02d:%02d", year, month, day, hour, min, sec);
return std::string(buf);
}
int main(int argc, char* argv[]) {
srand(time(0));
print_banner();
if (argc < 2) {
std::cerr << "[-] Ошибка: Не указан целевой файл.\nИспользование: " << argv[0] << " <путь_к_файлу> [--auto]\n";
return 1;
}
std::string filename = argv[1];
bool auto_mode = (argc > 2 && std::string(argv[2]) == "--auto");
std::cout << "[+] Целевой файл: " << filename << "\n\n";
std::string make, model, software, date, geo_lat = "0", geo_lon = "0";
bool use_gps = false;
if (auto_mode) {
int idx = rand() % PRESETS.size();
make = PRESETS[idx].make;
model = PRESETS[idx].model;
software = PRESETS[idx].software;
date = generate_random_date();
double lat = 35.6762, lon = 139.6503;
apply_gps_jitter(lat, lon);
geo_lat = std::to_string(lat);
geo_lon = std::to_string(lon);
use_gps = true;
std::cout << "[*] Режим --auto: Сгенерирован случайный профиль маскировки.\n";
} else {
std::cout << "--- 1. Настройка легенды устройства ---\n";
int p_idx = rand() % PRESETS.size();
make = get_input("Производитель (Make)", PRESETS[p_idx].make);
model = get_input("Модель устройства (Model)", PRESETS[p_idx].model);
software = get_input("Основное ПО (Software)", PRESETS[p_idx].software);
date = get_input("Дата оригинального снимка (YYYY:MM:DD HH:MM:SS)", "2019:05:14 11:23:04");
std::cout << "\n--- 2. Настройка гео-позиционирования ---\n";
std::string geo_choice = get_input("Использовать Geofencing по адресу? (yes/no)", "yes");
if (geo_choice == "yes" || geo_choice == "y") {
std::string address = get_input("Введите адрес/город/место (например, 'Eiffel Tower')", "Tokyo City");
double lat = 0.0, lon = 0.0;
if (fetch_gps_from_osm(address, lat, lon)) {
apply_gps_jitter(lat, lon);
geo_lat = std::to_string(lat);
geo_lon = std::to_string(lon);
use_gps = true;
std::cout << "[✓] Координаты сгенерированы с учетом Jitter: " << geo_lat << ", " << geo_lon << "\n";
} else {
std::cout << "[-] Локация не найдена. GPS-теги опущены.\n";
}
} else {
std::string manual_gps = get_input("Введите координаты (Dec '55.75, 37.61' или DMS '55 45 0 N')", "none");
if (manual_gps != "none") {
size_t comma = manual_gps.find(",");
if (comma != std::string::npos) {
geo_lat = manual_gps.substr(0, comma);
geo_lon = manual_gps.substr(comma + 1);
use_gps = true;
} else {
geo_lat = manual_gps;
use_gps = true;
}
}
}
}
make = escape_quotes(make); model = escape_quotes(model); software = escape_quotes(software); date = escape_quotes(date);
std::cout << "\n[*] Запуск протокола глубокого отравления метаданных...\n";
std::stringstream cmd_builder;
cmd_builder << "exiftool ";
cmd_builder << "-all= -XMP:All= -IPTC:All= --ThumbnailImage= ";
std::string history_chain = "History: Created with " + make + " " + model + "; Exported via " + software;
cmd_builder << "-Comment=\"" << history_chain << "\" ";
// cmd_builder << "-History=\"" << history_chain << "\" ";
cmd_builder << "-Make=\"" << make << "\" "
<< "-Model=\"" << model << "\" "
<< "-Software=\"" << software << "\" "
<< "-DateTimeOriginal=\"" << date << "\" "
<< "-CreateDate=\"" << date << "\" "
<< "-ModifyDate=\"" << date << "\" ";
cmd_builder << "-ColorSpace=sRGB -ColorSpaceTags=1 ";
if (use_gps) {
if (geo_lat.find("N") != std::string::npos || geo_lat.find("S") != std::string::npos) {
cmd_builder << "-GPSPosition=\"" << geo_lat << "\" ";
} else {
double f_lat = std::stod(geo_lat);
cmd_builder << "-GPSLatitude=" << geo_lat << " -GPSLongitude=" << geo_lon << " "
<< "-GPSLatitudeRef=" << (f_lat >= 0 ? "N" : "S") << " "
<< "-GPSLongitudeRef=" << (std::stod(geo_lon) >= 0 ? "E" : "W") << " ";
}
}
cmd_builder << "-FileModifyDate=\"" << date << "\" "
<< "-FileAccessDate=\"" << date << "\" ";
cmd_builder << "-XMP-xmp:Toolkit= -XMP:Toolkit= ";
cmd_builder << "-overwrite_original \"" << filename << "\" > /dev/null 2>&1";
int status = std::system(cmd_builder.str().c_str());
#ifndef _WIN32
std::system("history -c 2>/dev/null || true");
#endif
if (status == 0) {
std::cout << "[✓] Отравление завершено. Вся мета-структура заменена ложным следом.\n\n";
std::cout << "--- Итоговый срез для анализаторов (Проверка) ---\n";
std::string verify_cmd = "exiftool -Time:All -Make -Model -Software -GPSPosition -Comment \"" + filename + "\"";
std::system(verify_cmd.c_str());
std::cout << "--------------------------------------------------------------\n";
} else {
std::cerr << "[-] Произошла непредвиденная ошибка на этапе инъекции данных.\n";
}
return 0;
}