-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuzzer_with_PinTool.cpp
More file actions
818 lines (640 loc) · 19.2 KB
/
Fuzzer_with_PinTool.cpp
File metadata and controls
818 lines (640 loc) · 19.2 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
// > C:\Users\Nick\Downloads\pinmsvc11\pin.exe -t C:\Users\Nick\Downloads\Models\6\Project_Fuzzer\coverager.dll -- vuln20.exe
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <windows.h>
#define N 20
#define NAME_LOG "log_reg"
#define NAME_LOG_TXT ".txt"
#define HEADER (48)
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)
#define PATH_TO_CONFIG(x) "config_" STRINGIZE(x)
#define PATH_TO_CONFIG_DEF(x) "config_" STRINGIZE(x) "_default"
#define PATH_TO_VULN(x) "vuln" STRINGIZE(x) ".exe"
char * path_config = PATH_TO_CONFIG(N);
char * path_config_default = PATH_TO_CONFIG_DEF(N);
char * path_vuln = PATH_TO_VULN(N);
#define PATH_TO_PIN "C:\\Users\\Nick\\Downloads\\pinmsvc11\\pin.exe -t "
//#define PATH_TO_DLL_FOR_PIN "C:\\Users\\Nick\\Downloads\\Models\\6\\Project_Fuzzer\\coverager.dll -- "
#define PATH_TO_DLL_FOR_PIN "..\\coverager.dll -d logs\\log_"
#define PATH_TO_DLL_FOR_PIN_ADD " -- "
//char * path_to_pin_dll = PATH_TO_PIN PATH_TO_DLL_FOR_PIN PATH_TO_DLL_FOR_PIN_ADD PATH_TO_VULN(N);
int g_count_for_pin = -1;
FILE * g_statisctic;
int g_count_blocks = 0;
int g_count_total_size = 0;
int past_g_count_blocks = MAXINT;
int past_g_count_total_size = MAXINT;
bool g_flag_for_pin = false;
std::string changes = "";
void Get_Registers_State(CONTEXT *cont, const char *error, HANDLE hProcess)
{
unsigned char buffer[4048] = { 0 };
SIZE_T recvSize = 0;
std::string new_name_log = "logs\\log_" + std::to_string(g_count_for_pin) + "\\";
new_name_log += NAME_LOG NAME_LOG_TXT;
//std::string new_name_log = NAME_LOG NAME_LOG_TXT;
FILE * file = fopen(new_name_log.c_str(), "wb");
fprintf(file, "Exception: %s\n", error);
//fprintf(file, "offset: %d value: 0x%x count: %d\n", g_offset, g_value, g_count);
fprintf(file, "%s", changes.c_str());
fprintf(file, "EAX : 0x%p ESP : 0x%p\n", (void *)cont->Eax, (void *)cont->Esp);
fprintf(file, "EBX : 0x%p EBP : 0x%p\n", (void *)cont->Ebx, (void *)cont->Ebp);
fprintf(file, "ECX : 0x%p EDI : 0x%p\n", (void *)cont->Ecx, (void *)cont->Edi);
fprintf(file, "EDX : 0x%p ESI : 0x%p\n", (void *)cont->Edx, (void *)cont->Esi);
fprintf(file, "EIP : 0x%p FLG : 0x%p\n", (void *)cont->Eip, (void *)cont->EFlags);
// ÷èòàåì èç ïàìÿòè ïî óêàçàòåëþ íà âåðøèíó ñòåêà (ESP)
ReadProcessMemory(hProcess, (void *)cont->Esp, buffer, sizeof(buffer), &recvSize);
if (recvSize != 0)
{
std::cout << "Stack: " << recvSize << " bytes read" << std::endl;
fprintf(file, "\nStack (%d bytes read):\n", recvSize);
for (int i = 0; i < recvSize; i++)
{
if ((i + 1) % 4 == 1)
{
fprintf(file, "0x%p : ", (void *)((char *)cont->Esp + i));
}
if (buffer[i] < 0x10)
{
fprintf(file, "0");
}
fprintf(file, "%X ", (int)buffer[i]);
//cout << hex << uppercase << (int)buffer[i];
if ((i + 1) % 4 == 0)
{
fprintf(file, "\n");
}
}
}
else
{
std::cout << "ReadProcessMemory failed: " << GetLastError() << std::endl;
}
fprintf(file, "--------------------------------\n\n");
fclose(file);
}
void Show_Bytes()
{
unsigned char *byteBuffer;
int size;
FILE * pConfFile = fopen(path_config, "rb");
if (pConfFile == nullptr)
{
std::cout << "file did not open" << std::endl;
return;
}
fseek(pConfFile, 0, SEEK_END);
size = ftell(pConfFile);
rewind(pConfFile);
byteBuffer = new unsigned char[size];
if (byteBuffer == nullptr)
{
std::cout << "memory is not allocated" << std::endl;
return;
}
int result = fread(byteBuffer, sizeof(unsigned char), size, pConfFile);
if (result != size)
{
std::cout << "fread returned " << result << std::endl;
return;
}
fclose(pConfFile);
int i;
std::cout << "\t";
for (i = 0; i < 0x10; i++)
{
std::cout << std::hex << '0' << i << " ";
}
std::cout << std::endl << "00:\t";
for (i = 0; i < size; i++)
{
if (byteBuffer[i] < 0x10)
{
std::cout << "0";
}
std::cout << std::hex << std::uppercase << (int)byteBuffer[i] << " ";
if ((i + 1) % 0x10 == 0)
{
std::cout << std::endl << (i + 1) / 0x10 << "0" << ":\t";
}
}
std::cout << std::endl;
delete[] byteBuffer;
}
void Change_Byte(int offset, unsigned char new_value)
{
FILE * pConfFile = fopen(path_config, "r+b");
if (pConfFile == nullptr)
{
std::cout << "file did not open" << std::endl;
return;
}
//g_count = 1;
//g_value = new_value;
//g_offset = offset;
char _res[5] = { 0 };
changes += "offset: " + std::to_string(offset);
changes += " value: ";
std::sprintf(_res, "0x%x", new_value);
changes += _res;
changes += "\n";
//changes += "offset: " + std::to_string(offset);
//changes += " value: " + std::to_string(new_value) + "\n";
fseek(pConfFile, offset, SEEK_SET);
fputc(new_value, pConfFile);
fclose(pConfFile);
}
void Change_Few_Bytes(int offset, int count, unsigned char new_value)
{
FILE * pConfFile = fopen(path_config, "r+b");
if (pConfFile == nullptr)
{
std::cout << "file did not open" << std::endl;
return;
}
//g_count = count;
//g_value = new_value;
//g_offset = offset;
char _res[MAX_PATH] = { 0 };
changes += "offset: " + std::to_string(offset);
changes += " value: ";
std::sprintf(_res, "0x%x", new_value);
changes += _res;
changes += " count: ";
std::sprintf(_res, "0x%x", count);
changes += "\n";
//changes += "offset: " + std::to_string(offset);
//changes += " value: " + std::to_string(new_value);
//changes += " count: " + std::to_string(count) + "\n";
fseek(pConfFile, offset, SEEK_SET);
for (int i = 0; i < count; i++)
{
fputc(new_value, pConfFile);
}
fclose(pConfFile);
}
void Write_To_End(int count, unsigned char new_value)
{
FILE * pConfFile = fopen(path_config, "r+b");
if (pConfFile == nullptr)
{
std::cout << "file did not open" << std::endl;
return;
}
fseek(pConfFile, 0, SEEK_END);
for (int i = 0; i < count; i++)
{
fputc(new_value, pConfFile);
}
fclose(pConfFile);
}
void MySystem(const char *szPath)
{
STARTUPINFO si;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
memset(&pi, 0, sizeof(pi));
DEBUG_EVENT debug_event = { 0 };
bool result = false;
if (CreateProcess(NULL, (LPSTR)szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
DWORD dwWait = WaitForSingleObject(pi.hProcess, INFINITE);
if (dwWait == WAIT_OBJECT_0)
{
result = true;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
}
void Parsing_Pin_Log(const char * input_file)
{
// Parsing_pin_log
FILE *infile;
char *buffer;
long numbytes;
// open an existing file for reading
infile = fopen(input_file, "r");
// quit if the file does not exist
if (infile == NULL)
{
std::cout << "File does not exist: " << std::dec << GetLastError() << std::endl;
return;
}
// Get the number of bytes
fseek(infile, 0L, SEEK_END);
numbytes = ftell(infile);
// reset the file position indicator to the beginning of the file
fseek(infile, 0L, SEEK_SET);
// grab sufficient memory for the buffer to hold the text
buffer = (char*)calloc(numbytes, sizeof(char));
// memory error
if (buffer == NULL)
{
std::cout << "Memory error: " << std::dec << GetLastError() << std::endl;
return;
}
// copy all the text into the buffe
fread(buffer, sizeof(char), numbytes, infile);
fclose(infile);
// confirm we have read the file by outputing it to the console
printf("The file called test.dat contains this text\n\n%s", buffer);
char *copy_buffer = _strdup(buffer);
char *istr = strstr(copy_buffer, "blocks = ");
char *istr1 = strtok(istr, " ");
istr1 = strtok(NULL, " ");
istr1 = strtok(NULL, " ");
//free(copy_buffer);
copy_buffer = _strdup(buffer);
char *istr_total = strstr(copy_buffer, "total_size = ");
char *istr1_total = strtok(istr_total, " ");
istr1_total = strtok(NULL, " ");
istr1_total = strtok(NULL, " ");
// free the memory we used for the buffer
free(buffer);
g_count_blocks = atoi(istr1);
g_count_total_size = atoi(istr1_total);
//free(istr1_total); free(istr_total);
//free(istr1); free(istr);
//free(copy_buffer);
}
void Run_Program()
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
DEBUG_EVENT debug_event = { 0 };
HANDLE thread;
CONTEXT cont;
BOOL status;
ZeroMemory(&pi, sizeof(pi));
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
//----------------------------------------------------------
//----------------------------------------------------------
std::string new_dir_log = "mkdir logs\\log_" + std::to_string(g_count_for_pin);
system(new_dir_log.c_str());
std::string path_to_pin_dll = PATH_TO_PIN PATH_TO_DLL_FOR_PIN + std::to_string(g_count_for_pin) + PATH_TO_DLL_FOR_PIN_ADD PATH_TO_VULN(N);
MySystem(path_to_pin_dll.c_str());
Parsing_Pin_Log(("logs\\log_" + std::to_string(g_count_for_pin) + "\\coverager.log").c_str());
g_statisctic = fopen("logs\\statistic.txt", "ab");
if (g_count_blocks >= past_g_count_blocks && g_count_total_size != past_g_count_total_size)
{
fclose(g_statisctic);
g_count_for_pin++;
return;
}
past_g_count_blocks = g_count_blocks;
past_g_count_total_size = g_count_total_size;
fprintf(g_statisctic, "#log_%d;\t%d;\t%d;\n", g_count_for_pin, g_count_blocks, g_count_total_size);
g_flag_for_pin = true;
//BOOL res = CopyFileA(path_config_default, path_config, false);
BOOL res = CopyFileA(path_config, path_config_default, false);
if (res == false)
{
std::cout << "CopyFileA failed: " << std::dec << GetLastError() << std::endl;
}
changes = "";
//----------------------------------------------------------
//----------------------------------------------------------
status = CreateProcessA(path_vuln, NULL, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
if (status == false)
{
std::cout << "CreateProcess failed: " << std::dec << GetLastError() << std::endl;
return;
}
while (true)
{
// îæèäàåì ñîáûòèå îòëàäêè
status = WaitForDebugEvent(&debug_event, 500);
if (status == false)
{
if (GetLastError() != ERROR_SEM_TIMEOUT)
std::cout << "WaitForDebugEvent failed: " << std::dec << GetLastError() << std::endl;
break;
}
// ñìîòðèì êîä ñîáûòèÿ
if (debug_event.dwDebugEventCode != EXCEPTION_DEBUG_EVENT)
{
// åñëè ýòî íå èñêëþ÷åíèå - ïðîäîëæàåì îæèäàòü
ContinueDebugEvent(debug_event.dwProcessId, debug_event.dwThreadId, DBG_CONTINUE);
continue;
}
// ïîëó÷àåì õýíäë ïîòîêà, â êîòîðîì ïðîèçîøëî ñîáûòèå îòëàäêè
thread = OpenThread(THREAD_ALL_ACCESS, FALSE, debug_event.dwThreadId);
if (thread == NULL)
{
std::cout << "OpenThread failed: " << std::dec << GetLastError() << std::endl;
break;
}
cont.ContextFlags = CONTEXT_FULL;
// ïî õýíäëó ïîëó÷àåì åãî êîíòåêñò
status = GetThreadContext(thread, &cont);
if (status == false)
{
std::cout << "GetThreadContext failed: " << std::dec << GetLastError() << std::endl;
CloseHandle(thread);
break;
}
switch (debug_event.u.Exception.ExceptionRecord.ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
// ïîïûòêà ÷òåíèÿ èëè çàïèñè çàùèùåííîé ïàìÿòè
Get_Registers_State(&cont, "Access Violation", pi.hProcess);
//MySystem(path_to_pin_dll.c_str());
//Parsing_Pin_Log(("logs\\log_" + std::to_string(g_count_for_pin) + "\\coverager.log").c_str());
fprintf(g_statisctic, "\t\tAccess Violation;\n");
break;
case EXCEPTION_STACK_OVERFLOW:
Get_Registers_State(&cont, "Stack overflow", pi.hProcess);
//MySystem(path_to_pin_dll.c_str());
//Parsing_Pin_Log(("logs\\log_" + std::to_string(g_count_for_pin) + "\\coverager.log").c_str());
fprintf(g_statisctic, "\t\tStack overflow;\n");
break;
default:
std::cout << "Unknown exception: " << std::dec << debug_event.u.Exception.ExceptionRecord.ExceptionCode << std::endl;
//fprintf(stat, "\t--Unknown exception\n");
//fprintf(stat, "\n");
ContinueDebugEvent(debug_event.dwProcessId, debug_event.dwThreadId, DBG_CONTINUE);
}
}
fclose(g_statisctic);
g_count_for_pin++;
CloseHandle(pi.hProcess);
}
void Return_Default_Version()
{
BOOL res = CopyFileA(path_config_default, path_config, false);
if (res == false)
{
std::cout << "CopyFileA failed: " << std::dec << GetLastError() << std::endl;
}
changes = "";
}
void Find_Boundary_Symbol(char symbol)
{
int position = -1;
int counter = 0;
int size;
FILE * pConfFile = fopen(path_config, "rb");
if (pConfFile == nullptr)
{
std::cout << "file did not open" << std::endl;
return;
}
fseek(pConfFile, 0, SEEK_END);
size = ftell(pConfFile);
rewind(pConfFile);
for (int i = 0; i < size; i++)
{
if (fgetc(pConfFile) == symbol)
{
counter++;
position = i;
}
}
std::cout << "symbol : " << symbol << " counter : " << counter << " position : " << position << std::endl;
fclose(pConfFile);
}
void Auto_Fuzzing(int new_value, int mode)
{
switch (mode)
{
case 1:
for (int i = 1; i < HEADER; i++)
{
Change_Byte(i, new_value);
Run_Program();
Return_Default_Version();
if (g_flag_for_pin == true)
{
g_flag_for_pin = false;
g_statisctic = fopen("logs\\statistic.txt", "ab");
fprintf(g_statisctic, "\t\t(offset %d, value %d)\n", i, new_value);
fclose(g_statisctic);
}
}
break;
case 2:
for (int i = 2; i < HEADER; i += 2)
{
Change_Byte(i, new_value >> 8);
Change_Byte(i + 1, (unsigned char)new_value);
Run_Program();
Return_Default_Version();
if (g_flag_for_pin == true)
{
g_flag_for_pin = false;
g_statisctic = fopen("logs\\statistic.txt", "ab");
fprintf(g_statisctic, "\t\t(offset %d, value %d)\n", i, new_value);
fclose(g_statisctic);
}
}
break;
case 3:
for (int i = 4; i < HEADER; i += 4)
{
Change_Byte(i, new_value >> 24);
Change_Byte(i + 1, new_value >> 16);
Change_Byte(i + 2, new_value >> 8);
Change_Byte(i + 3, (unsigned char)new_value);
Run_Program();
Return_Default_Version();
if (g_flag_for_pin == true)
{
g_flag_for_pin = false;
g_statisctic = fopen("logs\\statistic.txt", "ab");
fprintf(g_statisctic, "\t\t(offset %d, value %d)\n", i, new_value);
fclose(g_statisctic);
}
}
break;
default:
std::cout << "Invalid mode" << std::endl;
}
}
void Compare_Configs()
{
int compare_arr[HEADER] = { 0 }; // âñå ïîëÿ îäèíàêîââûå
int byte[HEADER] = { 0 };
FILE *pFileConf;
int i;
pFileConf = fopen(path_config, "rb");
if (pFileConf == nullptr)
{
std::cout << "fopen failed" << std::endl;
return;
}
for (i = 0; i < HEADER; i++)
{
byte[i] = fgetc(pFileConf);
}
fclose(pFileConf);
char *path_to_conf = new char[strlen(path_config) + 1];
int len = strlen(path_config);
strncpy(path_to_conf, path_config, len + 1);
path_to_conf[len - 1] = 0;
path_to_conf[len - 2] = '1';
for (i = 2; i < 10; i++) // ñðàâíèì 10 êîíôèãîâ
{
path_to_conf[len - 2] = i + '0';
pFileConf = fopen(path_to_conf, "rb");
//printf("path: %s\n", path_to_conf);
if (pFileConf == nullptr)
{
std::cout << "fopen failed" << std::endl;
return;
}
int j;
for (j = 0; j < HEADER; j++)
{
if (byte[j] != fgetc(pFileConf))
{
// ðàçíûå ïîëÿ ïîìå÷àþòñÿ åäèíèöåé
compare_arr[j] = 1;
}
}
fclose(pFileConf);
}
std::cout << "Follow bytes matched: " << std::endl << std::endl;
std::cout << " ";
for (int i = 0; i < 0x10; i++)
{
std::cout << std::hex << " " << '0' << i;
}
std::cout << std::endl << "00: ";
for (int i = 0; i < HEADER; i++)
{
std::cout << "0" << compare_arr[i] << " ";
if ((i + 1) % 0x10 == 0)
{
std::cout << std::endl << (i + 1) / 0x10 << "0" << ": ";
}
}
std::cout << "BUFFER" << std::endl;
std::cout << std::endl;
}
#define AVAILABLE_COMMANDS \
"1. Show config file bytes\n\
2. Change one byte\n\
3. Change a few bytes\n\
4. Write to the end\n\
5. Run vuln.exe\n\
6. Return default version of config file\n\
7. Find boundary symbols\n\
8. Auto fuzzing\n\
9. Compare config files\n\
0. Exit"
void ProcessRequest(int command)
{
int offset, value, count, mode;
std::string path_to_pin_dll = PATH_TO_PIN PATH_TO_DLL_FOR_PIN + std::to_string(g_count_for_pin) + PATH_TO_DLL_FOR_PIN_ADD PATH_TO_VULN(N);
unsigned int values[] = {
0x00,
0xFF,
0xFF / 2,
0xFF / 2 - 1,
0xFF / 2 + 1,
0x0000,
0xFFFF,
0xFFFF / 2,
0xFFFF / 2 - 1,
0xFFFF / 2 + 1,
0x00000000,
0xFFFFFFFF,
0xFFFFFFFF / 2,
0xFFFFFFFF / 2 - 1,
0xFFFFFFFF / 2 + 1,
};
switch (command)
{
case 1:
Show_Bytes();
break;
case 2:
std::cout << "Offset : ";
std::cin >> std::dec >> offset;
std::cout << "Value : ";
std::cin >> std::hex >> value;
Change_Byte(offset, value);
break;
case 3:
std::cout << "Offset (dec) : ";
std::cin >> std::dec >> offset;
std::cout << "Count (dec) : ";
std::cin >> std::dec >> count;
std::cout << "Value (hex) : ";
std::cin >> std::hex >> value;
Change_Few_Bytes(offset, count, value);
break;
case 4:
std::cout << "Count (dec) : ";
std::cin >> std::dec >> count;
std::cout << "Value (hex) : ";
std::cin >> std::hex >> value;
Write_To_End(count, value);
break;
case 5:
Run_Program();
break;
case 6:
Return_Default_Version();
break;
case 7:
Find_Boundary_Symbol(',');
Find_Boundary_Symbol(':');
Find_Boundary_Symbol('=');
Find_Boundary_Symbol(';');
break;
case 8:
// Get start count coverage code
system(("mkdir logs\\log_" + std::to_string(g_count_for_pin)).c_str());
//MySystem((PATH_TO_PIN PATH_TO_DLL_FOR_PIN + std::to_string(g_count_for_pin) + PATH_TO_DLL_FOR_PIN_ADD PATH_TO_VULN(N)).c_str);
//C:\Users\Nick\Downloads\pinmsvc11\pin.exe -t coverager.dll -d logs\log_# -- vuln20.exe
MySystem(path_to_pin_dll.c_str());
Parsing_Pin_Log(("logs\\log_" + std::to_string(g_count_for_pin) + "\\coverager.log").c_str());
g_statisctic = fopen("logs\\statistic.txt", "ab");
fprintf(g_statisctic, "#log_%d;\t%d;\t%d;\n", g_count_for_pin, g_count_blocks, g_count_total_size);
fclose(g_statisctic);
g_count_for_pin++;
past_g_count_blocks = g_count_blocks;
past_g_count_total_size = g_count_total_size;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 5; j++)
{
Auto_Fuzzing(values[i * 5 + j], i + 1);
}
}
break;
case 9:
Compare_Configs();
break;
default:
std::cout << "Invalid request" << std::endl;
}
}
int main()
{
system("mkdir logs");
g_statisctic = fopen("logs\\statistic.txt", "wb");
fprintf(g_statisctic, "For each run, the folder \"log_#\" is created, \
in the folder the files are \"covere*\" - code coverage, \
if there is a file log_reg.txt - was exception\
\n#log_#;\tblocks;\ttotal_size;\n");
fclose(g_statisctic);
int select;
std::cout << AVAILABLE_COMMANDS << std::endl << std::endl;
while (true)
{
std::cout << "Enter: ";
std::cin >> select;
if (select == 0)
break;
ProcessRequest(select);
std::cout << std::endl << AVAILABLE_COMMANDS << std::endl << std::endl;
}
return 0;
}