Jump to content

Recommended Posts

  • 4 weeks later...
Posted

Hi, I am writing a clicker for L2 and stuck with smartguard. I understand that I have to use some trampoline to bypass api hook from smartguard, but I can't find good document on how using it.

 

As far as I understand, trampoline must be place in a DLL, and that DLL must inject to L2. I have to find what api guard.des is hooking and then write a trampoline to jump to original function. In my case, I need to use SendInput() or keybd_event() or SendMessage( [WM_KEYDOWN / WM_KEYUP] ). Then I must find the actual address of  these function in module User32.dll and then write a trampoline to jump back to this function. That is pretty much everything I understand about api hook / detours.

 

But It seem not right. I think I got it wrong somewhere.

 

I use hookshark to find which api detours guard.des using, and the only interesting detour I found on the L2.exe process is GetRawInputData and it doesn't make sense. So, Guard.des doesn't hook on SendInput, keybd_event or SendMessage as it is no use to write trampoline for these function.

 

This is where I stuck.

Appreciate any help :)

 

 

Posted

Why clicker? Just go for a bot. But if u really want to, the as far as i know L2 uses directinput which is resistant by nature of it to keybd_event or SendInput. Did you try inejcting messages directly to window procedure? This works in most cases. Dont use Hookshark program, write one yourself. The popular one has soem defects, doesnt show all hooks, especially cant scan ntdll where most of interesting stuff resides.

 

And what do you mean by saying "That is pretty much everything I understand about api hook" ? You have to avoid any modifications when creating a cheat, more mods = higher detect ratio and you definitel dont want it. Hooking is terrible idea (look at l2tower which hooks like 20 functions, doesnt work anywhere).

 

So right now reverse to the window creation, find the address of WndProc and try here. BTW Can you show screenshot with log from hookshark? Im interested how many did he find... :)

 

Greetz

Posted

Why clicker? Just go for a bot. But if u really want to, the as far as i know L2 uses directinput which is resistant by nature of it to keybd_event or SendInput. Did you try inejcting messages directly to window procedure? This works in most cases. Dont use Hookshark program, write one yourself. The popular one has soem defects, doesnt show all hooks, especially cant scan ntdll where most of interesting stuff resides.

 

And what do you mean by saying "That is pretty much everything I understand about api hook" ? You have to avoid any modifications when creating a cheat, more mods = higher detect ratio and you definitel dont want it. Hooking is terrible idea (look at l2tower which hooks like 20 functions, doesnt work anywhere).

 

So right now reverse to the window creation, find the address of WndProc and try here. BTW Can you show screenshot with log from hookshark? Im interested how many did he find... :)

 

Greetz

:dat: :dat:

Posted

I mean I am newb at hook and reverse engineering stuffs and that is what I've read somewhere from the internet  :D

 

Mouse hook and keyboard hook are the only kind of hook that I know. Since I am a noob clicker is easiest to code for me, and clicker is enough for me.

 

On some private high/mid rate server, there are other way to farm than hunt mobs, such as raid boss Zaken which need about 12 - 14 players (or 14 boxes on a single computer), and clicker is the best. My clicker just does SendMessage with WM_KEYDOWN / WM_KEYUP to the correct L2 hwnd(s) and everything is good: one player, one computer, 14 L2 client windows and one clicker. That's it.

 

Before L2 exilium upgraded with smartguard my clicker worked fine. You know what happened after they upgraded with smartguard  :D

 

Like I said, I am noob at this hook / detour stuffs, and the information I find on the internet is not helping much.

 

Here are the logs

post-133584-0-12635200-1443437460_thumb.png

usermodehook.txt

log.txt

Posted

The one which makes your clicker not work is most probably this:

 

[6596] L2.exe!window.dll->?StaticWndProc@WWindow@@SGJPAUHWND__@@IIJ@Z       || [0x1101C480] => guard.des [0x72FD382B]            || Inline - Detour [5 Bytes] || push ebp            || jmp 72FD3830h
 

Did you try to preapre the stack + original entry instructions and call it? This would work almost for sure

Posted (edited)

The one which makes your clicker not work is most probably this:

 

