librex 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (435) hide show
  1. data/README.markdown +1 -1
  2. metadata +3 -436
  3. data/lib/rex/LICENSE +0 -29
  4. data/lib/rex/arch.rb +0 -103
  5. data/lib/rex/arch/sparc.rb +0 -75
  6. data/lib/rex/arch/sparc.rb.ut.rb +0 -18
  7. data/lib/rex/arch/x86.rb +0 -513
  8. data/lib/rex/arch/x86.rb.ut.rb +0 -93
  9. data/lib/rex/assembly/nasm.rb +0 -104
  10. data/lib/rex/assembly/nasm.rb.ut.rb +0 -22
  11. data/lib/rex/codepage.map +0 -104
  12. data/lib/rex/compat.rb +0 -311
  13. data/lib/rex/constants.rb +0 -113
  14. data/lib/rex/elfparsey.rb +0 -11
  15. data/lib/rex/elfparsey/elf.rb +0 -123
  16. data/lib/rex/elfparsey/elfbase.rb +0 -258
  17. data/lib/rex/elfparsey/exceptions.rb +0 -27
  18. data/lib/rex/elfscan.rb +0 -12
  19. data/lib/rex/elfscan/scanner.rb +0 -207
  20. data/lib/rex/elfscan/search.rb +0 -46
  21. data/lib/rex/encoder/alpha2.rb +0 -31
  22. data/lib/rex/encoder/alpha2/alpha_mixed.rb +0 -68
  23. data/lib/rex/encoder/alpha2/alpha_upper.rb +0 -79
  24. data/lib/rex/encoder/alpha2/generic.rb +0 -114
  25. data/lib/rex/encoder/alpha2/unicode_mixed.rb +0 -117
  26. data/lib/rex/encoder/alpha2/unicode_upper.rb +0 -129
  27. data/lib/rex/encoder/ndr.rb +0 -89
  28. data/lib/rex/encoder/ndr.rb.ut.rb +0 -44
  29. data/lib/rex/encoder/nonalpha.rb +0 -61
  30. data/lib/rex/encoder/nonupper.rb +0 -64
  31. data/lib/rex/encoder/xdr.rb +0 -106
  32. data/lib/rex/encoder/xdr.rb.ut.rb +0 -29
  33. data/lib/rex/encoder/xor.rb +0 -69
  34. data/lib/rex/encoder/xor/dword.rb +0 -13
  35. data/lib/rex/encoder/xor/dword_additive.rb +0 -13
  36. data/lib/rex/encoders/xor_dword.rb +0 -35
  37. data/lib/rex/encoders/xor_dword_additive.rb +0 -53
  38. data/lib/rex/encoders/xor_dword_additive.rb.ut.rb +0 -12
  39. data/lib/rex/encoding/xor.rb +0 -20
  40. data/lib/rex/encoding/xor.rb.ts.rb +0 -14
  41. data/lib/rex/encoding/xor/byte.rb +0 -15
  42. data/lib/rex/encoding/xor/byte.rb.ut.rb +0 -21
  43. data/lib/rex/encoding/xor/dword.rb +0 -21
  44. data/lib/rex/encoding/xor/dword.rb.ut.rb +0 -15
  45. data/lib/rex/encoding/xor/dword_additive.rb +0 -92
  46. data/lib/rex/encoding/xor/dword_additive.rb.ut.rb +0 -15
  47. data/lib/rex/encoding/xor/exceptions.rb +0 -17
  48. data/lib/rex/encoding/xor/generic.rb +0 -146
  49. data/lib/rex/encoding/xor/generic.rb.ut.rb +0 -120
  50. data/lib/rex/encoding/xor/qword.rb +0 -15
  51. data/lib/rex/encoding/xor/word.rb +0 -21
  52. data/lib/rex/encoding/xor/word.rb.ut.rb +0 -13
  53. data/lib/rex/exceptions.rb +0 -275
  54. data/lib/rex/exceptions.rb.ut.rb +0 -44
  55. data/lib/rex/exploitation/cmdstager.rb +0 -9
  56. data/lib/rex/exploitation/cmdstager/base.rb +0 -175
  57. data/lib/rex/exploitation/cmdstager/debug_asm.rb +0 -142
  58. data/lib/rex/exploitation/cmdstager/debug_write.rb +0 -136
  59. data/lib/rex/exploitation/cmdstager/tftp.rb +0 -63
  60. data/lib/rex/exploitation/cmdstager/vbs.rb +0 -128
  61. data/lib/rex/exploitation/egghunter.rb +0 -277
  62. data/lib/rex/exploitation/egghunter.rb.ut.rb +0 -25
  63. data/lib/rex/exploitation/encryptjs.rb +0 -77
  64. data/lib/rex/exploitation/heaplib.js.b64 +0 -331
  65. data/lib/rex/exploitation/heaplib.rb +0 -94
  66. data/lib/rex/exploitation/javascriptosdetect.rb +0 -897
  67. data/lib/rex/exploitation/obfuscatejs.rb +0 -335
  68. data/lib/rex/exploitation/omelet.rb +0 -320
  69. data/lib/rex/exploitation/omelet.rb.ut.rb +0 -13
  70. data/lib/rex/exploitation/opcodedb.rb +0 -818
  71. data/lib/rex/exploitation/opcodedb.rb.ut.rb +0 -279
  72. data/lib/rex/exploitation/seh.rb +0 -92
  73. data/lib/rex/exploitation/seh.rb.ut.rb +0 -19
  74. data/lib/rex/file.rb +0 -112
  75. data/lib/rex/file.rb.ut.rb +0 -16
  76. data/lib/rex/image_source.rb +0 -12
  77. data/lib/rex/image_source/disk.rb +0 -60
  78. data/lib/rex/image_source/image_source.rb +0 -46
  79. data/lib/rex/image_source/memory.rb +0 -37
  80. data/lib/rex/io/bidirectional_pipe.rb +0 -157
  81. data/lib/rex/io/datagram_abstraction.rb +0 -35
  82. data/lib/rex/io/ring_buffer.rb +0 -364
  83. data/lib/rex/io/stream.rb +0 -319
  84. data/lib/rex/io/stream_abstraction.rb +0 -197
  85. data/lib/rex/io/stream_server.rb +0 -211
  86. data/lib/rex/job_container.rb +0 -187
  87. data/lib/rex/logging.rb +0 -4
  88. data/lib/rex/logging/log_dispatcher.rb +0 -179
  89. data/lib/rex/logging/log_sink.rb +0 -42
  90. data/lib/rex/logging/sinks/flatfile.rb +0 -55
  91. data/lib/rex/logging/sinks/stderr.rb +0 -43
  92. data/lib/rex/machparsey.rb +0 -9
  93. data/lib/rex/machparsey/exceptions.rb +0 -34
  94. data/lib/rex/machparsey/mach.rb +0 -209
  95. data/lib/rex/machparsey/machbase.rb +0 -408
  96. data/lib/rex/machscan.rb +0 -9
  97. data/lib/rex/machscan/scanner.rb +0 -217
  98. data/lib/rex/mime.rb +0 -9
  99. data/lib/rex/mime/header.rb +0 -77
  100. data/lib/rex/mime/message.rb +0 -144
  101. data/lib/rex/mime/part.rb +0 -20
  102. data/lib/rex/nop/opty2.rb +0 -108
  103. data/lib/rex/nop/opty2.rb.ut.rb +0 -23
  104. data/lib/rex/nop/opty2_tables.rb +0 -300
  105. data/lib/rex/ole.rb +0 -205
  106. data/lib/rex/ole/clsid.rb +0 -47
  107. data/lib/rex/ole/difat.rb +0 -141
  108. data/lib/rex/ole/directory.rb +0 -231
  109. data/lib/rex/ole/direntry.rb +0 -240
  110. data/lib/rex/ole/docs/dependencies.txt +0 -8
  111. data/lib/rex/ole/docs/references.txt +0 -1
  112. data/lib/rex/ole/fat.rb +0 -99
  113. data/lib/rex/ole/header.rb +0 -204
  114. data/lib/rex/ole/minifat.rb +0 -77
  115. data/lib/rex/ole/propset.rb +0 -144
  116. data/lib/rex/ole/samples/create_ole.rb +0 -27
  117. data/lib/rex/ole/samples/dir.rb +0 -35
  118. data/lib/rex/ole/samples/dump_stream.rb +0 -34
  119. data/lib/rex/ole/samples/ole_info.rb +0 -23
  120. data/lib/rex/ole/storage.rb +0 -395
  121. data/lib/rex/ole/stream.rb +0 -53
  122. data/lib/rex/ole/substorage.rb +0 -49
  123. data/lib/rex/ole/util.rb +0 -157
  124. data/lib/rex/parser/arguments.rb +0 -97
  125. data/lib/rex/parser/arguments.rb.ut.rb +0 -67
  126. data/lib/rex/parser/ini.rb +0 -185
  127. data/lib/rex/parser/ini.rb.ut.rb +0 -29
  128. data/lib/rex/parser/ip360_aspl_xml.rb +0 -102
  129. data/lib/rex/parser/ip360_xml.rb +0 -97
  130. data/lib/rex/parser/nessus_xml.rb +0 -118
  131. data/lib/rex/parser/netsparker_xml.rb +0 -94
  132. data/lib/rex/parser/nexpose_xml.rb +0 -136
  133. data/lib/rex/parser/nmap_xml.rb +0 -137
  134. data/lib/rex/parser/retina_xml.rb +0 -109
  135. data/lib/rex/payloads.rb +0 -1
  136. data/lib/rex/payloads/win32.rb +0 -2
  137. data/lib/rex/payloads/win32/common.rb +0 -26
  138. data/lib/rex/payloads/win32/kernel.rb +0 -53
  139. data/lib/rex/payloads/win32/kernel/common.rb +0 -54
  140. data/lib/rex/payloads/win32/kernel/migration.rb +0 -12
  141. data/lib/rex/payloads/win32/kernel/recovery.rb +0 -50
  142. data/lib/rex/payloads/win32/kernel/stager.rb +0 -194
  143. data/lib/rex/peparsey.rb +0 -12
  144. data/lib/rex/peparsey/exceptions.rb +0 -32
  145. data/lib/rex/peparsey/pe.rb +0 -212
  146. data/lib/rex/peparsey/pe_memdump.rb +0 -63
  147. data/lib/rex/peparsey/pebase.rb +0 -1680
  148. data/lib/rex/peparsey/section.rb +0 -136
  149. data/lib/rex/pescan.rb +0 -13
  150. data/lib/rex/pescan/analyze.rb +0 -309
  151. data/lib/rex/pescan/scanner.rb +0 -206
  152. data/lib/rex/pescan/search.rb +0 -56
  153. data/lib/rex/platforms.rb +0 -1
  154. data/lib/rex/platforms/windows.rb +0 -51
  155. data/lib/rex/poly.rb +0 -132
  156. data/lib/rex/poly/block.rb +0 -477
  157. data/lib/rex/poly/register.rb +0 -100
  158. data/lib/rex/poly/register/x86.rb +0 -40
  159. data/lib/rex/post.rb +0 -8
  160. data/lib/rex/post/dir.rb +0 -51
  161. data/lib/rex/post/file.rb +0 -172
  162. data/lib/rex/post/file_stat.rb +0 -220
  163. data/lib/rex/post/gen.pl +0 -13
  164. data/lib/rex/post/io.rb +0 -182
  165. data/lib/rex/post/meterpreter.rb +0 -4
  166. data/lib/rex/post/meterpreter/channel.rb +0 -445
  167. data/lib/rex/post/meterpreter/channel_container.rb +0 -54
  168. data/lib/rex/post/meterpreter/channels/pool.rb +0 -160
  169. data/lib/rex/post/meterpreter/channels/pools/file.rb +0 -62
  170. data/lib/rex/post/meterpreter/channels/pools/stream_pool.rb +0 -103
  171. data/lib/rex/post/meterpreter/channels/stream.rb +0 -87
  172. data/lib/rex/post/meterpreter/client.rb +0 -364
  173. data/lib/rex/post/meterpreter/client_core.rb +0 -274
  174. data/lib/rex/post/meterpreter/dependencies.rb +0 -3
  175. data/lib/rex/post/meterpreter/extension.rb +0 -32
  176. data/lib/rex/post/meterpreter/extensions/espia/espia.rb +0 -58
  177. data/lib/rex/post/meterpreter/extensions/espia/tlv.rb +0 -16
  178. data/lib/rex/post/meterpreter/extensions/incognito/incognito.rb +0 -94
  179. data/lib/rex/post/meterpreter/extensions/incognito/tlv.rb +0 -21
  180. data/lib/rex/post/meterpreter/extensions/networkpug/networkpug.rb +0 -57
  181. data/lib/rex/post/meterpreter/extensions/networkpug/tlv.rb +0 -15
  182. data/lib/rex/post/meterpreter/extensions/priv/fs.rb +0 -118
  183. data/lib/rex/post/meterpreter/extensions/priv/passwd.rb +0 -61
  184. data/lib/rex/post/meterpreter/extensions/priv/priv.rb +0 -111
  185. data/lib/rex/post/meterpreter/extensions/priv/tlv.rb +0 -28
  186. data/lib/rex/post/meterpreter/extensions/sniffer/sniffer.rb +0 -101
  187. data/lib/rex/post/meterpreter/extensions/sniffer/tlv.rb +0 -26
  188. data/lib/rex/post/meterpreter/extensions/stdapi/constants.rb +0 -333
  189. data/lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb +0 -282
  190. data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +0 -266
  191. data/lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb +0 -103
  192. data/lib/rex/post/meterpreter/extensions/stdapi/fs/io.rb +0 -48
  193. data/lib/rex/post/meterpreter/extensions/stdapi/net/config.rb +0 -144
  194. data/lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb +0 -73
  195. data/lib/rex/post/meterpreter/extensions/stdapi/net/route.rb +0 -56
  196. data/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb +0 -137
  197. data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb +0 -180
  198. data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_server_channel.rb +0 -167
  199. data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb +0 -208
  200. data/lib/rex/post/meterpreter/extensions/stdapi/railgun.rb.ts.rb +0 -6
  201. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb +0 -38106
  202. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb.ut.rb +0 -31
  203. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb +0 -47
  204. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb.ut.rb +0 -36
  205. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_advapi32.rb +0 -1818
  206. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_iphlpapi.rb +0 -96
  207. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb +0 -3848
  208. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_netapi32.rb +0 -26
  209. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ntdll.rb +0 -153
  210. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_shell32.rb +0 -21
  211. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_user32.rb +0 -3169
  212. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ws2_32.rb +0 -599
  213. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb +0 -318
  214. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb +0 -100
  215. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb.ut.rb +0 -42
  216. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb +0 -148
  217. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb.ut.rb +0 -127
  218. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/multicall.rb +0 -309
  219. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb +0 -204
  220. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/tlv.rb +0 -51
  221. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/util.rb +0 -630
  222. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb +0 -75
  223. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb.ut.rb +0 -103
  224. data/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb +0 -149
  225. data/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +0 -97
  226. data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log.rb +0 -192
  227. data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log_subsystem/event_record.rb +0 -41
  228. data/lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb +0 -61
  229. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb +0 -370
  230. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/image.rb +0 -129
  231. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/io.rb +0 -55
  232. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/memory.rb +0 -336
  233. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/thread.rb +0 -141
  234. data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry.rb +0 -279
  235. data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_key.rb +0 -193
  236. data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb +0 -102
  237. data/lib/rex/post/meterpreter/extensions/stdapi/sys/thread.rb +0 -180
  238. data/lib/rex/post/meterpreter/extensions/stdapi/tlv.rb +0 -211
  239. data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +0 -227
  240. data/lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb +0 -63
  241. data/lib/rex/post/meterpreter/inbound_packet_handler.rb +0 -30
  242. data/lib/rex/post/meterpreter/object_aliases.rb +0 -83
  243. data/lib/rex/post/meterpreter/packet.rb +0 -688
  244. data/lib/rex/post/meterpreter/packet_dispatcher.rb +0 -431
  245. data/lib/rex/post/meterpreter/packet_parser.rb +0 -94
  246. data/lib/rex/post/meterpreter/packet_response_waiter.rb +0 -83
  247. data/lib/rex/post/meterpreter/ui/console.rb +0 -137
  248. data/lib/rex/post/meterpreter/ui/console/command_dispatcher.rb +0 -62
  249. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +0 -730
  250. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/espia.rb +0 -108
  251. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/incognito.rb +0 -241
  252. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/networkpug.rb +0 -231
  253. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv.rb +0 -61
  254. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/elevate.rb +0 -98
  255. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/passwd.rb +0 -51
  256. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb +0 -132
  257. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/sniffer.rb +0 -187
  258. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi.rb +0 -65
  259. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +0 -442
  260. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +0 -298
  261. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +0 -486
  262. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +0 -315
  263. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb +0 -157
  264. data/lib/rex/post/meterpreter/ui/console/interactive_channel.rb +0 -95
  265. data/lib/rex/post/permission.rb +0 -26
  266. data/lib/rex/post/process.rb +0 -57
  267. data/lib/rex/post/thread.rb +0 -57
  268. data/lib/rex/post/ui.rb +0 -52
  269. data/lib/rex/proto.rb +0 -13
  270. data/lib/rex/proto.rb.ts.rb +0 -8
  271. data/lib/rex/proto/dcerpc.rb +0 -6
  272. data/lib/rex/proto/dcerpc.rb.ts.rb +0 -9
  273. data/lib/rex/proto/dcerpc/client.rb +0 -361
  274. data/lib/rex/proto/dcerpc/client.rb.ut.rb +0 -491
  275. data/lib/rex/proto/dcerpc/exceptions.rb +0 -150
  276. data/lib/rex/proto/dcerpc/handle.rb +0 -47
  277. data/lib/rex/proto/dcerpc/handle.rb.ut.rb +0 -85
  278. data/lib/rex/proto/dcerpc/ndr.rb +0 -72
  279. data/lib/rex/proto/dcerpc/ndr.rb.ut.rb +0 -41
  280. data/lib/rex/proto/dcerpc/packet.rb +0 -253
  281. data/lib/rex/proto/dcerpc/packet.rb.ut.rb +0 -56
  282. data/lib/rex/proto/dcerpc/response.rb +0 -187
  283. data/lib/rex/proto/dcerpc/response.rb.ut.rb +0 -15
  284. data/lib/rex/proto/dcerpc/uuid.rb +0 -84
  285. data/lib/rex/proto/dcerpc/uuid.rb.ut.rb +0 -46
  286. data/lib/rex/proto/dhcp.rb +0 -7
  287. data/lib/rex/proto/dhcp/constants.rb +0 -33
  288. data/lib/rex/proto/dhcp/server.rb +0 -292
  289. data/lib/rex/proto/drda.rb +0 -5
  290. data/lib/rex/proto/drda.rb.ts.rb +0 -17
  291. data/lib/rex/proto/drda/constants.rb +0 -49
  292. data/lib/rex/proto/drda/constants.rb.ut.rb +0 -23
  293. data/lib/rex/proto/drda/packet.rb +0 -252
  294. data/lib/rex/proto/drda/packet.rb.ut.rb +0 -109
  295. data/lib/rex/proto/drda/utils.rb +0 -123
  296. data/lib/rex/proto/drda/utils.rb.ut.rb +0 -84
  297. data/lib/rex/proto/http.rb +0 -5
  298. data/lib/rex/proto/http.rb.ts.rb +0 -12
  299. data/lib/rex/proto/http/client.rb +0 -821
  300. data/lib/rex/proto/http/client.rb.ut.rb +0 -95
  301. data/lib/rex/proto/http/handler.rb +0 -46
  302. data/lib/rex/proto/http/handler/erb.rb +0 -128
  303. data/lib/rex/proto/http/handler/erb.rb.ut.rb +0 -21
  304. data/lib/rex/proto/http/handler/erb.rb.ut.rb.rhtml +0 -1
  305. data/lib/rex/proto/http/handler/proc.rb +0 -60
  306. data/lib/rex/proto/http/handler/proc.rb.ut.rb +0 -24
  307. data/lib/rex/proto/http/header.rb +0 -161
  308. data/lib/rex/proto/http/header.rb.ut.rb +0 -46
  309. data/lib/rex/proto/http/packet.rb +0 -407
  310. data/lib/rex/proto/http/packet.rb.ut.rb +0 -165
  311. data/lib/rex/proto/http/request.rb +0 -356
  312. data/lib/rex/proto/http/request.rb.ut.rb +0 -214
  313. data/lib/rex/proto/http/response.rb +0 -90
  314. data/lib/rex/proto/http/response.rb.ut.rb +0 -149
  315. data/lib/rex/proto/http/server.rb +0 -369
  316. data/lib/rex/proto/http/server.rb.ut.rb +0 -79
  317. data/lib/rex/proto/ntlm.rb +0 -7
  318. data/lib/rex/proto/ntlm.rb.ut.rb +0 -177
  319. data/lib/rex/proto/ntlm/base.rb +0 -326
  320. data/lib/rex/proto/ntlm/constants.rb +0 -74
  321. data/lib/rex/proto/ntlm/crypt.rb +0 -415
  322. data/lib/rex/proto/ntlm/exceptions.rb +0 -16
  323. data/lib/rex/proto/ntlm/message.rb +0 -536
  324. data/lib/rex/proto/ntlm/utils.rb +0 -764
  325. data/lib/rex/proto/proxy/socks4a.rb +0 -440
  326. data/lib/rex/proto/rfb.rb +0 -19
  327. data/lib/rex/proto/rfb.rb.ut.rb +0 -37
  328. data/lib/rex/proto/rfb/cipher.rb +0 -84
  329. data/lib/rex/proto/rfb/client.rb +0 -207
  330. data/lib/rex/proto/rfb/constants.rb +0 -52
  331. data/lib/rex/proto/smb.rb +0 -7
  332. data/lib/rex/proto/smb.rb.ts.rb +0 -8
  333. data/lib/rex/proto/smb/client.rb +0 -1952
  334. data/lib/rex/proto/smb/client.rb.ut.rb +0 -223
  335. data/lib/rex/proto/smb/constants.rb +0 -1047
  336. data/lib/rex/proto/smb/constants.rb.ut.rb +0 -18
  337. data/lib/rex/proto/smb/crypt.rb +0 -36
  338. data/lib/rex/proto/smb/evasions.rb +0 -66
  339. data/lib/rex/proto/smb/exceptions.rb +0 -858
  340. data/lib/rex/proto/smb/simpleclient.rb +0 -306
  341. data/lib/rex/proto/smb/simpleclient.rb.ut.rb +0 -128
  342. data/lib/rex/proto/smb/utils.rb +0 -103
  343. data/lib/rex/proto/smb/utils.rb.ut.rb +0 -20
  344. data/lib/rex/proto/sunrpc.rb +0 -1
  345. data/lib/rex/proto/sunrpc/client.rb +0 -195
  346. data/lib/rex/proto/tftp.rb +0 -12
  347. data/lib/rex/proto/tftp/constants.rb +0 -39
  348. data/lib/rex/proto/tftp/server.rb +0 -497
  349. data/lib/rex/proto/tftp/server.rb.ut.rb +0 -28
  350. data/lib/rex/script.rb +0 -42
  351. data/lib/rex/script/base.rb +0 -59
  352. data/lib/rex/script/meterpreter.rb +0 -15
  353. data/lib/rex/script/shell.rb +0 -9
  354. data/lib/rex/service.rb +0 -48
  355. data/lib/rex/service_manager.rb +0 -141
  356. data/lib/rex/service_manager.rb.ut.rb +0 -32
  357. data/lib/rex/services/local_relay.rb +0 -423
  358. data/lib/rex/socket.rb +0 -684
  359. data/lib/rex/socket.rb.ut.rb +0 -107
  360. data/lib/rex/socket/comm.rb +0 -119
  361. data/lib/rex/socket/comm/local.rb +0 -412
  362. data/lib/rex/socket/comm/local.rb.ut.rb +0 -75
  363. data/lib/rex/socket/ip.rb +0 -130
  364. data/lib/rex/socket/parameters.rb +0 -345
  365. data/lib/rex/socket/parameters.rb.ut.rb +0 -51
  366. data/lib/rex/socket/range_walker.rb +0 -346
  367. data/lib/rex/socket/range_walker.rb.ut.rb +0 -55
  368. data/lib/rex/socket/ssl_tcp.rb +0 -184
  369. data/lib/rex/socket/ssl_tcp.rb.ut.rb +0 -39
  370. data/lib/rex/socket/ssl_tcp_server.rb +0 -122
  371. data/lib/rex/socket/ssl_tcp_server.rb.ut.rb +0 -61
  372. data/lib/rex/socket/subnet_walker.rb +0 -75
  373. data/lib/rex/socket/subnet_walker.rb.ut.rb +0 -28
  374. data/lib/rex/socket/switch_board.rb +0 -278
  375. data/lib/rex/socket/switch_board.rb.ut.rb +0 -52
  376. data/lib/rex/socket/tcp.rb +0 -76
  377. data/lib/rex/socket/tcp.rb.ut.rb +0 -64
  378. data/lib/rex/socket/tcp_server.rb +0 -66
  379. data/lib/rex/socket/tcp_server.rb.ut.rb +0 -44
  380. data/lib/rex/socket/udp.rb +0 -164
  381. data/lib/rex/socket/udp.rb.ut.rb +0 -44
  382. data/lib/rex/struct2.rb +0 -5
  383. data/lib/rex/struct2/c_struct.rb +0 -181
  384. data/lib/rex/struct2/c_struct_template.rb +0 -39
  385. data/lib/rex/struct2/constant.rb +0 -26
  386. data/lib/rex/struct2/element.rb +0 -44
  387. data/lib/rex/struct2/generic.rb +0 -73
  388. data/lib/rex/struct2/restraint.rb +0 -54
  389. data/lib/rex/struct2/s_string.rb +0 -72
  390. data/lib/rex/struct2/s_struct.rb +0 -111
  391. data/lib/rex/sync.rb +0 -6
  392. data/lib/rex/sync/event.rb +0 -94
  393. data/lib/rex/sync/read_write_lock.rb +0 -176
  394. data/lib/rex/sync/ref.rb +0 -57
  395. data/lib/rex/sync/thread_safe.rb +0 -82
  396. data/lib/rex/test.rb +0 -35
  397. data/lib/rex/text.rb +0 -1163
  398. data/lib/rex/text.rb.ut.rb +0 -190
  399. data/lib/rex/thread_factory.rb +0 -42
  400. data/lib/rex/time.rb +0 -65
  401. data/lib/rex/transformer.rb +0 -115
  402. data/lib/rex/transformer.rb.ut.rb +0 -38
  403. data/lib/rex/ui.rb +0 -21
  404. data/lib/rex/ui/interactive.rb +0 -298
  405. data/lib/rex/ui/output.rb +0 -78
  406. data/lib/rex/ui/output/none.rb +0 -18
  407. data/lib/rex/ui/progress_tracker.rb +0 -96
  408. data/lib/rex/ui/subscriber.rb +0 -149
  409. data/lib/rex/ui/text/color.rb +0 -97
  410. data/lib/rex/ui/text/color.rb.ut.rb +0 -18
  411. data/lib/rex/ui/text/dispatcher_shell.rb +0 -467
  412. data/lib/rex/ui/text/input.rb +0 -117
  413. data/lib/rex/ui/text/input/buffer.rb +0 -75
  414. data/lib/rex/ui/text/input/readline.rb +0 -129
  415. data/lib/rex/ui/text/input/socket.rb +0 -95
  416. data/lib/rex/ui/text/input/stdio.rb +0 -45
  417. data/lib/rex/ui/text/irb_shell.rb +0 -57
  418. data/lib/rex/ui/text/output.rb +0 -80
  419. data/lib/rex/ui/text/output/buffer.rb +0 -61
  420. data/lib/rex/ui/text/output/file.rb +0 -43
  421. data/lib/rex/ui/text/output/socket.rb +0 -43
  422. data/lib/rex/ui/text/output/stdio.rb +0 -40
  423. data/lib/rex/ui/text/progress_tracker.rb +0 -56
  424. data/lib/rex/ui/text/progress_tracker.rb.ut.rb +0 -34
  425. data/lib/rex/ui/text/shell.rb +0 -328
  426. data/lib/rex/ui/text/table.rb +0 -279
  427. data/lib/rex/ui/text/table.rb.ut.rb +0 -55
  428. data/lib/rex/zip.rb +0 -93
  429. data/lib/rex/zip/archive.rb +0 -184
  430. data/lib/rex/zip/blocks.rb +0 -182
  431. data/lib/rex/zip/entry.rb +0 -104
  432. data/lib/rex/zip/samples/comment.rb +0 -32
  433. data/lib/rex/zip/samples/mkwar.rb +0 -138
  434. data/lib/rex/zip/samples/mkzip.rb +0 -19
  435. data/lib/rex/zip/samples/recursive.rb +0 -58
