metasm 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.hgtags +3 -0
  4. data/Gemfile +1 -0
  5. data/INSTALL +61 -0
  6. data/LICENCE +458 -0
  7. data/README +29 -21
  8. data/Rakefile +10 -0
  9. data/TODO +10 -12
  10. data/doc/code_organisation.txt +2 -0
  11. data/doc/core/DynLdr.txt +247 -0
  12. data/doc/core/ExeFormat.txt +43 -0
  13. data/doc/core/Expression.txt +220 -0
  14. data/doc/core/GNUExports.txt +27 -0
  15. data/doc/core/Ia32.txt +236 -0
  16. data/doc/core/SerialStruct.txt +108 -0
  17. data/doc/core/VirtualString.txt +145 -0
  18. data/doc/core/WindowsExports.txt +61 -0
  19. data/doc/core/index.txt +1 -0
  20. data/doc/style.css +6 -3
  21. data/doc/usage/debugger.txt +327 -0
  22. data/doc/usage/index.txt +1 -0
  23. data/doc/use_cases.txt +2 -2
  24. data/metasm.gemspec +22 -0
  25. data/{lib/metasm.rb → metasm.rb} +11 -3
  26. data/{lib/metasm → metasm}/compile_c.rb +13 -7
  27. data/metasm/cpu/arc.rb +8 -0
  28. data/metasm/cpu/arc/decode.rb +425 -0
  29. data/metasm/cpu/arc/main.rb +191 -0
  30. data/metasm/cpu/arc/opcodes.rb +588 -0
  31. data/{lib/metasm → metasm/cpu}/arm.rb +7 -5
  32. data/{lib/metasm → metasm/cpu}/arm/debug.rb +2 -2
  33. data/{lib/metasm → metasm/cpu}/arm/decode.rb +13 -12
  34. data/{lib/metasm → metasm/cpu}/arm/encode.rb +23 -8
  35. data/{lib/metasm → metasm/cpu}/arm/main.rb +0 -3
  36. data/metasm/cpu/arm/opcodes.rb +324 -0
  37. data/{lib/metasm → metasm/cpu}/arm/parse.rb +25 -13
  38. data/{lib/metasm → metasm/cpu}/arm/render.rb +2 -2
  39. data/metasm/cpu/arm64.rb +15 -0
  40. data/metasm/cpu/arm64/debug.rb +38 -0
  41. data/metasm/cpu/arm64/decode.rb +289 -0
  42. data/metasm/cpu/arm64/encode.rb +41 -0
  43. data/metasm/cpu/arm64/main.rb +105 -0
  44. data/metasm/cpu/arm64/opcodes.rb +232 -0
  45. data/metasm/cpu/arm64/parse.rb +20 -0
  46. data/metasm/cpu/arm64/render.rb +95 -0
  47. data/{lib/metasm/ppc.rb → metasm/cpu/bpf.rb} +2 -4
  48. data/metasm/cpu/bpf/decode.rb +142 -0
  49. data/metasm/cpu/bpf/main.rb +60 -0
  50. data/metasm/cpu/bpf/opcodes.rb +81 -0
  51. data/metasm/cpu/bpf/render.rb +41 -0
  52. data/metasm/cpu/cy16.rb +9 -0
  53. data/metasm/cpu/cy16/decode.rb +253 -0
  54. data/metasm/cpu/cy16/main.rb +63 -0
  55. data/metasm/cpu/cy16/opcodes.rb +78 -0
  56. data/metasm/cpu/cy16/render.rb +41 -0
  57. data/metasm/cpu/dalvik.rb +11 -0
  58. data/{lib/metasm → metasm/cpu}/dalvik/decode.rb +35 -13
  59. data/{lib/metasm → metasm/cpu}/dalvik/main.rb +51 -2
  60. data/{lib/metasm → metasm/cpu}/dalvik/opcodes.rb +19 -11
  61. data/metasm/cpu/ia32.rb +17 -0
  62. data/{lib/metasm → metasm/cpu}/ia32/compile_c.rb +5 -7
  63. data/{lib/metasm → metasm/cpu}/ia32/debug.rb +5 -5
  64. data/{lib/metasm → metasm/cpu}/ia32/decode.rb +246 -59
  65. data/{lib/metasm → metasm/cpu}/ia32/decompile.rb +7 -7
  66. data/{lib/metasm → metasm/cpu}/ia32/encode.rb +19 -13
  67. data/{lib/metasm → metasm/cpu}/ia32/main.rb +51 -8
  68. data/metasm/cpu/ia32/opcodes.rb +1424 -0
  69. data/{lib/metasm → metasm/cpu}/ia32/parse.rb +47 -16
  70. data/{lib/metasm → metasm/cpu}/ia32/render.rb +31 -4
  71. data/metasm/cpu/mips.rb +14 -0
  72. data/{lib/metasm → metasm/cpu}/mips/compile_c.rb +1 -1
  73. data/metasm/cpu/mips/debug.rb +42 -0
  74. data/{lib/metasm → metasm/cpu}/mips/decode.rb +46 -16
  75. data/{lib/metasm → metasm/cpu}/mips/encode.rb +4 -3
  76. data/{lib/metasm → metasm/cpu}/mips/main.rb +11 -4
  77. data/{lib/metasm → metasm/cpu}/mips/opcodes.rb +86 -17
  78. data/{lib/metasm → metasm/cpu}/mips/parse.rb +1 -1
  79. data/{lib/metasm → metasm/cpu}/mips/render.rb +1 -1
  80. data/{lib/metasm/dalvik.rb → metasm/cpu/msp430.rb} +1 -1
  81. data/metasm/cpu/msp430/decode.rb +247 -0
  82. data/metasm/cpu/msp430/main.rb +62 -0
  83. data/metasm/cpu/msp430/opcodes.rb +101 -0
  84. data/{lib/metasm → metasm/cpu}/pic16c/decode.rb +6 -7
  85. data/{lib/metasm → metasm/cpu}/pic16c/main.rb +0 -0
  86. data/{lib/metasm → metasm/cpu}/pic16c/opcodes.rb +1 -1
  87. data/{lib/metasm/mips.rb → metasm/cpu/ppc.rb} +4 -4
  88. data/{lib/metasm → metasm/cpu}/ppc/decode.rb +18 -12
  89. data/{lib/metasm → metasm/cpu}/ppc/decompile.rb +3 -3
  90. data/{lib/metasm → metasm/cpu}/ppc/encode.rb +2 -2
  91. data/{lib/metasm → metasm/cpu}/ppc/main.rb +17 -12
  92. data/{lib/metasm → metasm/cpu}/ppc/opcodes.rb +11 -5
  93. data/metasm/cpu/ppc/parse.rb +55 -0
  94. data/metasm/cpu/python.rb +8 -0
  95. data/metasm/cpu/python/decode.rb +136 -0
  96. data/metasm/cpu/python/main.rb +36 -0
  97. data/metasm/cpu/python/opcodes.rb +180 -0
  98. data/{lib/metasm → metasm/cpu}/sh4.rb +1 -1
  99. data/{lib/metasm → metasm/cpu}/sh4/decode.rb +48 -17
  100. data/{lib/metasm → metasm/cpu}/sh4/main.rb +13 -4
  101. data/{lib/metasm → metasm/cpu}/sh4/opcodes.rb +7 -8
  102. data/metasm/cpu/x86_64.rb +15 -0
  103. data/{lib/metasm → metasm/cpu}/x86_64/compile_c.rb +28 -17
  104. data/{lib/metasm → metasm/cpu}/x86_64/debug.rb +4 -4
  105. data/{lib/metasm → metasm/cpu}/x86_64/decode.rb +57 -15
  106. data/{lib/metasm → metasm/cpu}/x86_64/encode.rb +55 -26
  107. data/{lib/metasm → metasm/cpu}/x86_64/main.rb +14 -6
  108. data/metasm/cpu/x86_64/opcodes.rb +136 -0
  109. data/{lib/metasm → metasm/cpu}/x86_64/parse.rb +10 -2
  110. data/metasm/cpu/x86_64/render.rb +35 -0
  111. data/metasm/cpu/z80.rb +9 -0
  112. data/metasm/cpu/z80/decode.rb +313 -0
  113. data/metasm/cpu/z80/main.rb +67 -0
  114. data/metasm/cpu/z80/opcodes.rb +224 -0
  115. data/metasm/cpu/z80/render.rb +59 -0
  116. data/{lib/metasm/os/main.rb → metasm/debug.rb} +160 -401
  117. data/{lib/metasm → metasm}/decode.rb +35 -4
  118. data/{lib/metasm → metasm}/decompile.rb +15 -16
  119. data/{lib/metasm → metasm}/disassemble.rb +201 -45
  120. data/{lib/metasm → metasm}/disassemble_api.rb +651 -87
  121. data/{lib/metasm → metasm}/dynldr.rb +220 -133
  122. data/{lib/metasm → metasm}/encode.rb +10 -1
  123. data/{lib/metasm → metasm}/exe_format/a_out.rb +9 -6
  124. data/{lib/metasm → metasm}/exe_format/autoexe.rb +1 -0
  125. data/{lib/metasm → metasm}/exe_format/bflt.rb +57 -27
  126. data/{lib/metasm → metasm}/exe_format/coff.rb +11 -3
  127. data/{lib/metasm → metasm}/exe_format/coff_decode.rb +53 -20
  128. data/{lib/metasm → metasm}/exe_format/coff_encode.rb +11 -13
  129. data/{lib/metasm → metasm}/exe_format/dex.rb +13 -5
  130. data/{lib/metasm → metasm}/exe_format/dol.rb +1 -0
  131. data/{lib/metasm → metasm}/exe_format/elf.rb +93 -57
  132. data/{lib/metasm → metasm}/exe_format/elf_decode.rb +143 -34
  133. data/{lib/metasm → metasm}/exe_format/elf_encode.rb +122 -31
  134. data/metasm/exe_format/gb.rb +65 -0
  135. data/metasm/exe_format/javaclass.rb +424 -0
  136. data/{lib/metasm → metasm}/exe_format/macho.rb +204 -16
  137. data/{lib/metasm → metasm}/exe_format/main.rb +26 -3
  138. data/{lib/metasm → metasm}/exe_format/mz.rb +1 -0
  139. data/{lib/metasm → metasm}/exe_format/nds.rb +7 -4
  140. data/{lib/metasm → metasm}/exe_format/pe.rb +71 -8
  141. data/metasm/exe_format/pyc.rb +167 -0
  142. data/{lib/metasm → metasm}/exe_format/serialstruct.rb +67 -14
  143. data/{lib/metasm → metasm}/exe_format/shellcode.rb +7 -3
  144. data/metasm/exe_format/shellcode_rwx.rb +114 -0
  145. data/metasm/exe_format/swf.rb +205 -0
  146. data/{lib/metasm → metasm}/exe_format/xcoff.rb +7 -7
  147. data/metasm/exe_format/zip.rb +335 -0
  148. data/metasm/gui.rb +13 -0
  149. data/{lib/metasm → metasm}/gui/cstruct.rb +35 -41
  150. data/{lib/metasm → metasm}/gui/dasm_coverage.rb +11 -11
  151. data/{lib/metasm → metasm}/gui/dasm_decomp.rb +7 -20
  152. data/{lib/metasm → metasm}/gui/dasm_funcgraph.rb +0 -0
  153. data/metasm/gui/dasm_graph.rb +1695 -0
  154. data/{lib/metasm → metasm}/gui/dasm_hex.rb +12 -8
  155. data/{lib/metasm → metasm}/gui/dasm_listing.rb +43 -28
  156. data/{lib/metasm → metasm}/gui/dasm_main.rb +310 -53
  157. data/{lib/metasm → metasm}/gui/dasm_opcodes.rb +5 -19
  158. data/{lib/metasm → metasm}/gui/debug.rb +93 -27
  159. data/{lib/metasm → metasm}/gui/gtk.rb +162 -40
  160. data/{lib/metasm → metasm}/gui/qt.rb +12 -2
  161. data/{lib/metasm → metasm}/gui/win32.rb +179 -42
  162. data/{lib/metasm → metasm}/gui/x11.rb +59 -59
  163. data/{lib/metasm → metasm}/main.rb +389 -264
  164. data/{lib/metasm/os/remote.rb → metasm/os/gdbremote.rb} +146 -54
  165. data/{lib/metasm → metasm}/os/gnu_exports.rb +1 -1
  166. data/{lib/metasm → metasm}/os/linux.rb +628 -151
  167. data/metasm/os/main.rb +330 -0
  168. data/{lib/metasm → metasm}/os/windows.rb +132 -42
  169. data/{lib/metasm → metasm}/os/windows_exports.rb +141 -0
  170. data/{lib/metasm → metasm}/parse.rb +26 -24
  171. data/{lib/metasm → metasm}/parse_c.rb +221 -116
  172. data/{lib/metasm → metasm}/preprocessor.rb +55 -40
  173. data/{lib/metasm → metasm}/render.rb +14 -38
  174. data/misc/hexdump.rb +2 -1
  175. data/misc/lint.rb +58 -0
  176. data/misc/txt2html.rb +9 -7
  177. data/samples/bindiff.rb +3 -4
  178. data/samples/dasm-plugins/bindiff.rb +15 -0
  179. data/samples/dasm-plugins/bookmark.rb +133 -0
  180. data/samples/dasm-plugins/c_constants.rb +57 -0
  181. data/samples/dasm-plugins/colortheme_solarized.rb +125 -0
  182. data/samples/dasm-plugins/cppobj_funcall.rb +60 -0
  183. data/samples/dasm-plugins/dasm_all.rb +70 -0
  184. data/samples/dasm-plugins/demangle_cpp.rb +31 -0
  185. data/samples/dasm-plugins/deobfuscate.rb +251 -0
  186. data/samples/dasm-plugins/dump_text.rb +35 -0
  187. data/samples/dasm-plugins/export_graph_svg.rb +86 -0
  188. data/samples/dasm-plugins/findgadget.rb +75 -0
  189. data/samples/dasm-plugins/hl_opcode.rb +32 -0
  190. data/samples/dasm-plugins/hotfix_gtk_dbg.rb +19 -0
  191. data/samples/dasm-plugins/imm2off.rb +34 -0
  192. data/samples/dasm-plugins/match_libsigs.rb +93 -0
  193. data/samples/dasm-plugins/patch_file.rb +95 -0
  194. data/samples/dasm-plugins/scanfuncstart.rb +36 -0
  195. data/samples/dasm-plugins/scanxrefs.rb +26 -0
  196. data/samples/dasm-plugins/selfmodify.rb +197 -0
  197. data/samples/dasm-plugins/stringsxrefs.rb +28 -0
  198. data/samples/dasmnavig.rb +1 -1
  199. data/samples/dbg-apihook.rb +24 -9
  200. data/samples/dbg-plugins/heapscan.rb +283 -0
  201. data/samples/dbg-plugins/heapscan/compiled_heapscan_lin.c +155 -0
  202. data/samples/dbg-plugins/heapscan/compiled_heapscan_win.c +128 -0
  203. data/samples/dbg-plugins/heapscan/graphheap.rb +616 -0
  204. data/samples/dbg-plugins/heapscan/heapscan.rb +709 -0
  205. data/samples/dbg-plugins/heapscan/winheap.h +174 -0
  206. data/samples/dbg-plugins/heapscan/winheap7.h +307 -0
  207. data/samples/dbg-plugins/trace_func.rb +214 -0
  208. data/samples/disassemble-gui.rb +35 -5
  209. data/samples/disassemble.rb +31 -6
  210. data/samples/dump_upx.rb +24 -12
  211. data/samples/dynamic_ruby.rb +12 -3
  212. data/samples/exeencode.rb +6 -5
  213. data/samples/factorize-headers-peimports.rb +1 -1
  214. data/samples/lindebug.rb +175 -381
  215. data/samples/metasm-shell.rb +1 -2
  216. data/samples/peldr.rb +2 -2
  217. data/tests/all.rb +1 -1
  218. data/tests/arc.rb +26 -0
  219. data/tests/dynldr.rb +22 -4
  220. data/tests/expression.rb +55 -0
  221. data/tests/graph_layout.rb +285 -0
  222. data/tests/ia32.rb +79 -26
  223. data/tests/mips.rb +9 -2
  224. data/tests/x86_64.rb +66 -18
  225. metadata +330 -218
  226. data/lib/metasm/arm/opcodes.rb +0 -177
  227. data/lib/metasm/gui.rb +0 -23
  228. data/lib/metasm/gui/dasm_graph.rb +0 -1354
  229. data/lib/metasm/ia32.rb +0 -14
  230. data/lib/metasm/ia32/opcodes.rb +0 -873
  231. data/lib/metasm/ppc/parse.rb +0 -52
  232. data/lib/metasm/x86_64.rb +0 -12
  233. data/lib/metasm/x86_64/opcodes.rb +0 -118
  234. data/samples/gdbclient.rb +0 -583
  235. data/samples/rubstop.rb +0 -399
