InfaceMaxtoCode 源代码

        桃源企业文件管理系统挺好,想看看实现.晕重要程序集全被加密.Reflector拿它一点办法都没有.后来用IDA, 一下子IL代码就出来了. MaxtoCode上了解到,它的加密,还没有程序能够反编译经过它加密的程序. 牛都吹到天上去了!!这不费了老大劲把InfaceMaxtoCode类的源代码搞出来了.

        以下代码仅供研究学习,有坏心眼的人就别看了!

public   class  InfaceMaxtoCode
{
    
// Fields
    private static string IInfaceMaxtoCode_interface_string;
    
private static bool started;

    
// Methods
    static InfaceMaxtoCode();
    
public InfaceMaxtoCode();
    
private static string ByteToString(byte[] inbuf);
    
private static string ByteToString(byte[] inbuf, int Index, int Count);
    [DllImport(
"mytaoyuan.dll", CharSet=CharSet.Unicode, SetLastError=true, ExactSpelling=true, PreserveSig=false)]
    
private static extern int CheckRuntime(IntPtr ImageBase);
    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
public static extern int CloseHandle(IntPtr hObject);
    
public static bool GetCurMachineofFramework(ref MachineClass mc);
    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
private static extern uint GetCurrentProcessId();
    [DllImport(
"KERNEL32.DLL", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true, PreserveSig=false)]
    
private static extern IntPtr GetModuleHandleA(string lpModuleName);
    
private static string GetRuntimeName();
    
private static void LicenseHelper();
    
private static void LoadRuntimes();
    [DllImport(
"mytaoyuan.dll", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true, PreserveSig=false)]
    
private static extern bool MainDLL(IntPtr RuntimeBase, IntPtr AppBase);
    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
public static extern IntPtr OpenProcess(uint dwDesiredAccess, int bInheritHandle, uint dwProcessId);
    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
public static extern int ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, uint size, ref IntPtr lpNumberOfBytesRead);
    [DllImport(
"KERNEL32.DLL", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true, PreserveSig=false)]
    
private static extern bool SetEnvironmentVariableA(string lpName, string lpValue);
    
public static void Startup();
    
private static string WarningString();
    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
public static extern int WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, uint size, ref IntPtr lpNumberOfBytesWritten);
}


 

 

public   class  InfaceMaxtoCode
{
    
// Fields
    private static string IInfaceMaxtoCode_interface_string;
    
private static bool started = false;

    
// Methods
    private static string ByteToString(byte[] inbuf)
    
{
        
return Encoding.ASCII.GetString(inbuf);
    }


    
private static string ByteToString(byte[] inbuf, int Index, int Count)
    
{
        
return Encoding.ASCII.GetString(inbuf, Index, Count);
    }


    [DllImport(
"mytaoyuan.dll", CharSet=CharSet.Unicode, SetLastError=true, ExactSpelling=true, PreserveSig=false)]
    
private static extern int CheckRuntime(IntPtr ImageBase);
    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
public static extern int CloseHandle(IntPtr hObject);
    
public static bool GetCurMachineofFramework(ref MachineClass mc)
    
{
        
// This item is obfuscated and can not be translated.
        OOl0lO1O00ll looll;
        IntPtr zero 
= IntPtr.Zero;
        IntPtr lpBaseAddress 
= IntPtr.Zero;
        mc 
= (MachineClass) 0;
        
byte[] bytes = new byte[] 0x6d0x730x630x6f0x720x770x6b0x730x2e1000x6c0x6c };
        
byte[] buffer2 = new byte[] 0x6d0x730x630x6f0x720x730x760x720x2e1000x6c0x6c };
        
byte[] buffer3 = new byte[] 0x6d0x730x630x6f0x720x6a0x690x74 };
        lpBaseAddress 
= GetModuleHandleA(Encoding.ASCII.GetString(bytes));
        
if (lpBaseAddress == IntPtr.Zero)
        
{
            lpBaseAddress 
= GetModuleHandleA(Encoding.ASCII.GetString(buffer2));
        }

        
if (lpBaseAddress == IntPtr.Zero)
        
{
            lpBaseAddress 
= GetModuleHandleA(Encoding.ASCII.GetString(buffer3));
        }

        
byte[] buffer = new byte[0x2000];
        zero 
= OpenProcess(0x181, GetCurrentProcessId());
        
if (IntPtr.ToInt32() == 0)
        
{
            
return false;
        }

        IntPtr lpNumberOfBytesRead 
= new IntPtr();
        ReadProcessMemory(zero, lpBaseAddress, buffer, 
0x2000ref lpNumberOfBytesRead);
        CloseHandle(zero);
        looll.e_magic 
