Network: WoW Gold | WoW Accounts | MPS Games | FPSowned
MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides
Homepage »      Register »      Hall of Fame »      Ranks And Awards »      Advertise »      Marketplace »
 
Sign up



Do you like this excellent information? Then Donate HERE to remove ads and support the MMOwned community.


Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > World of Warcraft > Bots and Programs > WoW Memory Editing

WoW Memory Editing WoW Memory Editing for learning purposes only.
This section is more advanced than others on MMOwned Read the section specific rules, infractions will be given out if u break them!That is including the expectations! - If you don't meet them then don't post

Reply
 
LinkBack Thread Tools
  #16  
Old 10-08-2009
flo8464's Avatar
flo8464 is offline.
Knight
  
 
Join Date: Apr 2009
Posts: 217
Reputation: 11
Points: 936, Level: 2
Points: 936, Level: 2 Points: 936, Level: 2 Points: 936, Level: 2
Level up: 8%, 464 Points needed
Level up: 8% Level up: 8% Level up: 8%
Activity: 16.0%
Activity: 16.0% Activity: 16.0% Activity: 16.0%

Quote:
Originally Posted by lanman92 View Post
If you're using C++, is there ANY reason to be out of process? Anyway, I would say make an inline function and put an asm block in it. Much nicer. Then you can just copy the bytes out of that function into the process and execute it. I don't really see any problem with that asm, but you never know when it's in shellcode...
Is there a reliable way to determine the length of a C/C++-function?

Another problem is that most compilers will create a stackframe etc even if your function is just something like this

Code:
void nothing()
{
   asm {"mov eax, 1"}
}
Reply With Quote


Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx.

  #17  
Old 10-08-2009
lanman92 is offline.
Site Donator
  
 
Join Date: Mar 2007
Posts: 764
Reputation: 20
Points: 3,864, Level: 6
Points: 3,864, Level: 6 Points: 3,864, Level: 6 Points: 3,864, Level: 6
Level up: 30%, 636 Points needed
Level up: 30% Level up: 30% Level up: 30%
Activity: 6.0%
Activity: 6.0% Activity: 6.0% Activity: 6.0%

I don't think they do if you do __declspec(naked). I don't remember exactly how to do it, but there's a DLL injection tutorial on edgeofnowhere.cc and it shows how it's done. It's not really C++, more C-like.
Reply With Quote
  #18  
Old 10-08-2009
furang's Avatar
furang is offline.
Master Sergeant
  
 
Join Date: Jul 2009
Posts: 84
Reputation: 19
Points: 315, Level: 1
Points: 315, Level: 1 Points: 315, Level: 1 Points: 315, Level: 1
Level up: 79%, 85 Points needed
Level up: 79% Level up: 79% Level up: 79%
Activity: 5.1%
Activity: 5.1% Activity: 5.1% Activity: 5.1%