@@ -16,44 +16,63 @@ class TestIa32 < Test::Unit::TestCase
16
16
 
17
17
  def assert_equal(a, b) super(b, a) end
18
18
 
19
+ def bin(s)
20
+ if s.respond_to?(:force_encoding)
21
+ s.force_encoding('BINARY')
22
+ else
23
+ s
24
+ end
25
+ end
26
+
19
27
  def test_basic
20
- assert_equal(assemble("nop"), "\x90")
21
- assert_equal(assemble("push eax"), "\x50")
22
- assert_equal(assemble("push 2"), "\x6a\x02")
23
- assert_equal(assemble("push 142"), "\x68\x8e\0\0\0")
28
+ assert_equal(assemble("nop"), bin("\x90"))
29
+ assert_equal(assemble("push eax"), bin("\x50"))
30
+ assert_equal(assemble("push 2"), bin("\x6a\x02"))
31
+ assert_equal(assemble("push 142"), bin("\x68\x8e\0\0\0"))
24
32
  end
25
33
 
26
34
  def test_sz
27
- assert_equal(assemble("dec eax"), "\x48")
28
- assert_equal(assemble("dec ax"), "\x66\x48")
29
- assert_equal(assemble("dec al"), "\xfe\xc8")
35
+ assert_equal(assemble("dec eax"), bin("\x48"))
36
+ assert_equal(assemble("dec ax"), bin("\x66\x48"))
37
+ assert_equal(assemble("dec al"), bin("\xfe\xc8"))
30
38
  assert_equal(assemble("arpl [edi+70h], bp"), "cop")