[6596] L2.exe!window.dll->?StaticWndProc@WWindow@@SGJPAUHWND__@@IIJ@Z       || [0x1101C480] => guard.des [0x72FD382B]            || Inline - Detour [5 Bytes] || push ebp            || jmp 72FD3830h

 

It starts to make sense. So, guard.des detours the callback function that handle all the messages sent to L2 client hwnd and filters out WM_KEYUP /  WM_KEYDOWN. That is probably why message WM_CHAR still works.

 

 

 

Did you try to preapre the stack + original entry instructions and call it? This would work almost for sure

Well, that is beyond my knowledge :D

 

But at least, I have something to search for. I guess I have a lot of reading to do.

 

Thanks alot.

Edited by 1413
Posted (edited)

I've never been using the detour/retour terminology :) You have to understand how hooking works and how do the "hooker" call real function. The algorithm is to copy instructions from the functions entry and overwrite them with a jump to your code, and create a jump back to real function using the copied instructions and adding a jump to it. If you manage to find or reproduce these instructions then you are set. It may sound very compilcated at start but u need to check it carefully. Do you use a debugger? Its million times easier with one

Edited by Szakalaka
Posted

I've never been using the detour/retour terminology :) You have to understand how hooking works and how do the "hooker" call real function. The algorithm is to copy instructions from the functions entry and overwrite them with a jump to your code, and create a jump back to real function using the copied instructions and adding a jump to it. If you manage to find or reproduce these instructions then you are set. It may sound very compilcated at start but u need to check it carefully. Do you use a debugger? Its million times easier with one

 

I had a hunch a debugger could be useful someday, then I collected some, such as IDA pro, ollydbg... But never use them before because I have no idea how to read ASM :D

 

So, I have to find the address of the callback function StaticWndProc in the memory, then overwrite the first 5 bytes with my instructions that jump to my_function in my_dll and then my function will jump back to the 6th byte and run the original StaticWndProc. I think I read somewhere they call it trampoline, but actually it is access memory of other process and overwrite a part of that process' memory with my instructions, am I right?

 

I have a question, since guard.des overwrite the first 5 bytes with inline-detour which jump to a function in guard.des, is that right? I think maybe we just need to overwrite that 5 bytes with the original 5 bytes of the original function, like undo what guard.des does and bam StaticWndProc now received WM_KEYDOWN again.

Posted

Welp i wrote a big post and it did not send it somehow... So basically u are right with the jump idea, but u cannot unhook guard.des, it will detect it immidietly. You can try to disable the checking loop but without asm knowledge u wont do it, so what you need to do is to reproduce first 5 bytes, then add jump to the 6th and call function that way. I may make short video on it maybe

