![]() |
|
|
#1 |
|
Архивный участник
Join Date: May 2006
Posts: 55
|
First of all, big thanks to Aspire for his shares on this forum.
And of course thanks to all other devs This party invite fix entirely based on shared information and analysis of linex and zzcat dlls Code of dll (masm32) based on Aspire posted source: Code:
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
.data?
szViewPacket db 1024 dup (?)
.const
szDestClass db 'Notepad',0
__DEBUG__ equ TRUE
ifdef __DEBUG__
include \masm32\include\debug.inc
includelib \masm32\lib\debug.lib
endif
.code
PatchAddrProc proc
;this proc will run on dll load so here we must put WriteProcessMemory for automated memory modification. at this time i use olly to call dll :)
ret
PatchAddrProc endp
_SendtoNotepad proc _lpsz;just utility to send debug info in windows notepad.
local @hWinNotepad
pushad
invoke FindWindow,addr szDestClass,NULL
.if eax
mov ecx,eax
invoke ChildWindowFromPoint,ecx,20,20
.endif
.if eax
mov @hWinNotepad,eax
mov esi,_lpsz
@@:
lodsb
or al,al
jz @F
movzx eax,al
invoke PostMessage,@hWinNotepad,WM_CHAR,eax,1
jmp @B
@@:
.endif
popad
ret
_SendtoNotepad endp
FUNC_GET_OBJECTID_1 equ 517B90h
FUNC_GET_OBJECTID_2 equ 58C8B6h
FUNC_GET_OBJECTID_3 equ 406970h
FUNC_GET_OBJECTID_4 equ 41E4D0h
;ObjectName to ObjectID conversion. this proc identical in zzcats dll and linex
GetCharObjectByName proc uses ebx edi esi,_lpCharName
local @CharObject[12]:byte
local @szBuffer[148]:byte
lea eax,@szBuffer
push eax
push _lpCharName
mov eax,FUNC_GET_OBJECTID_1
call eax
add esp,08h
sub esp,124h
mov esi,esp
xor ebx,ebx
mov dword ptr [esi + 0120h],8Bh
mov dword ptr [esi + 011Ch],ebx
mov word ptr ds:[esi + 4],bx
lea edx,@szBuffer
push edx
mov eax,FUNC_GET_OBJECTID_2
call eax ;strlen
add esp,4
push eax
lea eax,@szBuffer
push eax
mov ecx,esi
mov eax,FUNC_GET_OBJECTID_3
call eax
lea ecx,@CharObject
push ecx
mov ecx,16922550h
mov eax,FUNC_GET_OBJECTID_4
call eax
mov eax,dword ptr @CharObject
ret
GetCharObjectByName endp
;this proc must be called from server. all packets from client will go here
RecvPacketProc proc uses ebx edi esi
local @szPacket[2048]:byte
local @OpCode:dword
local @isC4Packet:dword
local @PacketSize:dword
local @OpCodeLen:dword
local @lpstObject:dword
local @ObjectID:dword
pushad
OFFSET_LENGTH equ 10h
OFFSET_OPCODE equ 12h
.if al == 029h;0x29 - party invite OpCode
mov ecx,ebx
add ecx,OFFSET_OPCODE + 1
invoke GetCharObjectByName,ecx
mov @lpstObject,eax
;return from GetCharObjectByName must not be equal to zero, it will cause crash.
;zero will return if user /invite offline char. So we exit from proc.
.if @lpstObject == 0
popad
ret
.endif
mov eax,dword ptr [eax + 18h]
mov @ObjectID,eax
ifdef __DEBUG__
.const
dbgRequestPartyMsg db 'RequestParty Packet Received, the character id is %X',0Dh,0Ah,0
.code
invoke wsprintf,addr szViewPacket,addr dbgRequestPartyMsg,@ObjectID
invoke _SendtoNotepad,addr szViewPacket
endif
mov eax,@ObjectID
mov [ebx + OFFSET_OPCODE + 1],eax
mov dword ptr [ebx + OFFSET_OPCODE + 1 + sizeof dword],0
mov word ptr [ebx + OFFSET_OPCODE + 1 + sizeof dword + sizeof dword],599h
mov word ptr [ebx + OFFSET_LENGTH],0Bh
.endif
popad
ret
RecvPacketProc endp
DLLMain proc _hInstance,_dwReason,_dwReserved
mov eax,_dwReason
.if eax == DLL_PROCESS_ATTACH
mov eax,_hInstance
mov hInstance,eax
invoke PatchAddrProc
mov eax,TRUE
.elseif eax == DLL_THREAD_ATTACH
mov eax,TRUE
.elseif eax == DLL_THREAD_DETACH
mov eax,TRUE
.elseif eax == DLL_PROCESS_DETACH
mov eax,TRUE
.endif
ret
DLLMain endp
end DLLMain
Now about place from we will call dll. In my server (C3 PP release) it looks like: Code:
0050F945 3C AA CMP AL,0AA;OpCode check 0050F947 72 1D JB SHORT serveror.0050F966; here jump if OpCode less than 0хAA (С1-С2 packet) 0050F949 -E9 728B1A00 JMP serveror.006B84C0;here jump all others, in my case alt+m and /loc Code:
0050F945 3C AA CMP AL,0AA 0050F947 -0F82 7A17EAFF JB 006B8B4A;any free space in l2server where enough space to call dll and jump back 0050F94D -E9 6E8B1A00 JMP serveror.006B84C0; jump to greater than 0xAA packets adress little shifted Code:
006B8B4A E8 7885CFFF CALL patch.003B10C7;here must be exact adress of dlls RecvPacketProc entry point. in your case it may be different 006B8B4F -E9 126EE5FF JMP serveror.0050F966;after dll make their work just return Now i have 1 big problem: client crash on multisell list select (server C3 PP release, client C3 551). May be somebody have some info about multisell packet? |
|
|
|
|
#2 |
|
Архивный участник
Join Date: May 2006
Posts: 36
|
1) Multisell in HF pack (Aspire's code:P)
2) Entry point wrong selected, return point too, read Aspire's message about that key - that is post CMD - and you need first chain - it's somewhere higher where Getcurrentprocess placed. |
|
|
|
|
#3 | |
|
Архивный участник
Join Date: May 2006
Posts: 55
|
Multisell fix from HF pack designed for C4. Sadly it dont work on 551 client C3 (still crashing). And i dont look for just hex to apply and know nothing about how it work. I mean information about multisell packet assembling process on server side will be more useful.
About entry: where else we can put entry point? And what wrong with my return adress? it exact same adress where "normal" C3 server go. when you say Quote:
Code:
00590492 |. 59 POP ECX 00590493 |. 75 10 JNZ SHORT serveror.005904A5 00590495 |. FF75 08 PUSH DWORD PTR SS:[EBP+8] ; /ExitCode 00590498 |. FF15 E4505B00 CALL DWORD PTR DS:[<&KERNEL32.GetCurrent>; |[GetCurrentProcess 0059049E |. 50 PUSH EAX ; |hProcess 0059049F |. FF15 A4515B00 CALL DWORD PTR DS:[<&KERNEL32.TerminateP>; \TerminateProcess 005904A5 |> 837D 0C 00 CMP DWORD PTR SS:[EBP+C],0 005904A9 |. 8A45 10 MOV AL,BYTE PTR SS:[EBP+10] btw with this fix my test server work fine more than 16 hours and still up. |
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: May 2006
Posts: 36
|
.005902c7 push (or entry point flag, or free mem, or fill with nop)
.005902c7: call @Entrypoint .005902cc: pop eax @Entrypoint 1)push 'dll name' 2)call LoadlibraryA ; Kernel32 3)test eax,eax 4)jne @exit 5)push -5 6)call ExitProcess; Kernel32 @Exit 7)mov [202f889c],eax 8) retn 9) int 3 |
|
|
|
|
#5 |
|
Архивный участник
Join Date: Apr 2006
Posts: 461
|
One question, since I am also learning to do dll injection and working on a dll on the side...if it gets to be pretty good I'll post the source in C++/ASM so people can develop off of it.
My question was, what is the address of the RequestParty function that we are overwriting? I would like to know so I can WriteProcessMemory(). Also, it would help me in debugging things like random party loot. Thanks a lot in advance. I really hope to keep learning. |
|
|
|
|
#6 |
|
Архивный участник
Join Date: May 2006
Posts: 36
|
main idea must be - hook packet from client with header 29h and return to same point, coz party packet have many parts like erro system, loot manager, smartid manager, party windows..., so to fix objectid we must hook first part of packet, all another maybe not needed, need just correctly return to exe from dll or all another parts will be bypassed.
|
|
|
|
|
#7 |
|
Архивный участник
Join Date: Apr 2006
Posts: 461
|
I know random party loot works fine in zzcats dll, just in his the cp, hp, and mp bars are switched (cause he didn't hook one of the party window functions). I believe a fix for that is on the forums, hex fix, and so fixing that should be pretty easy.
I will spend the next few hours here working on my dll code, and I will use your party packet as a base for my party packet. I hope you don't mind ^_^;;. I will just hook it in using loadlibrary at the very end of the exe. I will probably also have to hook the one line you showed, where the pakcet header is compared in the AL register. Anyways, I got an A- in MASM in college, but no classes on reverse engineering L2server.exe unfortunately :P |
|
|
|
|
#8 | |
|
Архивный участник
Join Date: May 2006
Posts: 55
|
Quote:
|
|
|
|
|
|
#9 | |
|
Архивный участник
Join Date: Nov 2005
Posts: 504
|
Quote:
also mcrabben7, the party window update blah blah packet for zzcat's dll was changed, but zzcat put the value for the CP at the end of the packet, instead of the beginning, so just changing where the engine.dll reads the CP from the packet is an easy fix for this. |
|
|
|
|
|
#10 | ||
|
Архивный участник
Join Date: May 2006
Posts: 36
|
Quote:
|
||
|
|
|
|
#11 |
|
Архивный участник
Join Date: Mar 2006
Posts: 97
|
Guys, can you share ready *.dll?
|
|
|
|
|
#12 |
|
Архивный участник
Join Date: Jan 2006
Posts: 11
|
Zeran just compile it
leecher
|
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|