Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 Stickies
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 09.10.2005, 06:50   #1
tontor
Архивный участник
 
Join Date: May 2005
Posts: 109
Default [Share] server side html exploit fix, cloning char fix

[edit] be sure to look for updates later on in the thread [/edit]
Heres my solution for html exploits, I'll explain how it works. Each time a client requests a html the server will parse the requested html for valid commands, crc them, and store them in a vector referenced by this characters accountid. each call that handles a bypass or link cmd has been hooked, so every bypass or link cmd the client sends to the server, now gets, crcd and checked against the users table in the vector. If the cmd crc matches one that was previously stored for this user, the cmd is verified and the user is permitted to pass the cmd, when it fails to match the cmd and account are is logged to the l2server console and error log files as a possible exploit attempt. Every time a user successfully completes a cmd or enterworld is called (if they relog), their table is cleared. Link is handled the same way, only on failure it will retrieve the file linkerr.htm displaying it to the user, just put an access denied msg or whatever you please here.


The vector size supports a default of 200,000 accounts, and a cmdlist of no more then 40 commands per html. At allocation time this uses ~30mb of memory, should you exceed 200,000 accounts it will double its size, until it can accomodate that high of account id(this will be buggy and cause problems in most cases cause of threading). So long as your html does not have more then 40cmds or a teleport list larger then 40 locations will work fine, and if you exceed that limit of 40, all cmds past the 40th will be ignored, and logged as an exploit.


Now that said there are a few things to explain about the effects this can cause.

First off, the method most versions of l2walker (maybe other bot clients also) handle htmls differs from ncsofts client, a side effect of this is that a majority of l2walker users will be logged as exploiters every time they access an npc, and denied access to use them. (not a bad side effect). If you see alot of failed teleport requests, warehouse withdraws, recipe crafting, from a certain account id, they are using a 3rd party client such as l2walker.

Second, didn't feel the need to handle in-game BBS since i don't think anyone ever uses it because it causes a lot of stability problems. So all _bbs commands logged as html exploit can be ignored, its simply an unhandled call.

Next, there appears to be a a few htmls for quests and such where the htmls include a link command that has extra spaces between "link nameof.htm", if you see alot of warnings for a html similar to something like name_q017_9823.htm, use grep or some other regexp program on all the html files in your html folder and locate the html that is calling link for this, and check it, it will have an extra space or something similar to this that is causing it to be reported incorrectly, and denying users access. (powergrep for windows is what i use).

(the following have link followed by 2 spaces and need to be corrected)
terry_q0213_22.htm
terry_q0213_21.htm
terry_q0213_18.htm
terry_q0213_08.htm
terry_q0213_06.htm
blacksmith_pushkin_q0218_07.htm

(the following have a space before the link cmd)
charkeren_q0412_01.htm

This patch should work for all, or most C1, C2, and C3 servers. I've tested it with c1 and c3 but not c2. Make a backup of your original l2server.exe, extract patch.exe and patch.dll into a folder with l2server.exe and run patch.exe once, after this you may discard patch.exe. l2server.exe will now force load of patch.dll opening a new console as you run it, displaying a list of calls that were hooked. Be sure that all of these are patched successfully, and if any fail then your l2server already has a modification at this address and wont be applied, most likely causing crashes and who knows what else. If you used my link+tp patch I posted on the forum awhile ago i suggest you use n l2server.exe without it, if you don't i believe link and teleport patches will fail but may still run fine.


Also this patch fixes the issue with people using l2walker to clone chars (livid mentioned something about there was a duping method using this), instead of just closing the user socket this calls leaveworld also making this method not work any longer.

I believe that covers about everything.
I've attached the patch and some fixed htmls.
tontor is offline  
Old 09.10.2005, 07:12   #2
Enishi
Архивный участник
 
Join Date: Apr 2005
Posts: 354
Default

Simply amazing.
Enishi is offline  
Old 09.10.2005, 07:28   #3
Livid
Архивный участник
 
Join Date: Apr 2005
Posts: 314
Default

O_O
Livid is offline  
Old 09.10.2005, 07:33   #4
Juiced
Архивный участник
 