31
39
  end
32
40
 
33
41
  def test_16
34
- assert_equal(assemble("push 142", @@cpu16), "\x68\x8e\0")
35
- assert_equal(assemble("code16 push 142", @@cpu16), "\x68\x8e\0")
36
- assert_equal(assemble("code16 push 142"), "\x68\x8e\0")
37
- assert_equal(assemble("push.i16 142"), "\x66\x68\x8e\0")
38
- assert_equal(assemble("mov eax, 42"), "\xb8\x2a\0\0\0")
39
- assert_equal(assemble("code16 mov ax, 42"), "\xb8\x2a\0")
42
+ assert_equal(assemble("push 142", @@cpu16), bin("\x68\x8e\0"))
43
+ assert_equal(assemble("code16 push 142", @@cpu16), bin("\x68\x8e\0"))
44
+ assert_equal(assemble("code16 push 142"), bin("\x68\x8e\0"))
45
+ assert_equal(assemble("push.i16 142"), bin("\x66\x68\x8e\0"))
46
+ assert_equal(assemble("mov eax, 42"), bin("\xb8\x2a\0\0\0"))
47
+ assert_equal(assemble("code16 mov ax, 42"), bin("\xb8\x2a\0"))
40
48
  end
41
49
 
42
50
  def test_jmp
43
- assert_equal(assemble("jmp $"), "\xeb\xfe")
44
- assert_equal(assemble("jmp.i32 $"), "\xe9\xfb\xff\xff\xff")
51
+ assert_equal(assemble("jmp $"), bin("\xeb\xfe"))
52
+ assert_equal(assemble("jmp.i32 $"), bin("\xe9\xfb\xff\xff\xff"))
53
+ end
54
+
55
+ def test_opsz
56
+ assert_equal(assemble("cbw"), bin("\x66\x98"))
57
+ assert_equal(assemble("cwde"), bin("\x98"))
58
+
59
+ assert_equal(assemble("cbw", @@cpu16), bin("\x98"))
60
+ assert_equal(assemble("cwde", @@cpu16), bin("\x66\x98"))
61
+
62
+ assert_equal(assemble("cmpxchg8b [eax]"), bin("\x0f\xc7\x08"))
63
+ assert_equal(assemble("cmpxchg8b [bx]", @@cpu16), bin("\x66\x0f\xc7\x0f"))
45
64
  end
46
65
 
47
66
  def test_mrmsz
48
- assert_equal(assemble("mov [eax], ebx"), "\x89\x18")
49
- assert_equal(assemble("mov [eax], bl"), "\x88\x18")
50
- assert_equal(assemble("mov ebx, [eax]"), "\x8b\x18")
51
- assert_equal(assemble("mov bl, [eax]"), "\x8a\x18")
52
- assert_equal(assemble("mov bl, [bx]"), "\x67\x8a\x1f")
53
- assert_equal(assemble("mov bl, [bx]", @@cpu16), "\x8a\x1f")
54
- assert_equal(assemble("code16 mov bl, [bx]"), "\x8a\x1f")
55
- assert_equal(assemble("mov bl, [0]"), "\x8a\x1d\0\0\0\0")
56
- assert_equal(assemble("mov.a16 bl, [0]"), "\x67\x8a\x1e\0\0")
67
+ assert_equal(assemble("mov [eax], ebx"), bin("\x89\x18"))
68
+ assert_equal(assemble("mov [eax], bl"), bin("\x88\x18"))
69
+ assert_equal(assemble("mov ebx, [eax]"), bin("\x8b\x18"))
70
+ assert_equal(assemble("mov bl, [eax]"), bin("\x8a\x18"))
71
+ assert_equal(assemble("mov bl, [bx]"), bin("\x67\x8a\x1f"))
72
+ assert_equal(assemble("mov bl, [bx]", @@cpu16), bin("\x8a\x1f"))
73
+ assert_equal(assemble("code16 mov bl, [bx]"), bin("\x8a\x1f"))
74
+ assert_equal(assemble("mov bl, [0]"), bin("\x8a\x1d\0\0\0\0"))
75
+ assert_equal(assemble("mov.a16 bl, [0]"), bin("\x67\x8a\x1e\0\0"))
57
76
  end
58
77
 
59
78
  def test_err
@@ -64,7 +83,7 @@ class TestIa32 < Test::Unit::TestCase
64
83
  end
65
84
 
66
85
  def test_C
67
- src = "int bla(void) { volatile int i=0; return ++i; }"
86
+ src = "int bla(void) { volatile int i=0; return (int)++i; }"
68
87
  assert_equal(Metasm::Shellcode.compile_c(@@cpu32, src).encode_string,
69
88
  ["5589E583EC04C745FC00000000FF45FC8B45FC89EC5DC3"].pack('H*'))
