- Joined
- Feb 18, 2013
- Messages
- 1,123
- Reaction score
- 174
Here's a little base for a multi threaded scanner, bruteforce program or whatever you want it to be.
I wanted todo an multi threaded rcon bruteforcer, but i was too lazy and [member=1371].silent[/member] was too lazy to answer me properly so he could do it.
I wanted todo an multi threaded rcon bruteforcer, but i was too lazy and [member=1371].silent[/member] was too lazy to answer me properly so he could do it.
// 0X688 - UGBASE.EU
// btw, this base sucks there are better ways (but it's functional) x.x
#include <Windows.h>
#include <iostream>
#include <stddef.h>
#include <vector>
std::vector<std::string> password_list;
std::vector < std::vector<std::string> > thread_password_list;
const int iProcessingThreads = 4;
HANDLE *dwThreads;
typedef struct ThreadData {
int iOwnID;
std::vector<std::string> *p_List;
} THREADData, *PThreadData;
// Threading happens here / actual code.
DWORD WINAPI WorkerThread ( LPVOID params )
{
PThreadData data = (PThreadData)params;
int iListSize = data->p_List->size();
DWORD iLastReport = GetTickCount();
printf ( "Thread %i started passwords to process: %i\n", data->iOwnID, iListSize );
for ( int it = 0; it != iListSize; it++ )
{
std::string password = data->p_List->at ( it );
//printf("THREAD %i - Testing Password: %s\n", data->iOwnID, password.c_str() );
if ( GetTickCount()-iLastReport > 5000 )
{
printf("THREAD %i - %i/%i passwords checked.\n", data->iOwnID, it, iListSize );
iLastReport = GetTickCount();
}
Sleep ( 100 ); // cool down the cpu maaan!
}
return 0;
}
//
int main()
{
for ( int it = 0; it != 859; it ++ )
password_list.push_back ( "Test.");
int iListSize = password_list.size();
int iPWSPerList = iListSize/iProcessingThreads;
if ( !iPWSPerList ) // list is pretty small or you have an insane amount of threads.
iPWSPerList = 1;
for ( int it = 0; it != iProcessingThreads; it ++ )
{
std::vector<std::string> list;
int iPWSAllocated = iPWSPerList;
if ( iPWSAllocated > (iListSize=password_list.size()) )
iPWSAllocated = iListSize;
printf("Thread %i:\n", it);
list.reserve(iPWSAllocated);
for ( int i = 0; i != iPWSAllocated; i ++ )
list.push_back(std::string());
std::copy_n(std::next(std::begin(password_list), 0), iPWSAllocated, std::begin(list));
password_list.erase(password_list.begin(), password_list.begin()+iPWSAllocated);
printf("-> %i Passwords\n", list.size());
thread_password_list.push_back ( list );
}
// Copy leftovers to the last thread.
int iPasswordsLeft = password_list.size();
for ( int i = 0; i != iPasswordsLeft; i ++ )
thread_password_list [ thread_password_list.size()-1 ].push_back(std::string());
std::copy_n(std::next(std::begin(password_list), 0), iPasswordsLeft, std::begin(thread_password_list [ thread_password_list.size()-1 ]));
printf("%i Passwords were left assigned them to the last thread.\n", iPasswordsLeft);
password_list.clear();
printf("----------------------------------------------\n");
printf("Starting Threads\n");
printf("----------------------------------------------\n");
// Start threads, assign pointers etc.
dwThreads = new HANDLE [ iProcessingThreads ];
DWORD dwThreadID;
for ( int it = 0; it != iProcessingThreads; it ++ )
{
PThreadData data = (PThreadData)alloca(sizeof(THREADData));
data->iOwnID = it;
data->p_List = &thread_password_list[it];
dwThreads [ it ] = CreateThread ( NULL, NULL, WorkerThread, data, NULL, &dwThreadID );
}
getchar();
return 0;
}