Join Date: Oct 2005
Posts: 17
Default

Scan type: Realtime Protection Scan
Event: Virus Found!
Virus name: W32.Small.gen
File: C:\DOCUME~1\CaDuSiMs\CONFIG~1\Temp\Rar$EXxx.xx5\pa tch.exe
Location: Quarantine
Computer: CADU
User: CaDuSiMs
Action taken: Clean failed : Quarantine succeeded : Access denied
Date found: Sun Oct 09 04:33:38 2005
Juiced is offline  
Old 09.10.2005, 07:34   #5
SoaPy
Архивный участник
 
Join Date: Feb 2005
Posts: 705
Default

Good Work Tontor, tnx
SoaPy is offline  
Old 09.10.2005, 07:39   #6
toolpunk
Архивный участник
 
Join Date: May 2005
Posts: 2,033
Default

lol you got a virus XD
W32.Small.gen...
detected by norton antivirus corp...
so dont tell me im talking shit.
its true. you should scan your pc for viruses
btw i dont say this happened on purpose but i wanted to warn everyone and especially you to scan your system for viruses.
so its rather a good advice than criticism...

edit: damn juiced was faster XD
toolpunk is offline  
Old 09.10.2005, 07:48   #7
tontor
Архивный участник
 
Join Date: May 2005
Posts: 109
Default

Quote:
Originally Posted by Juiced
Scan type: Realtime Protection Scan
Event: Virus Found!
Virus name: W32.Small.gen
File: C:\DOCUME~1\CaDuSiMs\CONFIG~1\Temp\Rar$EXxx.xx5\pa tch.exe
Location: Quarantine
Computer: CADU
User: CaDuSiMs
Action taken: Clean failed : Quarantine succeeded : Access denied
Date found: Sun Oct 09 04:33:38 2005
Quote:
Originally Posted by toolpunk
lol you got a virus XD
W32.Small.gen...
detected by norton antivirus corp...
so dont tell me im talking shit.
its true. you should scan your pc for viruses
btw i dont say this happened on purpose but i wanted to warn everyone and especially you to scan your system for viruses.
so its rather a good advice than criticism...

edit: damn juiced was faster XD
This is not a virus, but a false positive by some virus scanners. The full source to patch.exe is below. Review and compile it yourself if you wish.

Code:
;Static DLL Injection for MASM by Aphex
;http://www.iamaphex.cjb.net
;unremote@knology.net
;This uses code by Yodah and Freddy K

;What this does: It forces a PE to load a DLL everytime it is ran by
;patching the actual file. No other loaders or memory injectors are needed.

;How it does this: It opens the PE file, adds a section to the end of the file,
;alters the entry point to execute this section first. Then the new code loads
;a dll and jumps back to the original entry point where it runs as normal. ;)

;NOTE: you must add this linker option "/SECTION:.text,RWX"
;ml.exe /coff patch.asm /link /SECTION:.text,RWX /SUBSYSTEM:WINDOWS /OPT:NOREF
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

SEH_STRUCT struct
  OrgEsp dword 0
  OrgEbp dword 0
  SaveEip dword 0
SEH_STRUCT ends

.data
;-------> Path to EXE to be patched with DLL <-------
szTarget byte 'L2Server.exe', 0

.data?
dwFile dword ?
dwSize dword ?
dwBytes dword ?
dwImage dword ?
dwBuffer dword ?
dwHeader dword ?
dwLength dword ?
dwSections dword ?

.data
errmsg	db	'failed to open l2server.exe',0
sucmsg	db	'patching l2server.exe succeeded',0
titlemsg db	'beepbeepboop',0