70
89
  end
@@ -74,9 +93,43 @@ class TestIa32 < Test::Unit::TestCase
74
93
  end
75
94
 
76
95
  def test_dasm
77
- d = disassemble("\x90")
96
+ d = disassemble(bin("\x90"))
78
97
  assert_equal(d.decoded[0].class, Metasm::DecodedInstruction)
79
98
  assert_equal(d.decoded[0].opcode.name, "nop")
99
+
100
+ assert_equal(disassemble(bin("\x66\x0f\xc7\x08")).decoded[0], nil)
101
+ assert_equal(disassemble(bin("\x0f\xc7\x08")).decoded[0].opcode.name, "cmpxchg8b")
80
102
  end
81
103
 
104
+ def test_pfx
105
+ assert_equal(assemble("nop"), bin("\x90"))
106
+ assert_equal(assemble("pause"), bin("\xf3\x90"))
107
+ assert_equal(disassemble(bin("\x90")).decoded.values.first.opcode.name, "nop")
108
+ assert_equal(disassemble(bin("\xf3\x90")).decoded.values.first.opcode.name, "pause")
109
+ end
110
+
111
+ def test_avx
112
+ assert_equal(disassemble(bin("\xc4\xc3\x75\x42\xc2\x03")).decoded[0].instruction.to_s, "vmpsadbw ymm0, ymm1, ymm2, 3")
113
+ assert_equal(assemble("vmpsadbw ymm0, ymm1, ymm2, 3"), bin("\xc4\xc3\x75\x42\xc2\x03"))
114
+ assert_equal(assemble("vpblendvb xmm1, xmm2, xmm3, xmm4"), bin("\xc4\xc3\x69\x4c\xcb\x40"))
115
+ assert_equal(assemble("vgatherdpd xmm1, qword ptr [edx+xmm1], xmm2"), bin("\xc4\xc2\xe9\x92\x0c\x0a"))
116
+ assert_equal(disassemble(bin("\xc4\xc2\xe9\x92\x0c\x0a")).decoded[0].instruction.to_s, "vgatherdpd xmm1, qword ptr [edx+xmm1], xmm2")
117
+ end
118
+
119
+ def backtrace(asm, expr, cpu=@@cpu32)
120
+ raw = assemble(asm + "\n nop", cpu)
121
+ disassemble(raw, cpu).backtrace(expr, raw.length-1).first
122
+ end
123
+
124
+ def test_backtrace
125
+ assert_equal(backtrace("mov eax, 10", :eax), Metasm::Expression[10])
126
+ assert_equal(backtrace("mov eax, 0x1234\n ror eax, 8", :eax), Metasm::Expression[0x34000012])
127
+ assert_equal(backtrace("mov eax, 0x1234\n ror al, 4", :eax), Metasm::Expression[0x1243])
128
+ assert_equal(backtrace("mov eax, 0x1234\n shr al, 4", :eax), Metasm::Expression[0x1203])
129
+ assert_equal(backtrace("mov eax, 0x1234\n shl ah, 4", :eax), Metasm::Expression[0x2034])
130
+ assert_equal(backtrace("mov eax, 0xf000_0000\n add eax, 0x2000_0000\n shr eax, 28", :eax), Metasm::Expression[1])
131
+ assert_equal(backtrace("mov eax, 0xf000_0000\n add eax, 0x2000_0000\n ror eax, 28", :eax), Metasm::Expression[1])
132
+ assert_equal(backtrace("mov eax, 1\n mov ebx, 2\n xchg al, bl", :eax), Metasm::Expression[2])
133
+ assert_equal(backtrace("mov eax, 0x01020304\n xchg al, ah", :eax), Metasm::Expression[0x01020403])
134
+ end
82
135
  end
@@ -105,12 +105,19 @@ EOS
105
105
  # '' << "\x80" => 8bits
106
106
  # '' << 0x80 => ascii
107
107
  # Edata.data is ascii for now, so this is needed to make the test work.
108
- str = ''
109
- "\x24\x0e\xff\xfb\x01\xc0\x70\x27\x24\x0b\xff\xb7\x05\x10\xff\xff\x28\x08\x82\x82\x01\x60\x58\x27\x03\xeb\xc8\x21\x28\x17\x82\x82\x8f\x31\xff\xfc\x24\x0d\xff\xfb\x01\xa0\x68\x27\x21\xaf\xff\xfd\x8f\x28\xff\xfc\x02\xef\xb8\x21\x01\x11\x18\x26\x02\xee\xf0\x2b\xaf\x23\xff\xfc\x21\xa6\xff\xff\x17\xc0\xff\xf9\x03\x2d\xc8\x21\x24\x02\x10\x33\x01\x4a\x54\x0c\0\0\0\0".each_byte { |b| str << b }
108
+ str = bin("\x24\x0e\xff\xfb\x01\xc0\x70\x27\x24\x0b\xff\xb7\x05\x10\xff\xff\x28\x08\x82\x82\x01\x60\x58\x27\x03\xeb\xc8\x21\x28\x17\x82\x82\x8f\x31\xff\xfc\x24\x0d\xff\xfb\x01\xa0\x68\x27\x21\xaf\xff\xfd\x8f\x28\xff\xfc\x02\xef\xb8\x21\x01\x11\x18\x26\x02\xee\xf0\x2b\xaf\x23\xff\xfc\x21\xa6\xff\xff\x17\xc0\xff\xf9\x03\x2d\xc8\x21\x24\x02\x10\x33\x01\x4a\x54\x0c\0\0\0\0")
110
109
  assert_equal(str, sc.encoded.data)
111
110
 
112
111
  dasm_src = Metasm::Shellcode.disassemble(Metasm::MIPS.new(:big), sc.encoded.data).to_s
113
112
  lines = dasm_src.respond_to?(:lines) ? dasm_src.lines : dasm_src.to_a
114
113
  assert_equal(28, lines.grep(/\S/).length)
115
114
  end
115
+
116
+ def bin(s)
117
+ if s.respond_to?(:force_encoding)
118
+ s.force_encoding('BINARY')
119
+ else
120
+ s
121
+ end
122
+ end
116
123
  end
@@ -17,15 +17,24 @@ class TestX86_64 < Test::Unit::TestCase
17
17
  assert_equal(Metasm::X86_64, Metasm::Ia32.new(64).class)
18
18
  end
19
19
 
20
+ def bin(s)
21
+ if s.respond_to?(:force_encoding)
22
+ s.force_encoding('BINARY')
23
+ else
24
+ s
25
+ end
26
+ end
27
+
20
28
  def test_basic
21
- assert_equal("\x90", assemble("nop"))
22
- assert_equal("\x50", assemble("push rax"))
23
- assert_equal("\x41\x50", assemble("push r8"))
24
- assert_equal("\x6a\x02", assemble("push 2"))
25
- assert_equal("\x68\x8e\0\0\0", assemble("push 142"))
26
- assert_equal("\x48\xbb\xef\xcd\xab\x89\x67\x45\x23\x01", assemble("mov rbx, 0123456789abcdefh"))
27
- assert_equal("\x8d\x05\x0c\0\0\0", assemble("lea eax, [rip+12]"))
28
- assert_equal("\x8d\x04\x25\x0c\0\0\0", assemble("lea eax, [12]"))
29
+ assert_equal(bin("\x90"), assemble("nop"))
30
+ assert_equal(bin("\x50"), assemble("push rax"))
31
+ assert_equal(bin("\x41\x50"), assemble("push r8"))
32
+ assert_equal(bin("\x6a\x02"), assemble("push 2"))
33
+ assert_equal(bin("\x68\x8e\0\0\0"), assemble("push 142"))
34
+ assert_equal(bin("\x48\xbb\xef\xcd\xab\x89\x67\x45\x23\x01"), assemble("mov rbx, 0123456789abcdefh"))
35
+ assert_equal(bin("\x8d\x05\x0c\0\0\0"), assemble("lea eax, [rip+12]"))
36
+ assert_equal(bin("\x8d\x04\x25\x0c\0\0\0"), assemble("lea eax, [12]"))
37
+ assert_equal(bin("\x48\x81\xE3\xFF\xF0\xFF\xFF"), assemble("and rbx, 0xffffffff_fffff0ff"))
29
38
  end
