吾爱汇编

 找回密码
 立即注册

QQ登录

绑定QQ避免忘记帐号

查看: 6493|回复: 25

[原创逆向图文] C#逆向教程(6)小结

  [复制链接]
Dean 发表于 2014-10-20 15:02 | 显示全部楼层 |阅读模式

这一课主要对之前的内容进行一些补充和总结,大部分新手知识都已经讲解完毕,剩下的就是需要多操作,多练,多思考
----------------------------------------------------------------------------------------------------------------------------------
第一课中ILDASM生成的IL和RES文件可以用微软提供的ILASM进行打包,CMD下执行命令ilasm /resource=XXX.res XXX.il即可生成可执行EXE,如果不报错的话
----------------------------------------------------------------------------------------------------------------------------------
在WIN32中,可执行文件在执行时,操作系统把可执行文件加载到内存中,执行其中的.text节的代码,执行完毕后由操作系统卸载
在NET中,导入表中只有mscoree.dll,执行开始,载入内存,跳到_CoreExeMain执行,NET框架开始接手程序的执行,不再和操作系统有关


另外接触NET还会经常听到一个名词,JIT(Just In-Time compile)只有在需要的时候把IL代码编译成本机指令,IL代码传入JIT,输出的是本机代码
----------------------------------------------------------------------------------------------------------------------------------
MSIL也是一种基于堆栈的语言,但是和WIN32不同的是,堆栈元素不是按照字节来区分大小,而是一个抽象概念,仅代表一个元素,不关心元素的大小和类型


条件跳转指令是从栈顶取一个bool类型值,true为非0,false为0
brtrue不为0则跳
brfalse 为0则跳


比较跳转是从堆栈顶部取2个值进行比较,满足条件则跳,比如beq,bgt,bge,blt,ble等
----------------------------------------------------------------------------------------------------------------------------------
最后说一下DE4DOT,玩NET的都知道,但是有几个人真正了解DE4DOT和知道DE4DOT有扩展命令可以灵活运用呢


有时候一个混淆,DE4DOT是能搞定的,但是要加命令,不是简单的DE4DOT 路径