.code
EntryPoint:
jmp PatchEnd
PatchBegin:
jmp SkipData
szName byte '.PATCH', 2 dup (0)
szLoadLibrary byte 'LoadLibraryA', 0
;-------> Path to DLL to be patched into EXE <-------
szDll byte 'patch.dll', 0
SEH SEH_STRUCT <>
_LoadLibrary dword 0
dwKernelBase dword 0
dwEntryPoint dword 0
_DllOff dword 0
SkipData:
assume fs:NOTHING
pushad
call Root
Root:
pop ebp
sub ebp, offset Root
push dword ptr [esp + 20h]
call Base
or eax, eax
jz Return
mov [ebp + dwKernelBase], eax
lea eax, [ebp + offset szLoadLibrary]
push eax
push [ebp + dwKernelBase]
call Address
or eax, eax
jz Return
mov [ebp + _LoadLibrary], eax
lea eax, [ebp + offset szDll]
push eax
call [ebp + _LoadLibrary]
mov [ebp + offset _DllOff], eax
Return:
mov eax, [ebp + dwEntryPoint]
mov [esp + 1ch], eax
popad
jmp eax
Base:
mov edi, [esp + 4]
lea eax, [ebp + offset SehHandler]
push eax
push dword ptr fs:[0]
lea eax, [ebp + offset SEH]
assume eax:ptr SEH_STRUCT
mov [eax].OrgEsp, esp
mov [eax].OrgEbp, ebp 
lea ebx, [ebp + offset Continue]
mov [eax].SaveEip, ebx
mov fs:[0], esp
assume eax:NOTHING
and edi, 0FFFF0000h
.while TRUE
  .if word ptr [edi] == IMAGE_DOS_SIGNATURE
    mov esi, edi
    add esi, [esi + 03Ch]
    .if dword ptr [esi] == IMAGE_NT_SIGNATURE
      .break
    .endif
  .endif
Continue:
  sub edi, 010000h
  .if edi < 070000000h
    mov edi, 0BFF70000h
    .break
  .endif
.endw
xchg eax, edi 
pop dword ptr fs:[0]
add esp, 4
ret 4
Address:
lea eax, [ebp + offset SehHandler]
push eax
push dword ptr fs:[0]
lea eax, [ebp + offset SEH]
assume eax:ptr SEH_STRUCT
mov [eax].OrgEsp, esp
mov [eax].OrgEbp, ebp
lea ebx, [ebp + offset Continue]
mov [eax].SaveEip, ebx
mov fs:[0], esp
assume eax:NOTHING
mov esi, [esp + 0ch]
.if word ptr [esi] != IMAGE_DOS_SIGNATURE
  jmp Halt
.endif
add esi, [esi + 03Ch]
.if dword ptr [esi] != IMAGE_NT_SIGNATURE
  jmp Halt
.endif
mov edi, [esp + 10h]
mov ecx, 150
xor al, al
repnz scasb
mov ecx, edi
sub ecx, [esp + 10h]
mov edx, [esi + 078h]
add edx, [esp + 0ch]
assume edx:ptr IMAGE_EXPORT_DIRECTORY
mov ebx, [edx].AddressOfNames
add ebx, [esp + 0ch]
xor eax, eax
.repeat
  mov edi, [ebx]
  add edi, [esp + 0ch]
  mov esi, [esp + 10h]
  push ecx
  repz cmpsb
  .if zero?
    add esp, 4
    .break
  .endif
  pop ecx
  add ebx, 4
  inc eax
.until eax == [edx].NumberOfNames
.if eax == [edx].NumberOfNames
  jmp Halt
.endif
mov esi, [edx].AddressOfNameOrdinals
add esi, [esp + 0ch]
push edx
mov ebx, 2
xor edx, edx
mul ebx
pop edx
add eax, esi
xor ecx, ecx
mov word ptr cx, [eax]
mov edi, [edx].AddressOfFunctions
xor edx, edx
mov ebx, 4
mov eax, ecx
mul ebx
add eax, [esp + 0ch]
add eax, edi
mov eax, [eax]
add eax, [esp + 0ch]
jmp Exit
assume edx:nothing
Halt:
xor eax, eax
Exit:
pop dword ptr fs:[0]
add esp, 4
ret 8
SehHandler proc c pExcept:dword, pFrame:dword, pContext:dword, pDispatch:dword
mov eax, pContext
assume eax:ptr CONTEXT
push SEH.SaveEip
pop [eax].regEip
push SEH.OrgEsp
pop [eax].regEsp
push SEH.OrgEbp
pop [eax].regEbp
mov eax, ExceptionContinueExecution
ret
SehHandler endp
PatchEnd:
mov eax, offset PatchEnd
sub eax, offset PatchBegin
mov dwLength, eax
invoke CreateFile, offset szTarget, GENERIC_READ or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0
.if eax == INVALID_HANDLE_VALUE
  invoke MessageBox, NULL,addr errmsg,addr titlemsg,MB_OK
  invoke ExitProcess, 0
.endif
mov dwFile, eax
invoke GetFileSize, dwFile, 0
mov dwSize, eax
add eax, 2000h
invoke GlobalAlloc, GMEM_FIXED or GMEM_ZEROINIT, eax
mov dwBuffer, eax
invoke ReadFile, dwFile, dwBuffer, dwSize, offset dwBytes, 0
mov esi, dwBuffer
add esi, 03ch
mov eax, dword ptr [esi]
mov dwHeader, eax
sub eax, 03ch
add esi, eax
assume esi:ptr IMAGE_NT_HEADERS
mov ax, [esi].FileHeader.NumberOfSections
mov dwSections, eax
inc [esi].FileHeader.NumberOfSections
mov eax, [esi].OptionalHeader.AddressOfEntryPoint
add eax, [esi].OptionalHeader.ImageBase
mov dwEntryPoint, eax
mov eax, [esi].OptionalHeader.SizeOfImage
mov dwImage, eax
add [esi].OptionalHeader.SizeOfImage, 1000h
mov [esi].OptionalHeader.AddressOfEntryPoint, eax
assume esi:NOTHING
mov esi, dwBuffer
add esi, dwHeader
add esi, 0f8h
assume esi:ptr IMAGE_SECTION_HEADER
mov eax, 0E0000060h
mov [esi].Characteristics, eax
mov eax, 28h
mov ecx, dwSections
imul ecx
add esi, eax
mov eax, dword ptr [szName]
mov dword ptr [esi].Name1, eax
mov eax, dword ptr[szName+4]
mov dword ptr [esi].Name1+4, eax
mov eax, 1000h
mov [esi].Misc.VirtualSize, eax
mov eax, dwImage
mov [esi].VirtualAddress, eax
mov eax, dwLength
mov [esi].SizeOfRawData, eax
mov eax, dwSize
mov [esi].PointerToRawData, eax
mov eax, 0E0000020h
mov [esi].Characteristics, eax
assume esi:NOTHING
mov edi, dwBuffer
add edi, dwSize
lea eax, PatchBegin
xchg esi, eax
mov ecx, dwLength
rep movsb
invoke SetFilePointer, dwFile, 0, 0, FILE_BEGIN
mov eax, dwSize
add eax, dwLength
invoke  WriteFile, dwFile, dwBuffer, eax, offset dwBytes, 0
invoke CloseHandle, dwFile
invoke GlobalFree, dwBuffer
invoke MessageBox, NULL,addr sucmsg,addr titlemsg,MB_OK
invoke ExitProcess, 0
end EntryPoint
tontor is offline  
Old 09.10.2005, 08:22   #8
flakka
Архивный участник
 
Join Date: Mar 2005
Posts: 1,143
Default

Nice post, tontor.

And second, you guys need to seriously get a better AV scanner. Norton sucks - plain and simple. The only good thing it has is the sandbox feature, and even with that, it can't scan anything for crap. I just scanned it with F-Prot, and nothing came back. No false positives, and no virus. It's clean like tontor said.

So please, please get rid of anything Symantec/Norton related off your PCs. :P Worst piece of software, ever.

Sorry for hijacking the thread, but I just can't stand Norton. And people do need to know that there's better alternatives out there that are less resource hungry and have better scanning engines.
flakka is offline  
Old 09.10.2005, 08:32   #9
demon
Архивный участник
 
Join Date: May 2005
Posts: 367
Default

what about f-secure ^^ sucks too ?
demon is offline  
Old 09.10.2005, 08:45   #10
OnlyOne
Архивный участник
 
Join Date: Apr 2005
Posts: 98
Default