30
39
 
31
40
  def test_err
@@ -35,6 +44,8 @@ class TestX86_64 < Test::Unit::TestCase
35
44
  assert_raise(Metasm::ParseError) { assemble("add [bx]") }
36
45
  assert_raise(Metasm::ParseError) { assemble("add [eip+4*eax]") }
37
46
  assert_raise(Metasm::ParseError) { assemble("add ah, r8b") }
47
+ assert_raise(Metasm::EncodeError) { assemble("and rbx, 0x1_ffffffff_ffffffff") }
48
+ assert_raise(Metasm::EncodeError) { assemble("mov rbx, 011123456789abcdefh") }
38
49
  end
39
50
 
40
51
  def disassemble(bin, cpu=@@cpu)
@@ -42,21 +53,58 @@ class TestX86_64 < Test::Unit::TestCase
42
53
  end
43
54
 
44
55
  def test_dasm
45
- d = disassemble("\x90")
56
+ d = disassemble(bin("\x90"))
46
57
  assert_equal(Metasm::DecodedInstruction, d.decoded[0].class)
47
58
  assert_equal('nop', d.decoded[0].opcode.name)
48
59
  end
49
60
 
50
61
  def test_rex
51
- assert_equal("\xfe\xc0", assemble("inc al"))
52
- assert_equal("\xfe\xc4", assemble("inc ah"))
53
- assert_equal("\x40\xfe\xc4", assemble("inc spl"))
54
- assert_equal("\x41\xfe\xc4", assemble("inc r12b"))
62
+ assert_equal(bin("\xfe\xc0"), assemble("inc al"))
63
+ assert_equal(bin("\xfe\xc4"), assemble("inc ah"))
64
+ assert_equal(bin("\x40\xfe\xc4"), assemble("inc spl"))
65
+ assert_equal(bin("\x41\xfe\xc4"), assemble("inc r12b"))
55
66
  op = lambda { |s| i = disassemble(s).decoded[0].instruction ; i.to_s ; i.args.last.to_s }
56
- assert_equal('al', op["\xfe\xc0"])
57
- assert_equal('ah', op["\xfe\xc4"])
58
- assert_equal('spl', op["\x40\xfe\xc4"])
59
- assert_equal('r12b', op["\x41\xfe\xc4"])
60
- assert_equal('[rip-6+12h]', op["\x8d\x05\x0c\0\0\0"])
67
+ assert_equal('al', op[bin("\xfe\xc0")])
68
+ assert_equal('ah', op[bin("\xfe\xc4")])
69
+ assert_equal('spl', op[bin("\x40\xfe\xc4")])
70
+ assert_equal('r12b', op[bin("\x41\xfe\xc4")])
71
+ assert_equal('[rip-6+12h]', op[bin("\x8d\x05\x0c\0\0\0")])
61
72
  end
73
+
74
+ def test_opsz
75
+ assert_equal(bin("\x66\x98"), assemble("cbw"))
76
+ assert_equal(bin("\x98"), assemble("cwde"))
77
+ assert_equal(bin("\x48\x98"), assemble("cdqe"))
78
+
79
+ assert_equal(bin("\x0f\xc7\x08"), assemble("cmpxchg8b [rax]"))
80
+ assert_equal(bin("\x48\x0f\xc7\x08"), assemble("cmpxchg16b [rax]"))
81
+
82
+ assert_equal(nil, disassemble(bin("\x66\x0f\xc7\x08")).decoded[0])
83
+ assert_equal('cmpxchg8b', disassemble(bin("\x47\x0f\xc7\x08")).decoded[0].opcode.name)
84
+ assert_equal('cmpxchg16b', disassemble(bin("\x48\x0f\xc7\x08")).decoded[0].opcode.name)
85
+ end
86
+
87
+ def test_avx
88
+ assert_equal('vmpsadbw ymm12, ymm14, ymm2, 3', disassemble(bin("\xc4\x63\x0d\x42\xe2\x03")).decoded[0].instruction.to_s)
89
+ assert_equal(bin("\xc4\x63\x0d\x42\xe2\x03"), assemble('vmpsadbw ymm12, ymm14, ymm2, 3'))
90
+ assert_equal(bin("\xc5\x31\x63\xc2"), assemble('vpacksswb xmm8, xmm9, xmm2'))
91
+ assert_equal(bin("\xc4\x41\x31\x63\xc2"), assemble('vpacksswb xmm8, xmm9, xmm10'))
92
+ assert_equal(bin("\xc5\x31\x63\x04\x5a"), assemble('vpacksswb xmm8, xmm9, [rdx+2*rbx]'))
93
+ assert_equal(bin("\xc4\x01\x31\x63\x04\x5a"), assemble('vpacksswb xmm8, xmm9, [r10+2*r11]'))
94
+ assert_equal(bin("\xc4\x22\x99\x92\x14\x1a"), assemble('vgatherdpd xmm10, qword ptr [rdx+xmm11], xmm12'))
95
+ assert_equal('vgatherdpd xmm10, qword ptr [rdx+xmm11], xmm12', disassemble(bin("\xc4\x22\x99\x92\x14\x1a")).decoded[0].instruction.to_s)
96
+ end
97
+
98
+ def test_lol
99
+ # x64 nop weirdnesses
100
+ assert_equal(bin("\x87\xc0"), assemble('xchg eax, eax'))
101
+ assert_equal('xchg r8, rax', disassemble(bin("\x49\x90")).decoded[0].instruction.to_s)
102
+ end
103
+
104
+ def test_C_size
105
+ assert_nothing_raised {
106
+ Metasm::Shellcode.compile_c(@@cpu, "void main(void) { int i=5670, j=8907 ; i = i*j; }").encode_string
107
+ }
108
+ end
109
+
62
110
  end
metadata CHANGED
@@ -1,255 +1,367 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: metasm
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 1
10
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Yoann Guillot
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-04-30 00:00:00 Z
19
- dependencies: []
20
-
21
- description: Metasm is a cross-architecture assembler, disassembler, compiler, linker and debugger in pure Ruby with no dependencies.
22
- email: yoann@ofjj.net
11
+ date: 2014-12-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: ''
42
+ email:
43
+ - john at ofjj.net
23
44
  executables: []
24
-
25
45
  extensions: []
26
-
27
46
  extra_rdoc_files: []
28
-
29
- files:
47
+ files:
48
+ - ".gitignore"
49
+ - ".hgtags"
30
50
  - BUGS
31
51
  - CREDITS
52
+ - Gemfile
53
+ - INSTALL
54
+ - LICENCE
32
55
  - README
56
+ - Rakefile
33
57
  - TODO
