- WH
- ESP
- Anty SS
#include "HLSDK/stdafx.h"
#include "AsiMain.h"
extern "C" DLLEXPORT S32 AILCALL RIB_Main(HPROVIDER provider_handle,
U32 up_down,
RIB_alloc_provider_handle_ptr RIB_alloc_provider_handle,
RIB_register_interface_ptr RIB_register_interface,
RIB_unregister_interface_ptr RIB_unregister_interface
)
{
if(up_down)
{
//code loaded
}
else
{
//code on unload
}
return 1;
}
#include "HLSDK/stdafx.h"
#include "AsiMain.h"
extern "C" DLLEXPORT S32 AILCALL RIB_Main(HPROVIDER provider_handle,
U32 up_down,
RIB_alloc_provider_handle_ptr RIB_alloc_provider_handle,
RIB_register_interface_ptr RIB_register_interface,
RIB_unregister_interface_ptr RIB_unregister_interface
)
{
if(up_down)
{
//code loaded
}
else
{
//code on unload
}
return 1;
}
#include "HLSDK/stdafx.h" #include "AsiMain.h" extern "C" DLLEXPORT S32 AILCALL RIB_Main(HPROVIDER provider_handle, U32 up_down, RIB_alloc_provider_handle_ptr RIB_alloc_provider_handle, RIB_register_interface_ptr RIB_register_interface, RIB_unregister_interface_ptr RIB_unregister_interface ) { if(up_down) { //code loaded } else { //code on unload } return 1; }Zawartość AsiMain.h
#ifdef _WIN32
#define AILCALL __stdcall
#else
#define AILCALL
#endif
#ifndef C8
#define C8 char
#endif
#ifndef U32
#define U32 unsigned int
#endif
#ifndef S32
#define S32 signed int
#endif
#ifndef UINTa
#define UINTa unsigned int
#endif
#define FAR
typedef U32 HPROVIDER;
typedef S32 RIBRESULT;
typedef enum
{
RIB_NONE = 0, // No type
RIB_CUSTOM, // Used for pointers to application-specific structures
RIB_DEC, // Used for 32-bit integer values to be reported in decimal
RIB_HEX, // Used for 32-bit integer values to be reported in hex
RIB_FLOAT, // Used for 32-bit single-precision FP values
RIB_PERCENT, // Used for 32-bit single-precision FP values to be reported as percentages
RIB_BOOL, // Used for Boolean-constrained integer values to be reported as TRUE or FALSE
RIB_STRING, // Used for pointers to null-terminated ASCII strings
RIB_READONLY = 0x80000000 // Property is read-only
}
RIB_DATA_SUBTYPE;
typedef enum
{
RIB_FUNCTION = 0,
RIB_PROPERTY // Property: read-only or read-write data type
}
RIB_ENTRY_TYPE;
typedef struct
{
RIB_ENTRY_TYPE type;
C8 FAR *entry_name;
UINTa token;
RIB_DATA_SUBTYPE subtype; // Property subtype
}
RIB_INTERFACE_ENTRY;
typedef HPROVIDER (*RIB_alloc_provider_handle_ptr) (long module);
typedef RIBRESULT (*RIB_register_interface_ptr) (HPROVIDER provider, C8 const FAR *interface_name, S32 entry_count, RIB_INTERFACE_ENTRY const FAR *rlist);
typedef RIBRESULT (*RIB_unregister_interface_ptr) (HPROVIDER provider, C8 const FAR *interface_name, S32 entry_count, RIB_INTERFACE_ENTRY const FAR *rlist);
extern "C" DLLEXPORT S32 AILCALL RIB_Main(HPROVIDER provider_handle,
U32 up_down,
RIB_alloc_provider_handle_ptr RIB_alloc_provider_handle,
RIB_register_interface_ptr RIB_register_interface,
RIB_unregister_interface_ptr RIB_unregister_interface
);
#ifdef _WIN32
#define AILCALL __stdcall
#else
#define AILCALL
#endif
#ifndef C8
#define C8 char
#endif
#ifndef U32
#define U32 unsigned int
#endif
#ifndef S32
#define S32 signed int
#endif
#ifndef UINTa
#define UINTa unsigned int
#endif
#define FAR
typedef U32 HPROVIDER;
typedef S32 RIBRESULT;
typedef enum
{
RIB_NONE = 0, // No type
RIB_CUSTOM, // Used for pointers to application-specific structures
RIB_DEC, // Used for 32-bit integer values to be reported in decimal
RIB_HEX, // Used for 32-bit integer values to be reported in hex
RIB_FLOAT, // Used for 32-bit single-precision FP values
RIB_PERCENT, // Used for 32-bit single-precision FP values to be reported as percentages
RIB_BOOL, // Used for Boolean-constrained integer values to be reported as TRUE or FALSE
RIB_STRING, // Used for pointers to null-terminated ASCII strings
RIB_READONLY = 0x80000000 // Property is read-only
}
RIB_DATA_SUBTYPE;
typedef enum
{
RIB_FUNCTION = 0,
RIB_PROPERTY // Property: read-only or read-write data type
}
RIB_ENTRY_TYPE;
typedef struct
{
RIB_ENTRY_TYPE type;
C8 FAR *entry_name;
UINTa token;
RIB_DATA_SUBTYPE subtype; // Property subtype
}
RIB_INTERFACE_ENTRY;
typedef HPROVIDER (*RIB_alloc_provider_handle_ptr) (long module);
typedef RIBRESULT (*RIB_register_interface_ptr) (HPROVIDER provider, C8 const FAR *interface_name, S32 entry_count, RIB_INTERFACE_ENTRY const FAR *rlist);
typedef RIBRESULT (*RIB_unregister_interface_ptr) (HPROVIDER provider, C8 const FAR *interface_name, S32 entry_count, RIB_INTERFACE_ENTRY const FAR *rlist);
extern "C" DLLEXPORT S32 AILCALL RIB_Main(HPROVIDER provider_handle,
U32 up_down,
RIB_alloc_provider_handle_ptr RIB_alloc_provider_handle,
RIB_register_interface_ptr RIB_register_interface,
RIB_unregister_interface_ptr RIB_unregister_interface
);
#ifdef _WIN32 #define AILCALL __stdcall #else #define AILCALL #endif #ifndef C8 #define C8 char #endif #ifndef U32 #define U32 unsigned int #endif #ifndef S32 #define S32 signed int #endif #ifndef UINTa #define UINTa unsigned int #endif #define FAR typedef U32 HPROVIDER; typedef S32 RIBRESULT; typedef enum { RIB_NONE = 0, // No type RIB_CUSTOM, // Used for pointers to application-specific structures RIB_DEC, // Used for 32-bit integer values to be reported in decimal RIB_HEX, // Used for 32-bit integer values to be reported in hex RIB_FLOAT, // Used for 32-bit single-precision FP values RIB_PERCENT, // Used for 32-bit single-precision FP values to be reported as percentages RIB_BOOL, // Used for Boolean-constrained integer values to be reported as TRUE or FALSE RIB_STRING, // Used for pointers to null-terminated ASCII strings RIB_READONLY = 0x80000000 // Property is read-only } RIB_DATA_SUBTYPE; typedef enum { RIB_FUNCTION = 0, RIB_PROPERTY // Property: read-only or read-write data type } RIB_ENTRY_TYPE; typedef struct { RIB_ENTRY_TYPE type; C8 FAR *entry_name; UINTa token; RIB_DATA_SUBTYPE subtype; // Property subtype } RIB_INTERFACE_ENTRY; typedef HPROVIDER (*RIB_alloc_provider_handle_ptr) (long module); typedef RIBRESULT (*RIB_register_interface_ptr) (HPROVIDER provider, C8 const FAR *interface_name, S32 entry_count, RIB_INTERFACE_ENTRY const FAR *rlist); typedef RIBRESULT (*RIB_unregister_interface_ptr) (HPROVIDER provider, C8 const FAR *interface_name, S32 entry_count, RIB_INTERFACE_ENTRY const FAR *rlist); extern "C" DLLEXPORT S32 AILCALL RIB_Main(HPROVIDER provider_handle, U32 up_down, RIB_alloc_provider_handle_ptr RIB_alloc_provider_handle, RIB_register_interface_ptr RIB_register_interface, RIB_unregister_interface_ptr RIB_unregister_interface );Kod powyżej tak naprawdę nie robi nić możemy do niego dodać ładowanie naszej biblioteki poprzez np.
HINSTANCE LoadME;
LoadMe = LoadLibrary("..\\enter a Path To Your Dll here\\LoadMe.dll");
if (LoadMe != 0)
printf("LoadMe library loaded!\n");
else
printf("LoadMe library failed to load!\n");
HINSTANCE LoadME;
LoadMe = LoadLibrary("..\\enter a Path To Your Dll here\\LoadMe.dll");
if (LoadMe != 0)
printf("LoadMe library loaded!\n");
else
printf("LoadMe library failed to load!\n");
HINSTANCE LoadME; LoadMe = LoadLibrary("..\\enter a Path To Your Dll here\\LoadMe.dll"); if (LoadMe != 0) printf("LoadMe library loaded!\n"); else printf("LoadMe library failed to load!\n");Spróbujmy dodać teraz kod będzie reagował na komendę w konsoli i wypisywał coś do niej. Na początku potrzebujemy IDA PRO lub programu podobnego do niego. Otwieramy plik hw.so i zaczynamy jego analizę następnie Edit-> Segments-> Rebase Program i ustawiamy ImageBase na on 0x40000000. Szukamy ScreenShake.