@@ -1,227 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rex/post/ui'
4
-
5
- module Rex
6
- module Post
7
- module Meterpreter
8
- module Extensions
9
- module Stdapi
10
-
11
- ###
12
- #
13
- # Allows for interacting with the user interface on the remote machine,
14
- # such as by disabling the keyboard and mouse.
15
- #
16
- # WARNING:
17
- #
18
- # Using keyboard and mouse enabling/disabling features will result in
19
- # a DLL file being written to disk.
20
- #
21
- ###
22
- class UI < Rex::Post::UI
23
-
24
- include Rex::Post::Meterpreter::ObjectAliasesContainer
25
-
26
- ##
27
- #
28
- # Constructor
29
- #
30
- ##
31
-
32
- #
33
- # Initializes the post-exploitation user-interface manipulation subsystem.
34
- #
35
- def initialize(client)
36
- self.client = client
37
- end
38
-
39
- ##
40
- #
41
- # Device enabling/disabling
42
- #
43
- ##
44
-
45
- #
46
- # Disable keyboard input on the remote machine.
47
- #
48
- def disable_keyboard
49
- return enable_keyboard(false)
50
- end
51
-
52
- #
53
- # Enable keyboard input on the remote machine.
54
- #
55
- def enable_keyboard(enable = true)
56
- request = Packet.create_request('stdapi_ui_enable_keyboard')
57
-
58
- request.add_tlv(TLV_TYPE_BOOL, enable)
59
-
60
- response = client.send_request(request)
61
-
62
- return true
63
- end
64
-
65
- #
66
- # Disable mouse input on the remote machine.
67
- #
68
- def disable_mouse
69
- return enable_mouse(false)
70
- end
71
-
72
- #
73
- # Enable mouse input on the remote machine.
74
- #
75
- def enable_mouse(enable = true)
76
- request = Packet.create_request('stdapi_ui_enable_mouse')
77
-
78
- request.add_tlv(TLV_TYPE_BOOL, enable)
79
-
80
- response = client.send_request(request)
81
-
82
- return true
83
- end
84
-
85
- #
86
- # Returns the number of seconds the remote machine has been idle
87
- # from user input.
88
- #
89
- def idle_time
90
- request = Packet.create_request('stdapi_ui_get_idle_time')
91
-
92
- response = client.send_request(request)
93
-
94
- return response.get_tlv_value(TLV_TYPE_IDLE_TIME);
95
- end
96
-
97
- #
98
- # Enumerate desktops.
99
- #
100
- def enum_desktops
101
- request = Packet.create_request('stdapi_ui_desktop_enum')
102
- response = client.send_request(request)
103
- desktopz = []
104
- if( response.result == 0 )
105
- response.each( TLV_TYPE_DESKTOP ) { | desktop |
106
- desktopz << {
107
- 'session' => desktop.get_tlv_value( TLV_TYPE_DESKTOP_SESSION ),
108
- 'station' => desktop.get_tlv_value( TLV_TYPE_DESKTOP_STATION ),
109
- 'name' => desktop.get_tlv_value( TLV_TYPE_DESKTOP_NAME )
110
- }
111
- }
112
- end
113
- return desktopz
114
- end
115
-
116
- #
117
- # Get the current desktop meterpreter is using.
118
- #
119
- def get_desktop
120
- request = Packet.create_request( 'stdapi_ui_desktop_get' )
121
- response = client.send_request( request )
122
- desktop = {}
123
- if( response.result == 0 )
124
- desktop = {
125
- 'session' => response.get_tlv_value( TLV_TYPE_DESKTOP_SESSION ),
126
- 'station' => response.get_tlv_value( TLV_TYPE_DESKTOP_STATION ),
127
- 'name' => response.get_tlv_value( TLV_TYPE_DESKTOP_NAME )
128
- }
129
- end
130
- return desktop
131
- end
132
-
133
- #
134
- # Change the meterpreters current desktop. The switch param sets this
135
- # new desktop as the interactive one (The local users visible desktop
136
- # with screen/keyboard/mouse control).
137
- #
138
- def set_desktop( session=-1, station='WinSta0', name='Default', switch=false )
139
- request = Packet.create_request( 'stdapi_ui_desktop_set' )
140
- request.add_tlv( TLV_TYPE_DESKTOP_SESSION, session )
141
- request.add_tlv( TLV_TYPE_DESKTOP_STATION, station )
142
- request.add_tlv( TLV_TYPE_DESKTOP_NAME, name )
143
- request.add_tlv( TLV_TYPE_DESKTOP_SWITCH, switch )
144
- response = client.send_request( request )
145
- if( response.result == 0 )
146
- return true
147
- end
148
- return false
149
- end
150
-
151
- #
152
- # Grab a screenshot of the interactive desktop
153
- #
154
- def screenshot( quality=50 )
155
- request = Packet.create_request( 'stdapi_ui_desktop_screenshot' )
156
- request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_QUALITY, quality )
157
- # include the x64 screenshot dll if the host OS is x64
158
- if( client.sys.config.sysinfo['Architecture'] =~ /^\S*x64\S*/ )
159
- screenshot_path = ::File.join( Msf::Config.install_root, 'data', 'meterpreter', 'screenshot.x64.dll' )
160
- screenshot_path = ::File.expand_path( screenshot_path )
161
- screenshot_dll = ''
162
- ::File.open( screenshot_path, 'rb' ) do |f|
163
- screenshot_dll += f.read( f.stat.size )
164
- end
165
- request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_BUFFER, screenshot_dll, false, true )
166
- request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_LENGTH, screenshot_dll.length )
167
- end
168
- # but allways include the x86 screenshot dll as we can use it for wow64 processes if we are on x64
169
- screenshot_path = ::File.join( Msf::Config.install_root, 'data', 'meterpreter', 'screenshot.dll' )
170
- screenshot_path = ::File.expand_path( screenshot_path )
171
- screenshot_dll = ''
172
- ::File.open( screenshot_path, 'rb' ) do |f|
173
- screenshot_dll += f.read( f.stat.size )
174
- end
175
- request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_BUFFER, screenshot_dll, false, true )
176
- request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_LENGTH, screenshot_dll.length )
177
- # send the request and return the jpeg image if successfull.
178
- response = client.send_request( request )
179
- if( response.result == 0 )
180
- return response.get_tlv_value( TLV_TYPE_DESKTOP_SCREENSHOT )
181
- end
182
- return nil
183
- end
184
-
185
- #
186
- # Unlock or lock the desktop
187
- #
188
- def unlock_desktop(unlock=true)
189
- request = Packet.create_request('stdapi_ui_unlock_desktop')
190
- request.add_tlv(TLV_TYPE_BOOL, unlock)
191
- response = client.send_request(request)
192
- return true
193
- end
194
-
195
- #
196
- # Start the keyboard sniffer
197
- #
198
- def keyscan_start
199
- request = Packet.create_request('stdapi_ui_start_keyscan')
200
- response = client.send_request(request)
201
- return true
202
- end
203
-
204
- #
205
- # Stop the keyboard sniffer
206
- #
207
- def keyscan_stop
208
- request = Packet.create_request('stdapi_ui_stop_keyscan')
209
- response = client.send_request(request)
210
- return true
211
- end
212
-
213
- #
214
- # Dump the keystroke buffer
215
- #
216
- def keyscan_dump
217
- request = Packet.create_request('stdapi_ui_get_keys')
218
- response = client.send_request(request)
219
- return response.get_tlv_value(TLV_TYPE_KEYS_DUMP);
220
- end
221
-
222
- protected
223
- attr_accessor :client # :nodoc:
224
-
225
- end
226
-
227
- end; end; end; end; end
@@ -1,63 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- module Rex
4
- module Post
5
- module Meterpreter
6
- module Extensions
7
- module Stdapi
8
- module Webcam
9
-
10
- ###
11
- #
12
- # This meterpreter extension can list and capture from webcams and/or microphone
13
- #
14
- ###
15
- class Webcam
16
-
17
- def initialize(client)
18
- @client = client
19
- end
20
-
21
- def webcam_list
22
- response = client.send_request(Packet.create_request('webcam_list'))
23
- names = []
24
- response.get_tlvs( TLV_TYPE_WEBCAM_NAME ).each{ |tlv|
25
- names << tlv.value
26
- }
27
- names
28
- end
29
-
30
- # Starts recording video from video source of index #{cam}
31
- def webcam_start(cam)
32
- request = Packet.create_request('webcam_start')
33
- request.add_tlv(TLV_TYPE_WEBCAM_INTERFACE_ID, cam)
34
- client.send_request(request)
35
- true
36
- end
37
-
38
- def webcam_get_frame(quality)
39
- request = Packet.create_request('webcam_get_frame')
40
- request.add_tlv(TLV_TYPE_WEBCAM_QUALITY, quality)
41
- response = client.send_request(request)
42
- response.get_tlv( TLV_TYPE_WEBCAM_IMAGE ).value
43
- end
44
-
45
- def webcam_stop
46
- client.send_request( Packet.create_request( 'webcam_stop' ) )
47
- true
48
- end
49
-
50
- # Record from default audio source for #{duration} seconds;
51
- # returns a low-quality wav file
52
- def record_mic(duration)
53
- request = Packet.create_request('webcam_audio_record')
54
- request.add_tlv(TLV_TYPE_AUDIO_DURATION, duration)
55
- response = client.send_request(request)
56
- response.get_tlv( TLV_TYPE_AUDIO_DATA ).value
57
- end
58
-
59
- attr_accessor :client
60
-
61
- end
62
-
63
- end; end; end; end; end; end
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- module Rex
4
- module Post
5
- module Meterpreter
6
-
7
- ###
8
- #
9
- # Mixin that provides stubs for handling inbound packets
10
- #
11
- ###
12
- module InboundPacketHandler
13
-
14
- #
15
- # Stub request handler that returns false by default.
16
- #
17
- def request_handler(client, packet)
18
- return false
19
- end
20
-
21
- #
22
- # Stub response handler that returns false by default.
23
- #
24
- def response_handler(client, packet)
25
- return false
26
- end
27
-
28
- end
29
-
30
- end; end; end
@@ -1,83 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- module Rex
4
- module Post
5
- module Meterpreter
6
-
7
- ###
8
- #
9
- # Mixin for classes that wish to have object aliases but do not
10
- # really need to inherit from the ObjectAliases class.
11
- #
12
- ###
13
- module ObjectAliasesContainer
14
-
15
- #
16
- # Initialize the instance's aliases.
17
- #
18
- def initialize_aliases(aliases = {})
19
- self.aliases = aliases
20
- end
21
-
22
- #
23
- # Pass-thru aliases.
24
- #
25
- def method_missing(symbol, *args)
26
- self.aliases[symbol.to_s]
27
- end
28
-
29
- #
30
- # Recursively dumps all of the aliases registered with a class that
31
- # is kind_of? ObjectAliases.
32
- #
33
- def dump_alias_tree(parent_path, current = nil)
34
- items = []
35
-
36
- if (current == nil)
37
- current = self
38
- end
39
-
40
- # If the current object may have object aliases...
41
- if (current.kind_of?(Rex::Post::Meterpreter::ObjectAliases))
42
- current.aliases.each_key { |x|
43
- current_path = parent_path + '.' + x
44
-
45
- items << current_path
46
-
47
- items.concat(dump_alias_tree(current_path,
48
- current.aliases[x]))
49
- }
50
- end
51
-
52
- return items
53
- end
54
-
55
- #
56
- # The hash of aliases.
57
- #
58
- attr_accessor :aliases
59
- end
60
-
61
- ###
62
- #
63
- # Generic object aliases from a class instance referenced symbol to an
64
- # associated object of an arbitrary type
65
- #
66
- ###
67
- class ObjectAliases
68
- include Rex::Post::Meterpreter::ObjectAliasesContainer
69
-
70
- ##
71
- #
72
- # Constructor
73
- #
74
- ##
75
-
76
- # An instance
77
- def initialize(aliases = {})
78
- initialize_aliases(aliases)
79
- end
80
- end
81
-
82
-
83
- end; end; end
@@ -1,688 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- module Rex
4
- module Post
5
- module Meterpreter
6
-
7
- #
8
- # Constants
9
- #
10
- PACKET_TYPE_REQUEST = 0
11
- PACKET_TYPE_RESPONSE = 1
12
- PACKET_TYPE_PLAIN_REQUEST = 10
13
- PACKET_TYPE_PLAIN_RESPONSE = 11
14
-
15
- #
16
- # TLV Meta Types
17
- #
18
- TLV_META_TYPE_NONE = 0
19
- TLV_META_TYPE_STRING = (1 << 16)
20
- TLV_META_TYPE_UINT = (1 << 17)
21
- TLV_META_TYPE_RAW = (1 << 18)
22
- TLV_META_TYPE_BOOL = (1 << 19)
23
- TLV_META_TYPE_QWORD = (1 << 20)
24
- TLV_META_TYPE_COMPRESSED = (1 << 29)
25
- TLV_META_TYPE_GROUP = (1 << 30)
26
- TLV_META_TYPE_COMPLEX = (1 << 31)
27
-
28
- # Exclude compressed from the mask since other meta types (e.g. RAW) can also
29
- # be compressed
30
- TLV_META_MASK = (
31
- TLV_META_TYPE_STRING |
32
- TLV_META_TYPE_UINT |
33
- TLV_META_TYPE_RAW |
34
- TLV_META_TYPE_BOOL |
35
- TLV_META_TYPE_QWORD |
36
- TLV_META_TYPE_GROUP |
37
- TLV_META_TYPE_COMPLEX
38
- )
39
-
40
- #
41
- # TLV base starting points
42
- #
43
- TLV_RESERVED = 0
44
- TLV_EXTENSIONS = 20000
45
- TLV_USER = 40000
46
- TLV_TEMP = 60000
47
-
48
- #
49
- # TLV Specific Types
50
- #
51
- TLV_TYPE_ANY = TLV_META_TYPE_NONE | 0
52
- TLV_TYPE_METHOD = TLV_META_TYPE_STRING | 1
53
- TLV_TYPE_REQUEST_ID = TLV_META_TYPE_STRING | 2
54
- TLV_TYPE_EXCEPTION = TLV_META_TYPE_GROUP | 3
55
- TLV_TYPE_RESULT = TLV_META_TYPE_UINT | 4
56
-
57
- TLV_TYPE_STRING = TLV_META_TYPE_STRING | 10
58
- TLV_TYPE_UINT = TLV_META_TYPE_UINT | 11
59
- TLV_TYPE_BOOL = TLV_META_TYPE_BOOL | 12
60
-
61
- TLV_TYPE_LENGTH = TLV_META_TYPE_UINT | 25
62
- TLV_TYPE_DATA = TLV_META_TYPE_RAW | 26
63
- TLV_TYPE_FLAGS = TLV_META_TYPE_UINT | 27
64
-
65
- TLV_TYPE_CHANNEL_ID = TLV_META_TYPE_UINT | 50
66
- TLV_TYPE_CHANNEL_TYPE = TLV_META_TYPE_STRING | 51
67
- TLV_TYPE_CHANNEL_DATA = TLV_META_TYPE_RAW | 52
68
- TLV_TYPE_CHANNEL_DATA_GROUP = TLV_META_TYPE_GROUP | 53
69
- TLV_TYPE_CHANNEL_CLASS = TLV_META_TYPE_UINT | 54
70
- TLV_TYPE_CHANNEL_PARENTID = TLV_META_TYPE_UINT | 55
71
-
72
- TLV_TYPE_SEEK_WHENCE = TLV_META_TYPE_UINT | 70
73
- TLV_TYPE_SEEK_OFFSET = TLV_META_TYPE_UINT | 71
74
- TLV_TYPE_SEEK_POS = TLV_META_TYPE_UINT | 72
75
-
76
- TLV_TYPE_EXCEPTION_CODE = TLV_META_TYPE_UINT | 300
77
- TLV_TYPE_EXCEPTION_STRING = TLV_META_TYPE_STRING | 301
78
-
79
- TLV_TYPE_LIBRARY_PATH = TLV_META_TYPE_STRING | 400
80
- TLV_TYPE_TARGET_PATH = TLV_META_TYPE_STRING | 401
81
- TLV_TYPE_MIGRATE_PID = TLV_META_TYPE_UINT | 402
82
- TLV_TYPE_MIGRATE_LEN = TLV_META_TYPE_UINT | 403
83
- TLV_TYPE_MIGRATE_PAYLOAD = TLV_META_TYPE_STRING | 404
84
- TLV_TYPE_MIGRATE_ARCH = TLV_META_TYPE_UINT | 405
85
-
86
- TLV_TYPE_CIPHER_NAME = TLV_META_TYPE_STRING | 500
87
- TLV_TYPE_CIPHER_PARAMETERS = TLV_META_TYPE_GROUP | 501
88
-
89
- #
90
- # Core flags
91
- #
92
- LOAD_LIBRARY_FLAG_ON_DISK = (1 << 0)
93
- LOAD_LIBRARY_FLAG_EXTENSION = (1 << 1)
94
- LOAD_LIBRARY_FLAG_LOCAL = (1 << 2)
95
-
96
- ###
97
- #
98
- # Base TLV (Type-Length-Value) class
99
- #
100
- ###
101
- class Tlv
102
- attr_accessor :type, :value, :compress
103
-
104
- ##
105
- #
106
- # Constructor
107
- #
108
- ##
109
-
110
- #
111
- # Returns an instance of a TLV.
112
- #
113
- def initialize(type, value = nil, compress=false)
114
- @type = type
115
- @compress = compress
116
-
117
- if (value != nil)
118
- if (type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)
119
- if (value.kind_of?(Fixnum))
120
- @value = value.to_s
121
- else
122
- @value = value.dup
123
- end
124
- else
125
- @value = value
126
- end
127
- end
128
- end
129
-
130
- def inspect
131
- utype = type ^ TLV_META_TYPE_COMPRESSED
132
- meta = case (utype & TLV_META_MASK)
133
- when TLV_META_TYPE_STRING; "STRING"
134
- when TLV_META_TYPE_UINT; "INT"
135
- when TLV_META_TYPE_RAW; "RAW"
136
- when TLV_META_TYPE_BOOL; "BOOL"
137
- when TLV_META_TYPE_QWORD; "QWORD"
138
- when TLV_META_TYPE_GROUP; "GROUP"
139
- when TLV_META_TYPE_COMPLEX; "COMPLEX"
140
- else; 'unknown-meta-type'
141
- end
142
- stype = case type
143
- when PACKET_TYPE_REQUEST; "Request"
144
- when PACKET_TYPE_RESPONSE; "Response"
145
- when TLV_TYPE_REQUEST_ID; "REQUEST-ID"
146
- when TLV_TYPE_METHOD; "METHOD"
147
- when TLV_TYPE_RESULT; "RESULT"
148
- when TLV_TYPE_EXCEPTION; "EXCEPTION"
149
- when TLV_TYPE_STRING; "STRING"
150
- when TLV_TYPE_UINT; "UINT"
151
- when TLV_TYPE_BOOL; "BOOL"
152
-
153
- when TLV_TYPE_LENGTH; "LENGTH"
154
- when TLV_TYPE_DATA; "DATA"
155
- when TLV_TYPE_FLAGS; "FLAGS"
156
-
157
- when TLV_TYPE_CHANNEL_ID; "CHANNEL-ID"
158
- when TLV_TYPE_CHANNEL_TYPE; "CHANNEL-TYPE"
159
- when TLV_TYPE_CHANNEL_DATA; "CHANNEL-DATA"
160
- when TLV_TYPE_CHANNEL_DATA_GROUP; "CHANNEL-DATA-GROUP"
161
- when TLV_TYPE_CHANNEL_CLASS; "CHANNEL-CLASS"
162
- when TLV_TYPE_CHANNEL_PARENTID; "CHANNEL-PARENTID"
163
-
164
- when TLV_TYPE_SEEK_WHENCE; "SEEK-WHENCE"
165
- when TLV_TYPE_SEEK_OFFSET; "SEEK-OFFSET"
166
- when TLV_TYPE_SEEK_POS; "SEEK-POS"
167
-
168
- when TLV_TYPE_EXCEPTION_CODE; "EXCEPTION-CODE"
169
- when TLV_TYPE_EXCEPTION_STRING; "EXCEPTION-STRING"
170
-
171
- when TLV_TYPE_LIBRARY_PATH; "LIBRARY-PATH"
172
- when TLV_TYPE_TARGET_PATH; "TARGET-PATH"
173
- when TLV_TYPE_MIGRATE_PID; "MIGRATE-PID"
174
- when TLV_TYPE_MIGRATE_LEN; "MIGRATE-LEN"
175
- when TLV_TYPE_MIGRATE_PAYLOAD; "MIGRATE-PAYLOAD"
176
- when TLV_TYPE_MIGRATE_ARCH; "MIGRATE-ARCH"
177
-
178
- # Extension classes don't exist yet, so can't use their constants
179
- # here.
180
- #when Extensions::Stdapi::TLV_TYPE_IP; 'ip-address'
181
- else; "unknown-#{type}"
182
- end
183
- val = value.inspect
184
- if val.length > 50
185
- val = val[0,50] + ' ..."'
186
- end
187
- "#<#{self.class} type=#{stype} #{self.class.to_s =~ /Packet/ ? "tlvs=#{@tlvs.inspect}" : "meta=#{meta} value=#{val}"} >"
188
- end
189
-
190
- ##
191
- #
192
- # Conditionals
193
- #
194
- ##
195
-
196
- #
197
- # Checks to see if a TLVs meta type is equivalent to the meta type passed.
198
- #
199
- def meta_type?(meta)
200
- return (self.type & meta == meta)
201
- end
202
-
203
- #
204
- # Checks to see if the TLVs type is equivalent to the type passed.
205
- #
206
- def type?(type)
207
- return self.type == type
208
- end
209
-
210
- #
211
- # Checks to see if the TLVs value is equivalent to the value passed.
212
- #
213
- def value?(value)
214
- return self.value == value
215
- end
216
-
217
- ##
218
- #
219
- # Serializers
220
- #
221
- ##
222
-
223
- #
224
- # Converts the TLV to raw.
225
- #
226
- def to_r
227
- raw = value.to_s;
228
-
229
- if (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)
230
- raw += "\x00"
231
- elsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)
232
- raw = [value].pack("N")
233
- elsif (self.type & TLV_META_TYPE_QWORD == TLV_META_TYPE_QWORD)
234
- raw = [ self.htonq( value.to_i ) ].pack("Q")
235
- elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)
236
- if (value == true)
237
- raw = [1].pack("c")
238
- else
239
- raw = [0].pack("c")
240
- end
241
- end
242
-
243
- # check if the tlv is to be compressed...
244
- if( @compress )
245
- raw_uncompressed = raw
246
- # compress the raw data
247
- raw_compressed = Rex::Text.zlib_deflate( raw_uncompressed )
248
- # check we have actually made the raw data smaller...
249
- # (small blobs often compress slightly larger then the origional)
250
- # if the compressed data is not smaller, we dont use the compressed data
251
- if( raw_compressed.length < raw_uncompressed.length )
252
- # if so, set the TLV's type to indicate compression is used
253
- self.type = self.type | TLV_META_TYPE_COMPRESSED
254
- # update the raw data with the uncompressed data length + compressed data
255
- # (we include the uncompressed data length as the C side will need to know this for decompression)
256
- raw = [ raw_uncompressed.length ].pack("N") + raw_compressed
257
- end
258
- end
259
-
260
- return [raw.length + 8, self.type].pack("NN") + raw
261
- end
262
-
263
- #
264
- # Translates the raw format of the TLV into a sanitize version.
265
- #
266
- def from_r(raw)
267
- self.value = nil
268
-
269
- length, self.type = raw.unpack("NN");
270
-
271
- # check if the tlv value has been compressed...
272
- if( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )
273
- # set this TLV as using compression
274
- @compress = true
275
- # remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the
276
- # tlv type to its origional, allowing for transparent data compression.
277
- self.type = self.type ^ TLV_META_TYPE_COMPRESSED
278
- # decompress the compressed data (skipping the length and type DWORD's)
279
- raw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )
280
- # update the length to reflect the decompressed data length (+8 for the length and type DWORD's)
281
- length = raw_decompressed.length + 8
282
- # update the raw buffer with the new length, decompressed data and updated type.
283
- raw = [length, self.type].pack("NN") + raw_decompressed
284
- end
285
-
286
- if (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)
287
- if (raw.length > 0)
288
- self.value = raw[8..length-2]
289
- else
290
- self.value = nil
291
- end
292
- elsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)
293
- self.value = raw.unpack("NNN")[2]
294
- elsif (self.type & TLV_META_TYPE_QWORD == TLV_META_TYPE_QWORD)
295
- self.value = raw.unpack("NNQ")[2]
296
- self.value = self.ntohq( self.value )
297
- elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)
298
- self.value = raw.unpack("NNc")[2]
299
-
300
- if (self.value == 1)
301
- self.value = true
302
- else
303
- self.value = false
304
- end
305
- else
306
- self.value = raw[8..length-1]
307
- end
308
-
309
- return length;
310
- end
311
-
312
- protected
313
-
314
- def htonq( value )
315
- if( [1].pack( 's' ) == [1].pack( 'n' ) )
316
- return value
317
- end
318
- return [ value ].pack( 'Q' ).reverse.unpack( 'Q' ).first
319
- end
320
-
321
- def ntohq( value )
322
- return htonq( value )
323
- end
324
-
325
- end
326
-
327
- ###
328
- #
329
- # Group TLVs contain zero or more TLVs
330
- #
331
- ###
332
- class GroupTlv < Tlv
333
- attr_accessor :tlvs
334
-
335
- ##
336
- #
337
- # Constructor
338
- #
339
- ##
340
-
341
- #
342
- # Initializes the group TLV container to the supplied type
343
- # and creates an empty TLV array.
344
- #
345
- def initialize(type)
346
- super(type)
347
-
348
- self.tlvs = [ ]
349
- end
350
-
351
- ##
352
- #
353
- # Group-based TLV accessors
354
- #
355
- ##
356
-
357
- #
358
- # Enumerates TLVs of the supplied type.
359
- #
360
- def each(type = TLV_TYPE_ANY, &block)
361
- get_tlvs(type).each(&block)
362
- end
363
-
364
- #
365
- # Synonym for each.
366
- #
367
- def each_tlv(type = TLV_TYPE_ANY, &block)
368
- each(type, block)
369
- end
370
-
371
- #
372
- # Enumerates TLVs of a supplied type with indexes.
373
- #
374
- def each_with_index(type = TLV_TYPE_ANY, &block)
375
- get_tlvs(type).each_with_index(&block)
376
- end
377
-
378
- #
379
- # Synonym for each_with_index.
380
- #
381
- def each_tlv_with_index(type = TLV_TYPE_ANY, &block)
382
- each_with_index(type, block)
383
- end
384
-
385
- #
386
- # Returns an array of TLVs for the given type.
387
- #
388
- def get_tlvs(type)
389
- if (type == TLV_TYPE_ANY)
390
- return self.tlvs
391
- else
392
- type_tlvs = []
393
-
394
- self.tlvs.each() { |tlv|
395
- if (tlv.type?(type))
396
- type_tlvs << tlv
397
- end
398
- }
399
-
400
- return type_tlvs
401
- end
402
- end
403
-
404
- ##
405
- #
406
- # TLV management
407
- #
408
- ##
409
-
410
- #
411
- # Adds a TLV of a given type and value.
412
- #
413
- def add_tlv(type, value = nil, replace = false, compress=false)
414
-
415
- # If we should replace any TLVs with the same type...remove them first
416
- if (replace)
417
- each(type) { |tlv|
418
- if (tlv.type == type)
419
- self.tlvs.delete(tlv)
420
- end
421
- }
422
- end
423
-
424
- if (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)
425
- tlv = GroupTlv.new(type)
426
- else
427
- tlv = Tlv.new(type, value, compress)
428
- end
429
-
430
- self.tlvs << tlv
431
-
432
- return tlv
433
- end
434
-
435
- #
436
- # Adds zero or more TLVs to the packet.
437
- #
438
- def add_tlvs(tlvs)
439
- if (tlvs != nil)
440
- tlvs.each { |tlv|
441
- add_tlv(tlv['type'], tlv['value'])
442
- }
443
- end
444
- end
445
-
446
- #
447
- # Gets the first TLV of a given type.
448
- #
449
- def get_tlv(type, index = 0)
450
- type_tlvs = get_tlvs(type)
451
-
452
- if (type_tlvs.length > index)
453
- return type_tlvs[index]
454
- end
455
-
456
- return nil
457
- end
458
-
459
- #
460
- # Returns the value of a TLV if it exists, otherwise nil.
461
- #
462
- def get_tlv_value(type, index = 0)
463
- tlv = get_tlv(type, index)
464
-
465
- return (tlv != nil) ? tlv.value : nil
466
- end
467
-
468
- #
469
- # Returns an array of values for all tlvs of type type.
470
- #
471
- def get_tlv_values(type)
472
- get_tlvs(type).collect { |a| a.value }
473
- end
474
-
475
- #
476
- # Checks to see if the container has a TLV of a given type.
477
- #
478
- def has_tlv?(type)
479
- return get_tlv(type) != nil
480
- end
481
-
482
- #
483
- # Zeros out the array of TLVs.
484
- #
485
- def reset
486
- self.tlvs = []
487
- end
488
-
489
- ##
490
- #
491
- # Serializers
492
- #
493
- ##
494
-
495
- #
496
- # Converts all of the TLVs in the TLV array to raw and prefixes them
497
- # with a container TLV of this instance's TLV type.
498
- #
499
- def to_r
500
- raw = ''
501
-
502
- self.each() { |tlv|
503
- raw << tlv.to_r
504
- }
505
-
506
- return [raw.length + 8, self.type].pack("NN") + raw
507
- end
508
-
509
- #
510
- # Converts the TLV group container from raw to all of the individual
511
- # TLVs.
512
- #
513
- def from_r(raw)
514
- offset = 8
515
-
516
- # Reset the TLVs array
517
- self.tlvs = []
518
- self.type = raw.unpack("NN")[1]
519
-
520
- # Enumerate all of the TLVs
521
- while (offset < raw.length-1)
522
-
523
- tlv = nil
524
-
525
- # Get the length and type
526
- length, type = raw[offset..offset+8].unpack("NN")
527
-
528
- if (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)
529
- tlv = GroupTlv.new(type)
530
- else
531
- tlv = Tlv.new(type)
532
- end
533
-
534
- tlv.from_r(raw[offset..offset+length])
535
-
536
- # Insert it into the list of TLVs
537
- tlvs << tlv
538
-
539
- # Move up
540
- offset += length
541
- end
542
- end
543
-
544
- end
545
-
546
- ###
547
- #
548
- # The logical meterpreter packet class
549
- #
550
- ###
551
- class Packet < GroupTlv
552
- attr_accessor :created_at
553
-
554
- ##
555
- #
556
- # Factory
557
- #
558
- ##
559
-
560
- #
561
- # Creates a request with the supplied method.
562
- #
563
- def Packet.create_request(method = nil)
564
- return Packet.new(PACKET_TYPE_REQUEST, method)
565
- end
566
-
567
- #
568
- # Creates a response to a request if one is provided.
569
- #
570
- def Packet.create_response(request = nil)
571
- response_type = PACKET_TYPE_RESPONSE
572
- method = nil
573
-
574
- if (request)
575
- if (request.type?(PACKET_TYPE_PLAIN_REQUEST))
576
- response_type = PACKET_TYPE_PLAIN_RESPONSE
577
- end
578
-
579
- method = request.method
580
- end
581
-
582
- return Packet.new(response_type, method)
583
- end
584
-
585
- ##
586
- #
587
- # Constructor
588
- #
589
- ##
590
-
591
- #
592
- # Initializes the packet to the supplied packet type and method,
593
- # if any. If the packet is a request, a request identifier is
594
- # created.
595
- #
596
- def initialize(type = nil, method = nil)
597
- super(type)
598
-
599
- if (method)
600
- self.method = method
601
- end
602
-
603
- self.created_at = ::Time.now
604
-
605
- # If it's a request, generate a random request identifier
606
- if ((type == PACKET_TYPE_REQUEST) ||
607
- (type == PACKET_TYPE_PLAIN_REQUEST))
608
- rid = ''
609
-
610
- 32.times { |val| rid << rand(10).to_s }
611
-
612
- add_tlv(TLV_TYPE_REQUEST_ID, rid)
613
- end
614
- end
615
-
616
- ##
617
- #
618
- # Conditionals
619
- #
620
- ##
621
-
622
- #
623
- # Checks to see if the packet is a response.
624
- #
625
- def response?
626
- return ((self.type == PACKET_TYPE_RESPONSE) ||
627
- (self.type == PACKET_TYPE_PLAIN_RESPONSE))
628
- end
629
-
630
- ##
631
- #
632
- # Accessors
633
- #
634
- ##
635
-
636
- #
637
- # Checks to see if the packet's method is equal to the supplied method.
638
- #
639
- def method?(method)
640
- return (get_tlv_value(TLV_TYPE_METHOD) == method)
641
- end
642
-
643
- #
644
- # Sets the packet's method TLV to the method supplied.
645
- #
646
- def method=(method)
647
- add_tlv(TLV_TYPE_METHOD, method, true)
648
- end
649
-
650
- #
651
- # Returns the value of the packet's method TLV.
652
- #
653
- def method
654
- return get_tlv_value(TLV_TYPE_METHOD)
655
- end
656
-
657
- #
658
- # Checks to see if the packet's result value is equal to the supplied
659
- # result.
660
- #
661
- def result?(result)
662
- return (get_tlv_value(TLV_TYPE_RESULT) == result)
663
- end
664
-
665
- #
666
- # Sets the packet's result TLV.
667
- #
668
- def result=(result)
669
- add_tlv(TLV_TYPE_RESULT, result, true)
670
- end
671
-
672
- #
673
- # Gets the value of the packet's result TLV.
674
- #
675
- def result
676
- return get_tlv_value(TLV_TYPE_RESULT)
677
- end
678
-
679
- #
680
- # Gets the value of the packet's request identifier TLV.
681
- #
682
- def rid
683
- return get_tlv_value(TLV_TYPE_REQUEST_ID)
684
- end
685
- end
686
-
687
- end; end; end
688
-