-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.cpp
More file actions
40 lines (34 loc) · 1.39 KB
/
Copy pathgenerator.cpp
File metadata and controls
40 lines (34 loc) · 1.39 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
#include <iostream>
#include <fstream>
#include <string>
// تابع بازگشتی برای ساخت پسووردها بر اساس الگو
void generate_with_mask(std::ofstream& file, std::string current, const std::string& mask, const std::string& chars, int index) {
// وقتی به انتهای الگو رسیدیم، کلمه کامل شده و در فایل ذخیره میشود
if (index == mask.length()) {
file << current << "\n";
return;
}
// اگر جایگاه فعلی مجهول بود ('?') تمام حروف انتخابی را تست کن
if (mask[index] == '?') {
for (char c : chars) {
generate_with_mask(file, current + c, mask, chars, index + 1);
}
}
// اگر حرف ثابت بود، همان را قرار بده و برو مرحله بعدی
else {
generate_with_mask(file, current + mask[index], mask, chars, index + 1);
}
}
// رابطی که پایتون آن را صدا میزند
extern "C" {
void create_wordlist_mask(const char* mask_cstr, const char* charset_cstr, const char* output_filename) {
std::ofstream file(output_filename);
if (!file.is_open()) {
return;
}
std::string mask(mask_cstr);
std::string chars(charset_cstr);
generate_with_mask(file, "", mask, chars, 0);
file.close();
}
}