34
- - tests/parse_c.rb
35
- - tests/dynldr.rb
36
- - tests/encodeddata.rb
37
- - tests/mips.rb
38
- - tests/x86_64.rb
39
- - tests/all.rb
40
- - tests/preprocessor.rb
41
- - tests/ia32.rb
42
- - tests/dasm.rb
43
- - misc/objdiff.rb
44
- - misc/pdfparse.rb
45
- - misc/ppc_pdf2oplist.rb
46
- - misc/objscan.rb
47
- - misc/tcp_proxy_hex.rb
48
- - misc/hexdump.rb
58
+ - doc/code_organisation.txt
59
+ - doc/const_missing.txt
60
+ - doc/core/DynLdr.txt
61
+ - doc/core/ExeFormat.txt
62
+ - doc/core/Expression.txt
63
+ - doc/core/GNUExports.txt
64
+ - doc/core/Ia32.txt
65
+ - doc/core/SerialStruct.txt
66
+ - doc/core/VirtualString.txt
67
+ - doc/core/WindowsExports.txt
68
+ - doc/core/index.txt
69
+ - doc/core_classes.txt
70
+ - doc/feature_list.txt
71
+ - doc/index.txt
72
+ - doc/install_notes.txt
73
+ - doc/style.css
74
+ - doc/usage/debugger.txt
75
+ - doc/usage/index.txt
76
+ - doc/use_cases.txt
77
+ - metasm.gemspec
78
+ - metasm.rb
79
+ - metasm/compile_c.rb
80
+ - metasm/cpu/arc.rb
81
+ - metasm/cpu/arc/decode.rb
82
+ - metasm/cpu/arc/main.rb
83
+ - metasm/cpu/arc/opcodes.rb
84
+ - metasm/cpu/arm.rb
85
+ - metasm/cpu/arm/debug.rb
86
+ - metasm/cpu/arm/decode.rb
87
+ - metasm/cpu/arm/encode.rb
88
+ - metasm/cpu/arm/main.rb
89
+ - metasm/cpu/arm/opcodes.rb
90
+ - metasm/cpu/arm/parse.rb
91
+ - metasm/cpu/arm/render.rb
92
+ - metasm/cpu/arm64.rb
93
+ - metasm/cpu/arm64/debug.rb
94
+ - metasm/cpu/arm64/decode.rb
95
+ - metasm/cpu/arm64/encode.rb
96
+ - metasm/cpu/arm64/main.rb
97
+ - metasm/cpu/arm64/opcodes.rb
98
+ - metasm/cpu/arm64/parse.rb
99
+ - metasm/cpu/arm64/render.rb
100
+ - metasm/cpu/bpf.rb
101
+ - metasm/cpu/bpf/decode.rb
102
+ - metasm/cpu/bpf/main.rb
103
+ - metasm/cpu/bpf/opcodes.rb
104
+ - metasm/cpu/bpf/render.rb
105
+ - metasm/cpu/cy16.rb
106
+ - metasm/cpu/cy16/decode.rb
107
+ - metasm/cpu/cy16/main.rb
108
+ - metasm/cpu/cy16/opcodes.rb
109
+ - metasm/cpu/cy16/render.rb
110
+ - metasm/cpu/dalvik.rb
111
+ - metasm/cpu/dalvik/decode.rb
112
+ - metasm/cpu/dalvik/main.rb
113
+ - metasm/cpu/dalvik/opcodes.rb
114
+ - metasm/cpu/ia32.rb
115
+ - metasm/cpu/ia32/compile_c.rb
116
+ - metasm/cpu/ia32/debug.rb
117
+ - metasm/cpu/ia32/decode.rb
118
+ - metasm/cpu/ia32/decompile.rb
119
+ - metasm/cpu/ia32/encode.rb
120
+ - metasm/cpu/ia32/main.rb
121
+ - metasm/cpu/ia32/opcodes.rb
122
+ - metasm/cpu/ia32/parse.rb
123
+ - metasm/cpu/ia32/render.rb
124
+ - metasm/cpu/mips.rb
125
+ - metasm/cpu/mips/compile_c.rb
126
+ - metasm/cpu/mips/debug.rb
127
+ - metasm/cpu/mips/decode.rb
128
+ - metasm/cpu/mips/encode.rb
129
+ - metasm/cpu/mips/main.rb
130
+ - metasm/cpu/mips/opcodes.rb
131
+ - metasm/cpu/mips/parse.rb
132
+ - metasm/cpu/mips/render.rb
133
+ - metasm/cpu/msp430.rb
134
+ - metasm/cpu/msp430/decode.rb
135
+ - metasm/cpu/msp430/main.rb
136
+ - metasm/cpu/msp430/opcodes.rb
137
+ - metasm/cpu/pic16c/decode.rb
138
+ - metasm/cpu/pic16c/main.rb
139
+ - metasm/cpu/pic16c/opcodes.rb
140
+ - metasm/cpu/ppc.rb
141
+ - metasm/cpu/ppc/decode.rb
142
+ - metasm/cpu/ppc/decompile.rb
143
+ - metasm/cpu/ppc/encode.rb
144
+ - metasm/cpu/ppc/main.rb
145
+ - metasm/cpu/ppc/opcodes.rb
146
+ - metasm/cpu/ppc/parse.rb
147
+ - metasm/cpu/python.rb
148
+ - metasm/cpu/python/decode.rb
149
+ - metasm/cpu/python/main.rb
150
+ - metasm/cpu/python/opcodes.rb
151
+ - metasm/cpu/sh4.rb
152
+ - metasm/cpu/sh4/decode.rb
153
+ - metasm/cpu/sh4/main.rb
154
+ - metasm/cpu/sh4/opcodes.rb
155
+ - metasm/cpu/x86_64.rb
156
+ - metasm/cpu/x86_64/compile_c.rb
157
+ - metasm/cpu/x86_64/debug.rb
158
+ - metasm/cpu/x86_64/decode.rb
159
+ - metasm/cpu/x86_64/encode.rb
160
+ - metasm/cpu/x86_64/main.rb
161
+ - metasm/cpu/x86_64/opcodes.rb
162
+ - metasm/cpu/x86_64/parse.rb
163
+ - metasm/cpu/x86_64/render.rb
164
+ - metasm/cpu/z80.rb
165
+ - metasm/cpu/z80/decode.rb
166
+ - metasm/cpu/z80/main.rb
167
+ - metasm/cpu/z80/opcodes.rb
168
+ - metasm/cpu/z80/render.rb
169
+ - metasm/debug.rb
170
+ - metasm/decode.rb
171
+ - metasm/decompile.rb
172
+ - metasm/disassemble.rb
173
+ - metasm/disassemble_api.rb
174
+ - metasm/dynldr.rb
175
+ - metasm/encode.rb
176
+ - metasm/exe_format/a_out.rb
177
+ - metasm/exe_format/autoexe.rb
178
+ - metasm/exe_format/bflt.rb
179
+ - metasm/exe_format/coff.rb
180
+ - metasm/exe_format/coff_decode.rb
181
+ - metasm/exe_format/coff_encode.rb
182
+ - metasm/exe_format/dex.rb
183
+ - metasm/exe_format/dol.rb
184
+ - metasm/exe_format/elf.rb
185
+ - metasm/exe_format/elf_decode.rb
186
+ - metasm/exe_format/elf_encode.rb
187
+ - metasm/exe_format/gb.rb
188
+ - metasm/exe_format/javaclass.rb
189
+ - metasm/exe_format/macho.rb
190
+ - metasm/exe_format/main.rb
191
+ - metasm/exe_format/mz.rb
192
+ - metasm/exe_format/nds.rb
193
+ - metasm/exe_format/pe.rb
194
+ - metasm/exe_format/pyc.rb
195
+ - metasm/exe_format/serialstruct.rb
196
+ - metasm/exe_format/shellcode.rb
197
+ - metasm/exe_format/shellcode_rwx.rb
198
+ - metasm/exe_format/swf.rb
199
+ - metasm/exe_format/xcoff.rb
200
+ - metasm/exe_format/zip.rb
201
+ - metasm/gui.rb
202
+ - metasm/gui/cstruct.rb
203
+ - metasm/gui/dasm_coverage.rb
204
+ - metasm/gui/dasm_decomp.rb
205
+ - metasm/gui/dasm_funcgraph.rb
206
+ - metasm/gui/dasm_graph.rb
207
+ - metasm/gui/dasm_hex.rb
208
+ - metasm/gui/dasm_listing.rb
209
+ - metasm/gui/dasm_main.rb
210
+ - metasm/gui/dasm_opcodes.rb
211
+ - metasm/gui/debug.rb
212
+ - metasm/gui/gtk.rb
213
+ - metasm/gui/qt.rb
214
+ - metasm/gui/win32.rb
215
+ - metasm/gui/x11.rb
216
+ - metasm/main.rb
217
+ - metasm/os/gdbremote.rb
218
+ - metasm/os/gnu_exports.rb
219
+ - metasm/os/linux.rb
220
+ - metasm/os/main.rb
221
+ - metasm/os/windows.rb
222
+ - metasm/os/windows_exports.rb
223
+ - metasm/parse.rb
224
+ - metasm/parse_c.rb
225
+ - metasm/preprocessor.rb
226
+ - metasm/render.rb
49
227
  - misc/bottleneck.rb
