Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Nostale
You last visited: Today at 12:23

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Hook Send problem (UK)

Discussion on Hook Send problem (UK) within the Nostale forum part of the MMORPGs category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jul 2007
Posts: 120
Received Thanks: 71
Hook Send problem (UK)

Hello folks,

I'm trying to hook the "send" function of nostale.

I wrote this little piece of code
Code:
#include <Windows.h>
#include <fstream>
#include <detours.h>

using namespace std; // byte me
void __cdecl add_log (char *fmt, ...);

//int __usercall sub_5D9464<eax>(int a1<eax>, int a2<edx>, int a3<edi>)
DWORD orgAddress = 0x5d9464;
DWORD jumpAddress;

void *DetourCreate(BYTE *src, const BYTE *dst, const int len);

// wrapper for __usercall
__declspec(naked) void send_unencrypted_hook()
{
	
	_asm pushad;
	_asm pushfd;
	
	DWORD a1,a2;
	char * command;

	__asm{
		
		mov a1,eax;
		mov command,edx;
		mov a2,edi;
	}

	add_log("Send hook: %d %d %s",a1,a2,command);

	
	_asm popfd;
	_asm popad;
	_asm jmp jumpAddress
	_asm ret // never gets here
}


DWORD initHook()
{
	add_log("Inside hook thread");
	//jumpAddress = (DWORD)DetourFunction((PBYTE)orgAddress,(PBYTE)send_unencrypted_hook);
	 jumpAddress = (DWORD)DetourCreate((PBYTE)orgAddress,(PBYTE)send_unencrypted_hook,6);
	return true;
}

void __cdecl add_log (char *fmt, ...)
{
	ofstream ofile;    
	ofile.open("mylog.txt", ios::app);
    if(ofile != NULL)
    {
        if(!fmt) { return; }

        va_list va_alist;
        char logbuf[256] = {0};

        va_start (va_alist, fmt);
        _vsnprintf (logbuf+strlen(logbuf), sizeof(logbuf) - strlen(logbuf), fmt, va_alist);
        va_end (va_alist);

        ofile << logbuf << endl;
    }
	ofile.close();
}


BOOL WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
{
	DisableThreadLibraryCalls(hMod);

	switch(dwReason)
	{
	case DLL_PROCESS_ATTACH:
		CreateThread(0,0,(LPTHREAD_START_ROUTINE)initHook,0,0,0);
		break;
	}
	
	return TRUE;
}



void *DetourCreate(BYTE *src, const BYTE *dst, const int len)
{
	BYTE *jmp = (BYTE*)malloc(len+5);
	DWORD dwBack;

	VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
	memcpy(jmp, src, len);	
	jmp += len;
	jmp[0] = 0xE9;
	*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
	src[0] = 0xE9;
	*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
	for (int i=5; i<len; i++)  src[i]=0x90;
	VirtualProtect(src, len, dwBack, &dwBack);
	return (jmp-len);
}
this is the sendhook function:


Somehow, i'm still not doing something right with the registers, and I can't figure out what.

When I do something in game i get the error msg: Error in address: xxx, couldnt write address: xxx.

The data that the hook gets is alright:

Send hook: 72055760 4837768 say hello
Send hook: 72055760 500 ncif 1 455015
Send hook: 72055760 100 walk 34 103 0 11
blackmorpheus is offline  
Old 10/17/2011, 17:52   #2
 
yoyoboss09's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 387
Received Thanks: 33
what exactly are you trying to do? o-o
yoyoboss09 is offline  
Old 10/17/2011, 17:55   #3
 
Rorc's Avatar
 
elite*gold: 113
The Black Market: 133/2/0
Join Date: Dec 2009
Posts: 16,685
Received Thanks: 4,449
I think the hook is just for a test right now, as I'm seeing.
And from what it looks like, it's gonna be some sort of packet Bot?
Rorc is offline  
Old 10/17/2011, 18:56   #4
 
elite*gold: 115
Join Date: Oct 2007
Posts: 9,390
Received Thanks: 12,344
Using Microsoft's Detours-library instead of your own detour-function would make your hook easier since you wouldn't have to deal with the registers.
ms​ is offline  
Thanks
2 Users
Old 10/17/2011, 19:27   #5
 
