2021年1月4日星期一

Is possible to get the C# assembly binary file

My professor wants me to tell him if I can get the code of an assembly binary file. For me it is not possible. The file can be call with : https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase.invoke?view=net-5.0#System_Reflection_MethodBase_Invoke_System_Object_System_Object___

((Assembly)obj).EntryPoint.Invoke((object)null, (object[])null);  //object was defined before  

Thanxs !

[EDIT]

Thanks all for your answers, i have already tried dotpeek, ildasm.. -> not working

The file is not a dll.

file_read = Path.Combine(Application.StartupPath, "testfile");  bytes = File.ReadAllBytes(string.Concat(file_read));  bytes2 = Memrestore((byte[])bytes);  objAssembly = Assembly.Load((byte[])bytes2);  ((Assembly)objAssembly).EntryPoint.Invoke(null, null);  

My professor help me a little bit, bytes2 contain all the byte in the testfile.

On visual studio if i watch this variable and right click->Go to disassembly I get this :

0000000012E5F082  mov         edx,9B4000Eh    0000000012E5F087  int         21h    0000000012E5F089  mov         eax,21CD4C01h    0000000012E5F08E  push        rsp    0000000012E5F08F  push        70207369h    0000000012E5F094  jb          0000000012E5F105    0000000012E5F096  jb          0000000012E5F0FA    0000000012E5F099  ins         dword ptr [rdi],dx    0000000012E5F09A  and         byte ptr [rbx+61h],ah    0000000012E5F09D  outs        dx,byte ptr [rsi]    0000000012E5F09E  outs        dx,byte ptr [rsi]    0000000012E5F09F  outs        dx,dword ptr [rsi]    0000000012E5F0A0  je          0000000012E5F0C2    0000000012E5F0A2  ?? ??????   0000000012E5F0A3  and         byte ptr gs:[rdx+75h],dh    0000000012E5F0A7  outs        dx,byte ptr [rsi]    0000000012E5F0A8  and         byte ptr [rcx+6Eh],ch    0000000012E5F0AB  and         byte ptr [rdi+rcx*2+53h],al    0000000012E5F0AF  and         byte ptr [rbp+6Fh],ch    0000000012E5F0B2  ?? ??????   0000000012E5F0B3  ?? ??????   0000000012E5F0B4  or          eax,240A0Dh    0000000012E5F0BA  add         byte ptr [rax],al    0000000012E5F0BC  add         byte ptr [rax],al    0000000012E5F0BE  add         byte ptr [rax],al    0000000012E5F0C0  push        rax    0000000012E5F0C1  add         byte ptr [r8],r8b    0000000012E5F0C4  add         qword ptr [rbx],r8    0000000012E5F0C7  add         byte ptr [rsi],dl    0000000012E5F0C9  cmp         dl,dh  

(It is an extract of the file)

My question is : it is possible to revert this assembler code to c# ?

https://stackoverflow.com/questions/65562953/is-possible-to-get-the-c-sharp-assembly-binary-file January 04, 2021 at 08:45PM

没有评论:

发表评论