50
228
  - misc/cheader-findpppath.rb
51
229
  - misc/hexdiff.rb
230
+ - misc/hexdump.rb
231
+ - misc/lint.rb
52
232
  - misc/metasm-all.rb
233
+ - misc/objdiff.rb
234
+ - misc/objscan.rb
235
+ - misc/pdfparse.rb
236
+ - misc/ppc_pdf2oplist.rb
237
+ - misc/tcp_proxy_hex.rb
53
238
  - misc/txt2html.rb
54
- - doc/const_missing.txt
55
- - doc/index.txt
56
- - doc/code_organisation.txt
57
- - doc/feature_list.txt
58
- - doc/style.css
59
- - doc/use_cases.txt
60
- - doc/core_classes.txt
61
- - doc/install_notes.txt
62
- - samples/source.asm
63
- - samples/win32livedasm.rb
64
- - samples/machoencode.rb
65
- - samples/hotfix_gtk_dbg.rb
66
- - samples/dbg-apihook.rb
67
- - samples/rubstop.rb
68
- - samples/scan_pt_gnu_stack.rb
69
- - samples/pe_listexports.rb
70
- - samples/compilation-steps.rb
71
- - samples/testraw.rb
72
- - samples/bindiff.rb
73
- - samples/factorize-headers.rb
74
- - samples/pe-ia32-cpuid.rb
75
239
  - samples/a.out.rb
76
- - samples/shellcode-dynlink.rb
77
- - samples/pe-testrelocs.rb
78
- - samples/exeencode.rb
79
- - samples/lindebug.rb
80
- - samples/elfencode.rb
81
- - samples/dynamic_ruby.rb
82
- - samples/dump_upx.rb
240
+ - samples/asmsyntax.rb
241
+ - samples/bindiff.rb
242
+ - samples/compilation-steps.rb
83
243
  - samples/cparser_makestackoffset.rb
84
- - samples/disassemble.rb
85
- - samples/win32genloader.rb
86
- - samples/pe-mips.rb
244
+ - samples/dasm-backtrack.rb
245
+ - samples/dasm-plugins/bindiff.rb
246
+ - samples/dasm-plugins/bookmark.rb
247
+ - samples/dasm-plugins/c_constants.rb
248
+ - samples/dasm-plugins/colortheme_solarized.rb
249
+ - samples/dasm-plugins/cppobj_funcall.rb
250
+ - samples/dasm-plugins/dasm_all.rb
251
+ - samples/dasm-plugins/demangle_cpp.rb
252
+ - samples/dasm-plugins/deobfuscate.rb
253
+ - samples/dasm-plugins/dump_text.rb
254
+ - samples/dasm-plugins/export_graph_svg.rb
255
+ - samples/dasm-plugins/findgadget.rb
256
+ - samples/dasm-plugins/hl_opcode.rb
257
+ - samples/dasm-plugins/hotfix_gtk_dbg.rb
258
+ - samples/dasm-plugins/imm2off.rb
259
+ - samples/dasm-plugins/match_libsigs.rb
260
+ - samples/dasm-plugins/patch_file.rb
261
+ - samples/dasm-plugins/scanfuncstart.rb
262
+ - samples/dasm-plugins/scanxrefs.rb
263
+ - samples/dasm-plugins/selfmodify.rb
264
+ - samples/dasm-plugins/stringsxrefs.rb
265
+ - samples/dasmnavig.rb
266
+ - samples/dbg-apihook.rb
267
+ - samples/dbg-plugins/heapscan.rb
268
+ - samples/dbg-plugins/heapscan/compiled_heapscan_lin.c
269
+ - samples/dbg-plugins/heapscan/compiled_heapscan_win.c
270
+ - samples/dbg-plugins/heapscan/graphheap.rb
271
+ - samples/dbg-plugins/heapscan/heapscan.rb
272
+ - samples/dbg-plugins/heapscan/winheap.h
273
+ - samples/dbg-plugins/heapscan/winheap7.h
274
+ - samples/dbg-plugins/trace_func.rb
275
+ - samples/dbghelp.rb
87
276
  - samples/disassemble-gui.rb
88
- - samples/linux_injectsyscall.rb
89
- - samples/peldr.rb
90
- - samples/r0trace.rb
277
+ - samples/disassemble.rb
278
+ - samples/dump_upx.rb
279
+ - samples/dynamic_ruby.rb
91
280
  - samples/elf_list_needed.rb
92
- - samples/dasmnavig.rb
93
- - samples/win32hooker.rb
94
- - samples/peencode.rb
95
- - samples/win32hooker-advanced.rb
281
+ - samples/elf_listexports.rb
282
+ - samples/elfencode.rb
283
+ - samples/exeencode.rb
96
284
  - samples/factorize-headers-elfimports.rb
97
- - samples/win32remotescan.rb
98
- - samples/struct_offset.rb
99
- - samples/wintrace.rb
100
- - samples/pe-hook.rb
101
- - samples/metasm-shell.rb
102
- - samples/pe-shutdown.rb
103
- - samples/dasm-backtrack.rb
104
- - samples/testpe.rb
285
+ - samples/factorize-headers-peimports.rb
286
+ - samples/factorize-headers.rb
105
287
  - samples/generate_libsigs.rb
288
+ - samples/hotfix_gtk_dbg.rb
106
289
  - samples/install_win_env.rb
290
+ - samples/lindebug.rb
291
+ - samples/linux_injectsyscall.rb
292
+ - samples/machoencode.rb
293
+ - samples/metasm-shell.rb
294
+ - samples/pe-hook.rb
295
+ - samples/pe-ia32-cpuid.rb
296
+ - samples/pe-mips.rb
297
+ - samples/pe-shutdown.rb
298
+ - samples/pe-testrelocs.rb
107
299
  - samples/pe-testrsrc.rb
300
+ - samples/pe_listexports.rb
301
+ - samples/peencode.rb
302
+ - samples/peldr.rb
108
303
  - samples/preprocess-flatten.rb
109
- - samples/gdbclient.rb
110
- - samples/dbghelp.rb
304
+ - samples/r0trace.rb
305
+ - samples/scan_pt_gnu_stack.rb
111
306
  - samples/scanpeexports.rb
112
- - samples/factorize-headers-peimports.rb
113
- - samples/elf_listexports.rb
114
307
  - samples/shellcode-c.rb
