Reputation: 53
I tryed to write a little brute force program. The password program returns 1 when the password is right and 0 when wrong. So its very easy an short.
In the bruteforce program I call the pw program with createprocess().
My problem is that when trying to crack the pw my pc gets very slow and I have to restart.
Here is the code.
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
char newKey[10] = " ";
strcat(newKey, key);
if(CreateProcess("C:\\Users\\Christoph\\Dropbox\\test\\bin\\Debug\\test.exe", // Application name
newKey, // Application arguments
0,
0,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
0,
0, // Working directory
&siStartupInfo,
&piProcessInfo) == FALSE)
Do I have to kill the processes by my self? At the first few seconds i get over 1k keys per second. Can you please help me?
Thanks
Upvotes: 0
Views: 136
Reputation: 5477
Going to take a bit of a guess here, but are you cleaning up the handles returned to you by CreateProcess
in the last parameter's PROCESS_INFORMATION
structure?
The hProcess
and hThread
handles need to be closed when not using them, or else you'll leak handles just like a memory leak.
That being said, spawning a new process for each key to be tried in a brute-force manner is highly inefficient. CreateProcess
is relatively expensive, and will not give you reasonable performance.
Furthermore, and this is my personal observation, so there is no real proof backing this, I have seen Windows having trouble handling a large number of processes. From observing Google Chrome, which spawns each tab in a new process, I have noticed the system becoming relatively slow, with the occasional system-wide hangs. Especially in the early days of Chrome.
Upvotes: 3