AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   Decompiling Plugins (.amx/x -> .sma) (https://forums.alliedmods.net/showthread.php?t=19368)

BAILOPAN 10-15-2005 04:41

Decompiling Plugins (.amx/x -> .sma)
 
Topic: How do you decode a closed source plugin back to source code?

This is a hot topic for some people, and I've been asked about it many times. After the Sputnik53 incident, I decided to publically reveal how it's done. Currently, I'm writing a multipart-article on the SourceMod devlog.

This is not for the faint of heart, and you should step into this with knowledge of C and processor memory layout. I'll update this post as I complete more pieces of the tutorial.

Part 1 - Introduction to the VM
Part 2 - Basic Disassembly
Part 3 - Decoding Branches
Part 4 - Local procedures, variables, and multi-branches
Part 5 - Optimization
Part 6 - Stocks, floats, ternary operators, and for loops
Part 7 - Multi-part if statements, multi-dimensional arrays

BAILOPAN 10-16-2005 06:31

Part 4 added.

Zenith77 10-16-2005 12:09

Nice, very very nice.



p.s. Whats the answer to the bonus question :lol:

BAILOPAN 10-17-2005 05:54

Part 5 added.

Worth noting here too: Wraith's AMXReader now supports AMX Mod X 1.60 plugins.

LynX 10-17-2005 07:16

w00teh!!!

Baileh finally decided to make mine life happy again ^^

Wraith, 10-17-2005 11:29

It is also worth noting that the disassembler isn't idiot proof. If you have a problem or request you can find me in #adminmod on gamesurge.

BAILOPAN 10-28-2005 05:15

Part 6 added.

BAILOPAN 10-30-2005 06:00

Part 7 added.

ssjGoten 08-09-2006 15:05

Re: Decompiling Plugins (.amx/x -> .sma)
 
when i open AmxReader gives me that error "The Application failed initialize properly (0xc0000135). Click on OK to terminate the application" :((


Pls help me :(

k007 08-09-2006 15:20

Re: Decompiling Plugins (.amx/x -> .sma)
 
Nice gj BAIL

Greenberet 08-09-2006 15:44

Re: Decompiling Plugins (.amx/x -> .sma)
 
Quote:

Originally Posted by ssjGoten
when i open AmxReader gives me that error "The Application failed initialize properly (0xc0000135). Click on OK to terminate the application" :((


Pls help me :(

make sure that you have the newest .NET Framework

johnjg75 08-09-2006 15:51

I remember when you showed me how to do this before, bail. :D

ssjGoten 08-09-2006 17:43

Re: Decompiling Plugins (.amx/x -> .sma)
 
what is this ???
Code:

PROC  plugin_init
    line                    0x8              0x0
    push.c                0x28
    push.c                0x18
    push.c                  0x0
    push.c                  0xC
    sysreq.c    [BAD SYSREQ]
    stack                  0x10
    line                    0x9              0x0
    push.c                  0x0
    push.c                  0x0
    push.c                0x78
    push.c                0x4C
    push.c                0x10
    sysreq.c    [BAD SYSREQ]
    stack                  0x14
    zero.pri 
    retn     
ENDP


Zenith77 08-09-2006 20:04

Re: Decompiling Plugins (.amx/x -> .sma)
 
If you have no clue what that is, then don't even bother until you gain more experience in programming.

Greenberet 08-10-2006 01:14

Re: Decompiling Plugins (.amx/x -> .sma)
 
Quote:

Originally Posted by ssjGoten
what is this ???

read part 1-7 then you will know what this is

ssjGoten 08-10-2006 05:33

Re: Decompiling Plugins (.amx/x -> .sma)
 
I read but for nothing

Give a dictionary for those codes


SweatyBanana 08-10-2006 10:50

Re: Decompiling Plugins (.amx/x -> .sma)
 
I have a question..How do you determine what an array was called?

Hawk552 08-10-2006 12:41

Re: Decompiling Plugins (.amx/x -> .sma)
 
Quote:

Originally Posted by SweatyBanana
I have a question..How do you determine what an array was called?

I don't think you can, since the VM generally never needs to do name lookups on arrays. You can just pass an offset in the DAT section to where the first cell of the array is if you have to find it.

I wish Bail would finish this. It looks almost done, but I've already read the entire thing and it seems to be missing just a few things.

SweatyBanana 08-10-2006 14:47

Re: Decompiling Plugins (.amx/x -> .sma)
 
Aww I was hoping you could..

Oh well.


pretty complicated this is..

took me 30 mins of reading then re-writing the decompile and all I got was the #defines, the #includes, and the whole plugin_init.

Zenith77 08-11-2006 00:11

Re: Decompiling Plugins (.amx/x -> .sma)
 
Quote:

I wish Bail would finish this. It looks almost done, but I've already read the entire thing and it seems to be missing just a few things.
Either I'm very sleepy, or I over-read someting, becuase I never got what the LINE mnemonic does. This would actually been cake if I would have learned assembly (Started to, but quit, no time, o heck, I'll start now).

Anyway, please BAIL finish this. I actually beta tested krot@l's hack mod on his test server, but that was before I ever had any clue on what amx mod or amxx was.

BAILOPAN 08-18-2006 20:15

Re: Decompiling Plugins (.amx/x -> .sma)
 
For AMX Mod X plugins 1.50+ and higher, all symbol names are kept in a symbol database. Unfortunately, Wraith's Disassembler does not support this yet.

reyi 12-13-2006 17:36

Re: Decompiling Plugins (.amx/x -> .sma)
 
the Wraith’s AMXReader/Disassembler link destroyed :(

plzz new linkkkkkkkkkkkkkkkkkkkkkkk :)

SweatyBanana 12-13-2006 18:48

Re: Decompiling Plugins (.amx/x -> .sma)
 
Yea that would be good.

cybermind 12-14-2006 15:58

Re: Decompiling Plugins (.amx/x -> .sma)
 
Here is the latest version I have.

It's the source and binaries, binaries are in Release.

http://cybermind.user.stfunoob.com/m...sassembler.zip

SweatyBanana 12-14-2006 19:54

Re: Decompiling Plugins (.amx/x -> .sma)
 
As the original link is dead, I suggest to prevent it in future you upload it to AMXX.

|POW|Da_ghost 12-15-2006 18:18

Re: Decompiling Plugins (.amx/x -> .sma)
 
Well i also made a link for the file on my webhost(So if the old link dies This will jump in)
http://www.daghost.xionize.com/files...sassembler.zip

SweatyBanana 12-15-2006 22:02

Re: Decompiling Plugins (.amx/x -> .sma)
 
Mine too..

http://www.chaos-realms.com/aoa/myFi...sassembler.zip

BAILOPAN 12-19-2006 09:49

Re: Decompiling Plugins (.amx/x -> .sma)
 
I will talk to Wraith.

cybermind 12-25-2006 02:04

Re: Decompiling Plugins (.amx/x -> .sma)
 
Wraith,'s site is back up

dxteam 12-26-2006 14:20

Re: Decompiling Plugins (.amx/x -> .sma)
 
help plz with decompile superheromysql.amxx

cybermind 12-26-2006 17:44

Re: Decompiling Plugins (.amx/x -> .sma)
 
Quote:

Originally Posted by dxteam (Post 420095)
help plz with decompile superheromysql.amxx

Have you tried?

kalaeon 12-29-2006 08:06

Re: Decompiling Plugins (.amx/x -> .sma)
 
Hi.. can someone help me please. I was trying to decode this but... this plugin isn't simple.... Here is...
http://server.united-games.cz/?q=dis...d.zip&download
Here are functions of plugin... (It is Czech plugin and i'll translate functions to eng...)
PS: I asked creator of ugcmd to get me it in sma but he can't :(
Commands:

CONSOLE:

* ughelp - help all commands
* ugmaplist - somethink like maplist
* ugkick - ID player, you can kick he by ID
* ugkick #ID - kick player by ID
* ugkick nick - kick player by nick
* ugsay - when i wrote to console ugsay AMXX tha BEST ---> i see on HUD AMXX tha BEST

SAY:

* ugrr - Restart round
* ugrm - 3x Restart a start game (write LIVE)
* ugknife - restart for knife rounds
* ugwarmup - ser server for warmup (money, time etc.)
* ugmatch - set server for match
* ugaimawp - set server for play AIM a AWP maps (freezetime 1)
* ugmr5 - when is DRAW... startmoney 10 000 and mr 5
* ugpause - Pause/Unpause game
* ugdust2 - change map de_dust2
* uginferno - change map de_inferno
* ugnuke - change map de_nuke
* ugtrain - change map de_train
* ugcplmill - change map de_cpl_mill
* ugcplstrike - change map de_cpl_strike
* ugcplfire - change map de_cpl_fire
* ugcbble - change map de_cbble
* ugaztec - change map de_aztec
* ugforge - change map de_forge
* ugprodigy - change map de_prodigy
* ugawp - change map aim_awp
* ugruins - change map awp_ruins
* uggowenna - change map awp_gowenna
* ugindia - change map awp_india
* ugskawp - change map aim_sk_awp
* ugspace - change map awp_space
* ugdarkness - change map awp_darkness
* ugaim - change map aim_map
* ugaim2 - change map aim_map2
* ughlo - change map aim_map_hlo
* ugskaim - change map aim_sk_ak_m4
* ugheadshot - change map aim_headshot
* ugbono - change map aim_b0n0
* ugak - change map ak_47
* uglazy - change map aim_lazy

sorry for my english, but i am learning it...... Someone who help me please... it is nice plugin but creator is ********... Say and console commands can use all players but i can to adjust it for only ADMINS can use it.... Please decompyle it or create new one... I think you can do it by i am newbie and i am not... Thx men

SweatyBanana 12-29-2006 12:09

Re: Decompiling Plugins (.amx/x -> .sma)
 
Suggestions/Requests board..
Quote:

You are not authorized to access this page.
Attach it next time.

sawce 01-04-2007 02:25

Re: Decompiling Plugins (.amx/x -> .sma)
 
Quote:

Originally Posted by kalaeon (Post 421299)
Hi.. can someone help me please. ...

I dont think you understand the amount of effort it takes to decompile a single, small plugin.

A 'typical' sized function takes around 15-20 minutes, longer stuff will take much longer, and everything is prone to error.

Typical plugins generally consist of 10ish functions. Larger ones will obviously have more.

SSJ2GOKU 01-07-2007 18:58

Re: Decompiling Plugins (.amx/x -> .sma)
 
i'm trying to make a c# program that remakes the easy functions, just as a bit of help
but u gotta put the dissassembled code in the program before it works
amxx files are too hard for meh to start from that part

but the structures still are strange :P
hopefully it works ^^


if anyone wants to help me with it, you're all welcome
i'll surely release it on this board then if its completed and working

btw i gotta add a line: "i'm not responsible any abuse of this program incluidng copyright breaking"

update: i'm changing it to active server page program

Sacky 06-05-2007 06:18

Re: Decompiling Plugins (.amx/x -> .sma)
 
I'm having some problems with Wraiths AMX Diassembler, whenever it try's to represent a call to a native function it does it like this:

0xB4 SYSREQ.C [BAD SYSREQ]

All throughout the disassembled file, is there any fix for this? (AMX Compiled with 3.2.3664.0 Pawn Compiler)

hoboman 02-02-2008 17:22

Re: Decompiling Plugins (.amx/x -> .sma)
 
there are no longer any sites that have the AmxReader for download :(

purple nurple 02-09-2008 17:26

Re: Decompiling Plugins (.amx/x -> .sma)
 
1 Attachment(s)
here you go. the decompiler i don't know it its the latest but here.

micke1101 04-05-2008 06:45

Re: Decompiling Plugins (.amx/x -> .sma)
 
can anyone update this?
the links dosent work (not the one in the first post but when you go in to the links you have to check some links they have)

shine771 04-11-2008 19:04

Re: Decompiling Plugins (.amx/x -> .sma)
 
I tried decompiling many plugins... It always shows: [BAD SYSREQ]...
There should be the natives name.. Help?


All times are GMT -4. The time now is 16:31.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.