115
- - samples/asmsyntax.rb
116
- - lib/metasm.rb
117
- - lib/metasm/x86_64/decode.rb
118
- - lib/metasm/x86_64/main.rb
119
- - lib/metasm/x86_64/debug.rb
120
- - lib/metasm/x86_64/parse.rb
121
- - lib/metasm/x86_64/opcodes.rb
122
- - lib/metasm/x86_64/encode.rb
123
- - lib/metasm/x86_64/compile_c.rb
124
- - lib/metasm/decode.rb
125
- - lib/metasm/pic16c/decode.rb
126
- - lib/metasm/pic16c/main.rb
127
- - lib/metasm/pic16c/opcodes.rb
128
- - lib/metasm/main.rb
129
- - lib/metasm/sh4/decode.rb
130
- - lib/metasm/sh4/main.rb
131
- - lib/metasm/sh4/opcodes.rb
132
- - lib/metasm/parse_c.rb
133
- - lib/metasm/arm.rb
134
- - lib/metasm/os/main.rb
135
- - lib/metasm/os/gnu_exports.rb
136
- - lib/metasm/os/windows_exports.rb
137
- - lib/metasm/os/linux.rb
138
- - lib/metasm/os/remote.rb
139
- - lib/metasm/os/windows.rb
140
- - lib/metasm/exe_format/main.rb
141
- - lib/metasm/exe_format/dol.rb
142
- - lib/metasm/exe_format/elf_encode.rb
143
- - lib/metasm/exe_format/elf_decode.rb
144
- - lib/metasm/exe_format/shellcode.rb
145
- - lib/metasm/exe_format/mz.rb
146
- - lib/metasm/exe_format/coff_encode.rb
147
- - lib/metasm/exe_format/pe.rb
148
- - lib/metasm/exe_format/macho.rb
149
- - lib/metasm/exe_format/dex.rb
150
- - lib/metasm/exe_format/coff.rb
151
- - lib/metasm/exe_format/bflt.rb
152
- - lib/metasm/exe_format/autoexe.rb
153
- - lib/metasm/exe_format/serialstruct.rb
154
- - lib/metasm/exe_format/xcoff.rb
155
- - lib/metasm/exe_format/a_out.rb
156
- - lib/metasm/exe_format/coff_decode.rb
157
- - lib/metasm/exe_format/nds.rb
158
- - lib/metasm/exe_format/elf.rb
159
- - lib/metasm/parse.rb
160
- - lib/metasm/dynldr.rb
161
- - lib/metasm/ppc/decode.rb
162
- - lib/metasm/ppc/main.rb
163
- - lib/metasm/ppc/parse.rb
164
- - lib/metasm/ppc/opcodes.rb
165
- - lib/metasm/ppc/decompile.rb
166
- - lib/metasm/ppc/encode.rb
167
- - lib/metasm/disassemble.rb
168
- - lib/metasm/gui/dasm_main.rb
169
- - lib/metasm/gui/debug.rb
170
- - lib/metasm/gui/dasm_hex.rb
171
- - lib/metasm/gui/dasm_opcodes.rb
172
- - lib/metasm/gui/dasm_graph.rb
173
- - lib/metasm/gui/qt.rb
174
- - lib/metasm/gui/dasm_funcgraph.rb
175
- - lib/metasm/gui/x11.rb
176
- - lib/metasm/gui/dasm_coverage.rb
177
- - lib/metasm/gui/cstruct.rb
178
- - lib/metasm/gui/dasm_listing.rb
179
- - lib/metasm/gui/win32.rb
180
- - lib/metasm/gui/dasm_decomp.rb
181
- - lib/metasm/gui/gtk.rb
182
- - lib/metasm/mips.rb
183
- - lib/metasm/ia32/decode.rb
184
- - lib/metasm/ia32/main.rb
185
- - lib/metasm/ia32/debug.rb
186
- - lib/metasm/ia32/parse.rb
187
- - lib/metasm/ia32/opcodes.rb
188
- - lib/metasm/ia32/decompile.rb
189
- - lib/metasm/ia32/encode.rb
190
- - lib/metasm/ia32/render.rb
191
- - lib/metasm/ia32/compile_c.rb
192
- - lib/metasm/x86_64.rb
193
- - lib/metasm/disassemble_api.rb
194
- - lib/metasm/gui.rb
195
- - lib/metasm/decompile.rb
196
- - lib/metasm/preprocessor.rb
197
- - lib/metasm/ppc.rb
198
- - lib/metasm/encode.rb
199
- - lib/metasm/ia32.rb
200
- - lib/metasm/mips/decode.rb
201
- - lib/metasm/mips/main.rb
202
- - lib/metasm/mips/parse.rb
203
- - lib/metasm/mips/opcodes.rb
204
- - lib/metasm/mips/encode.rb
205
- - lib/metasm/mips/render.rb
206
- - lib/metasm/mips/compile_c.rb
207
- - lib/metasm/dalvik/decode.rb
208
- - lib/metasm/dalvik/main.rb
209
- - lib/metasm/dalvik/opcodes.rb
210
- - lib/metasm/render.rb
211
- - lib/metasm/compile_c.rb
212
- - lib/metasm/dalvik.rb
213
- - lib/metasm/sh4.rb
214
- - lib/metasm/arm/decode.rb
215
- - lib/metasm/arm/main.rb
216
- - lib/metasm/arm/debug.rb
217
- - lib/metasm/arm/parse.rb
218
- - lib/metasm/arm/opcodes.rb
219
- - lib/metasm/arm/encode.rb
220
- - lib/metasm/arm/render.rb
308
+ - samples/shellcode-dynlink.rb
309
+ - samples/source.asm
310
+ - samples/struct_offset.rb
311
+ - samples/testpe.rb
312
+ - samples/testraw.rb
313
+ - samples/win32genloader.rb
314
+ - samples/win32hooker-advanced.rb
315
+ - samples/win32hooker.rb
316
+ - samples/win32livedasm.rb
317
+ - samples/win32remotescan.rb
318
+ - samples/wintrace.rb
319
+ - tests/all.rb
320
+ - tests/arc.rb
321
+ - tests/dasm.rb
322
+ - tests/dynldr.rb
323
+ - tests/encodeddata.rb
324
+ - tests/expression.rb
325
+ - tests/graph_layout.rb
326
+ - tests/ia32.rb
327
+ - tests/mips.rb
328
+ - tests/parse_c.rb
329
+ - tests/preprocessor.rb
330
+ - tests/x86_64.rb
221
331
  homepage: http://metasm.cr0.org
222
- licenses:
223
- - GPL-2
332
+ licenses:
333
+ - LGPL
334
+ metadata: {}
224
335
  post_install_message:
225
336
  rdoc_options: []
226
-
227
- require_paths:
228
- - lib
229
- required_ruby_version: !ruby/object:Gem::Requirement
230
- none: false
231
- requirements:
337
+ require_paths:
338
+ - "."
339
+ required_ruby_version: !ruby/object:Gem::Requirement
340
+ requirements:
232
341
  - - ">="
233
- - !ruby/object:Gem::Version
234
- hash: 3
235
- segments:
236
- - 0
237
- version: "0"
238
- required_rubygems_version: !ruby/object:Gem::Requirement
239
- none: false
240
- requirements:
342
+ - !ruby/object:Gem::Version
343
+ version: '0'
344
+ required_rubygems_version: !ruby/object:Gem::Requirement
345
+ requirements:
241
346
  - - ">="
242
- - !ruby/object:Gem::Version
243
- hash: 3
244
- segments:
245
- - 0
246
- version: "0"
347
+ - !ruby/object:Gem::Version
348
+ version: '0'
247
349
  requirements: []
248
-
249
350
  rubyforge_project:
250
- rubygems_version: 1.7.2
351
+ rubygems_version: 2.4.3
251
352
  signing_key:
252
- specification_version: 3
253
- summary: Metasm is a cross-architecture assembler, disassembler, compiler, linker and debugger in pure Ruby with no dependencies.
254
- test_files: []
255
-
353
+ specification_version: 4
354
+ summary: Metasm is a cross-architecture assembler, disassembler, linker, and debugger.
355
+ test_files:
356
+ - tests/all.rb
357
+ - tests/arc.rb
358
+ - tests/dasm.rb
359
+ - tests/dynldr.rb
360
+ - tests/encodeddata.rb
361
+ - tests/expression.rb
362
+ - tests/graph_layout.rb
363
+ - tests/ia32.rb
364
+ - tests/mips.rb
365
+ - tests/parse_c.rb
366
+ - tests/preprocessor.rb
367
+ - tests/x86_64.rb