well scanned with kaspersky and nothing found :lol:
OnlyOne is offline  
Old 09.10.2005, 09:10   #11
demon
Архивный участник
 
Join Date: May 2005
Posts: 367
Default

except bbs all others are hack attempt ? or space error.
demon is offline  
Old 09.10.2005, 10:32   #12
top-gear
Архивный участник
 
Join Date: Aug 2005
Posts: 605
Default

I think it's a great share if it acrually works. The problem is that it may leave other kind of "doors" open. or not...?
top-gear is offline  
Old 09.10.2005, 11:16   #13
toolpunk
Архивный участник
 
Join Date: May 2005
Posts: 2,033
Default

f-secure?! LOL... sorry but that isnt any better in my opinion...
btw im runnin on windows server 2k3 means i cant use just a virus prog...
needs to be a corporate version since antivirus companies wanna earn money
so i ended up using noton corp. it works just fine and is secure
toolpunk is offline  
Old 09.10.2005, 11:19   #14
hamidouch
Архивный участник
 
Join Date: Mar 2005
Posts: 475
Default

yes demon it is,
tontor fukin nice u fixed it ^^
no more+20 cmd problem
hamidouch is offline  
Old 09.10.2005, 11:30   #15
Phantom2005
Архивный участник
 
Join Date: Aug 2005
Posts: 394
Default

thx m8! this is a really great share
Phantom2005 is offline  
Old 09.10.2005, 12:04   #16
midnight
Архивный участник
 
Join Date: Jun 2005
Posts: 199
Default

Quote:
Originally Posted by demon
except bbs all others are hack attempt ? or space error.
what should i do to make this window appear?
midnight is offline  
Old 09.10.2005, 12:32   #17
Eliot
Архивный участник
 
Join Date: Mar 2005
Posts: 368
Default

tontor, i owe You one. I swear if i ever meet You, You will be drunk as hell :P Im buying (If You are really Japanese this may actually happen so beware :P)

Not only because You shared the fix, You shared a lot more, You showed us the way how to attach a external program to l2server. This way we can manage to archieve something we never thought about before. Macros, Reccomend, CP, Recipe Books. It's possible now ! We just need a bloody good coder
Eliot is offline  
Old 09.10.2005, 14:30   #18
blaher
Архивный участник
 
Join Date: Sep 2005
Posts: 23
Default

hmm ? ;/
blaher is offline  
Old 09.10.2005, 15:24   #19
Silentz0r
Архивный участник
 
Join Date: Apr 2005
Posts: 122
Default

Fixed. ty.
Silentz0r is offline  
Old 09.10.2005, 15:59   #20
horyfilipe
Архивный участник
 
Join Date: Jul 2005
Posts: 242
Default

thank you and congratulations!
horyfilipe is offline  
Old 09.10.2005, 16:25   #21
horyfilipe
Архивный участник
 
Join Date: Jul 2005
Posts: 242
Default

Hmm... world announce disappeared and when i tried //gmspeed 5 server freezed.. any suggestion?

link and tp patch failed but i think it has nothing to do with that..
horyfilipe is offline  
Old 09.10.2005, 16:38   #22
Sauron
Архивный участник
 
Join Date: Feb 2005
Posts: 357
Default

Quote:
Originally Posted by Livid
O_O
Sauron is offline  
Old 09.10.2005, 16:51   #23
horyfilipe
Архивный участник
 
Join Date: Jul 2005
Posts: 242
Default

Actualy I thought it was //gmspeed freezing, but it isnt.. someway the server is freezing and it doesnt crash, have to kill.. any idea?
horyfilipe is offline  
Old 09.10.2005, 17:01   #24
astranger
Архивный участник
 
Join Date: Mar 2005
Posts: 41
Default

good job and thanks for sharing
astranger is offline  
Old 09.10.2005, 17:06   #25
LDragonL
Архивный участник
 
Join Date: May 2005
Posts: 133
Default

This is a very very nice tool !
Thanx a lot man !
LDragonL is offline  
 


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

Forum Jump


All times are GMT. The time now is 22:22.