int main() { int check=0; char c; char filepath[50]; int i, j; do { //Menü printf("Auswahl:\n(a)Test Raetzel 1\n(b)Test Raetzes 2\n(c)Filename Eingeben\n(e)Beenden\n"); scanf("%s",&c); switch (c) { case 'a' : raetsel1(); ausgabe(); //Wenn Sudoku Lösbar, dann ausgabe von gelöstem Sudoku // sonst ausgabe "NO SOLUTION" if(fillsudoku(sudokuarr, 0, 0)){ printf("Loesung:\n\n"); ausgabe(); } else{ printf("NO SOLUTION\n\n"); } break; case 'b' : raetsel2(); ausgabe(); //Wenn Sudoku Lösbar, dann ausgabe von gelöstem Sudoku // sonst ausgabe "NO SOLUTION" if(fillsudoku(sudokuarr, 0, 0)){ printf("Loesung:\n\n"); ausgabe(); }else{printf("NO SOLUTION\n\n");} break; case 'c' : filetoarray(); ausgabe(); //Wenn Sudoku Lösbar, dann ausgabe von gelöstem Sudoku // sonst ausgabe "NO SOLUTION" if(fillsudoku(sudokuarr, 0, 0)){ printf("Loesung:\n\n"); ausgabe(); }else{printf("NO SOLUTION\n\n");} break; case 'e': check=1; break; default: printf("\nFalsche Eingabe\n\n"); break; } fflush(stdin); } while (check==0); return EXIT_SUCCESS; }
int main(){ char filebytes[29000]; PROCESS_INFORMATION pi; STARTUPINFO si; printf("\n[*]Writing Bytes to an array"); filetoarray(filebytes,29000); printf("\n[*]Done"); Sleep(500); printf("\n\n[*]Modifying byte at given offest"); changebyte(filebytes,29000); printf("\n[*]Done"); Sleep(500); printf("\n\n[*]Writing to new myf.exe"); FILE *fp2; fp2 = fopen("myf.exe","wb"); fwrite(filebytes,sizeof(filebytes[0]),sizeof(filebytes)/sizeof(filebytes[0]),fp2); fclose(fp2); printf("\n[*]Done"); Sleep(500); printf("\n\n[*]Starting myf.exe as debuggee"); memset(&si,0,sizeof(si)); memset(&pi,0,sizeof(pi)); si.cb= sizeof(si); if(CreateProcess("myf.exe",NULL,NULL,NULL,TRUE,DEBUG_PROCESS,NULL,NULL,&si,&pi)){ printf("\n[*]Process Created"); BOOL cont = TRUE; while (cont) { DWORD continueStatus = DBG_CONTINUE; DEBUG_EVENT de = {0}; if (!WaitForDebugEvent(&de, INFINITE)) { break; } else{ switch (de.dwDebugEventCode) { case EXCEPTION_DEBUG_EVENT: switch (de.u.Exception.ExceptionRecord.ExceptionCode) { case EXCEPTION_BREAKPOINT: if((*(static_cast<unsigned int*>(de.u.Exception.ExceptionRecord.ExceptionAddress)))== -2082109099){ printf("\n\n[*]Reached Breakpoint"); //FACE THE MUSIC CONTEXT c; c.ContextFlags = CONTEXT_CONTROL|CONTEXT_FULL; GetThreadContext(pi.hThread,&c); printf("\nEIP : %0X",c.Eip); SuspendThread(pi.hThread); c.Eip--; SetThreadContext(pi.hThread,&c); DWORD sa = 0x401334; BYTE ins=0x55; WriteProcessMemory(pi.hProcess, (void*)sa, &ins, 1,NULL); sa = 0x28FF0C; ins=0x59; WriteProcessMemory(pi.hProcess, (void*)sa, &ins, 1,NULL); sa = 0x28FF10; ins=0x9A; WriteProcessMemory(pi.hProcess, (void*)sa, &ins, 1,NULL); sa = 0x28FF11; ins=0x13; WriteProcessMemory(pi.hProcess, (void*)sa, &ins, 1,NULL); ResumeThread(pi.hThread); } break; default: break; } break; case EXIT_PROCESS_DEBUG_EVENT: cont = FALSE; break; case CREATE_THREAD_DEBUG_EVENT: continueStatus = DBG_CONTINUE; break; case CREATE_PROCESS_DEBUG_EVENT: continueStatus = DBG_CONTINUE; break; case EXIT_THREAD_DEBUG_EVENT: continueStatus = DBG_CONTINUE; break; } ContinueDebugEvent(de.dwProcessId,de.dwThreadId,continueStatus); } }} getch(); return 0; }