elite*gold: 0
Join Date: Jul 2007
Posts: 120
Received Thanks: 71
Quote:
Originally Posted by Metin2Spieler97 View Post
Using Microsoft's Detours-library instead of your own detour-function would make your hook easier since you wouldn't have to deal with the registers.
I don't really see what you're saying here.

I'm dealing with a __usercall function. Parameters are not pushed onto the stack, they are inside the eax edx etc registers.
This is why i have to do a naked function, to handle the registers myself.

What this does is it logs all the actions that user does.
Later on i'll add a simple wrapper to call this function so you can let it act like a bot.
blackmorpheus is offline  
Old 10/17/2011, 19:54   #6
 
elite*gold: 115
Join Date: Oct 2007
Posts: 9,390
Received Thanks: 12,344
Perhaps the local variables inside your detour-function are overwriting some other values on the stack. Try saving the registers into global variables instead, maybe that will do the trick.
ms​ is offline  
Thanks
1 User
Old 10/17/2011, 21:19   #7
 
elite*gold: 0
Join Date: Jul 2007
Posts: 120
Received Thanks: 71
Quote:
Originally Posted by Metin2Spieler97 View Post
Perhaps the local variables inside your detour-function are overwriting some other values on the stack. Try saving the registers into global variables instead, maybe that will do the trick.
Thanks, this did the trick.

I was quickly browsing through the german threads, and i saw they had a similar tools, that's why i made this. My german is not that good so i don't really understand what they're doing with it.
blackmorpheus is offline  
Old 10/18/2011, 18:32   #8
 
elite*gold: 0
Join Date: Oct 2011
Posts: 33
Received Thanks: 133
So it's working?
(So the question in my thread is allready answered?)
Mr.Crunch is offline  
Old 10/18/2011, 19:34   #9
 
elite*gold: 0
Join Date: Jul 2007
Posts: 120
Received Thanks: 71
Quote:
Originally Posted by Mr.Crunch View Post
So it's working?
(So the question in my thread is allready answered?)
No, i still cannot send packets myself...
Where do you actually call this function?

In another thread, or do you hook somewhere in nostalex.dat ?
blackmorpheus is offline  
Reply


Similar Threads Similar Threads
Winsock send Hook Problem
08/08/2011 - General Coding - 20 Replies
Huhu, Ich würde gerne die send(...) Mehtode hooken, um das Socket abfangen zu können, damit ich danach eigene Pakete verschicken kann. Das Problem besteht darin, dass sobald ich die dll injecte(z.b in firefox) und ein paket versende, einmal die MessageBox erscheint, das send() aufgerufen wurde und danach das Programm abstürtzt. Zum hooken benutze ich microsoft detours 1.5 und arbeite unter win 7 64bit. Die dll compile ich als 32bit und injecte sie auch in einen 32bit prozess. Würde mich...
[Help]HackShield detected send,recv hook c++
08/17/2010 - C/C++ - 6 Replies
Entschuldigung für noch einen Thread am selben Tag aber das passt glaub ich nicht wirklich in das andere deswegen eröffne ich einen neuen. Wenn ich die Winsock send recv hooke detected das Hackshield nach ca. 2 minuten einen hack kann man das Bypassen ? Und wenn ja,wie sollte ich anfangen. Würde mich freuen auf eine Antwort. Mit freundlichen Grüßen :)
[osds] problem send item & send weapon
11/12/2009 - Dekaron Private Server - 3 Replies
Hello i have 2 problems with osds control panel when i try to send weapon i have no more weapon available i cant choice i have nothing but i can send armor succesfully and my second problem is send item when i try to send item the browser say Login Error, Please login again.anyone can be fix that please? i post screenshots http://panzer.power-heberg.com/itembug.JPG http://panzer.power-heberg.com/noweapon.JPG
Hshield send function hook
10/11/2008 - Kal Online - 12 Replies
ey kann mir wer nen tipp geben wie man die addressen rauskriegt von int vom hshield für recv und send funktion damit die gehooked wird??



All times are GMT +2. The time now is 12:23.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.