Still don't have lua_DoString() working. Had to change my shellcode and source too few times, but didn't help(((
New code with debug inlines (just to check there's no mess with addresses ):
Code:
int Lua_DoString(char *luastr)
{
		FILE* f;
		int res;
		char olo1[50];
		char olo2[50];
		void* strmem;
		DWORD codemem;
		char shellcode[]=
		"\x8B\x15\xB0\x05\x27\x01\x8B\x92\x94\x2D\x00\x00" //MOV EDX,DWORD PTR DS:[12705B0];  MOV EDX,DWORD PTR DS:[EDX+2D94]
		"\x64\xA1\x2C\x00\x00\x00\x8B\x00\x83\xC0\x08" //MOV EAX,DWORD PTR FS:[2C];  MOV EAX,DWORD PTR DS:[EAX],ADD EAX,8
		"\x89\x10\x6A\x00\xB8\x78\x56\x34\x12" //MOV DWORD PTR DS:[EAX],EDX,PUSH 0; MOV EAX,12345678 - luastr addr
		"\x50\x50\xE8\x89\xF6\x7C\x00\x83\xC4\x0C" //PUSH EAX,PUSH EAX,CALL 007CF6B0,ADD ESP,0C
		"\xC3";//retn
		f=fopen("D:\\crack\\hiew\\code.txt","wb");
		ReadProcessMemory( hProc, (LPVOID)(0x0133D5B0), (LPVOID)&res, sizeof(res), NULL );
		while (res!=0)
		{
		ReadProcessMemory( hProc, (LPVOID)(0x0133D5B0), (LPVOID)&res, sizeof(res), NULL );
		Sleep(0);
		}
		SuspendThread(mThread);
		strmem=VirtualAllocEx(hProc,NULL,1024,MEM_COMMIT,PAGE_READWRITE);
		if (strmem==NULL)
		ShowMessage("Can't alloc some mem");
		ShowMessage(HexToStr((DWORD)strmem));// showing me luastr addr
		WriteProcessMemory(hProc, strmem,&luastr[0],100,NULL);
	
		codemem=(DWORD)VirtualAllocEx(hProc,NULL,1024,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
		if (codemem==NULL)
		ShowMessage("Can't alloc some mem");

		WriteProcessMemory(hProc, (LPVOID)codemem,&shellcode[0],sizeof(shellcode),NULL);
		WriteProcessMemory(hProc, (LPVOID)(codemem+28),&strmem,sizeof(codemem),NULL);// fixing luastr addr
		
		ReadProcessMemory( hProc, (LPVOID)(codemem), (LPVOID)&olo1[0], 50, NULL );//check if code is written
		ReadProcessMemory( hProc, (LPVOID)(strmem), (LPVOID)&olo2[0], 50, NULL );// check if luastr is written

		fwrite(&olo1[0],1,50,f);//writing shellcode from wow to file
		fwrite(&olo2[0],1,50,f);//writing luastr from wow to file
		
		HANDLE rThread=CreateRemoteThread(hProc,NULL,0,(PTHREAD_START_ROUTINE)codemem,NULL,0,NULL);
		WaitForSingleObject(rThread, 10000);
		CloseHandle(rThread);
		
		ResumeThread(mThread);
		if(!VirtualFreeEx(hProc,(LPVOID)strmem,NULL,MEM_RELEASE)) ShowMessage ("Can't free mem");
		if(!VirtualFreeEx(hProc,(LPVOID)codemem,NULL,MEM_RELEASE)) ShowMessage ("Can't free mem");
		fclose(f);
		return 0;
}
And here's code.txt
Click the image to open in full size.
0xA040000 is the luastr's address
And here's what was read from 0x0A040000
Click the image to open in full size.
As you can see luastr is really there.
But anyway i get this
Click the image to open in full size.
and this
Click the image to open in full size.
If anyone has an idea what's wrong with my code please share your thoughts. I'd be very grateful. guaranteed!
__________________
i did it 4 lulz

Last edited by furang; 10-10-2009 at 11:35 AM.
Reply With Quote
  #19  
Old 10-09-2009
Ellesar1 is offline.
Site Donator
  
 
Join Date: Feb 2009
Posts: 60
Reputation: 12
Points: 577, Level: 1
Points: 577, Level: 1 Points: 577, Level: 1 Points: 577, Level: 1
Level up: 36%, 323 Points needed
Level up: 36% Level up: 36% Level up: 36%
Activity: 2.5%
Activity: 2.5% Activity: 2.5% Activity: 2.5%

sorry, i'm absolutely new to memory editing. so please don't flame if i'm wrong.

Quote:
WriteProcessMemory(hProc, strmem,&luastr[0],100,NULL);
how do you get this "100"? The lua string isn't that big. Couldn't it be that the random values which are lying in the memory after the luastr array make it crash?


same thing at
Quote:
WriteProcessMemory(hProc, (LPVOID)(codemem+28),&strmem,sizeof(codemem),NULL);// fixing luastr addr
you have allocated 1024 bytes for codemem. however, you write sizeof(codemem) = 1024 starting from offset 28. You overwrite the following 28 bytes in memory. My opinion is that the length has to be sizeof((DWORD)codemem)
//Edit
args. forget about it. codemem is just a longpointer... so sizeof(codemem) = 8 bytes, not 1024. i'm letting it here that some other beginner may use it...

please correct me if i'm wrong since I want to improve my knowledge in this area :-)

Last edited by Ellesar1; 10-09-2009 at 07:52 PM.
Reply With Quote
  #20  
Old 10-09-2009
furang's Avatar
furang is offline.
Master Sergeant
  
 
Join Date: Jul 2009
Posts: 84
Reputation: 19
Points: 315, Level: 1
Points: 315, Level: 1 Points: 315, Level: 1 Points: 315, Level: 1
Level up: 79%, 85 Points needed
Level up: 79% Level up: 79% Level up: 79%
Activity: 5.1%
Activity: 5.1% Activity: 5.1% Activity: 5.1%

This 100 is taken for debugging only. PoC luastr is less.
As you can see it in hiew screen luastr is terminated by zero byte. So it doesn't matter what comes next.
codemem is a pointer to the begining of allocated memory. So sizeof codemem is 4 because codemem is DWORD. So i overwrite 4 bytes starting 28 bytes from the begining.
Look at my code and hiew screens. It shows that shellcode and luastr are written alright and that pointer to luastr is fixed in shellcode. But fjr the reason i don't know wow crashes((
__________________
i did it 4 lulz
Reply With Quote
  #21  
Old 10-09-2009
Ellesar1 is offline.
Site Donator
  
 
Join Date: Feb 2009
Posts: 60
Reputation: 12
Points: 577, Level: 1
Points: 577, Level: 1 Points: 577, Level: 1 Points: 577, Level: 1
Level up: 36%, 323 Points needed
Level up: 36% Level up: 36% Level up: 36%
Activity: 2.5%
Activity: 2.5% Activity: 2.5% Activity: 2.5%

okay, examining your shellcode now

(TLS = [TIB + 0x2C])
(1 array index = 4 bytes value)

Quote:
TLS[2] := g_clientConnection + s_curMgrOffset
stack[0] := 0
stack[-1] := luastr
stack[-2] := luastr
call luaDoString
this is the code which remains when removing/combining all stuff into a minimum.

my questions:
- what is the purpose of overwriting global data in the wow address space to call a function oO? why do we need this g_clientConnection + s_curMgrOffset here?

- sure that it is TLS[2] that you have to overwrite? In the post from qjlex on page one of the thread, he overwrites TLS[4], so TLS + 16
Reply With Quote
  #22  
Old 10-09-2009
furang's Avatar
furang is offline.
Master Sergeant
  
 
Join Date: Jul 2009
Posts: 84
Reputation: 19
Points: 315, Level: 1
Points: 315, Level: 1 Points: 315, Level: 1 Points: 315, Level: 1
Level up: 79%, 85 Points needed
Level up: 79% Level up: 79% Level up: 79%
Activity: 5.1%
Activity: 5.1% Activity: 5.1% Activity: 5.1%

I guess i've misunderstood you, but.... well.
Quote:
what is the purpose of overwriting global data in the wow address space to call a function oO?
And what i overwrite? I allocate some free memory in wow, write there code and data, fixing pointer to data, execute code, free memory. Nothing's overwritten.
We need g_clientConnection + s_curMgrOffset to get TLS. And have you read all topic?
Look at it [Only registered and activated users can see links. ]
and this
Code:
                BotContro1l.mem.Asm.AddLine("FS mov EAX, [0x2C]");
                BotContro1l.mem.Asm.AddLine("mov EAX, [EAX]");
                BotContro1l.mem.Asm.AddLine("add EAX, 8");
                BotContro1l.mem.Asm.AddLine("mov [EAX], edx");
So as i undrstand it shiould be TLS[2], TLS + 0x8
Sorry. Maybe i misunderstood smth. Show me please what's wrong to your opinion.
__________________
i did it 4 lulz

Last edited by furang; 10-09-2009 at 09:30 PM.
Reply With Quote
  #23  
Old 10-09-2009
Ellesar1 is offline.
Site Donator
  
 
Join Date: Feb 2009
Posts: 60
Reputation: 12
Points: 577, Level: 1
Points: 577, Level: 1 Points: 577, Level: 1 Points: 577, Level: 1
Level up: 36%, 323 Points needed
Level up: 36% Level up: 36% Level up: 36%
Activity: 2.5%
Activity: 2.5% Activity: 2.5% Activity: 2.5%

you are right. seems that i've missed some part on page 1 since it all looks similar and i've lost the overview.

my guess about "overwriting" was that you read TLS base pointer via "FS mov EAX, [0x2C]", dereference via "mov EAX, [EAX]" and jump to offset 2 via "add EAX, 8". then you write edx = g_clientConnection + s_curMgrOffset to the location where EAX currently points to (which is [TLS[2 * 4]] ), thus overwriting what stood there before.

well, now that i've seen qjlex's second post it's clear that the asm cannot be the problem source since he got the same one except that he has allocated a 0x2048 block ( = 8264 bytes) for the code AND the string (which shouldn't make a difference) instead of taking two 1024 byte ones. (i think that he forgot that he wants to use decimal numbers and put the 0x before by accident)

your writeprocessmemory's cannot be the problem source either since they are stored properly. (maybe, the MEM_RESERVE flag should be also set with the MEM_COMMIT flag?)

one other possible thing could maybe be that you don't immediately suspend the wow thread when the lua lock gets released. instead, you yield with sleep(0) and check afterwards, if the outdated value of the lock states "lock was released". the wow thread could acquire it again in the meantime, ****ing it up and crashing.


ps: to the "We need g_clientConnection + s_curMgrOffset to get TLS." Sorry for bothering, but don't we get the TLS via "FS mov eax, [0x2C]" regardless of what we have computed in edx?

pps: why is the realm IP intact in the wowerror message, but the whole rest not... strange


ppps: what is it exactly which causes the crash? does it also crash if you don't call luaDoString actually? does it crash as soon as there is some assembler code you execute? does it crash even if you don't ever execute your assembler code?

Last edited by Ellesar1; 10-09-2009 at 10:16 PM.
Reply With Quote
  #24  
Old 10-09-2009
furang's Avatar
furang is offline.
Master Sergeant
  
 
Join Date: Jul 2009
Posts: 84
Reputation: 19
Points: 315, Level: 1
Points: 315, Level: 1 Points: 315, Level: 1 Points: 315, Level: 1
Level up: 79%, 85 Points needed
Level up: 79% Level up: 79% Level up: 79%
Activity: 5.1%
Activity: 5.1% Activity: 5.1% Activity: 5.1%

I've searched in Google.
[Only registered and activated users can see links. ]
All have similar code. [Only registered and activated users can see links. ]
But i can't understand what's wrong in my case. Gonna view BM's sources to undrstand what's the source of my problem. And check if lua lock is released when calling DoString.
10x for ideas.
__________________
i did it 4 lulz
Reply With Quote
  #25  
Old 10-10-2009
Ellesar1 is offline.
Site Donator
  
 
Join Date: Feb 2009
Posts: 60
Reputation: 12
Points: 577, Level: 1
Points: 577, Level: 1 Points: 577, Level: 1 Points: 577, Level: 1
Level up: 36%, 323 Points needed
Level up: 36% Level up: 36% Level up: 36%
Activity: 2.5%
Activity: 2.5% Activity: 2.5% Activity: 2.5%

found another difference between yours and the working ones:

you don't have set the PAGE_EXECUTE_READWRITE flag to the luastr memory. instead, you just set PAGE_READWRITE. don't think that it makes the difference since the luastr isn't executed anyways. but trying cannot make it worse.
Reply With Quote
  #26  
Old 10-10-2009
furang's Avatar
furang is offline.
Master Sergeant
  
 
Join Date: Jul 2009
Posts: 84
Reputation: 19
Points: 315, Level: 1
Points: 315, Level: 1 Points: 315, Level: 1 Points: 315, Level: 1
Level up: 79%, 85 Points needed
Level up: 79% Level up: 79% Level up: 79%
Activity: 5.1%
Activity: 5.1% Activity: 5.1% Activity: 5.1%

Quote:
pps: why is the realm IP intact in the wowerror message, but the whole rest not... strange
All that data is safe. I play on Russian server and the rest is unicode strings in ascii mode.
Quote:
ppps: what is it exactly which causes the crash? does it also crash if you don't call luaDoString actually? does it crash as soon as there is some assembler code you execute? does it crash even if you don't ever execute your assembler code?
No. It crashes only when i call lua_DoString(). I click the button (that calls lua_DoString) and in few seconds i have err. I tried to inject another shellcode. It was
Code:
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\xC3"
It's a NOP line with retn in the end. It does nothing. With this shellcode this function works fine, no crashes. So i suppose the source of the evil is my shellcode.
I also checked lua lock. It's always released (0) when i inject and call my code.
Now gonna debug it with int 3 (CC opcode). And how should i call function. I looked at opcode table. opcode for call is E8. But also FF 15. First is near call, second is far (as i understand). But don't understand waht should i use.
__________________
i did it 4 lulz
Reply With Quote
  #27  
Old 10-10-2009
flo8464's Avatar
flo8464 is offline.
Knight
  
 
Join Date: Apr 2009
Posts: 217
Reputation: 11
Points: 936, Level: 2
Points: 936, Level: 2 Points: 936, Level: 2 Points: 936, Level: 2
Level up: 8%, 464 Points needed
Level up: 8% Level up: 8% Level up: 8%
Activity: 16.0%
Activity: 16.0% Activity: 16.0% Activity: 16.0%

Code:
                BotContro1l.mem.Asm.AddLine("FS mov EAX, [0x2C]");
                BotContro1l.mem.Asm.AddLine("mov EAX, [EAX]");
                BotContro1l.mem.Asm.AddLine("add EAX, 8");
                BotContro1l.mem.Asm.AddLine("mov [EAX], edx");
This makes absolutly no sense. You are attempting to load the Object-Manager address (incorrectly) and then you overwrite it...

WoW does it like this:

Code:
.text:00476580 mov ecx, large fs:2Ch // fs points to TEB, 0x2C is the offset to the storage-pointer
.text:00476587 mov eax, TlsIndex // Index of the storage is loaded
.text:0047658C mov edx, [ecx+eax*4]
.text:0047658F mov ecx, [edx+8]
Reply With Quote
  #28  
Old 10-10-2009
furang's Avatar
furang is offline.
Master Sergeant
  
 
Join Date: Jul 2009
Posts: 84
Reputation: 19
Points: 315, Level: 1
Points: 315, Level: 1 Points: 315, Level: 1 Points: 315, Level: 1
Level up: 79%, 85 Points needed
Level up: 79% Level up: 79% Level up: 79%
Activity: 5.1%
Activity: 5.1% Activity: 5.1% Activity: 5.1%

But qjlex here [Only registered and activated users can see links. ] says that this works for him. My code's the same. And everywhere on forum it looks similar [Only registered and activated users can see links. ]
__________________
i did it 4 lulz
Reply With Quote
  #29  
Old 10-10-2009
Ellesar1 is offline.
Site Donator
  
 
Join Date: Feb 2009
Posts: 60
Reputation: 12
Points: 577, Level: 1
Points: 577, Level: 1 Points: 577, Level: 1 Points: 577, Level: 1
Level up: 36%, 323 Points needed
Level up: 36% Level up: 36% Level up: 36%
Activity: 2.5%
Activity: 2.5% Activity: 2.5% Activity: 2.5%

that's what i've meant with "overwriting". gave the idea up after i saw that the other implementation does the same thing with success. However, I don't understand why you have to patch those addresses even... just taking it as given that it is necessary.

Code:
char shellcode[]=
		"\x8B\x15\xB0\x05\x27\x01\x8B\x92\x94\x2D\x00\x00" //MOV EDX,DWORD PTR DS:[12705B0];  MOV EDX,DWORD PTR DS:[EDX+2D94]
		"\x64\xA1\x2C\x00\x00\x00\x8B\x00\x83\xC0\x08" //MOV EAX,DWORD PTR FS:[2C];  MOV EAX,DWORD PTR DS:[EAX],ADD EAX,8
		"\x89\x10\x6A\x00\xB8\x78\x56\x34\x12" //MOV DWORD PTR DS:[EAX],EDX,PUSH 0; MOV EAX,12345678 - luastr addr
		"\x50\x50\x83\xC4\x0C" //PUSH EAX,PUSH EAX,ADD ESP,0C
		"\xC3";//retn
what about this shellcode? does everything except the call.
Reply With Quote
  #30  
Old 10-10-2009
furang's Avatar
furang is offline.
Master Sergeant
  
 
Join Date: Jul 2009
Posts: 84
Reputation: 19
Points: 315, Level: 1
Points: 315, Level: 1 Points: 315, Level: 1 Points: 315, Level: 1
Level up: 79%, 85 Points needed
Level up: 79% Level up: 79% Level up: 79%
Activity: 5.1%
Activity: 5.1% Activity: 5.1% Activity: 5.1%

This doesn't crash wow now. Hm.... so call was the source of problems?
But i don't understand what is wrong. How to fix it? And maybe should i allocate 1 block of memory for both code and luastr?
__________________
i did it 4 lulz
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On



All times are GMT -4. The time now is 08:49 AM.




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493