附上DE4DOT使用说明

  1. de4dot v3.1.41592.3405 Copyright (C) 2011-2014 de4dot@gmail.com
  2. Latest version and source code: https://bitbucket.org/0xd4d/de4dot

  3. Some of the advanced options may be incompatible, causing a nice exception.
  4. With great power comes great responsibility.

  5. de4dot <options> <file options>
  6. Options:
  7.   -r DIR           Scan for .NET files in all subdirs
  8.   -ro DIR          Output base dir for recursively found files
  9.   -ru              Skip recursively found files with unsupported obfuscator
  10.   -d               Detect obfuscators and exit
  11.   --asm-path PATH  Add an assembly search path
  12.   --dont-rename    Don't rename classes, methods, etc.
  13.   --keep-names FLAGS
  14.                    Don't rename n(amespaces), t(ypes), p(rops), e(vents), f(ield
  15. s), m(ethods), a(rgs), g(enericparams), d(elegate fields). Can be combined, eg.
  16. efm
  17.   --dont-create-params
  18.                    Don't create method params when renaming
  19.   --dont-restore-props
  20.                    Don't restore properties/events
  21.   --default-strtyp TYPE
  22.                    Default string decrypter type
  23.   --default-strtok METHOD
  24.                    Default string decrypter method token or [type::][name][(args
  25. ,...)]
  26.   --no-cflow-deob  No control flow deobfuscation (NOT recommended)
  27.   --load-new-process
  28.                    Load executed assemblies into a new process
  29.   --keep-types     Keep obfuscator types, fields, methods
  30.   --preserve-tokens
  31.                    Preserve important tokens, #US, #Blob, extra sig data
  32.   --preserve-table FLAGS
  33.                    Preserve rids in table: tr (TypeRef), td (TypeDef), fd (Field
  34. ), md (Method), pd (Param), mr (MemberRef), s (StandAloneSig), ed (Event), pr (P
  35. roperty), ts (TypeSpec), ms (MethodSpec), all (all previous tables). Use - to di
  36. sable (eg. all,-pd). Can be combined: ed,fd,md
  37.   --preserve-strings
  38.                    Preserve #Strings heap offsets
  39.   --preserve-us    Preserve #US heap offsets
  40.   --preserve-blob  Preserve #Blob heap offsets
  41.   --preserve-sig-data
  42.                    Preserve extra data at the end of signatures
  43.   --one-file       Deobfuscate one file at a time
  44.   -v               Verbose
  45.   -vv              Very verbose
  46.   -h               Show this help message
  47.   --help           Same as -h

  48. File options:
  49.   -f FILE          Name of .NET file
  50.   -o FILE          Name of output file
  51.   -p TYPE          Obfuscator type (see below)
  52.   --strtyp TYPE    String decrypter type
  53.   --strtok METHOD  String decrypter method token or [type::][name][(args,...)]

  54. Deobfuscator options:
  55. Type un (Unknown)
  56.   --un-name REGEX  Valid name regex pattern (^[a-zA-Z_<{$][a-zA-Z_0-9<>{}$.`-]*$
  57. )

  58. Type an (Agile.NET)
  59.   --an-name REGEX  Valid name regex pattern (^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\
  60. u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  61.   --an-methods BOOL
  62.                    Decrypt methods (True)
  63.   --an-rsrc BOOL   Decrypt resources (True)
  64.   --an-stack BOOL  Remove all StackFrameHelper code (True)
  65.   --an-vm BOOL     Restore VM code (True)
  66.   --an-initlocals BOOL
  67.                    Set initlocals in method header (True)

  68. Type bl (Babel .NET)
  69.   --bl-name REGEX  Valid name regex pattern (^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\
  70. u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  71.   --bl-inline BOOL Inline short methods (True)
  72.   --bl-remove-inlined BOOL
  73.                    Remove inlined methods (True)
  74.   --bl-methods BOOL
  75.                    Decrypt methods (True)
  76.   --bl-rsrc BOOL   Decrypt resources (True)
  77.   --bl-consts BOOL Decrypt constants and arrays (True)
  78.   --bl-embedded BOOL
  79.                    Dump embedded assemblies (True)

  80. Type cf (CodeFort)
  81.   --cf-name REGEX  Valid name regex pattern (!^[a-zA-Z]{1,3}[        DISCUZ_CODE_6        ]amp;!^[_<>{}$.`-][        DISCUZ_CODE_6        ]amp;^[\
  82. u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  83.   --cf-embedded BOOL
  84.                    Dump embedded assemblies (True)

  85. Type cv (CodeVeil)
  86.   --cv-name REGEX  Valid name regex pattern (!^[A-Za-z]{1,2}[        DISCUZ_CODE_6        ]amp;^[\u2E80-\u9FFFa-z
  87. A-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)

  88. Type cw (CodeWall)
  89.   --cw-name REGEX  Valid name regex pattern (!^[0-9A-F]{32}[        DISCUZ_CODE_6        ]amp;!^[_<>{}$.`-][        DISCUZ_CODE_6        ]amp;^[\u
  90. 2E80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  91.   --cw-embedded BOOL
  92.                    Dump embedded assemblies (True)
  93.   --cw-decrypt-main BOOL
  94.                    Decrypt main embedded assembly (True)

  95. Type co (Crypto Obfuscator)
  96.   --co-name REGEX  Valid name regex pattern (!^(get_|set_|add_|remove_)?[A-Z]{1,
  97. 3}(?:`\d+)?[        DISCUZ_CODE_6        ]amp;!^(get_|set_|add_|remove_)?c[0-9a-f]{32}(?:`\d+)?[        DISCUZ_CODE_6        ]amp;^[\u2E80-\u9FFFa
  98. -zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  99.   --co-tamper BOOL Remove tamper protection code (True)
  100.   --co-consts BOOL Decrypt constants (True)
  101.   --co-inline BOOL Inline short methods (True)
  102.   --co-ldnull BOOL Restore ldnull instructions (True)

  103. Type ds (DeepSea)
  104.   --ds-name REGEX  Valid name regex pattern (^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\
  105. u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  106.   --ds-inline BOOL Inline short methods (True)
  107.   --ds-remove-inlined BOOL
  108.                    Remove inlined methods (True)
  109.   --ds-rsrc BOOL   Decrypt resources (True)
  110.   --ds-embedded BOOL
  111.                    Dump embedded assemblies (True)
  112.   --ds-fields BOOL Restore fields (True)
  113.   --ds-keys BOOL   Rename resource keys (True)
  114.   --ds-casts BOOL  Deobfuscate casts (True)

  115. Type df (Dotfuscator)
  116.   --df-name REGEX  Valid name regex pattern (!^(?:eval_)?[a-z][a-z0-9]{0,2}[        DISCUZ_CODE_6        ]amp;!^A
  117. _[0-9]+[        DISCUZ_CODE_6        ]amp;^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)

  118. Type dr3 (.NET Reactor)
  119.   --dr3-name REGEX Valid name regex pattern (^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\
  120. u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  121.   --dr3-types BOOL Restore types (object -> real type) (True)
  122.   --dr3-inline BOOL
  123.                    Inline short methods (True)
  124.   --dr3-remove-inlined BOOL
  125.                    Remove inlined methods (True)
  126.   --dr3-ns1 BOOL   Clear namespace if there's only one class in it (True)
  127.   --dr3-sn BOOL    Remove anti strong name code (True)

  128. Type dr4 (.NET Reactor)
  129.   --dr4-name REGEX Valid name regex pattern (^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\
  130. u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  131.   --dr4-methods BOOL
  132.                    Decrypt methods (True)
  133.   --dr4-bools BOOL Decrypt booleans (True)
  134.   --dr4-types BOOL Restore types (object -> real type) (True)
  135.   --dr4-inline BOOL
  136.                    Inline short methods (True)
  137.   --dr4-remove-inlined BOOL
  138.                    Remove inlined methods (True)
  139.   --dr4-embedded BOOL
  140.                    Dump embedded assemblies (True)
  141.   --dr4-rsrc BOOL  Decrypt resources (True)
  142.   --dr4-ns1 BOOL   Clear namespace if there's only one class in it (True)
  143.   --dr4-sn BOOL    Remove anti strong name code (True)
  144.   --dr4-sname BOOL Rename short names (False)

  145. Type ef (Eazfuscator.NET)
  146.   --ef-name REGEX  Valid name regex pattern (!^[a-zA-Z][        DISCUZ_CODE_6        ]amp;!^#=&!^dje_.+_ejd[        DISCUZ_CODE_6        ]amp;^[\u
  147. 2E80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)

  148. Type go (Goliath.NET)
  149.   --go-name REGEX  Valid name regex pattern (!^[A-Za-z]{1,2}(?:`\d+)?[        DISCUZ_CODE_6        ]amp;^[\u2E80-
  150. \u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  151.   --go-inline BOOL Inline short methods (True)
  152.   --go-remove-inlined BOOL
  153.                    Remove inlined methods (True)
  154.   --go-locals BOOL Restore locals (True)
  155.   --go-ints BOOL   Decrypt integers (True)
  156.   --go-arrays BOOL Decrypt arrays (True)
  157.   --go-sn BOOL     Remove anti strong name code (True)

  158. Type il (ILProtector)
  159.   --il-name REGEX  Valid name regex pattern (^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\
  160. u9FFFa-zA-Z_0-9<>{}$.`-]*$)

  161. Type mc (MaxtoCode)
  162.   --mc-name REGEX  Valid name regex pattern (!^[oO01l]+[        DISCUZ_CODE_6        ]amp;!^[A-F0-9]{20,}[        DISCUZ_CODE_6        ]amp;^[\u2E
  163. 80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  164.   --mc-cp INT      String code page (936)

  165. Type mp (MPRESS)
  166.   --mp-name REGEX  Valid name regex pattern (^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\
  167. u9FFFa-zA-Z_0-9<>{}$.`-]*$)

  168. Type rm (Rummage)
  169.   --rm-name REGEX  Valid name regex pattern (!.)

  170. Type sk (Skater .NET)
  171.   --sk-name REGEX  Valid name regex pattern (!`[^0-9]+&^[\u2E80-\u9FFFa-zA-Z_<{$
  172. ][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)

  173. Type sa (SmartAssembly)
  174.   --sa-name REGEX  Valid name regex pattern (^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\
  175. u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  176.   --sa-error BOOL  Remove automated error reporting code (True)
  177.   --sa-tamper BOOL Remove tamper protection code (True)
  178.   --sa-memory BOOL Remove memory manager code (True)

  179. Type sn (Spices.Net)
  180.   --sn-name REGEX  Valid name regex pattern (!^[a-zA-Z0-9]{1,2}[        DISCUZ_CODE_6        ]amp;^[\u2E80-\u9FFF
  181. a-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$)
  182.   --sn-inline BOOL Inline short methods (True)
  183.   --sn-remove-inlined BOOL
  184.                    Remove inlined methods (True)
  185.   --sn-ns1 BOOL    Clear namespace if there's only one class in it (True)
  186.   --sn-rsrc BOOL   Restore resource names (True)

  187. Type xc (Xenocode)
  188.   --xc-name REGEX  Valid name regex pattern (!^[oO01l]{4,}[        DISCUZ_CODE_6        ]amp;!^(get_|set_|add_|re
  189. move_|_)?[x_][a-f0-9]{16,}[        DISCUZ_CODE_6        ]amp;^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>
  190. {}$.`-]*$)

  191. String decrypter types
  192.   none             Don't decrypt strings
  193.   default          Use default string decrypter type (usually static)
  194.   static           Use static string decrypter if available
  195.   delegate         Use a delegate to call the real string decrypter
  196.   emulate          Call real string decrypter and emulate certain instructions

  197. Multiple regexes can be used if separated by '&'.
  198. Use '!' if you want to invert the regex. Example: !^[a-z\d]{1,2}[        DISCUZ_CODE_6        ]amp;!^[A-Z]_\d+[        DISCUZ_CODE_6        ]amp;^
  199. [\w.]+$

  200. Examples:
  201. de4dot -r c:\my\files -ro c:\my\output
  202. de4dot file1 file2 file3
  203. de4dot file1 -f file2 -o file2.out -f file3 -o file3.out
  204. de4dot file1 --strtyp delegate --strtok 06000123
复制代码
好了,暂时就到这里吧,后面可能会发一些实战

评分

参与人数 25HB +30 THX +15 收起 理由
花盗睡鼠 + 2 + 1 [吾爱汇编论坛52HB.COM]-软件反汇编逆向分析,软件安全必不可少!
29590 + 1
虚心学习 + 1 [吾爱汇编论坛52HB.COM]-感谢楼主热心分享,小小评分不成敬意!
24567 + 2
阿里嘎多 + 1
Jawon + 1
一路走来不容易 + 1
Soul1999 + 1
消逝的过去 + 1
zxjzzh + 1 [吾爱汇编论坛52HB.COM]-学破解防破解,知进攻懂防守!
三月十六 + 1
temp + 1
bnjzzheng + 1 [吾爱汇编论坛52HB.COM]-学破解防破解,知进攻懂防守!
玖霊後 + 1
叶落花开 + 2
XiaoWeiSec + 1
小声点我布隆 + 1
liugu0hai + 1 + 1 [吾爱汇编论坛52HB.COM]-感谢楼主热心分享,小小评分不成敬意!
jaunic + 2
hnymsh + 1
lies + 1
wpsys + 1 + 1 评分=感恩!简单却充满爱!感谢您的作品!
LagyHehe + 1 评分=感恩!简单却充满爱!感谢您的作品!
Crook + 3 + 1 系列教程必须加精!!
Shark恒 + 10 + 1 支持原创,感谢楼主!

查看全部评分

吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
Shark恒 发表于 2014-10-20 16:16 | 显示全部楼层
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
怕怕吓一跳 发表于 2014-10-21 18:31 | 显示全部楼层

dean老大的教程确实花了心思,我也只会一点点net,感谢您的帮助,望后面带来更好的实战例子
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
luozh7682 发表于 2015-9-27 09:49 | 显示全部楼层

讲得很好,希望继续更新,学习更多的C#逆向知识,方便以后逆向C#程序。
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
luozh7682 发表于 2015-9-27 10:14 | 显示全部楼层

感觉用RE逆向.NET程序,如果不能用DE4DOT脱壳去混淆的话,基本是没有成功的可能性的,因为反编译的代码根本看不懂,更无法进行阅读分析;其次是IL代码的修改,看懂了反编译代码也要能修改IL代码才能PJ。一个.NET程序,如果能脱壳去混淆,那已经成功了50%了。
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
muker 发表于 2021-12-8 04:51 | 显示全部楼层
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
weizuqiang 发表于 2022-1-26 21:31 | 显示全部楼层

学习更多的C#逆向知识,方便以后逆向C#程序
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
6378895 发表于 2022-1-27 01:03 | 显示全部楼层

吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
6378895 发表于 2022-1-27 01:08 | 显示全部楼层

吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
消逝的过去 发表于 2022-1-29 08:56 | 显示全部楼层

[快捷回复]-学破解防逆向,知进攻懂防守!
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

警告:本站严惩灌水回复,尊重自己从尊重他人开始!

1层
2层
3层
4层
5层
6层
7层
8层
9层
10层

免责声明

吾爱汇编(www.52hb.com)所讨论的技术及相关工具仅限用于研究学习,皆在提高软件产品的安全性,严禁用于不良动机。任何个人、团体、组织不得将其用于非法目的,否则,一切后果自行承担。吾爱汇编不承担任何因为技术滥用所产生的连带责任。吾爱汇编内容源于网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除。如有侵权请邮件或微信与我们联系处理。

站长邮箱:SharkHeng@sina.com
站长QQ:1140549900


QQ|RSS|手机版|小黑屋|帮助|吾爱汇编 ( 京公网安备11011502005403号 , 京ICP备20003498号-6 )|网站地图

Powered by Discuz!

吾爱汇编 www.52hb.com

快速回复 返回顶部 返回列表