= buffer[0+ (buffer[1* 0x100);
        looll.e_lfanew 
= ((buffer[60+ (buffer[0x3d* 0x100)) + (buffer[0x3e* 0x10000)) + (buffer[0x3f* 0x1000000);
        
if ((looll.e_lfanew + 6>= 0x2000)
        
{
            
return false;
        }

        looll.Signature 
= ((buffer[looll.e_lfanew] + (buffer[looll.e_lfanew + 1* 0x100)) + (buffer[looll.e_lfanew + 2* 0x10000)) + (buffer[looll.e_lfanew + 3* 0x1000000);
        looll.Machine 
= buffer[looll.e_lfanew + 4+ (buffer[looll.e_lfanew + 5* 0x100);
        
if ((looll.e_magic != 0x5a4d|| (looll.Signature != 0x4550))
        
{
            
return false;
        }

        
switch (looll.Machine)
        
{
            
case 0x14c:
                mc 
= (MachineClass) 1;
                
return true;

            
case 0x200:
                mc 
= (MachineClass) 3;
                
return true;

            
case 0x8664:
                mc 
= (MachineClass) 2;
                
return true;
        }

        mc 
= (MachineClass) 0;
        
return true;
    }


    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
private static extern uint GetCurrentProcessId();
    [DllImport(
"KERNEL32.DLL", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true, PreserveSig=false)]
    
private static extern IntPtr GetModuleHandleA(string lpModuleName);
    
private static string GetRuntimeName()
    
{
        
return ByteToString(new byte[] 0x6d0x790x740x610x6f0x790x750x611100x2e1000x6c0x6c });
    }


    
private static void LicenseHelper()
    
{
    }


    
private static unsafe void LoadRuntimes()
    
{
        
// This item is obfuscated and can not be translated.
        byte[] inbuf = new byte[12];
        inbuf[
0= 0x2f;
        inbuf[
1= 0x3a;
        inbuf[
2= 0x3b;
        inbuf[
3= 0x5c;
        inbuf[
4= 0x70;
        inbuf[
5= 0x61;
        inbuf[
6= 0x74;
        inbuf[
7= 0x68;
        inbuf[
8= 0;
        IntPtr zero 
= IntPtr.Zero;
        
if (!started)
        
{
            
string relativeSearchPath;
            MachineClass class2;
            started 
= true;
            WarningString();
            zero 
= GetModuleHandleA(Assembly.GetExecutingAssembly().Location);
            
string runtimeName = GetRuntimeName();
            
if (AppDomain.CurrentDomain.RelativeSearchPath != null)
            
{
                
if (AppDomain.CurrentDomain.RelativeSearchPath.IndexOf(ByteToString(inbuf, 11+ ByteToString(inbuf, 31)) != -1)
                
{
                    relativeSearchPath 
= AppDomain.CurrentDomain.RelativeSearchPath;
                }

                
else
                
{
                    relativeSearchPath 
= AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath;
                }

            }

            
else
            
{
                relativeSearchPath 
= AppDomain.CurrentDomain.BaseDirectory;
            }

            
string environmentVariable = Environment.GetEnvironmentVariable(Encoding.ASCII.GetString(inbuf, 44));
            
if (environmentVariable.IndexOf(relativeSearchPath) == -1)
            
{
                SetEnvironmentVariableA(ByteToString(inbuf, 
44), environmentVariable + ByteToString(inbuf, 21+ relativeSearchPath.Replace(ByteToString(inbuf, 01), ByteToString(inbuf, 31)));
            }

            
if (relativeSearchPath.Substring(relativeSearchPath.Length - 11== ByteToString(inbuf, 31))
            
{
                relativeSearchPath 
= relativeSearchPath;
            }

            
else
            
{
                relativeSearchPath 
= relativeSearchPath + ByteToString(inbuf, 31);
            }

            
if (environmentVariable.IndexOf(Path.GetTempPath()) == -1)
            
{
                SetEnvironmentVariableA(ByteToString(inbuf, 
44), environmentVariable + ByteToString(inbuf, 21+ relativeSearchPath.Replace(ByteToString(inbuf, 01), ByteToString(inbuf, 31)) + ByteToString(inbuf, 21+ Path.GetTempPath().Replace(ByteToString(inbuf, 01), ByteToString(inbuf, 31)));
            }

            
if (File.Exists(relativeSearchPath + runtimeName) && !File.Exists(Path.GetTempPath() + runtimeName))
            
{
                File.Copy(relativeSearchPath 
+ runtimeName, Path.GetTempPath() + runtimeName);
            }

            GetCurMachineofFramework(
ref class2);
            
int num = 5;
            
if (class2 == ((MachineClass) 1))
            
{
                num 
= CheckRuntime(zero);
            }

            
else
            
{
                num 
= CheckRuntime(zero);
            }

            
if (num == 0)
            
{
                IntPtr moduleHandleA 
= GetModuleHandleA(runtimeName);
                
if (class2 == ((MachineClass) 1))
                
{
                    started 
= MainDLL(moduleHandleA, zero);
                }

                
else
                
{
                    started 
= MainDLL(moduleHandleA, zero);
                }

            }

            
else
            
{
                
byte[] buffer2 = new byte[] 0x550x4e0x4b0x570x4f0x4e0x200x450x520x520x4f0x52 };
                
byte[] buffer3 = new byte[] 
                    
0x4e0x6f0x740x200x660x691101000x20700x720x610x6d0x650x770x6f
                    
0x720x6b0x200x520x751100x740x690x6d0x650x2c0x20800x6c0x650x61
                    
0x730x650x200x630x680x650x630x6b0x200x790x6f0x750x20700x720x61
                    
0x6d0x650x770x6f0x720x6b0x210x5c1100x5c0x72
                 }
;
                
byte[] buffer4 = new byte[] 
                    
0x540x680x650x20700x720x6d0x610x650x770x6f0x720x6b0x200x760x65
                    
0x720x730x690x6f1100x200x690x730x201100x6f0x740x200x730x750x70
                    
0x700x6f0x720x740x2c0x200x700x6c0x650x610x730x650x200x750x70100
                    
0x610x740x650x200x790x6f0x750x720x200x660x720x610x6d0x650x770x6f
                    
0x720x6b0x200x6f0x720x200x720x650x730x740x610x720x740x200x730x65
                    
0x740x750x700x200x2e0x4e0x450x540x200x660x720x610x6d0x650x770x6f
                    
0x720x6b0x5c1100x5c0x72800x6c0x650x610x730x650x200x670x650x74
                    
0x200x610x201100x650x770x200x720x751100x740x690x6d0x650x200x73
                    
0x750x700x700x6f0x720x740x200x740x6f0x200x770x650x620x730x690x74
                    
0x650x200x680x740x740x700x3a0x2f0x2f0x770x770x770x2e0x6d0x61120
                    
0x740x6f0x630x6f1000x650x2e0x630x6f0x6d0x2f700x720x610x6d0x65
                    
0x770x6f0x720x6b0x530x750x700x700x6f0x720x740x2e0x680x740x6d0x6c
                    
0x5c1100x5c0x72
                 }
;
                
byte[] buffer5 = new byte[] 
                    
0x540x680x650x20700x720x6d0x610x650x770x6f0x720x6b0x200x760x65
                    
0x720x730x690x6f1100x200x690x730x201100x6f0x740x200x730x750x70
                    
0x700x6f0x720x740x2c0x200x700x6c0x650x610x730x650x200x750x70100
                    
0x610x740x650x200x790x6f0x750x720x200x660x720x610x6d0x650x770x6f
                    
0x720x6b0x200x6f0x720x200x720x650x730x740x610x720x740x200x730x65
                    
0x740x750x700x200x2e0x4e0x450x540x200x660x720x610x6d0x650x770x6f
                    
0x720x6b0x5c1100x5c0x72800x6c0x650x610x730x650x200x670x650x74
                    
0x200x610x201100x650x770x200x720x751100x740x690x6d0x650x200x73
                    
0x750x700x700x6f0x720x740x200x740x6f0x200x770x650x620x730x690x74
                    
0x650x200x680x740x740x700x3a0x2f0x2f0x770x770x770x2e0x6d0x61120
                    
0x740x6f0x630x6f1000x650x2e0x630x6f0x6d0x2f700x720x610x6d0x65
                    
0x770x6f0x720x6b0x530x750x700x700x6f0x720x740x2e0x680x740x6d0x6c
                    
0x5c1100x5c0x720x450x720x720x6f0x720x200x430x6f1000x650x200x3a
                    
0x200x301200x300x300x300x330x5c1100x5c0x72
                 }
;
                
byte[] buffer6 = new byte[] 
                    
0x4d0x610x6b0x650x720x200x440x650x630x6f1000x650x720x200x450x72
                    
0x720x6f0x720x5c1100x5c0x72
                 }
;
                
byte[] buffer7 = new byte[0x20];
                buffer7[
0= 0x49;
                buffer7[
1= 0x6d;
                buffer7[
2= 0x70;
                buffer7[
3= 0x6f;
                buffer7[
4= 0x72;
                buffer7[
5= 0x74;
                buffer7[
6= 0x73;
                buffer7[
7= 0x20;
                buffer7[
8= 0x52;
                buffer7[
9= 0x75;
                buffer7[
10= 110;
                buffer7[
11= 0x74;
                buffer7[
12= 0x69;
                buffer7[
13= 0x6d;
                buffer7[
14= 0x65;
                buffer7[
15= 0x20;
                buffer7[
0x10= 0x44;
                buffer7[
0x11= 0x4c;
                buffer7[
0x12= 0x4c;
                buffer7[
0x13= 0x20;
                buffer7[
20= 0x69;
                buffer7[
0x15= 0x73;
                buffer7[
0x16= 0x20;
                buffer7[
0x17= 0x45;
                buffer7[
0x18= 0x72;
                buffer7[
0x19= 0x72;
                buffer7[
0x1a= 0x6f;
                buffer7[
0x1b= 0x72;
                buffer7[
0x1c= 0x5c;
                
byte[] buffer8 = new byte[] 0x520x751100x740x690x6d0x650x450x720x720x6f0x720x2e0x6c0x6f0x67 };
                
byte[] buffer9 = new byte[] 0x20 };
                
byte[] buffer10 = new byte[] 
                    
0x200x200x451200x630x700x740x690x6f1100x5c1100x5c0x720x5c110
                    
0x5c0x72
                 }
;
                
byte[] buffer11 = new byte[0x5f];
                buffer11[
0= 0x2d;
                buffer11[
1= 0x2d;
                buffer11[
2= 0x2d;
                buffer11[
3= 0x2d;
                buffer11[
4= 0x2d;
                buffer11[
5= 0x2d;
                buffer11[
6= 0x2d;
                buffer11[
7= 0x2d;
                buffer11[
8= 0x2d;
                buffer11[
9= 0x2d;
                buffer11[
10= 0x2d;
                buffer11[
11= 0x2d;
                buffer11[
12= 0x2d;
                buffer11[
13= 0x2d;
                buffer11[
14= 0x2d;
                buffer11[
15= 0x2d;
                buffer11[
0x10= 0x2d;
                buffer11[
0x11= 0x2d;
                buffer11[
0x12= 0x2d;
                buffer11[
0x13= 0x2d;
                buffer11[
20= 0x2d;
                buffer11[
0x15= 0x2d;
                buffer11[
0x16= 0x2d;
                buffer11[
0x17= 0x2d;
                buffer11[
0x18= 0x2d;
                buffer11[
0x19= 0x2d;
                buffer11[
0x1a= 0x2d;
                buffer11[
0x1b= 0x2d;
                buffer11[
0x1c= 0x2d;
                
byte[] buffer12 = new byte[] 
                    
0x5c1100x5c0x720x5c1100x5c0x720x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d
                    
0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d
                    
0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d
                    
0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d
                    
0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d
                    
0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x2d0x5c
                    
1100x5c0x720x5c1100x5c0x72
                 }
;
                
string s = ByteToString(buffer2);
                
switch (num)
                
{
                    
case 1:
                        s 
= ByteToString(buffer3);
                        
break;

                    
case 2:
                        s 
= ByteToString(buffer4);
                        
break;

                    
case 3:
                        s 
= ByteToString(buffer5);
                        
break;

                    
case 4:
                        s 
= ByteToString(buffer6);
                        
break;

                    
case 5:
                        s 
= ByteToString(buffer7);
                        
break;
                }

                FileStream stream 
= new FileStream(relativeSearchPath + ByteToString(buffer8), FileMode.Append, FileAccess.Write);
                
string str5 = ByteToString(buffer9) + ((string&DateTime.Now) + DateTime.ToShortTimeString() + ByteToString(buffer10);
                stream.Write(Encoding.ASCII.GetBytes(str5), 
0, str5.Length);
                str5 
= ByteToString(buffer11);
                stream.Write(Encoding.ASCII.GetBytes(str5), 
0, str5.Length);
                stream.Write(Encoding.ASCII.GetBytes(s), 
0, s.Length);
                str5 
= ByteToString(buffer12);
                stream.Write(Encoding.ASCII.GetBytes(str5), 
0, str5.Length);
                stream.Close();
            }

        }

    }


    [DllImport(
"mytaoyuan.dll", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true, PreserveSig=false)]
    
private static extern bool MainDLL(IntPtr RuntimeBase, IntPtr AppBase);
    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
public static extern IntPtr OpenProcess(uint dwDesiredAccess, int bInheritHandle, uint dwProcessId);
    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
public static extern int ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, uint size, ref IntPtr lpNumberOfBytesRead);
    [DllImport(
"KERNEL32.DLL", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true, PreserveSig=false)]
    
private static extern bool SetEnvironmentVariableA(string lpName, string lpValue);
    
public static void Startup()
    
{
        
if (!started)
        
{
            
try
            
{
                LoadRuntimes();
            }

            
finally
            
{
                LicenseHelper();
            }

        }

    }


    
private static string WarningString()
    
{
        
byte[] bytes = new byte[] 0xe40xb80xad0xe50x9b0xbd0x610x620x630 };
        
return Encoding.UTF8.GetString(bytes);
    }


    [DllImport(
"kernel32.dll", PreserveSig=false)]
    
public static extern int WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, uint size, ref IntPtr lpNumberOfBytesWritten);
}


 
Collapse Methods
 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值