Guest
This topic is now closed to further replies.



  • Posts

    • Changeset 411 (3596)   ZoneManager, Manors, Cursed Weapon, AI, Bugfixes, Organization   [Fishing is currently malfunctioning. Wait next revisions for item/skills reparse + fish rework.   ZoneManager - Ty Bandnentans for the backup job Rework ZoneManager, parsing L2OFF zones and associated parameters. Zones are now handled by name, and not anymore by custom, dynamic, id - making them easier to invoke, and allowing retail script to invoke them aswell. Zones are now extending Territory, and don't use anymore shapes (Circle/Rectangle/NPoly). Default shape is Polygon, cut into Triangles, through Territory. One more step down to delete "zone.form" package and ZoneForm class. All zone types are added as L2OFF. Custom zone types are deleted (ARTIFACT, SCRIPT,...) and good names are provided (Boss = NoRestart, NoLanding = NoFly, etc). NoRestart zones type (eg. previous Boss) behavior is now matching retail, and uses retail parameters aswell. It normally fixes the "instant teleport back to town when entering boss zones through few teleporters" issue. Implementation of onLogin/onLogout/onEnterRegion/onExitRegion methods types for zones. Implementation of EffectZoneTaskManager (a universal 666ms ticking task for all effect zones) and ZoneRevalidationTaskManager (a universal 666ms Creature revalidateZone task, avoiding multiple calls). Migrate zone related Stat Func application to zone onEnter/onExit, deleting ZoneManager#getZone calls upon stat calculation (run speed, hp/mp regen). Fix moving from same zone type to same zone type ; it doesn't consider to going out (hotfix). Should notably fix water re-entrance issue. Delete custom CastleTeleportZone, use retail Mass Teleporter HTMs and AI params. Manors - Ty LaRoja for fixes Fix an issue where turning in crops to the Manor Lord for materials would incorrectly add adena to the castle vault instead of deducting it, while seed sales are correctly handled. Fix an issue where the "Stop Purchase" button did not properly clear all crops. The last crop would remain set, and the manor wouldn't fully disable unless all adena was manually removed from the vault. Introduce //manor [change], allowing manually a manor cycle to run. Cursed Weapon CW passive skill is properly cleaned up. Ty Denzel for report. Don't store anymore Player reference on CursedWeapon. Store CursedWeapon reference upon Player, rather than itemId - for faster acquisition. Fix a NPE upon CursedWeapon#endOfLife. AI Fix aggressive monsters behavior. Ty Denzel for report, Bandnentans for fix. Fix EvilateA/B not respawning demons. Ty Bandnentans for report. Fix a conditional NPE over PartyLeaderHeretic2Aggressive AI. Fix Gordon script NPE. Ty Sahar for report. Move most DefaultNpc methods to Npc (npc isn't a parameter anymore, but the method caller). Overload NpcAi#addCastDesire with NpcSkillType parameter, since it was hard to read and error-prone. -> npc.getAI().addCastDesire(attacker, getNpcSkillByType(npc, NpcSkillType.DD_MAGIC), 1000000); -> npc.getAI().addCastDesire(attacker, NpcSkillType.DD_MAGIC, 1000000);. Implement NpcMaker#areaSetOnOff and Npc#areaSetOnOff. AIs can now activate and de-activate areas based on behavior (generally spawn and dying). Uncomment all scripts areas triggers. Implement Creature#isInThisTerritory, checking if a Creature is in a parametrized zone name. Uncomment all scripts areas triggers. Re-introduce back RandomAnimationTaskManager for Folks. Ty Bandnentans for report. getSeeRange() is now minimal Config.DEFAULT_SEE_RANGE - can't be lower - notably fix Gordon ON_SEE event. Implement NODE_ARRIVED EventHandler. Fix Gordon continuously running after attacking someone. Bugfixes Sanitize the username string in AuthLogin as it is in RequestAuthLogin. Ty artemis for fix. //set title is fixed (allows more than one token, and spaces between words). Add the possibility to clear title with no parameter. Add a missing sysMessage upon regular Pet's name set, remove one check processed by regex (and which had invalid sysMessage). Fix a "day 1" issue related to CH : if your clan was holding any CH, HP/MP regen was applied no matter the CH zone you were currently set. Remove run stance upon Npc#reduceCurrentHp, making Walker run when being hit. Ty Denzel for report. Fix an issue where Castle owners couldn't register for SCH. Fix the related SystemMessageId. Allow blocked interaction to scan at higher range. Organization Config : Introduce NAME_REGEX_PATTERN and TITLE_REGEX_PATTERN, delete ZONE_TOWN Config. Territory "Polygon to Triangle" algorithm is edited for an adapted version of Earcut (earcut4j without the hole handling), allowing monotone polygon and using Z-order curve index for faster spatial partitioning. Rewrite Triangle#intersects method to be more accurate. Drop grandboss_list SQL. The few "var" are now named "variable", prior to var keyword addition in Java. Update MariaDB connector from 3.1.4 to 3.5.3. Add //set pvp <number> and //set pk <number>. RoomInfo improvement - allocate and reuse a single List, rather than nullify it and create a new one.
    • any mod can change the title 'Rules' and move to the  marketplace? @Maxtor
    • One thing i want to add  is disabling root login, creating a new user with sudo privileges, setting up SSH key authentication and completely disabling password  logins and also avoid  exposure on port 80 completely. it's much better to manage them directly from your local machine using IP whitelisting on database user or firewall-iptables. This way, only trusted IPs have access. Even better ssh tunnel. Good job though. 
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock