Skip to content

Commit

Permalink
fix for last upd & additional ads removals
Browse files Browse the repository at this point in the history
  • Loading branch information
W1lliam1337 committed Dec 13, 2022
1 parent 72a0b36 commit 00024cb
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 241 deletions.
91 changes: 38 additions & 53 deletions DigitalInjector/features/features.cpp
Original file line number Diff line number Diff line change
@@ -1,99 +1,84 @@
#include "features.h"

void features::error_log(const char* message)
{
void features::error_log( const char* message ) {
std::cout << message << std::endl;
system("pause");
exit(0);
system( "pause" );
exit( 0 );
}

std::string features::random_string(const size_t length)
{
std::string features::random_string( const size_t length ) {
std::string r;
static constexpr char bet[] = { "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyzZ1234567890" };
srand(static_cast<unsigned>(time(nullptr)) * 5);
for (int i = 0; i < length; ++i)
{
r += bet[rand() % (sizeof bet - 1)];
srand( static_cast< unsigned >( time( nullptr ) ) * 5 );
for ( int i = 0; i < length; ++i ) {
r += bet[ rand( ) % ( sizeof bet - 1 ) ];
}
return r;
}

bool features::does_file_exist(const char* name)
{
if (FILE* file = fopen(name, "r"))
{
fclose(file);
bool features::does_file_exist( const char* name ) {
if ( FILE* file = fopen( name, "r" ) ) {
fclose( file );
return true;
}

return false;
}

DWORD features::get_process_id(const char* process_name)
{
const HANDLE h_snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
DWORD features::get_process_id( const char* process_name ) {
const HANDLE h_snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, NULL );

PROCESSENTRY32 pe32{};
pe32.dwSize = sizeof pe32;

if (!Process32First(h_snap, &pe32))
if ( !Process32First( h_snap, &pe32 ) )
return NULL;

do
{
if (!strcmp(pe32.szExeFile, process_name))
{
CloseHandle(h_snap);
do {
if ( !strcmp( pe32.szExeFile, process_name ) ) {
CloseHandle( h_snap );
return pe32.th32ProcessID;
}
} while (Process32Next(h_snap, &pe32));
} while ( Process32Next( h_snap, &pe32 ) );

CloseHandle(h_snap);
CloseHandle( h_snap );
return NULL;

}

uintptr_t features::get_module_base_address(const DWORD pid, const char* mod_name)
{
const HANDLE h_snap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid);
if (h_snap != INVALID_HANDLE_VALUE)
{
uintptr_t features::get_module_base_address( const DWORD pid, const char* mod_name ) {
const HANDLE h_snap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid );
if ( h_snap != INVALID_HANDLE_VALUE ) {
MODULEENTRY32 mod_entry{};
mod_entry.dwSize = sizeof mod_entry;
if (Module32First(h_snap, &mod_entry))
{
do
{
if (!strcmp(mod_entry.szModule, mod_name))
{
CloseHandle(h_snap);
return reinterpret_cast<uintptr_t>(mod_entry.modBaseAddr);
if ( Module32First( h_snap, &mod_entry ) ) {
do {
if ( !strcmp( mod_entry.szModule, mod_name ) ) {
CloseHandle( h_snap );
return reinterpret_cast< uintptr_t >( mod_entry.modBaseAddr );
}
} while (Module32Next(h_snap, &mod_entry));
} while ( Module32Next( h_snap, &mod_entry ) );
}
}
return 0;
}

bool features::inject(const DWORD process_id, const char* dll)
{
if (process_id == NULL)
bool features::inject( const DWORD process_id, const char* dll ) {
if ( process_id == NULL )
return false;

char custom_dll[MAX_PATH];
GetFullPathNameA(dll, MAX_PATH, custom_dll, nullptr);
char custom_dll[ MAX_PATH ];
GetFullPathNameA( dll, MAX_PATH, custom_dll, nullptr );

const HANDLE h_process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_id);
const LPVOID allocated_mem = VirtualAllocEx(h_process, nullptr, sizeof custom_dll, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
const HANDLE h_process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, process_id );
const LPVOID allocated_mem = VirtualAllocEx( h_process, nullptr, sizeof custom_dll, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE );

if (WriteProcessMemory(h_process, allocated_mem, custom_dll, sizeof custom_dll, nullptr))
{
CreateRemoteThread(h_process, nullptr, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(LoadLibrary),
allocated_mem, 0, nullptr);
if ( WriteProcessMemory( h_process, allocated_mem, custom_dll, sizeof custom_dll, nullptr ) ) {
CreateRemoteThread( h_process, nullptr, 0, reinterpret_cast< LPTHREAD_START_ROUTINE >( LoadLibrary ),
allocated_mem, 0, nullptr );

if (h_process)
CloseHandle(h_process);
if ( h_process )
CloseHandle( h_process );

return TRUE;
}
Expand Down
17 changes: 8 additions & 9 deletions DigitalInjector/features/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#include <iostream>
#include <TlHelp32.h>

namespace features
{
void error_log(const char* message);
void log(const char* message);
std::string random_string(size_t length);
bool does_file_exist(const char* name);
DWORD get_process_id(const char* process_name);
uintptr_t get_module_base_address(DWORD pid, const char* mod_name);
bool inject(DWORD process_id, const char* dll);
namespace features {
void error_log( const char* message );
void log( const char* message );
std::string random_string( size_t length );
bool does_file_exist( const char* name );
DWORD get_process_id( const char* process_name );
uintptr_t get_module_base_address( DWORD pid, const char* mod_name );
bool inject( DWORD process_id, const char* dll );
}
30 changes: 14 additions & 16 deletions DigitalInjector/main.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
#include "features/features.h"

int setup()
{
SetConsoleTitleA(features::random_string(26).c_str());
int setup( ) {
SetConsoleTitleA( features::random_string( 26 ).c_str( ) );

const DWORD process_id = features::get_process_id("Spotify.exe");
if (!process_id)
features::error_log("[!] Spotify.exe not founded.\n");
const DWORD process_id = features::get_process_id( "Spotify.exe" );
if ( !process_id )
features::error_log( "[!] Spotify.exe not founded.\n" );

std::cout << "[+] Spotify.exe founded." << std::dec << process_id << std::endl;
std::cout << "[+] Spotify.exe founded." << std::dec << process_id << std::endl;

const HANDLE game = OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_id);
if (!game)
features::error_log("OpenProcess error\n");
const HANDLE game = OpenProcess( PROCESS_ALL_ACCESS, FALSE, process_id );
if ( !game )
features::error_log( "OpenProcess error\n" );

features::error_log(features::inject(process_id, "patcher.dll") ? "[+] Injected.\n" : "[!] Injection Failed.\n");
features::error_log( features::inject( process_id, "patcher.dll" ) ? "[+] Injected.\n" : "[!] Injection Failed.\n" );

return 0;
return 0;
}

int main()
{
setup();
return 0;
int main( ) {
setup( );
return 0;
}
52 changes: 24 additions & 28 deletions DigitalSpotify/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,43 @@
#include "hooks/hooks.h"
#include "utils/utils.h"

int main(const HMODULE base)
{
utils::open_console();
printf("[ main ] console initialization was successful\n");
int main( const HMODULE base ) {
utils::open_console( );
printf( "[ main ] console initialization was successful\n" );

printf("[ info ] developer github: https://github.com/W1lliam1337\n");
printf("[ info ] 'del' - close the console\n");
printf( "[ info ] developer github: https://github.com/W1lliam1337\n" );
printf( "[ info ] press 'del' if you want to close the console\n" );

printf("[ main ] modules initialization...\n");
utils::init_modules(base);
printf( "[ main ] modules initialization...\n" );
utils::init_modules( base );

printf("[ main ] hooks initialization...\n");
hooks::instance();
printf( "[ main ] hooks initialization...\n" );
hooks::instance( );

while (!GetAsyncKeyState(VK_DELETE))
{
_getwch();
ShowWindow(GetConsoleWindow(), SW_HIDE);
while ( !GetAsyncKeyState( VK_DELETE ) ) {
_getwch( );
ShowWindow( GetConsoleWindow( ), SW_HIDE );
}

return 1;
}

BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
) {
switch ( ul_reason_for_call ) {
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(hModule);
CreateThread(nullptr, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(main), hModule, 0, nullptr);
DisableThreadLibraryCalls( hModule );
CreateThread( nullptr, 0, reinterpret_cast< LPTHREAD_START_ROUTINE >( main ), hModule, 0, nullptr );
return TRUE;
}
/*case DLL_PROCESS_DETACH:
{
utils::shutdown();
return TRUE;
}*/
/*case DLL_PROCESS_DETACH:
{
utils::shutdown();
return TRUE;
}*/
default: break;
}

Expand Down
Loading

0 comments on commit 00024cb

Please sign in to comment.