Raised This Month: $12 Target: $400
 3% 

Lysis: An experimental .smx decompiler


Post New Thread Reply   
 
Thread Tools Display Modes
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 06-23-2012 , 06:09   Re: Lysis: An experimental .smx decompiler
Reply With Quote #101

Quote:
Originally Posted by schmidt View Post
Error: bad file

Who can get source code?
Full error: (line #'s might be different on mine)
Code:
Unhandled Exception: System.Exception: bad file
   at SourcePawn.SourcePawnFile..ctor(Byte[] binary) in Lysis\SourcePawnFile.cs:line 441
   at Lysis.PawnFile.FromFile(String path) in Lysis\PawnFile.cs:line 47
   at Lysis.Program.Main(String[] args) in Lysis\Program.cs:line 94
It's becoming increasingly more common for closed-source communities to modify the *.smx in a way that blocks Lysis, but still loads on SourceMod.

Is Lysis just getting stuck on some unnecessary header changes?

Edit: Looks like the same issue over here. Time to ping psychonic.
__________________

Last edited by GoD-Tony; 06-23-2012 at 07:00.
GoD-Tony is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 06-23-2012 , 11:11   Re: Lysis: An experimental .smx decompiler
Reply With Quote #102

Quote:
Originally Posted by schmidt View Post
Error: bad file

Who can get source code?
https://bugs.alliedmods.net/show_bug.cgi?id=5358
Where did you get that plugin? Seems like some strange way of seperating admins
xbox_throttlespoof 123 ?


Quote:
Originally Posted by GoD-Tony View Post
Full error: (line #'s might be different on mine)
Code:
Unhandled Exception: System.Exception: bad file
   at SourcePawn.SourcePawnFile..ctor(Byte[] binary) in Lysis\SourcePawnFile.cs:line 441
   at Lysis.PawnFile.FromFile(String path) in Lysis\PawnFile.cs:line 47
   at Lysis.Program.Main(String[] args) in Lysis\Program.cs:line 94
It's becoming increasingly more common for closed-source communities to modify the *.smx in a way that blocks Lysis, but still loads on SourceMod.

Is Lysis just getting stuck on some unnecessary header changes?

Edit: Looks like the same issue over here. Time to ping psychonic.
Yes, it's some minor header changes that mock lysis. In the above one x.smx, the imagesize was changed from like 00001818 to 01001818, leaving the decompression check in the air, as it was expecting 16783081 uncompressed bytes instead of 5865.

Another change, which is also present in the kac thing you linked to is the removal of the null-terminator after the last section name. .dbg.strings\x00 would be .dbg.strings\x01 letting lysis skip too far and reading .dbg.strings€..

Changing both back to 00 fixed it.

You might be able to work around that, by touching the ReadString function and let it stop at any ascii control character instead of only 0.
Code:
if (bytes[count] == 0)
Code:
if (bytes[count] < 32)
For the imagesize change.. Well, one could simply remove the size check and only check, if the decompression was successful at all instead of expecting some kind of size.
Attached Files
File Type: sp Get Plugin or Get Source (kigen-ac-pub_1015_win32.sp - 518 views - 128.4 KB)
File Type: sp Get Plugin or Get Source (x.sp - 411 views - 2.1 KB)
__________________
Peace-Maker is offline
schmidt
BANNED
Join Date: Mar 2010
Location: Milky Way/Earth
Old 06-23-2012 , 16:43   Re: Lysis: An experimental .smx decompiler
Reply With Quote #103

Quote:
Originally Posted by Peace-Maker View Post
Where did you get that plugin? Seems like some strange way of seperating admins
xbox_throttlespoof 123 ?
here =)
Peace-Maker, thank you very much.
schmidt is offline
Send a message via Skype™ to schmidt
NiceAndSimple
Member
Join Date: Jan 2012
Old 07-06-2012 , 23:46   Re: Lysis: An experimental .smx decompiler
Reply With Quote #104

can somebody please decompile this for me, it is a knockback plugin ive used for my zriot server but when i went to go look for the thread again it was gone and all the configuration has to be changed in the .sp file then compiled.
Attached Files
File Type: smx knockback.smx (4.0 KB, 326 views)
NiceAndSimple is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 07-07-2012 , 00:01   Re: Lysis: An experimental .smx decompiler
Reply With Quote #105

You asked once about this btw: http://forums.alliedmods.net/showthread.php?p=1742986

it doesn't decompile too well:
PHP Code:

new PlVers:__version 5;
new 
Float:NULL_VECTOR[3];
new 
String:NULL_STRING[1];
new 
Extension:__ext_core 68;
new 
MaxClients;
new 
Extension:__ext_sdktools 184;
public 
Plugin:myinfo =
{
    
name "KnockBack",
    
description "Weapon Knock Back",
    
author "******************ο***************************",
    
version "1.0",
    
url ""
};
new 
String:weaponKB[28][2][64] =
{
    {
        
"knife",
        
"0.0"
    
},
    {
        
"glock",
        
"1000.0"
    
}
    {
        
"usp",
        
"1000.0"
    
}, 
Are any of these what you're looking for:
http://forums.alliedmods.net/showthread.php?t=60180
https://forums.alliedmods.net/showthread.php?t=156646
__________________
View my Plugins | Donate
TnTSCS is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-07-2012 , 13:24   Re: Lysis: An experimental .smx decompiler
Reply With Quote #106

You'll need to create that weaponKB array yourself again, but the plugin itself is straight forward.

PHP Code:
new PlVers:__version 5;
new 
Float:NULL_VECTOR[3];
new 
String:NULL_STRING[1];
new 
Extension:__ext_core 68;
new 
MaxClients;
new 
Extension:__ext_sdktools 184;
public 
Plugin:myinfo =
{
    
name "KnockBack",
    
description "Weapon Knock Back",
    
author "ýýżýýý",
    
version "1.0",
    
url ""
};
new 
String:weaponKB[28][2][64] =
{
    {
        
"knife",
        
"0.0"
    
},
    {
        
"glock",
        
"1000.0"
    
},
    {
        
"usp",
        
"1000.0"
    
}
}
public 
__ext_core_SetNTVOptional()
{
    
MarkNativeAsOptional("GetFeatureStatus");
    
MarkNativeAsOptional("RequireFeature");
    
MarkNativeAsOptional("AddCommandListener");
    
MarkNativeAsOptional("RemoveCommandListener");
    
VerifyCoreVersion();
    return 
0;
}

ScaleVector(Float:vec[3], Float:scale)
{
    new 
var1 vec;
    
var1[0] = FloatMul(var1[0], scale);
    new 
var2 vec[4];
    
var2 FloatMul(var2scale);
    new 
var3 vec[8];
    
var3 FloatMul(var3scale);
    return 
0;
}

MakeVectorFromPoints(Float:pt1[3], Float:pt2[3], Float:output[3])
{
    
output[0] = FloatSub(pt2[0], pt1[0]);
    
output[4] = FloatSub(pt2[4], pt1[4]);
    
output[8] = FloatSub(pt2[8], pt1[8]);
    return 
0;
}

bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
{
    return 
strcmp(str1str2caseSensitive) == 0;
}

public 
OnPluginStart()
{
    
CreateConVar("knockback_version""1.0""knockback plugin info cvar"8448false0.0false0.0);
    
HookEvent("player_hurt"EventHook:5EventHookMode:1);
    return 
0;
}

public 
Action:Player_Hurt(Handle:eventString:name[], bool:dontBroadcast)
{
    new 
Client GetClientOfUserId(GetEventInt(event"userid"));
    new 
Attacker GetClientOfUserId(GetEventInt(event"Attacker"));
    new 
var1;
    if (
AliveCheck(Client) == 1) {
        
decl String:k_weapon[32];
        
GetEventString(event"weapon"k_weapon32);
        new 
0;
        while (
28) {
            new 
var2 weaponKB[i][0][0];
            if (
StrEqual(var2[0][var2], k_weapontrue)) {
                
decl Float:Clientposition[3];
                
decl Float:targetposition[3];
                
decl Float:vector[3];
                
GetClientEyePosition(AttackerClientposition);
                
GetClientEyePosition(Clienttargetposition);
                
MakeVectorFromPoints(Clientpositiontargetpositionvector);
                
NormalizeVector(vectorvector);
                
ScaleVector(vectorStringToFloat(weaponKB[i][0][0][4]));
                
TeleportEntity(ClientNULL_VECTORNULL_VECTORvector);
            }
            
i++;
        }
    }
    return 
Action:0;
}

public 
bool:AliveCheck(Client)
{
    new 
var1;
    if (
Client 0) {
        if (
IsClientConnected(Client) == 1) {
            if (
IsClientInGame(Client) == 1) {
                if (
IsPlayerAlive(Client) == 1) {
                    return 
true;
                }
                return 
false;
            }
            return 
false;
        }
        return 
false;
    }
    return 
false;

__________________
Peace-Maker is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 07-07-2012 , 18:50   Re: Lysis: An experimental .smx decompiler
Reply With Quote #107

how did you get it to decompile so well?
__________________
View my Plugins | Donate
TnTSCS is offline
NiceAndSimple
Member
Join Date: Jan 2012
Old 07-07-2012 , 23:07   Re: Lysis: An experimental .smx decompiler
Reply With Quote #108

PHP Code:
new PlVers:__version 5;
new 
Float:NULL_VECTOR[3];
new 
String:NULL_STRING[1];
new 
Extension:__ext_core 68;
new 
MaxClients;
new 
Extension:__ext_sdktools 184;
public 
Plugin:myinfo =
{
    
name "KnockBack",
    
description "Weapon Knock Back",
    
author "ýýżýýý",
    
version "1.0",
    
url ""
};
new 
String:weaponKB[28][2][64] =
{
    {
        
"knife",
        
"0.0"
    
},
    {
        
"glock",
        
"40.0"
    
},
    {
        
"usp",
        
"40.0"
    
},
    {
        
"p228",
        
"40.0"
    
},
    {
        
"deagle",
        
"50.0"
    
},
    {
        
"fiveseven",
        
"40.0"
    
},
    {
        
"elite",
        
"40.0"
    
},
    {
        
"m3",
        
"100.0"
    
},
    {
        
"xm1014",
        
"80.0"
    
},
    {
        
"tmp",
        
"50.0"
    
},
    {
        
"mac10",
        
"50.0"
    
},
    {
        
"ump45",
        
"60.0"
    
},
    {
        
"mp5navy",
        
"60.0"
    
},
    {
        
"p90",
        
"60.0"
    
},
    {
        
"galil",
        
"70.0"
    
},
    {
        
"ak47",
        
"70.0"
    
},
    {
        
"m4a1",
        
"70.0"
    
},
    {
        
"famas",
        
"70.0"
    
},
    {
        
"aug",
        
"70.0"
    
},
    {
        
"sg552",
        
"70.0"
    
},
    {
        
"m249",
        
"70.0"
    
},
    {
        
"scout",
        
"150.0"
    
},    
    {
        
"awp",
        
"250.0"
    
},
    {
        
"sg550",
        
"80.0"
    
},
    {
        
"g3sg1",
        
"80.0"
    
}
}
public 
__ext_core_SetNTVOptional()
{
    
MarkNativeAsOptional("GetFeatureStatus");
    
MarkNativeAsOptional("RequireFeature");
    
MarkNativeAsOptional("AddCommandListener");
    
MarkNativeAsOptional("RemoveCommandListener");
    
VerifyCoreVersion();
    return 
0;
}

ScaleVector(Float:vec[3], Float:scale)
{
    new 
var1 vec;
    
var1[0] = FloatMul(var1[0], scale);
    new 
var2 vec[4];
    
var2 FloatMul(var2scale);
    new 
var3 vec[8];
    
var3 FloatMul(var3scale);
    return 
0;
}

MakeVectorFromPoints(Float:pt1[3], Float:pt2[3], Float:output[3])
{
    
output[0] = FloatSub(pt2[0], pt1[0]);
    
output[4] = FloatSub(pt2[4], pt1[4]);
    
output[8] = FloatSub(pt2[8], pt1[8]);
    return 
0;
}

bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
{
    return 
strcmp(str1str2caseSensitive) == 0;
}

public 
OnPluginStart()
{
    
CreateConVar("knockback_version""1.0""knockback plugin info cvar"8448false0.0false0.0);
    
HookEvent("player_hurt"EventHook:5EventHookMode:1);
    return 
0;
}

public 
Action:Player_Hurt(Handle:eventString:name[], bool:dontBroadcast)
{
    new 
Client GetClientOfUserId(GetEventInt(event"userid"));
    new 
Attacker GetClientOfUserId(GetEventInt(event"Attacker"));
    new 
var1;
    if (
AliveCheck(Client) == 1) {
        
decl String:k_weapon[32];
        
GetEventString(event"weapon"k_weapon32);
        new 
0;
        while (
28) {
            new 
var2 weaponKB[i][0][0];
            if (
StrEqual(var2[0][var2], k_weapontrue)) {
                
decl Float:Clientposition[3];
                
decl Float:targetposition[3];
                
decl Float:vector[3];
                
GetClientEyePosition(AttackerClientposition);
                
GetClientEyePosition(Clienttargetposition);
                
MakeVectorFromPoints(Clientpositiontargetpositionvector);
                
NormalizeVector(vectorvector);
                
ScaleVector(vectorStringToFloat(weaponKB[i][0][0][4]));
                
TeleportEntity(ClientNULL_VECTORNULL_VECTORvector);
            }
            
i++;
        }
    }
    return 
Action:0;
}

public 
bool:AliveCheck(Client)
{
    new 
var1;
    if (
Client 0) {
        if (
IsClientConnected(Client) == 1) {
            if (
IsClientInGame(Client) == 1) {
                if (
IsPlayerAlive(Client) == 1) {
                    return 
true;
                }
                return 
false;
            }
            return 
false;
        }
        return 
false;
    }
    return 
false;

I compiled this and got these 11 errors: And where the cool face is its meant to be an 8

/groups/sourcemod/compiler-1.4/include/core.inc(171) : warning 209: function "__ext_core_SetNTVOptional" should return a value
/groups/sourcemod/compiler-1.4/include/vector.inc(160) : warning 209: function "ScaleVector" should return a value
/groups/sourcemod/compiler-1.4/include/vector.inc(18 : warning 209: function "MakeVectorFromPoints" should return a value
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(1) : warning 213: tag mismatch
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(2) : error 021: symbol already defined: "NULL_VECTOR"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(3) : error 021: symbol already defined: "NULL_STRING"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(4) : warning 213: tag mismatch
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(5) : error 021: symbol already defined: "MaxClients"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(117) : error 052: multi-dimensional arrays must be fully initialized
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(119) : error 021: symbol already defined: "__ext_core_SetNTVOptional"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(129) : error 021: symbol already defined: "ScaleVector"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(130) : error 033: array must be indexed (variable "-unknown-")
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : error 028: invalid subscript (not an array or too many subscripts): "var1"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : warning 215: expression has no effect
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : error 001: expected token: ";", but found "]"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : error 029: invalid expression, assumed zero
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : fatal error 127: too many error messages on one line

Last edited by NiceAndSimple; 07-07-2012 at 23:42.
NiceAndSimple is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-08-2012 , 10:43   Re: Lysis: An experimental .smx decompiler
Reply With Quote #109

You can't just compile the decompiled plugins. You'll have to clean it up or better just rewrite it, as it's that simple. The only interesting code is in the player_hurt event handler.

Quote:
Originally Posted by TnTSCS View Post
how did you get it to decompile so well?
I changed the dumpStringArray method to not try to access invalid indexes, it's not a good solution as lots of the array is missing as you can see ;)
__________________

Last edited by Peace-Maker; 07-08-2012 at 10:45.
Peace-Maker is offline
NiceAndSimple
Member
Join Date: Jan 2012
Old 07-09-2012 , 03:27   Re: Lysis: An experimental .smx decompiler
Reply With Quote #110

Quote:
Originally Posted by Peace-Maker View Post
You can't just compile the decompiled plugins. You'll have to clean it up or better just rewrite it, as it's that simple. The only interesting code is in the player_hurt event handler.



I changed the dumpStringArray method to not try to access invalid indexes, it's not a good solution as lots of the array is missing as you can see ;)
Are you able to quickly do this for me? Please....
NiceAndSimple is offline
Reply


Thread Tools
Display Modes

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 -4. The time now is 11:18.


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