cl_enginefunc_t *cl_enginefuncs;
cl_enginefunc_t *cl_enginefuncs;
cl_enginefunc_t *cl_enginefuncs;Przed RibMain deklarujemy funkcje
void Hello()
{
cl_enginefuncs->Con_Printf("Hello You!\n");
}
void Hello()
{
cl_enginefuncs->Con_Printf("Hello You!\n");
}
void Hello() { cl_enginefuncs->Con_Printf("Hello You!\n"); }W RibMain dodajemy
HANDLE hw=LoadLibraryA("hw.dll");
cl_enginefuncs=(cl_enginefunc_t*)((unsigned long)hw+0x134260);
cl_enginefuncs->pfnAddCommand("SayHello",Hello);
HANDLE hw=LoadLibraryA("hw.dll");
cl_enginefuncs=(cl_enginefunc_t*)((unsigned long)hw+0x134260);
cl_enginefuncs->pfnAddCommand("SayHello",Hello);
HANDLE hw=LoadLibraryA("hw.dll"); cl_enginefuncs=(cl_enginefunc_t*)((unsigned long)hw+0x134260); cl_enginefuncs->pfnAddCommand("SayHello",Hello);Po wpisaniu w konsole SayHello dostaniemy wiadomość Hello You! Paczka projektu: darkHack.zip Download