librex 0.0.68 → 0.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (528) hide show
  1. checksums.yaml +15 -0
  2. data/README.markdown +1 -1
  3. data/Rakefile +18 -16
  4. data/lib/rex.rb +14 -10
  5. data/lib/rex/LICENSE +2 -2
  6. data/lib/rex/arch.rb +76 -76
  7. data/lib/rex/arch/sparc.rb +57 -58
  8. data/lib/rex/arch/x86.rb +506 -496
  9. data/lib/rex/assembly/nasm.rb +83 -84
  10. data/lib/rex/compat.rb +228 -173
  11. data/lib/rex/constants.rb +47 -37
  12. data/lib/rex/elfparsey.rb +0 -3
  13. data/lib/rex/elfparsey/elf.rb +107 -110
  14. data/lib/rex/elfparsey/elfbase.rb +244 -247
  15. data/lib/rex/elfparsey/exceptions.rb +0 -3
  16. data/lib/rex/elfscan.rb +0 -3
  17. data/lib/rex/elfscan/scanner.rb +184 -166
  18. data/lib/rex/elfscan/search.rb +35 -38
  19. data/lib/rex/encoder/alpha2.rb +1 -2
  20. data/lib/rex/encoder/alpha2/alpha_mixed.rb +52 -53
  21. data/lib/rex/encoder/alpha2/alpha_upper.rb +62 -63
  22. data/lib/rex/encoder/alpha2/generic.rb +77 -78
  23. data/lib/rex/encoder/alpha2/unicode_mixed.rb +101 -97
  24. data/lib/rex/encoder/alpha2/unicode_upper.rb +106 -107
  25. data/lib/rex/encoder/bloxor/bloxor.rb +326 -0
  26. data/lib/rex/encoder/ndr.rb +68 -68
  27. data/lib/rex/encoder/nonalpha.rb +50 -51
  28. data/lib/rex/encoder/nonupper.rb +50 -51
  29. data/lib/rex/encoder/xdr.rb +78 -78
  30. data/lib/rex/encoder/xor.rb +52 -53
  31. data/lib/rex/encoder/xor/dword.rb +1 -2
  32. data/lib/rex/encoder/xor/dword_additive.rb +1 -2
  33. data/lib/rex/encoders/xor_dword.rb +17 -18
  34. data/lib/rex/encoders/xor_dword_additive.rb +35 -36
  35. data/lib/rex/encoding/xor.rb +0 -1
  36. data/lib/rex/encoding/xor/byte.rb +3 -4
  37. data/lib/rex/encoding/xor/dword.rb +3 -4
  38. data/lib/rex/encoding/xor/dword_additive.rb +72 -73
  39. data/lib/rex/encoding/xor/exceptions.rb +2 -3
  40. data/lib/rex/encoding/xor/generic.rb +129 -130
  41. data/lib/rex/encoding/xor/qword.rb +3 -4
  42. data/lib/rex/encoding/xor/word.rb +3 -4
  43. data/lib/rex/exceptions.rb +100 -101
  44. data/lib/rex/exploitation/cmdstager.rb +3 -3
  45. data/lib/rex/exploitation/cmdstager/base.rb +170 -156
  46. data/lib/rex/exploitation/cmdstager/bourne.rb +105 -0
  47. data/lib/rex/exploitation/cmdstager/debug_asm.rb +110 -113
  48. data/lib/rex/exploitation/cmdstager/debug_write.rb +106 -109
  49. data/lib/rex/exploitation/cmdstager/echo.rb +164 -0
  50. data/lib/rex/exploitation/cmdstager/printf.rb +122 -0
  51. data/lib/rex/exploitation/cmdstager/tftp.rb +34 -27
  52. data/lib/rex/exploitation/cmdstager/vbs.rb +95 -98
  53. data/lib/rex/exploitation/egghunter.rb +359 -346
  54. data/lib/rex/exploitation/encryptjs.rb +60 -60
  55. data/lib/rex/exploitation/heaplib.rb +76 -76
  56. data/lib/rex/exploitation/js.rb +6 -0
  57. data/lib/rex/exploitation/js/detect.rb +69 -0
  58. data/lib/rex/exploitation/js/memory.rb +81 -0
  59. data/lib/rex/exploitation/js/network.rb +84 -0
  60. data/lib/rex/exploitation/js/utils.rb +33 -0
  61. data/lib/rex/exploitation/jsobfu.rb +448 -424
  62. data/lib/rex/exploitation/obfuscatejs.rb +301 -301
  63. data/lib/rex/exploitation/omelet.rb +257 -257
  64. data/lib/rex/exploitation/opcodedb.rb +699 -699
  65. data/lib/rex/exploitation/ropdb.rb +189 -0
  66. data/lib/rex/exploitation/seh.rb +68 -68
  67. data/lib/rex/file.rb +96 -49
  68. data/lib/rex/image_source.rb +0 -3
  69. data/lib/rex/image_source/disk.rb +45 -48
  70. data/lib/rex/image_source/image_source.rb +33 -36
  71. data/lib/rex/image_source/memory.rb +17 -20
  72. data/lib/rex/io/bidirectional_pipe.rb +118 -115
  73. data/lib/rex/io/datagram_abstraction.rb +13 -14
  74. data/lib/rex/io/ring_buffer.rb +273 -273
  75. data/lib/rex/io/stream.rb +284 -284
  76. data/lib/rex/io/stream_abstraction.rb +183 -181
  77. data/lib/rex/io/stream_server.rb +193 -193
  78. data/lib/rex/job_container.rb +167 -167
  79. data/lib/rex/logging.rb +0 -1
  80. data/lib/rex/logging/log_dispatcher.rb +113 -113
  81. data/lib/rex/logging/log_sink.rb +17 -17
  82. data/lib/rex/logging/sinks/flatfile.rb +36 -36
  83. data/lib/rex/logging/sinks/stderr.rb +27 -27
  84. data/lib/rex/mac_oui.rb +16572 -16571
  85. data/lib/rex/machparsey.rb +0 -1
  86. data/lib/rex/machparsey/exceptions.rb +0 -1
  87. data/lib/rex/machparsey/mach.rb +160 -161
  88. data/lib/rex/machparsey/machbase.rb +367 -368
  89. data/lib/rex/machscan.rb +0 -1
  90. data/lib/rex/machscan/scanner.rb +175 -176
  91. data/lib/rex/mime/encoding.rb +17 -0
  92. data/lib/rex/mime/header.rb +58 -58
  93. data/lib/rex/mime/message.rb +140 -137
  94. data/lib/rex/mime/part.rb +41 -12
  95. data/lib/rex/nop/opty2.rb +90 -90
  96. data/lib/rex/nop/opty2_tables.rb +273 -273
  97. data/lib/rex/ole.rb +0 -4
  98. data/lib/rex/ole/clsid.rb +26 -30
  99. data/lib/rex/ole/difat.rb +121 -125
  100. data/lib/rex/ole/directory.rb +205 -209
  101. data/lib/rex/ole/direntry.rb +217 -221
  102. data/lib/rex/ole/fat.rb +79 -83
  103. data/lib/rex/ole/header.rb +178 -182
  104. data/lib/rex/ole/minifat.rb +49 -53
  105. data/lib/rex/ole/propset.rb +113 -117
  106. data/lib/rex/ole/samples/create_ole.rb +8 -9
  107. data/lib/rex/ole/samples/dir.rb +10 -11
  108. data/lib/rex/ole/samples/dump_stream.rb +14 -15
  109. data/lib/rex/ole/samples/ole_info.rb +5 -6
  110. data/lib/rex/ole/storage.rb +372 -376
  111. data/lib/rex/ole/stream.rb +33 -37
  112. data/lib/rex/ole/substorage.rb +20 -24
  113. data/lib/rex/ole/util.rb +137 -141
  114. data/lib/rex/parser/acunetix_nokogiri.rb +398 -398
  115. data/lib/rex/parser/apple_backup_manifestdb.rb +116 -116
  116. data/lib/rex/parser/appscan_nokogiri.rb +359 -359
  117. data/lib/rex/parser/arguments.rb +88 -88
  118. data/lib/rex/parser/burp_session_nokogiri.rb +258 -258
  119. data/lib/rex/parser/ci_nokogiri.rb +184 -184
  120. data/lib/rex/parser/foundstone_nokogiri.rb +334 -333
  121. data/lib/rex/parser/fusionvm_nokogiri.rb +94 -94
  122. data/lib/rex/parser/ini.rb +167 -167
  123. data/lib/rex/parser/ip360_aspl_xml.rb +84 -84
  124. data/lib/rex/parser/ip360_xml.rb +77 -77
  125. data/lib/rex/parser/mbsa_nokogiri.rb +224 -224
  126. data/lib/rex/parser/nessus_xml.rb +100 -100
  127. data/lib/rex/parser/netsparker_xml.rb +89 -75
  128. data/lib/rex/parser/nexpose_raw_nokogiri.rb +677 -677
  129. data/lib/rex/parser/nexpose_simple_nokogiri.rb +322 -322
  130. data/lib/rex/parser/nexpose_xml.rb +105 -105
  131. data/lib/rex/parser/nmap_nokogiri.rb +386 -386
  132. data/lib/rex/parser/nmap_xml.rb +116 -116
  133. data/lib/rex/parser/nokogiri_doc_mixin.rb +223 -221
  134. data/lib/rex/parser/openvas_nokogiri.rb +162 -162
  135. data/lib/rex/parser/outpost24_nokogiri.rb +239 -0
  136. data/lib/rex/parser/retina_xml.rb +90 -90
  137. data/lib/rex/parser/unattend.rb +171 -0
  138. data/lib/rex/parser/wapiti_nokogiri.rb +89 -89
  139. data/lib/rex/payloads/win32/common.rb +14 -14
  140. data/lib/rex/payloads/win32/kernel.rb +36 -36
  141. data/lib/rex/payloads/win32/kernel/common.rb +32 -32
  142. data/lib/rex/payloads/win32/kernel/recovery.rb +27 -27
  143. data/lib/rex/payloads/win32/kernel/stager.rb +170 -170
  144. data/lib/rex/peparsey.rb +0 -3
  145. data/lib/rex/peparsey/exceptions.rb +0 -3
  146. data/lib/rex/peparsey/pe.rb +196 -199
  147. data/lib/rex/peparsey/pe_memdump.rb +35 -38
  148. data/lib/rex/peparsey/pebase.rb +1633 -1652
  149. data/lib/rex/peparsey/section.rb +115 -124
  150. data/lib/rex/pescan.rb +0 -3
  151. data/lib/rex/pescan/analyze.rb +351 -351
  152. data/lib/rex/pescan/scanner.rb +182 -182
  153. data/lib/rex/pescan/search.rb +59 -59
  154. data/lib/rex/platforms/windows.rb +37 -37
  155. data/lib/rex/poly.rb +111 -110
  156. data/lib/rex/poly/block.rb +419 -417
  157. data/lib/rex/poly/machine.rb +12 -0
  158. data/lib/rex/poly/machine/machine.rb +829 -0
  159. data/lib/rex/poly/machine/x86.rb +508 -0
  160. data/lib/rex/poly/register.rb +70 -70
  161. data/lib/rex/poly/register/x86.rb +22 -22
  162. data/lib/rex/post.rb +0 -1
  163. data/lib/rex/post/dir.rb +35 -36
  164. data/lib/rex/post/file.rb +140 -141
  165. data/lib/rex/post/file_stat.rb +198 -199
  166. data/lib/rex/post/io.rb +167 -168
  167. data/lib/rex/post/meterpreter.rb +1 -1
  168. data/lib/rex/post/meterpreter/channel.rb +389 -390
  169. data/lib/rex/post/meterpreter/channel_container.rb +33 -34
  170. data/lib/rex/post/meterpreter/channels/pool.rb +129 -130
  171. data/lib/rex/post/meterpreter/channels/pools/file.rb +35 -36
  172. data/lib/rex/post/meterpreter/channels/pools/stream_pool.rb +72 -73
  173. data/lib/rex/post/meterpreter/channels/stream.rb +62 -63
  174. data/lib/rex/post/meterpreter/client.rb +442 -436
  175. data/lib/rex/post/meterpreter/client_core.rb +326 -310
  176. data/lib/rex/post/meterpreter/dependencies.rb +0 -1
  177. data/lib/rex/post/meterpreter/extension.rb +12 -13
  178. data/lib/rex/post/meterpreter/extensions/espia/espia.rb +35 -36
  179. data/lib/rex/post/meterpreter/extensions/extapi/adsi/adsi.rb +71 -0
  180. data/lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb +169 -0
  181. data/lib/rex/post/meterpreter/extensions/extapi/extapi.rb +45 -0
  182. data/lib/rex/post/meterpreter/extensions/extapi/service/service.rb +104 -0
  183. data/lib/rex/post/meterpreter/extensions/extapi/tlv.rb +77 -0
  184. data/lib/rex/post/meterpreter/extensions/extapi/window/window.rb +56 -0
  185. data/lib/rex/post/meterpreter/extensions/extapi/wmi/wmi.rb +75 -0
  186. data/lib/rex/post/meterpreter/extensions/incognito/incognito.rb +70 -71
  187. data/lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb +361 -0
  188. data/lib/rex/post/meterpreter/extensions/kiwi/tlv.rb +76 -0
  189. data/lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb +78 -0
  190. data/lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb +22 -78
  191. data/lib/rex/post/meterpreter/extensions/lanattacks/tftp/tftp.rb +49 -0
  192. data/lib/rex/post/meterpreter/extensions/lanattacks/tlv.rb +4 -4
  193. data/lib/rex/post/meterpreter/extensions/mimikatz/mimikatz.rb +128 -0
  194. data/lib/rex/post/meterpreter/extensions/mimikatz/tlv.rb +16 -0
  195. data/lib/rex/post/meterpreter/extensions/networkpug/networkpug.rb +38 -39
  196. data/lib/rex/post/meterpreter/extensions/networkpug/tlv.rb +1 -1
  197. data/lib/rex/post/meterpreter/extensions/priv/fs.rb +95 -96
  198. data/lib/rex/post/meterpreter/extensions/priv/passwd.rb +39 -40
  199. data/lib/rex/post/meterpreter/extensions/priv/priv.rb +80 -85
  200. data/lib/rex/post/meterpreter/extensions/sniffer/sniffer.rb +94 -95
  201. data/lib/rex/post/meterpreter/extensions/stdapi/constants.rb +207 -147
  202. data/lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb +258 -259
  203. data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +366 -301
  204. data/lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb +72 -73
  205. data/lib/rex/post/meterpreter/extensions/stdapi/fs/io.rb +24 -25
  206. data/lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb +59 -0
  207. data/lib/rex/post/meterpreter/extensions/stdapi/net/config.rb +227 -149
  208. data/lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb +107 -108
  209. data/lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb +97 -0
  210. data/lib/rex/post/meterpreter/extensions/stdapi/net/resolve.rb +106 -0
  211. data/lib/rex/post/meterpreter/extensions/stdapi/net/route.rb +41 -42
  212. data/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb +102 -101
  213. data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb +151 -152
  214. data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_server_channel.rb +142 -142
  215. data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb +185 -185
  216. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb +38118 -38117
  217. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb +7 -7
  218. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_advapi32.rb +2086 -2084
  219. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_crypt32.rb +15 -15
  220. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_iphlpapi.rb +80 -80
  221. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb +3835 -3833
  222. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_netapi32.rb +84 -28
  223. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ntdll.rb +151 -137
  224. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_shell32.rb +15 -6
  225. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_user32.rb +3155 -3155
  226. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_version.rb +41 -0
  227. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_wlanapi.rb +70 -70
  228. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_wldap32.rb +128 -0
  229. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ws2_32.rb +596 -596
  230. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb +310 -301
  231. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb +71 -61
  232. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb +100 -100
  233. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_wrapper.rb +14 -14
  234. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/mock_magic.rb +488 -488
  235. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/multicall.rb +273 -264
  236. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/platform_util.rb +5 -5
  237. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb +240 -238
  238. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/tlv.rb +17 -15
  239. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb +61 -61
  240. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/util.rb +654 -635
  241. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb +49 -49
  242. data/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb +103 -102
  243. data/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +98 -68
  244. data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log.rb +165 -166
  245. data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log_subsystem/event_record.rb +16 -17
  246. data/lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb +34 -36
  247. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb +363 -364
  248. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/image.rb +102 -103
  249. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/io.rb +28 -29
  250. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/memory.rb +303 -304
  251. data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/thread.rb +113 -114
  252. data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry.rb +260 -261
  253. data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_key.rb +165 -166
  254. data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb +69 -70
  255. data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb +160 -161
  256. data/lib/rex/post/meterpreter/extensions/stdapi/sys/thread.rb +143 -144
  257. data/lib/rex/post/meterpreter/extensions/stdapi/tlv.rb +29 -12
  258. data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +230 -231
  259. data/lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb +181 -44
  260. data/lib/rex/post/meterpreter/inbound_packet_handler.rb +12 -13
  261. data/lib/rex/post/meterpreter/object_aliases.rb +56 -57
  262. data/lib/rex/post/meterpreter/packet.rb +591 -592
  263. data/lib/rex/post/meterpreter/packet_dispatcher.rb +506 -496
  264. data/lib/rex/post/meterpreter/packet_parser.rb +72 -73
  265. data/lib/rex/post/meterpreter/packet_response_waiter.rb +56 -57
  266. data/lib/rex/post/meterpreter/ui/console.rb +112 -112
  267. data/lib/rex/post/meterpreter/ui/console/command_dispatcher.rb +53 -53
  268. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +911 -854
  269. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/espia.rb +86 -86
  270. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi.rb +65 -0
  271. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/adsi.rb +198 -0
  272. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/clipboard.rb +444 -0
  273. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb +199 -0
  274. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/window.rb +118 -0
  275. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/wmi.rb +108 -0
  276. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/incognito.rb +220 -220
  277. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/kiwi.rb +509 -0
  278. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks.rb +60 -0
  279. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb +254 -0
  280. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb +159 -0
  281. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/mimikatz.rb +182 -0
  282. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/networkpug.rb +173 -173
  283. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv.rb +40 -40
  284. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/elevate.rb +75 -77
  285. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/passwd.rb +30 -30
  286. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb +105 -105
  287. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/sniffer.rb +182 -182
  288. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi.rb +37 -37
  289. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +504 -482
  290. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +401 -330
  291. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +883 -581
  292. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +296 -299
  293. data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb +320 -153
  294. data/lib/rex/post/meterpreter/ui/console/interactive_channel.rb +78 -78
  295. data/lib/rex/post/permission.rb +0 -1
  296. data/lib/rex/post/process.rb +39 -40
  297. data/lib/rex/post/thread.rb +41 -42
  298. data/lib/rex/post/ui.rb +35 -36
  299. data/lib/rex/proto/addp.rb +218 -0
  300. data/lib/rex/proto/dcerpc/client.rb +344 -344
  301. data/lib/rex/proto/dcerpc/exceptions.rb +128 -128
  302. data/lib/rex/proto/dcerpc/handle.rb +32 -32
  303. data/lib/rex/proto/dcerpc/ndr.rb +56 -56
  304. data/lib/rex/proto/dcerpc/packet.rb +249 -245
  305. data/lib/rex/proto/dcerpc/response.rb +170 -170
  306. data/lib/rex/proto/dcerpc/uuid.rb +65 -65
  307. data/lib/rex/proto/dcerpc/wdscp.rb +3 -0
  308. data/lib/rex/proto/dcerpc/wdscp/constants.rb +89 -0
  309. data/lib/rex/proto/dcerpc/wdscp/packet.rb +94 -0
  310. data/lib/rex/proto/dhcp.rb +0 -1
  311. data/lib/rex/proto/dhcp/constants.rb +0 -1
  312. data/lib/rex/proto/dhcp/server.rb +303 -304
  313. data/lib/rex/proto/drda/constants.rb +1 -1
  314. data/lib/rex/proto/drda/packet.rb +186 -186
  315. data/lib/rex/proto/drda/utils.rb +104 -104
  316. data/lib/rex/proto/http.rb +1 -0
  317. data/lib/rex/proto/http/client.rb +692 -820
  318. data/lib/rex/proto/http/client_request.rb +472 -0
  319. data/lib/rex/proto/http/handler.rb +25 -25
  320. data/lib/rex/proto/http/handler/erb.rb +104 -104
  321. data/lib/rex/proto/http/handler/proc.rb +37 -37
  322. data/lib/rex/proto/http/header.rb +149 -149
  323. data/lib/rex/proto/http/packet.rb +388 -382
  324. data/lib/rex/proto/http/request.rb +332 -335
  325. data/lib/rex/proto/http/response.rb +132 -72
  326. data/lib/rex/proto/http/server.rb +348 -338
  327. data/lib/rex/proto/iax2/call.rb +310 -310
  328. data/lib/rex/proto/iax2/client.rb +197 -197
  329. data/lib/rex/proto/iax2/codecs/alaw.rb +4 -4
  330. data/lib/rex/proto/iax2/codecs/mulaw.rb +4 -4
  331. data/lib/rex/proto/ipmi.rb +57 -0
  332. data/lib/rex/proto/ipmi/channel_auth_reply.rb +88 -0
  333. data/lib/rex/proto/ipmi/open_session_reply.rb +35 -0
  334. data/lib/rex/proto/ipmi/rakp2.rb +35 -0
  335. data/lib/rex/proto/ipmi/utils.rb +125 -0
  336. data/lib/rex/proto/natpmp.rb +1 -5
  337. data/lib/rex/proto/natpmp/constants.rb +4 -4
  338. data/lib/rex/proto/natpmp/packet.rb +25 -25
  339. data/lib/rex/proto/ntlm/base.rb +271 -271
  340. data/lib/rex/proto/ntlm/constants.rb +61 -61
  341. data/lib/rex/proto/ntlm/crypt.rb +348 -352
  342. data/lib/rex/proto/ntlm/exceptions.rb +3 -3
  343. data/lib/rex/proto/ntlm/message.rb +468 -471
  344. data/lib/rex/proto/ntlm/utils.rb +746 -746
  345. data/lib/rex/proto/pjl.rb +30 -0
  346. data/lib/rex/proto/pjl/client.rb +162 -0
  347. data/lib/rex/proto/proxy/socks4a.rb +440 -440
  348. data/lib/rex/proto/rfb.rb +1 -8
  349. data/lib/rex/proto/rfb/cipher.rb +46 -49
  350. data/lib/rex/proto/rfb/client.rb +179 -182
  351. data/lib/rex/proto/rfb/constants.rb +18 -21
  352. data/lib/rex/proto/smb/client.rb +1954 -1843
  353. data/lib/rex/proto/smb/constants.rb +533 -516
  354. data/lib/rex/proto/smb/crypt.rb +21 -21
  355. data/lib/rex/proto/smb/evasions.rb +43 -43
  356. data/lib/rex/proto/smb/exceptions.rb +791 -791
  357. data/lib/rex/proto/smb/simpleclient.rb +142 -286
  358. data/lib/rex/proto/smb/simpleclient/open_file.rb +106 -0
  359. data/lib/rex/proto/smb/simpleclient/open_pipe.rb +57 -0
  360. data/lib/rex/proto/smb/utils.rb +81 -81
  361. data/lib/rex/proto/sunrpc/client.rb +158 -158
  362. data/lib/rex/proto/tftp.rb +0 -1
  363. data/lib/rex/proto/tftp/client.rb +289 -289
  364. data/lib/rex/proto/tftp/constants.rb +9 -10
  365. data/lib/rex/proto/tftp/server.rb +466 -467
  366. data/lib/rex/random_identifier_generator.rb +176 -0
  367. data/lib/rex/registry.rb +1 -1
  368. data/lib/rex/registry/hive.rb +88 -88
  369. data/lib/rex/registry/lfkey.rb +25 -25
  370. data/lib/rex/registry/nodekey.rb +30 -30
  371. data/lib/rex/registry/regf.rb +10 -10
  372. data/lib/rex/registry/valuekey.rb +43 -43
  373. data/lib/rex/registry/valuelist.rb +13 -13
  374. data/lib/rex/ropbuilder/rop.rb +254 -253
  375. data/lib/rex/script.rb +21 -22
  376. data/lib/rex/script/base.rb +51 -50
  377. data/lib/rex/script/meterpreter.rb +2 -2
  378. data/lib/rex/service.rb +24 -24
  379. data/lib/rex/service_manager.rb +132 -132
  380. data/lib/rex/services/local_relay.rb +398 -398
  381. data/lib/rex/socket.rb +758 -763
  382. data/lib/rex/socket/comm.rb +95 -95
  383. data/lib/rex/socket/comm/local.rb +507 -440
  384. data/lib/rex/socket/ip.rb +118 -118
  385. data/lib/rex/socket/parameters.rb +351 -350
  386. data/lib/rex/socket/range_walker.rb +445 -368
  387. data/lib/rex/socket/ssl_tcp.rb +323 -317
  388. data/lib/rex/socket/ssl_tcp_server.rb +173 -158
  389. data/lib/rex/socket/subnet_walker.rb +48 -48
  390. data/lib/rex/socket/switch_board.rb +259 -259
  391. data/lib/rex/socket/tcp.rb +58 -56
  392. data/lib/rex/socket/tcp_server.rb +42 -42
  393. data/lib/rex/socket/udp.rb +152 -152
  394. data/lib/rex/sslscan/result.rb +200 -0
  395. data/lib/rex/sslscan/scanner.rb +205 -0
  396. data/lib/rex/struct2.rb +0 -1
  397. data/lib/rex/struct2/c_struct.rb +162 -163
  398. data/lib/rex/struct2/c_struct_template.rb +21 -22
  399. data/lib/rex/struct2/constant.rb +6 -7
  400. data/lib/rex/struct2/element.rb +30 -31
  401. data/lib/rex/struct2/generic.rb +60 -61
  402. data/lib/rex/struct2/restraint.rb +40 -41
  403. data/lib/rex/struct2/s_string.rb +60 -61
  404. data/lib/rex/struct2/s_struct.rb +97 -98
  405. data/lib/rex/sync.rb +0 -1
  406. data/lib/rex/sync/event.rb +62 -72
  407. data/lib/rex/sync/read_write_lock.rb +149 -149
  408. data/lib/rex/sync/ref.rb +42 -42
  409. data/lib/rex/sync/thread_safe.rb +59 -59
  410. data/lib/rex/text.rb +1803 -1315
  411. data/lib/rex/thread_factory.rb +25 -25
  412. data/lib/rex/time.rb +44 -44
  413. data/lib/rex/transformer.rb +91 -91
  414. data/lib/rex/ui/interactive.rb +265 -265
  415. data/lib/rex/ui/output.rb +66 -60
  416. data/lib/rex/ui/progress_tracker.rb +79 -79
  417. data/lib/rex/ui/subscriber.rb +144 -134
  418. data/lib/rex/ui/text/color.rb +76 -76
  419. data/lib/rex/ui/text/dispatcher_shell.rb +512 -505
  420. data/lib/rex/ui/text/input.rb +96 -96
  421. data/lib/rex/ui/text/input/buffer.rb +58 -58
  422. data/lib/rex/ui/text/input/readline.rb +114 -114
  423. data/lib/rex/ui/text/input/socket.rb +77 -77
  424. data/lib/rex/ui/text/input/stdio.rb +24 -24
  425. data/lib/rex/ui/text/irb_shell.rb +45 -41
  426. data/lib/rex/ui/text/output.rb +64 -60
  427. data/lib/rex/ui/text/output/buffer.rb +42 -42
  428. data/lib/rex/ui/text/output/buffer/stdout.rb +25 -0
  429. data/lib/rex/ui/text/output/file.rb +24 -24
  430. data/lib/rex/ui/text/output/socket.rb +24 -24
  431. data/lib/rex/ui/text/output/stdio.rb +29 -29
  432. data/lib/rex/ui/text/output/tee.rb +36 -36
  433. data/lib/rex/ui/text/progress_tracker.rb +37 -37
  434. data/lib/rex/ui/text/shell.rb +371 -361
  435. data/lib/rex/ui/text/table.rb +320 -284
  436. data/lib/rex/zip.rb +0 -1
  437. data/lib/rex/zip/archive.rb +115 -94
  438. data/lib/rex/zip/blocks.rb +101 -100
  439. data/lib/rex/zip/entry.rb +108 -99
  440. data/lib/rex/zip/jar.rb +261 -206
  441. data/lib/rex/zip/samples/comment.rb +1 -2
  442. data/lib/rex/zip/samples/mkwar.rb +12 -13
  443. data/lib/rex/zip/samples/mkzip.rb +1 -2
  444. data/lib/rex/zip/samples/recursive.rb +29 -30
  445. metadata +424 -446
  446. data/lib/rex/arch/sparc.rb.ut.rb +0 -19
  447. data/lib/rex/arch/x86.rb.ut.rb +0 -94
  448. data/lib/rex/assembly/nasm.rb.ut.rb +0 -23
  449. data/lib/rex/encoder/ndr.rb.ut.rb +0 -45
  450. data/lib/rex/encoder/xdr.rb.ut.rb +0 -30
  451. data/lib/rex/encoders/xor_dword_additive.rb.ut.rb +0 -13
  452. data/lib/rex/encoding/xor.rb.ts.rb +0 -15
  453. data/lib/rex/encoding/xor/byte.rb.ut.rb +0 -22
  454. data/lib/rex/encoding/xor/dword.rb.ut.rb +0 -16
  455. data/lib/rex/encoding/xor/dword_additive.rb.ut.rb +0 -16
  456. data/lib/rex/encoding/xor/generic.rb.ut.rb +0 -121
  457. data/lib/rex/encoding/xor/word.rb.ut.rb +0 -14
  458. data/lib/rex/exceptions.rb.ut.rb +0 -45
  459. data/lib/rex/exploitation/egghunter.rb.ut.rb +0 -28
  460. data/lib/rex/exploitation/javascriptosdetect.js +0 -1014
  461. data/lib/rex/exploitation/javascriptosdetect.rb +0 -43
  462. data/lib/rex/exploitation/omelet.rb.ut.rb +0 -27
  463. data/lib/rex/exploitation/opcodedb.rb.ut.rb +0 -280
  464. data/lib/rex/exploitation/seh.rb.ut.rb +0 -20
  465. data/lib/rex/file.rb.ut.rb +0 -17
  466. data/lib/rex/io/ring_buffer.rb.ut.rb +0 -135
  467. data/lib/rex/nop/opty2.rb.ut.rb +0 -24
  468. data/lib/rex/parser/arguments.rb.ut.rb +0 -68
  469. data/lib/rex/parser/ini.rb.ut.rb +0 -30
  470. data/lib/rex/post/meterpreter/extensions/stdapi/railgun.rb.ts.rb +0 -18
  471. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb.ut.rb +0 -39
  472. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb.ut.rb +0 -37
  473. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb.ut.rb +0 -52
  474. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb.ut.rb +0 -43
  475. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb.ut.rb +0 -128
  476. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_wrapper.rb.ut.rb +0 -64
  477. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/platform_util.rb.ut.rb +0 -29
  478. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb +0 -155
  479. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb.ut.rb +0 -128
  480. data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb.ut.rb +0 -124
  481. data/lib/rex/proto.rb.ts.rb +0 -9
  482. data/lib/rex/proto/dcerpc.rb.ts.rb +0 -10
  483. data/lib/rex/proto/dcerpc/client.rb.ut.rb +0 -492
  484. data/lib/rex/proto/dcerpc/handle.rb.ut.rb +0 -86
  485. data/lib/rex/proto/dcerpc/ndr.rb.ut.rb +0 -42
  486. data/lib/rex/proto/dcerpc/packet.rb.ut.rb +0 -57
  487. data/lib/rex/proto/dcerpc/response.rb.ut.rb +0 -16
  488. data/lib/rex/proto/dcerpc/uuid.rb.ut.rb +0 -47
  489. data/lib/rex/proto/drda.rb.ts.rb +0 -18
  490. data/lib/rex/proto/drda/constants.rb.ut.rb +0 -24
  491. data/lib/rex/proto/drda/packet.rb.ut.rb +0 -110
  492. data/lib/rex/proto/drda/utils.rb.ut.rb +0 -85
  493. data/lib/rex/proto/http.rb.ts.rb +0 -13
  494. data/lib/rex/proto/http/client.rb.ut.rb +0 -96
  495. data/lib/rex/proto/http/handler/erb.rb.ut.rb +0 -22
  496. data/lib/rex/proto/http/handler/erb.rb.ut.rb.rhtml +0 -1
  497. data/lib/rex/proto/http/handler/proc.rb.ut.rb +0 -25
  498. data/lib/rex/proto/http/header.rb.ut.rb +0 -47
  499. data/lib/rex/proto/http/packet.rb.ut.rb +0 -166
  500. data/lib/rex/proto/http/request.rb.ut.rb +0 -215
  501. data/lib/rex/proto/http/response.rb.ut.rb +0 -150
  502. data/lib/rex/proto/http/server.rb.ut.rb +0 -80
  503. data/lib/rex/proto/ntlm.rb.ut.rb +0 -181
  504. data/lib/rex/proto/rfb.rb.ut.rb +0 -40
  505. data/lib/rex/proto/smb.rb.ts.rb +0 -9
  506. data/lib/rex/proto/smb/client.rb.ut.rb +0 -224
  507. data/lib/rex/proto/smb/constants.rb.ut.rb +0 -19
  508. data/lib/rex/proto/smb/simpleclient.rb.ut.rb +0 -129
  509. data/lib/rex/proto/smb/utils.rb.ut.rb +0 -21
  510. data/lib/rex/proto/tftp/server.rb.ut.rb +0 -29
  511. data/lib/rex/service_manager.rb.ut.rb +0 -33
  512. data/lib/rex/socket.rb.ut.rb +0 -108
  513. data/lib/rex/socket/comm/local.rb.ut.rb +0 -76
  514. data/lib/rex/socket/parameters.rb.ut.rb +0 -52
  515. data/lib/rex/socket/range_walker.rb.ut.rb +0 -56
  516. data/lib/rex/socket/ssl_tcp.rb.ut.rb +0 -40
  517. data/lib/rex/socket/ssl_tcp_server.rb.ut.rb +0 -62
  518. data/lib/rex/socket/subnet_walker.rb.ut.rb +0 -29
  519. data/lib/rex/socket/switch_board.rb.ut.rb +0 -53
  520. data/lib/rex/socket/tcp.rb.ut.rb +0 -65
  521. data/lib/rex/socket/tcp_server.rb.ut.rb +0 -45
  522. data/lib/rex/socket/udp.rb.ut.rb +0 -45
  523. data/lib/rex/test.rb +0 -36
  524. data/lib/rex/text.rb.ut.rb +0 -193
  525. data/lib/rex/transformer.rb.ut.rb +0 -39
  526. data/lib/rex/ui/text/color.rb.ut.rb +0 -19
  527. data/lib/rex/ui/text/progress_tracker.rb.ut.rb +0 -35
  528. data/lib/rex/ui/text/table.rb.ut.rb +0 -56
@@ -147,21 +147,21 @@ NETBIOS_REDIR = 'CACACACACACACACACACACACACACACAAA'
147
147
 
148
148
 
149
149
 
150
- # 0 = open2
151
- # 1 = find_first
152
- # 2 = find_next
153
- # 3 = query_fs_info
154
- # 4 = set_fs_quota
155
- # 5 = query_path_info
156
- # 6 = set_path_info
157
- # 7 = query_file_info
158
- # 8 = set_file_info
159
- # 9 = fsctl
160
- # 10 = ioctl2
161
- # 11 = find_notify_first
162
- # 12 = find_notify_next
163
- # 13 = create_directory
164
- # 14 = session_setup
150
+ # 0 = open2
151
+ # 1 = find_first
152
+ # 2 = find_next
153
+ # 3 = query_fs_info
154
+ # 4 = set_fs_quota
155
+ # 5 = query_path_info
156
+ # 6 = set_path_info
157
+ # 7 = query_file_info
158
+ # 8 = set_file_info
159
+ # 9 = fsctl
160
+ # 10 = ioctl2
161
+ # 11 = find_notify_first
162
+ # 12 = find_notify_next
163
+ # 13 = create_directory
164
+ # 14 = session_setup
165
165
 
166
166
 
167
167
  # SMB_COM_TRANSACTION2 Commands
@@ -261,11 +261,28 @@ FILE_FILE_COMPRESSION = 0x00000008
261
261
  FILE_VOLUME_QUOTAS = 0x00000010
262
262
  FILE_VOLUME_IS_COMPRESSED = 0x00008000
263
263
 
264
+ # SMB_EXT_FILE_ATTR
265
+ # http://msdn.microsoft.com/en-us/library/ee878573(prot.20).aspx
266
+ SMB_EXT_FILE_ATTR_READONLY = 0x00000001
267
+ SMB_EXT_FILE_ATTR_HIDDEN = 0x00000002
268
+ SMB_EXT_FILE_ATTR_SYSTEM = 0x00000004
269
+ SMB_EXT_FILE_ATTR_DIRECTORY = 0x00000010
270
+ SMB_EXT_FILE_ATTR_ARCHIVE = 0x00000020
271
+ SMB_EXT_FILE_ATTR_NORMAL = 0x00000080
272
+ SMB_EXT_FILE_ATTR_TEMPORARY = 0x00000100
273
+ SMB_EXT_FILE_ATTR_COMPRESSED = 0x00000800
274
+ SMB_EXT_FILE_POSIX_SEMANTICS = 0x01000000
275
+ SMB_EXT_FILE_BACKUP_SEMANTICS = 0x02000000
276
+ SMB_EXT_FILE_DELETE_ON_CLOSE = 0x04000000
277
+ SMB_EXT_FILE_SEQUENTIAL_SCAN = 0x08000000
278
+ SMB_EXT_FILE_RANDOM_ACCESS = 0x10000000
279
+ SMB_EXT_FILE_NO_BUFFERING = 0x20000000
280
+ SMB_EXT_FILE_WRITE_THROUGH = 0x80000000
264
281
 
265
282
  # SMB Error Codes
266
283
  SMB_STATUS_SUCCESS = 0x00000000
267
284
  SMB_ERROR_BUFFER_OVERFLOW = 0x80000005
268
- SMB_STATUS_MORE_PROCESSING_REQUIRED = 0xC0000016
285
+ SMB_STATUS_MORE_PROCESSING_REQUIRED = 0xC0000016
269
286
  SMB_STATUS_ACCESS_DENIED = 0xC0000022
270
287
  SMB_STATUS_LOGON_FAILURE = 0xC000006D
271
288
 
@@ -273,157 +290,157 @@ SMB_STATUS_LOGON_FAILURE = 0xC000006D
273
290
  DIALECT = {}
274
291
 
275
292
  DIALECT['PC NETWORK PROGRAM 1.0'] = [
276
- SMB_COM_CHECK_DIRECTORY,
277
- SMB_COM_CLOSE,
278
- SMB_COM_CLOSE_PRINT_FILE,
279
- SMB_COM_CREATE,
280
- SMB_COM_CREATE_DIRECTORY,
281
- SMB_COM_CREATE_NEW,
282
- SMB_COM_CREATE_TEMPORARY,
283
- SMB_COM_DELETE,
284
- SMB_COM_DELETE_DIRECTORY,
285
- SMB_COM_FLUSH,
286
- SMB_COM_GET_PRINT_QUEUE,
287
- SMB_COM_LOCK_BYTE_RANGE,
288
- SMB_COM_NEGOTIATE,
289
- SMB_COM_OPEN,
290
- SMB_COM_OPEN_PRINT_FILE,
291
- SMB_COM_PROCESS_EXIT,
292
- SMB_COM_QUERY_INFORMATION,
293
- SMB_COM_QUERY_INFORMATION_DISK,
294
- SMB_COM_READ,
295
- SMB_COM_RENAME,
296
- SMB_COM_SEARCH,
297
- SMB_COM_SEEK,
298
- SMB_COM_SET_INFORMATION,
299
- SMB_COM_TREE_CONNECT,
300
- SMB_COM_TREE_DISCONNECT,
301
- SMB_COM_UNLOCK_BYTE_RANGE,
302
- SMB_COM_WRITE,
303
- SMB_COM_WRITE_PRINT_FILE
293
+ SMB_COM_CHECK_DIRECTORY,
294
+ SMB_COM_CLOSE,
295
+ SMB_COM_CLOSE_PRINT_FILE,
296
+ SMB_COM_CREATE,
297
+ SMB_COM_CREATE_DIRECTORY,
298
+ SMB_COM_CREATE_NEW,
299
+ SMB_COM_CREATE_TEMPORARY,
300
+ SMB_COM_DELETE,
301
+ SMB_COM_DELETE_DIRECTORY,
302
+ SMB_COM_FLUSH,
303
+ SMB_COM_GET_PRINT_QUEUE,
304
+ SMB_COM_LOCK_BYTE_RANGE,
305
+ SMB_COM_NEGOTIATE,
306
+ SMB_COM_OPEN,
307
+ SMB_COM_OPEN_PRINT_FILE,
308
+ SMB_COM_PROCESS_EXIT,
309
+ SMB_COM_QUERY_INFORMATION,
310
+ SMB_COM_QUERY_INFORMATION_DISK,
311
+ SMB_COM_READ,
312
+ SMB_COM_RENAME,
313
+ SMB_COM_SEARCH,
314
+ SMB_COM_SEEK,
315
+ SMB_COM_SET_INFORMATION,
316
+ SMB_COM_TREE_CONNECT,
317
+ SMB_COM_TREE_DISCONNECT,
318
+ SMB_COM_UNLOCK_BYTE_RANGE,
319
+ SMB_COM_WRITE,
320
+ SMB_COM_WRITE_PRINT_FILE
304
321
  ]
305
322
 
306
323
  DIALECT['LANMAN 1.0'] = DIALECT['PC NETWORK PROGRAM 1.0'] + [
307
- SMB_COM_COPY,
308
- SMB_COM_ECHO,
309
- SMB_COM_FIND,
310
- SMB_COM_FIND_CLOSE,
311
- SMB_COM_FIND_UNIQUE,
312
- SMB_COM_IOCTL,
313
- SMB_COM_IOCTL_SECONDARY,
314
- SMB_COM_LOCK_AND_READ,
315
- SMB_COM_LOCKING_ANDX,
316
- SMB_COM_MOVE,
317
- SMB_COM_OPEN_ANDX,
318
- SMB_COM_QUERY_INFORMATION2,
319
- SMB_COM_READ_ANDX,
320
- SMB_COM_READ_MPX,
321
- SMB_COM_READ_RAW,
322
- SMB_COM_SESSION_SETUP_ANDX,
323
- SMB_COM_SET_INFORMATION2,
324
- SMB_COM_TRANSACTION,
325
- SMB_COM_TRANSACTION_SECONDARY,
326
- SMB_COM_TREE_CONNECT_ANDX,
327
- SMB_COM_WRITE_AND_CLOSE,
328
- SMB_COM_WRITE_AND_UNLOCK,
329
- SMB_COM_WRITE_ANDX,
330
- SMB_COM_WRITE_COMPLETE,
331
- SMB_COM_WRITE_MPX,
332
- SMB_COM_WRITE_MPX_SECONDARY,
333
- SMB_COM_WRITE_RAW
324
+ SMB_COM_COPY,
325
+ SMB_COM_ECHO,
326
+ SMB_COM_FIND,
327
+ SMB_COM_FIND_CLOSE,
328
+ SMB_COM_FIND_UNIQUE,
329
+ SMB_COM_IOCTL,
330
+ SMB_COM_IOCTL_SECONDARY,
331
+ SMB_COM_LOCK_AND_READ,
332
+ SMB_COM_LOCKING_ANDX,
333
+ SMB_COM_MOVE,
334
+ SMB_COM_OPEN_ANDX,
335
+ SMB_COM_QUERY_INFORMATION2,
336
+ SMB_COM_READ_ANDX,
337
+ SMB_COM_READ_MPX,
338
+ SMB_COM_READ_RAW,
339
+ SMB_COM_SESSION_SETUP_ANDX,
340
+ SMB_COM_SET_INFORMATION2,
341
+ SMB_COM_TRANSACTION,
342
+ SMB_COM_TRANSACTION_SECONDARY,
343
+ SMB_COM_TREE_CONNECT_ANDX,
344
+ SMB_COM_WRITE_AND_CLOSE,
345
+ SMB_COM_WRITE_AND_UNLOCK,
346
+ SMB_COM_WRITE_ANDX,
347
+ SMB_COM_WRITE_COMPLETE,
348
+ SMB_COM_WRITE_MPX,
349
+ SMB_COM_WRITE_MPX_SECONDARY,
350
+ SMB_COM_WRITE_RAW
334
351
  ]
335
352
 
336
353
  DIALECT['LM1.2X002'] = DIALECT['LANMAN 1.0'] + [
337
- SMB_COM_FIND_CLOSE2,
338
- SMB_COM_LOGOFF_ANDX,
339
- SMB_COM_TRANSACTION2,
340
- SMB_COM_TRANSACTION2_SECONDARY
354
+ SMB_COM_FIND_CLOSE2,
355
+ SMB_COM_LOGOFF_ANDX,
356
+ SMB_COM_TRANSACTION2,
357
+ SMB_COM_TRANSACTION2_SECONDARY
341
358
  ]
342
359
 
343
360
  DIALECT['NTLM 0.12'] = DIALECT['LM1.2X002'] + [
344
- SMB_COM_NT_CANCEL,
345
- SMB_COM_NT_CREATE_ANDX,
346
- SMB_COM_NT_RENAME,
347
- SMB_COM_NT_TRANSACT,
348
- SMB_COM_NT_TRANSACT_SECONDARY
361
+ SMB_COM_NT_CANCEL,
362
+ SMB_COM_NT_CREATE_ANDX,
363
+ SMB_COM_NT_RENAME,
364
+ SMB_COM_NT_TRANSACT,
365
+ SMB_COM_NT_TRANSACT_SECONDARY
349
366
  ]
350
367
 
351
368
  # Create a NetBIOS session packet template
352
369
  def self.make_nbs (template)
353
- Rex::Struct2::CStructTemplate.new(
354
- [ 'uint8', 'Type', 0 ],
355
- [ 'uint8', 'Flags', 0 ],
356
- [ 'uint16n', 'PayloadLen', 0 ],
357
- [ 'template', 'Payload', template ]
358
- ).create_restraints(
359
- [ 'Payload', 'PayloadLen', nil, true ]
360
- )
370
+ Rex::Struct2::CStructTemplate.new(
371
+ [ 'uint8', 'Type', 0 ],
372
+ [ 'uint8', 'Flags', 0 ],
373
+ [ 'uint16n', 'PayloadLen', 0 ],
374
+ [ 'template', 'Payload', template ]
375
+ ).create_restraints(
376
+ [ 'Payload', 'PayloadLen', nil, true ]
377
+ )
361
378
  end
362
379
 
363
380
 
364
381
  # A raw NetBIOS session template
365
382
  NBRAW_HDR_PKT = Rex::Struct2::CStructTemplate.new(
366
- [ 'string', 'Payload', nil, '']
383
+ [ 'string', 'Payload', nil, '']
367
384
  )
368
385
  NBRAW_PKT = self.make_nbs(NBRAW_HDR_PKT)
369
386
 
370
387
 
371
388
  # The SMB header template
372
389
  SMB_HDR = Rex::Struct2::CStructTemplate.new(
373
- [ 'uint32n', 'Magic', 0xff534d42 ],
374
- [ 'uint8', 'Command', 0 ],
375
- [ 'uint32v', 'ErrorClass', 0 ],
376
- [ 'uint8', 'Flags1', 0 ],
377
- [ 'uint16v', 'Flags2', 0 ],
378
- [ 'uint16v', 'ProcessIDHigh', 0 ],
379
- [ 'uint32v', 'Signature1', 0 ],
380
- [ 'uint32v', 'Signature2', 0 ],
381
- [ 'uint16v', 'Reserved1', 0 ],
382
- [ 'uint16v', 'TreeID', 0 ],
383
- [ 'uint16v', 'ProcessID', 0 ],
384
- [ 'uint16v', 'UserID', 0 ],
385
- [ 'uint16v', 'MultiplexID', 0 ],
386
- [ 'uint8', 'WordCount', 0 ]
390
+ [ 'uint32n', 'Magic', 0xff534d42 ],
391
+ [ 'uint8', 'Command', 0 ],
392
+ [ 'uint32v', 'ErrorClass', 0 ],
393
+ [ 'uint8', 'Flags1', 0 ],
394
+ [ 'uint16v', 'Flags2', 0 ],
395
+ [ 'uint16v', 'ProcessIDHigh', 0 ],
396
+ [ 'uint32v', 'Signature1', 0 ],
397
+ [ 'uint32v', 'Signature2', 0 ],
398
+ [ 'uint16v', 'Reserved1', 0 ],
399
+ [ 'uint16v', 'TreeID', 0 ],
400
+ [ 'uint16v', 'ProcessID', 0 ],
401
+ [ 'uint16v', 'UserID', 0 ],
402
+ [ 'uint16v', 'MultiplexID', 0 ],
403
+ [ 'uint8', 'WordCount', 0 ]
387
404
  )
388
405
 
389
406
 
390
407
  # The SMB2 header template
391
408
  SMB2_HDR = Rex::Struct2::CStructTemplate.new(
392
- [ 'uint32n', 'Magic', 0xfe534d42 ],
393
- [ 'uint16v', 'HeaderLen', 64 ],
394
- [ 'uint16v', 'Reserved0', 0 ],
395
- [ 'uint32v', 'NTStatus', 0 ],
409
+ [ 'uint32n', 'Magic', 0xfe534d42 ],
410
+ [ 'uint16v', 'HeaderLen', 64 ],
411
+ [ 'uint16v', 'Reserved0', 0 ],
412
+ [ 'uint32v', 'NTStatus', 0 ],
396
413
 
397
- [ 'uint16v', 'Opcode', 0 ],
398
- [ 'uint16v', 'Reserved1', 0 ],
414
+ [ 'uint16v', 'Opcode', 0 ],
415
+ [ 'uint16v', 'Reserved1', 0 ],
399
416
 
400
- [ 'uint16v', 'Flags1', 0 ],
401
- [ 'uint16v', 'Flags2', 0 ],
417
+ [ 'uint16v', 'Flags1', 0 ],
418
+ [ 'uint16v', 'Flags2', 0 ],
402
419
 
403
- [ 'uint32v', 'ChainOffset', 0 ],
420
+ [ 'uint32v', 'ChainOffset', 0 ],
404
421
 
405
- [ 'uint32v', 'SequenceHigh', 0 ],
406
- [ 'uint32v', 'SequenceLow', 0 ],
422
+ [ 'uint32v', 'SequenceHigh', 0 ],
423
+ [ 'uint32v', 'SequenceLow', 0 ],
407
424
 
408
- [ 'uint32v', 'ProcessID', 0 ],
409
- [ 'uint32v', 'TreeID', 0 ],
410
- [ 'uint32v', 'UserIDHigh', 0 ],
411
- [ 'uint32v', 'UserIDLow', 0 ],
425
+ [ 'uint32v', 'ProcessID', 0 ],
426
+ [ 'uint32v', 'TreeID', 0 ],
427
+ [ 'uint32v', 'UserIDHigh', 0 ],
428
+ [ 'uint32v', 'UserIDLow', 0 ],
412
429
 
413
- [ 'uint32v', 'SignatureA', 0 ],
414
- [ 'uint32v', 'SignatureB', 0 ],
415
- [ 'uint32v', 'SignatureC', 0 ],
416
- [ 'uint32v', 'SignatureD', 0 ],
417
- [ 'string', 'Payload', nil, '']
430
+ [ 'uint32v', 'SignatureA', 0 ],
431
+ [ 'uint32v', 'SignatureB', 0 ],
432
+ [ 'uint32v', 'SignatureC', 0 ],
433
+ [ 'uint32v', 'SignatureD', 0 ],
434
+ [ 'string', 'Payload', nil, '']
418
435
  )
419
436
 
420
437
  # A basic SMB template to read all responses
421
438
  SMB_BASE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
422
- [ 'template', 'SMB', SMB_HDR ],
423
- [ 'uint16v', 'ByteCount', 0 ],
424
- [ 'string', 'Payload', nil, '' ]
439
+ [ 'template', 'SMB', SMB_HDR ],
440
+ [ 'uint16v', 'ByteCount', 0 ],
441
+ [ 'string', 'Payload', nil, '' ]
425
442
  ).create_restraints(
426
- [ 'Payload', 'ByteCount', nil, true ]
443
+ [ 'Payload', 'ByteCount', nil, true ]
427
444
  )
428
445
  SMB_BASE_PKT = self.make_nbs(SMB_BASE_HDR_PKT)
429
446
 
@@ -431,553 +448,553 @@ SMB_BASE_PKT = self.make_nbs(SMB_BASE_HDR_PKT)
431
448
  # A SMB template for SMB Dialect negotiation
432
449
  SMB_NEG_HDR_PKT = Rex::Struct2::CStructTemplate.new(
433
450
 
434
- [ 'template', 'SMB', SMB_HDR ],
435
- [ 'uint16v', 'ByteCount', 0 ],
436
- [ 'string', 'Payload', nil, '' ]
451
+ [ 'template', 'SMB', SMB_HDR ],
452
+ [ 'uint16v', 'ByteCount', 0 ],
453
+ [ 'string', 'Payload', nil, '' ]
437
454
  ).create_restraints(
438
- [ 'Payload', 'ByteCount', nil, true ]
455
+ [ 'Payload', 'ByteCount', nil, true ]
439
456
  )
440
457
  SMB_NEG_PKT = self.make_nbs(SMB_NEG_HDR_PKT)
441
458
 
442
459
 
443
460
  # A SMB template for SMB Dialect negotiation responses (LANMAN)
444
461
  SMB_NEG_RES_LM_HDR_PKT = Rex::Struct2::CStructTemplate.new(
445
- [ 'template', 'SMB', SMB_HDR ],
446
- [ 'uint16v', 'Dialect', 0 ],
447
- [ 'uint16v', 'SecurityMode', 0 ],
448
- [ 'uint16v', 'MaxBuff', 0 ],
449
- [ 'uint16v', 'MaxMPX', 0 ],
450
- [ 'uint16v', 'MaxVCS', 0 ],
451
- [ 'uint16v', 'RawMode', 0 ],
452
- [ 'uint32v', 'SessionKey', 0 ],
453
- [ 'uint16v', 'DosTime', 0 ],
454
- [ 'uint16v', 'DosDate', 0 ],
455
- [ 'uint16v', 'Timezone', 0 ],
456
- [ 'uint16v', 'KeyLength', 0 ],
457
- [ 'uint16v', 'Reserved1', 0 ],
458
- [ 'uint16v', 'ByteCount', 0 ],
459
- [ 'string', 'EncryptionKey', nil, '' ]
462
+ [ 'template', 'SMB', SMB_HDR ],
463
+ [ 'uint16v', 'Dialect', 0 ],
464
+ [ 'uint16v', 'SecurityMode', 0 ],
465
+ [ 'uint16v', 'MaxBuff', 0 ],
466
+ [ 'uint16v', 'MaxMPX', 0 ],
467
+ [ 'uint16v', 'MaxVCS', 0 ],
468
+ [ 'uint16v', 'RawMode', 0 ],
469
+ [ 'uint32v', 'SessionKey', 0 ],
470
+ [ 'uint16v', 'DosTime', 0 ],
471
+ [ 'uint16v', 'DosDate', 0 ],
472
+ [ 'uint16v', 'Timezone', 0 ],
473
+ [ 'uint16v', 'KeyLength', 0 ],
474
+ [ 'uint16v', 'Reserved1', 0 ],
475
+ [ 'uint16v', 'ByteCount', 0 ],
476
+ [ 'string', 'EncryptionKey', nil, '' ]
460
477
  ).create_restraints(
461
- [ 'EncryptionKey', 'ByteCount', nil, true ]
478
+ [ 'EncryptionKey', 'ByteCount', nil, true ]
462
479
  )
463
480
  SMB_NEG_RES_LM_PKT = self.make_nbs(SMB_NEG_RES_LM_HDR_PKT)
464
481
 
465
482
 
466
483
  # A SMB template for SMB Dialect negotiation responses (NTLM)
467
484
  SMB_NEG_RES_NT_HDR_PKT = Rex::Struct2::CStructTemplate.new(
468
- [ 'template', 'SMB', SMB_HDR ],
469
- [ 'uint16v', 'Dialect', 0 ],
470
- [ 'uint8', 'SecurityMode', 0 ],
471
- [ 'uint16v', 'MaxMPX', 0 ],
472
- [ 'uint16v', 'MaxVCS', 0 ],
473
- [ 'uint32v', 'MaxBuff', 0 ],
474
- [ 'uint32v', 'MaxRaw', 0 ],
475
- [ 'uint32v', 'SessionKey', 0 ],
476
- [ 'uint32v', 'Capabilities', 0 ],
477
- [ 'uint32v', 'SystemTimeLow', 0 ],
478
- [ 'uint32v', 'SystemTimeHigh', 0 ],
479
- [ 'uint16v', 'ServerTimeZone', 0 ],
480
- [ 'uint8', 'KeyLength', 0 ],
481
- [ 'uint16v', 'ByteCount', 0 ],
482
- [ 'string', 'Payload', nil, '' ]
485
+ [ 'template', 'SMB', SMB_HDR ],
486
+ [ 'uint16v', 'Dialect', 0 ],
487
+ [ 'uint8', 'SecurityMode', 0 ],
488
+ [ 'uint16v', 'MaxMPX', 0 ],
489
+ [ 'uint16v', 'MaxVCS', 0 ],
490
+ [ 'uint32v', 'MaxBuff', 0 ],
491
+ [ 'uint32v', 'MaxRaw', 0 ],
492
+ [ 'uint32v', 'SessionKey', 0 ],
493
+ [ 'uint32v', 'Capabilities', 0 ],
494
+ [ 'uint32v', 'SystemTimeLow', 0 ],
495
+ [ 'uint32v', 'SystemTimeHigh', 0 ],
496
+ [ 'uint16v', 'ServerTimeZone', 0 ],
497
+ [ 'uint8', 'KeyLength', 0 ],
498
+ [ 'uint16v', 'ByteCount', 0 ],
499
+ [ 'string', 'Payload', nil, '' ]
483
500
  ).create_restraints(
484
- [ 'Payload', 'ByteCount', nil, true ]
501
+ [ 'Payload', 'ByteCount', nil, true ]
485
502
  )
486
503
  SMB_NEG_RES_NT_PKT = self.make_nbs(SMB_NEG_RES_NT_HDR_PKT)
487
504
 
488
505
 
489
506
  # A SMB template for SMB Dialect negotiation responses (ERROR)
490
507
  SMB_NEG_RES_ERR_HDR_PKT = Rex::Struct2::CStructTemplate.new(
491
- [ 'template', 'SMB', SMB_HDR ],
492
- [ 'uint16v', 'Dialect', 0 ],
493
- [ 'uint16v', 'ByteCount', 0 ]
508
+ [ 'template', 'SMB', SMB_HDR ],
509
+ [ 'uint16v', 'Dialect', 0 ],
510
+ [ 'uint16v', 'ByteCount', 0 ]
494
511
  )
495
512
  SMB_NEG_RES_ERR_PKT = self.make_nbs(SMB_NEG_RES_ERR_HDR_PKT)
496
513
 
497
514
 
498
515
  # A SMB template for SMB Session Setup responses (LANMAN/NTLMV1)
499
516
  SMB_SETUP_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
500
- [ 'template', 'SMB', SMB_HDR ],
501
- [ 'uint8', 'AndX', 0 ],
502
- [ 'uint8', 'Reserved1', 0 ],
503
- [ 'uint16v', 'AndXOffset', 0 ],
504
- [ 'uint16v', 'Action', 0 ],
505
- [ 'uint16v', 'ByteCount', 0 ],
506
- [ 'string', 'Payload', nil, '' ]
517
+ [ 'template', 'SMB', SMB_HDR ],
518
+ [ 'uint8', 'AndX', 0 ],
519
+ [ 'uint8', 'Reserved1', 0 ],
520
+ [ 'uint16v', 'AndXOffset', 0 ],
521
+ [ 'uint16v', 'Action', 0 ],
522
+ [ 'uint16v', 'ByteCount', 0 ],
523
+ [ 'string', 'Payload', nil, '' ]
507
524
  ).create_restraints(
508
- [ 'Payload', 'ByteCount', nil, true ]
525
+ [ 'Payload', 'ByteCount', nil, true ]
509
526
  )
510
527
  SMB_SETUP_RES_PKT = self.make_nbs(SMB_SETUP_RES_HDR_PKT)
511
528
 
512
529
 
513
530
  # A SMB template for SMB Session Setup requests (LANMAN)
514
531
  SMB_SETUP_LANMAN_HDR_PKT = Rex::Struct2::CStructTemplate.new(
515
- [ 'template', 'SMB', SMB_HDR ],
516
- [ 'uint8', 'AndX', 0 ],
517
- [ 'uint8', 'Reserved1', 0 ],
518
- [ 'uint16v', 'AndXOffset', 0 ],
519
- [ 'uint16v', 'MaxBuff', 0 ],
520
- [ 'uint16v', 'MaxMPX', 0 ],
521
- [ 'uint16v', 'VCNum', 0 ],
522
- [ 'uint32v', 'SessionKey', 0 ],
523
- [ 'uint16v', 'PasswordLen', 0 ],
524
- [ 'uint32v', 'Reserved2', 0 ],
525
- [ 'uint16v', 'ByteCount', 0 ],
526
- [ 'string', 'Payload', nil, '' ]
532
+ [ 'template', 'SMB', SMB_HDR ],
533
+ [ 'uint8', 'AndX', 0 ],
534
+ [ 'uint8', 'Reserved1', 0 ],
535
+ [ 'uint16v', 'AndXOffset', 0 ],
536
+ [ 'uint16v', 'MaxBuff', 0 ],
537
+ [ 'uint16v', 'MaxMPX', 0 ],
538
+ [ 'uint16v', 'VCNum', 0 ],
539
+ [ 'uint32v', 'SessionKey', 0 ],
540
+ [ 'uint16v', 'PasswordLen', 0 ],
541
+ [ 'uint32v', 'Reserved2', 0 ],
542
+ [ 'uint16v', 'ByteCount', 0 ],
543
+ [ 'string', 'Payload', nil, '' ]
527
544
  ).create_restraints(
528
- [ 'Payload', 'ByteCount', nil, true ]
545
+ [ 'Payload', 'ByteCount', nil, true ]
529
546
  )
530
547
  SMB_SETUP_LANMAN_PKT = self.make_nbs(SMB_SETUP_LANMAN_HDR_PKT)
531
548
 
532
549
 
533
550
  # A SMB template for SMB Session Setup requests (NTLMV1)
534
551
  SMB_SETUP_NTLMV1_HDR_PKT = Rex::Struct2::CStructTemplate.new(
535
- [ 'template', 'SMB', SMB_HDR ],
536
- [ 'uint8', 'AndX', 0 ],
537
- [ 'uint8', 'Reserved1', 0 ],
538
- [ 'uint16v', 'AndXOffset', 0 ],
539
- [ 'uint16v', 'MaxBuff', 0 ],
540
- [ 'uint16v', 'MaxMPX', 0 ],
541
- [ 'uint16v', 'VCNum', 0 ],
542
- [ 'uint32v', 'SessionKey', 0 ],
543
- [ 'uint16v', 'PasswordLenLM', 0 ],
544
- [ 'uint16v', 'PasswordLenNT', 0 ],
545
- [ 'uint32v', 'Reserved2', 0 ],
546
- [ 'uint32v', 'Capabilities', 0 ],
547
- [ 'uint16v', 'ByteCount', 0 ],
548
- [ 'string', 'Payload', nil, '' ]
552
+ [ 'template', 'SMB', SMB_HDR ],
553
+ [ 'uint8', 'AndX', 0 ],
554
+ [ 'uint8', 'Reserved1', 0 ],
555
+ [ 'uint16v', 'AndXOffset', 0 ],
556
+ [ 'uint16v', 'MaxBuff', 0 ],
557
+ [ 'uint16v', 'MaxMPX', 0 ],
558
+ [ 'uint16v', 'VCNum', 0 ],
559
+ [ 'uint32v', 'SessionKey', 0 ],
560
+ [ 'uint16v', 'PasswordLenLM', 0 ],
561
+ [ 'uint16v', 'PasswordLenNT', 0 ],
562
+ [ 'uint32v', 'Reserved2', 0 ],
563
+ [ 'uint32v', 'Capabilities', 0 ],
564
+ [ 'uint16v', 'ByteCount', 0 ],
565
+ [ 'string', 'Payload', nil, '' ]
549
566
  ).create_restraints(
550
- [ 'Payload', 'ByteCount', nil, true ]
567
+ [ 'Payload', 'ByteCount', nil, true ]
551
568
  )
552
569
  SMB_SETUP_NTLMV1_PKT = self.make_nbs(SMB_SETUP_NTLMV1_HDR_PKT)
553
570
 
554
571
 
555
572
  # A SMB template for SMB Session Setup requests (When extended security is being used)
556
573
  SMB_SETUP_NTLMV2_HDR_PKT = Rex::Struct2::CStructTemplate.new(
557
- [ 'template', 'SMB', SMB_HDR ],
558
- [ 'uint8', 'AndX', 0 ],
559
- [ 'uint8', 'Reserved1', 0 ],
560
- [ 'uint16v', 'AndXOffset', 0 ],
561
- [ 'uint16v', 'MaxBuff', 0 ],
562
- [ 'uint16v', 'MaxMPX', 0 ],
563
- [ 'uint16v', 'VCNum', 0 ],
564
- [ 'uint32v', 'SessionKey', 0 ],
565
- [ 'uint16v', 'SecurityBlobLen', 0 ],
566
- [ 'uint32v', 'Reserved2', 0 ],
567
- [ 'uint32v', 'Capabilities', 0 ],
568
- [ 'uint16v', 'ByteCount', 0 ],
569
- [ 'string', 'Payload', nil, '' ]
574
+ [ 'template', 'SMB', SMB_HDR ],
575
+ [ 'uint8', 'AndX', 0 ],
576
+ [ 'uint8', 'Reserved1', 0 ],
577
+ [ 'uint16v', 'AndXOffset', 0 ],
578
+ [ 'uint16v', 'MaxBuff', 0 ],
579
+ [ 'uint16v', 'MaxMPX', 0 ],
580
+ [ 'uint16v', 'VCNum', 0 ],
581
+ [ 'uint32v', 'SessionKey', 0 ],
582
+ [ 'uint16v', 'SecurityBlobLen', 0 ],
583
+ [ 'uint32v', 'Reserved2', 0 ],
584
+ [ 'uint32v', 'Capabilities', 0 ],
585
+ [ 'uint16v', 'ByteCount', 0 ],
586
+ [ 'string', 'Payload', nil, '' ]
570
587
  ).create_restraints(
571
- [ 'Payload', 'ByteCount', nil, true ]
588
+ [ 'Payload', 'ByteCount', nil, true ]
572
589
  )
573
590
  SMB_SETUP_NTLMV2_PKT = self.make_nbs(SMB_SETUP_NTLMV2_HDR_PKT)
574
591
 
575
592
 
576
593
  # A SMB template for SMB Session Setup responses (When extended security is being used)
577
594
  SMB_SETUP_NTLMV2_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
578
- [ 'template', 'SMB', SMB_HDR ],
579
- [ 'uint8', 'AndX', 0 ],
580
- [ 'uint8', 'Reserved1', 0 ],
581
- [ 'uint16v', 'AndXOffset', 0 ],
582
- [ 'uint16v', 'Action', 0 ],
583
- [ 'uint16v', 'SecurityBlobLen', 0 ],
584
- [ 'uint16v', 'ByteCount', 0 ],
585
- [ 'string', 'Payload', nil, '' ]
595
+ [ 'template', 'SMB', SMB_HDR ],
596
+ [ 'uint8', 'AndX', 0 ],
597
+ [ 'uint8', 'Reserved1', 0 ],
598
+ [ 'uint16v', 'AndXOffset', 0 ],
599
+ [ 'uint16v', 'Action', 0 ],
600
+ [ 'uint16v', 'SecurityBlobLen', 0 ],
601
+ [ 'uint16v', 'ByteCount', 0 ],
602
+ [ 'string', 'Payload', nil, '' ]
586
603
  ).create_restraints(
587
- [ 'Payload', 'ByteCount', nil, true ]
604
+ [ 'Payload', 'ByteCount', nil, true ]
588
605
  )
589
606
  SMB_SETUP_NTLMV2_RES_PKT = self.make_nbs(SMB_SETUP_NTLMV2_RES_HDR_PKT)
590
607
 
591
608
 
592
609
  # A SMB template for SMB Tree Connect requests
593
610
  SMB_TREE_CONN_HDR_PKT = Rex::Struct2::CStructTemplate.new(
594
- [ 'template', 'SMB', SMB_HDR ],
595
- [ 'uint8', 'AndX', 0 ],
596
- [ 'uint8', 'Reserved1', 0 ],
597
- [ 'uint16v', 'AndXOffset', 0 ],
598
- [ 'uint16v', 'Flags', 0 ],
599
- [ 'uint16v', 'PasswordLen', 0 ],
600
- [ 'uint16v', 'ByteCount', 0 ],
601
- [ 'string', 'Payload', nil, '' ]
611
+ [ 'template', 'SMB', SMB_HDR ],
612
+ [ 'uint8', 'AndX', 0 ],
613
+ [ 'uint8', 'Reserved1', 0 ],
614
+ [ 'uint16v', 'AndXOffset', 0 ],
615
+ [ 'uint16v', 'Flags', 0 ],
616
+ [ 'uint16v', 'PasswordLen', 0 ],
617
+ [ 'uint16v', 'ByteCount', 0 ],
618
+ [ 'string', 'Payload', nil, '' ]
602
619
  ).create_restraints(
603
- [ 'Payload', 'ByteCount', nil, true ]
620
+ [ 'Payload', 'ByteCount', nil, true ]
604
621
  )
605
622
  SMB_TREE_CONN_PKT = self.make_nbs(SMB_TREE_CONN_HDR_PKT)
606
623
 
607
624
 
608
625
  # A SMB template for SMB Tree Connect requests
609
626
  SMB_TREE_CONN_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
610
- [ 'template', 'SMB', SMB_HDR ],
611
- [ 'uint8', 'AndX', 0 ],
612
- [ 'uint8', 'Reserved1', 0 ],
613
- [ 'uint16v', 'AndXOffset', 0 ],
614
- [ 'uint16v', 'OptionalSupport', 0 ],
615
- [ 'string', 'SupportWords', nil, '' ],
616
- [ 'uint16v', 'ByteCount', 0 ],
617
- [ 'string', 'Payload', nil, '' ]
627
+ [ 'template', 'SMB', SMB_HDR ],
628
+ [ 'uint8', 'AndX', 0 ],
629
+ [ 'uint8', 'Reserved1', 0 ],
630
+ [ 'uint16v', 'AndXOffset', 0 ],
631
+ [ 'uint16v', 'OptionalSupport', 0 ],
632
+ [ 'string', 'SupportWords', nil, '' ],
633
+ [ 'uint16v', 'ByteCount', 0 ],
634
+ [ 'string', 'Payload', nil, '' ]
618
635
  ).create_restraints(
619
- [ 'Payload', 'ByteCount', nil, true ]
636
+ [ 'Payload', 'ByteCount', nil, true ]
620
637
  )
621
638
  SMB_TREE_CONN_RES_PKT = self.make_nbs(SMB_TREE_CONN_RES_HDR_PKT)
622
639
 
623
640
 
624
641
  # A SMB template for SMB Tree Disconnect requests
625
642
  SMB_TREE_DISCONN_HDR_PKT = Rex::Struct2::CStructTemplate.new(
626
- [ 'template', 'SMB', SMB_HDR ],
627
- [ 'uint16v', 'ByteCount', 0 ],
628
- [ 'string', 'Payload', nil, '' ]
643
+ [ 'template', 'SMB', SMB_HDR ],
644
+ [ 'uint16v', 'ByteCount', 0 ],
645
+ [ 'string', 'Payload', nil, '' ]
629
646
  ).create_restraints(
630
- [ 'Payload', 'ByteCount', nil, true ]
647
+ [ 'Payload', 'ByteCount', nil, true ]
631
648
  )
632
649
  SMB_TREE_DISCONN_PKT = self.make_nbs(SMB_TREE_DISCONN_HDR_PKT)
633
650
 
634
651
 
635
652
  # A SMB template for SMB Tree Disconnect requests
636
653
  SMB_TREE_DISCONN_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
637
- [ 'template', 'SMB', SMB_HDR ],
638
- [ 'uint16v', 'ByteCount', 0 ],
639
- [ 'string', 'Payload', nil, '' ]
654
+ [ 'template', 'SMB', SMB_HDR ],
655
+ [ 'uint16v', 'ByteCount', 0 ],
656
+ [ 'string', 'Payload', nil, '' ]
640
657
  ).create_restraints(
641
- [ 'Payload', 'ByteCount', nil, true ]
658
+ [ 'Payload', 'ByteCount', nil, true ]
642
659
  )
643
660
  SMB_TREE_DISCONN_RES_PKT = self.make_nbs(SMB_TREE_DISCONN_RES_HDR_PKT)
644
661
 
645
662
 
646
663
  # A SMB template for SMB Transaction requests
647
664
  SMB_TRANS_HDR_PKT = Rex::Struct2::CStructTemplate.new(
648
- [ 'template', 'SMB', SMB_HDR ],
649
- [ 'uint16v', 'ParamCountTotal', 0 ],
650
- [ 'uint16v', 'DataCountTotal', 0 ],
651
- [ 'uint16v', 'ParamCountMax', 0 ],
652
- [ 'uint16v', 'DataCountMax', 0 ],
653
- [ 'uint8', 'SetupCountMax', 0 ],
654
- [ 'uint8', 'Reserved1', 0 ],
655
- [ 'uint16v', 'Flags', 0 ],
656
- [ 'uint32v', 'Timeout', 0 ],
657
- [ 'uint16v', 'Reserved2', 0 ],
658
- [ 'uint16v', 'ParamCount', 0 ],
659
- [ 'uint16v', 'ParamOffset', 0 ],
660
- [ 'uint16v', 'DataCount', 0 ],
661
- [ 'uint16v', 'DataOffset', 0 ],
662
- [ 'uint8', 'SetupCount', 0 ],
663
- [ 'uint8', 'Reserved3', 0 ],
664
- [ 'string', 'SetupData', nil, '' ],
665
- [ 'uint16v', 'ByteCount', 0 ],
666
- [ 'string', 'Payload', nil, '' ]
665
+ [ 'template', 'SMB', SMB_HDR ],
666
+ [ 'uint16v', 'ParamCountTotal', 0 ],
667
+ [ 'uint16v', 'DataCountTotal', 0 ],
668
+ [ 'uint16v', 'ParamCountMax', 0 ],
669
+ [ 'uint16v', 'DataCountMax', 0 ],
670
+ [ 'uint8', 'SetupCountMax', 0 ],
671
+ [ 'uint8', 'Reserved1', 0 ],
672
+ [ 'uint16v', 'Flags', 0 ],
673
+ [ 'uint32v', 'Timeout', 0 ],
674
+ [ 'uint16v', 'Reserved2', 0 ],
675
+ [ 'uint16v', 'ParamCount', 0 ],
676
+ [ 'uint16v', 'ParamOffset', 0 ],
677
+ [ 'uint16v', 'DataCount', 0 ],
678
+ [ 'uint16v', 'DataOffset', 0 ],
679
+ [ 'uint8', 'SetupCount', 0 ],
680
+ [ 'uint8', 'Reserved3', 0 ],
681
+ [ 'string', 'SetupData', nil, '' ],
682
+ [ 'uint16v', 'ByteCount', 0 ],
683
+ [ 'string', 'Payload', nil, '' ]
667
684
  ).create_restraints(
668
- [ 'Payload', 'ByteCount', nil, true ]
685
+ [ 'Payload', 'ByteCount', nil, true ]
669
686
  )
670
687
  SMB_TRANS_PKT = self.make_nbs(SMB_TRANS_HDR_PKT)
671
688
 
672
689
 
673
690
  # A SMB template for SMB Transaction responses
674
691
  SMB_TRANS_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
675
- [ 'template', 'SMB', SMB_HDR ],
676
- [ 'uint16v', 'ParamCountTotal', 0 ],
677
- [ 'uint16v', 'DataCountTotal', 0 ],
678
- [ 'uint16v', 'Reserved1', 0 ],
679
- [ 'uint16v', 'ParamCount', 0 ],
680
- [ 'uint16v', 'ParamOffset', 0 ],
681
- [ 'uint16v', 'ParamDisplace', 0 ],
682
- [ 'uint16v', 'DataCount', 0 ],
683
- [ 'uint16v', 'DataOffset', 0 ],
684
- [ 'uint16v', 'DataDisplace', 0 ],
685
- [ 'uint8', 'SetupCount', 0 ],
686
- [ 'uint8', 'Reserved2', 0 ],
687
- [ 'string', 'SetupData', nil, '' ],
688
- [ 'uint16v', 'ByteCount', 0 ],
689
- [ 'string', 'Payload', nil, '' ]
692
+ [ 'template', 'SMB', SMB_HDR ],
693
+ [ 'uint16v', 'ParamCountTotal', 0 ],
694
+ [ 'uint16v', 'DataCountTotal', 0 ],
695
+ [ 'uint16v', 'Reserved1', 0 ],
696
+ [ 'uint16v', 'ParamCount', 0 ],
697
+ [ 'uint16v', 'ParamOffset', 0 ],
698
+ [ 'uint16v', 'ParamDisplace', 0 ],
699
+ [ 'uint16v', 'DataCount', 0 ],
700
+ [ 'uint16v', 'DataOffset', 0 ],
701
+ [ 'uint16v', 'DataDisplace', 0 ],
702
+ [ 'uint8', 'SetupCount', 0 ],
703
+ [ 'uint8', 'Reserved2', 0 ],
704
+ [ 'string', 'SetupData', nil, '' ],
705
+ [ 'uint16v', 'ByteCount', 0 ],
706
+ [ 'string', 'Payload', nil, '' ]
690
707
  ).create_restraints(
691
- [ 'Payload', 'ByteCount', nil, true ]
708
+ [ 'Payload', 'ByteCount', nil, true ]
692
709
  )
693
710
  SMB_TRANS_RES_PKT = self.make_nbs(SMB_TRANS_RES_HDR_PKT)
694
711
 
695
712
  # A SMB template for SMB Transaction2 requests
696
713
  SMB_TRANS2_HDR_PKT = Rex::Struct2::CStructTemplate.new(
697
- [ 'template', 'SMB', SMB_HDR ],
698
- [ 'uint16v', 'ParamCountTotal', 0 ],
699
- [ 'uint16v', 'DataCountTotal', 0 ],
700
- [ 'uint16v', 'ParamCountMax', 0 ],
701
- [ 'uint16v', 'DataCountMax', 0 ],
702
- [ 'uint8', 'SetupCountMax', 0 ],
703
- [ 'uint8', 'Reserved1', 0 ],
704
- [ 'uint16v', 'Flags', 0 ],
705
- [ 'uint32v', 'Timeout', 0 ],
706
- [ 'uint16v', 'Reserved2', 0 ],
707
- [ 'uint16v', 'ParamCount', 0 ],
708
- [ 'uint16v', 'ParamOffset', 0 ],
709
- [ 'uint16v', 'DataCount', 0 ],
710
- [ 'uint16v', 'DataOffset', 0 ],
711
- [ 'uint8', 'SetupCount', 0 ],
712
- [ 'uint8', 'Reserved3', 0 ],
713
- [ 'string', 'SetupData', nil, '' ],
714
- [ 'uint16v', 'ByteCount', 0 ],
715
- [ 'string', 'Payload', nil, '' ]
714
+ [ 'template', 'SMB', SMB_HDR ],
715
+ [ 'uint16v', 'ParamCountTotal', 0 ],
716
+ [ 'uint16v', 'DataCountTotal', 0 ],
717
+ [ 'uint16v', 'ParamCountMax', 0 ],
718
+ [ 'uint16v', 'DataCountMax', 0 ],
719
+ [ 'uint8', 'SetupCountMax', 0 ],
720
+ [ 'uint8', 'Reserved1', 0 ],
721
+ [ 'uint16v', 'Flags', 0 ],
722
+ [ 'uint32v', 'Timeout', 0 ],
723
+ [ 'uint16v', 'Reserved2', 0 ],
724
+ [ 'uint16v', 'ParamCount', 0 ],
725
+ [ 'uint16v', 'ParamOffset', 0 ],
726
+ [ 'uint16v', 'DataCount', 0 ],
727
+ [ 'uint16v', 'DataOffset', 0 ],
728
+ [ 'uint8', 'SetupCount', 0 ],
729
+ [ 'uint8', 'Reserved3', 0 ],
730
+ [ 'string', 'SetupData', nil, '' ],
731
+ [ 'uint16v', 'ByteCount', 0 ],
732
+ [ 'string', 'Payload', nil, '' ]
716
733
  ).create_restraints(
717
- [ 'Payload', 'ByteCount', nil, true ]
734
+ [ 'Payload', 'ByteCount', nil, true ]
718
735
  )
719
736
  SMB_TRANS2_PKT = self.make_nbs(SMB_TRANS2_HDR_PKT)
720
737
 
721
738
 
722
739
  # A SMB template for SMB NTTransaction requests
723
740
  SMB_NTTRANS_HDR_PKT = Rex::Struct2::CStructTemplate.new(
724
- [ 'template', 'SMB', SMB_HDR ],
725
- [ 'uint8', 'SetupCountMax', 0 ],
726
- [ 'uint16v', 'Reserved1', 0 ],
727
- [ 'uint32v', 'ParamCountTotal', 0 ],
728
- [ 'uint32v', 'DataCountTotal', 0 ],
729
- [ 'uint32v', 'ParamCountMax', 0 ],
730
- [ 'uint32v', 'DataCountMax', 0 ],
731
- [ 'uint32v', 'ParamCount', 0 ],
732
- [ 'uint32v', 'ParamOffset', 0 ],
733
- [ 'uint32v', 'DataCount', 0 ],
734
- [ 'uint32v', 'DataOffset', 0 ],
735
- [ 'uint8', 'SetupCount', 0 ],
736
- [ 'uint16v', 'Subcommand', 0 ],
737
- [ 'string', 'SetupData', nil, '' ],
738
- [ 'uint16v', 'ByteCount', 0 ],
739
- [ 'string', 'Payload', nil, '' ]
741
+ [ 'template', 'SMB', SMB_HDR ],
742
+ [ 'uint8', 'SetupCountMax', 0 ],
743
+ [ 'uint16v', 'Reserved1', 0 ],
744
+ [ 'uint32v', 'ParamCountTotal', 0 ],
745
+ [ 'uint32v', 'DataCountTotal', 0 ],
746
+ [ 'uint32v', 'ParamCountMax', 0 ],
747
+ [ 'uint32v', 'DataCountMax', 0 ],
748
+ [ 'uint32v', 'ParamCount', 0 ],
749
+ [ 'uint32v', 'ParamOffset', 0 ],
750
+ [ 'uint32v', 'DataCount', 0 ],
751
+ [ 'uint32v', 'DataOffset', 0 ],
752
+ [ 'uint8', 'SetupCount', 0 ],
753
+ [ 'uint16v', 'Subcommand', 0 ],
754
+ [ 'string', 'SetupData', nil, '' ],
755
+ [ 'uint16v', 'ByteCount', 0 ],
756
+ [ 'string', 'Payload', nil, '' ]
740
757
  ).create_restraints(
741
- [ 'Payload', 'ByteCount', nil, true ]
758
+ [ 'Payload', 'ByteCount', nil, true ]
742
759
  )
743
760
  SMB_NTTRANS_PKT = self.make_nbs(SMB_NTTRANS_HDR_PKT)
744
761
 
745
762
 
746
763
  # A SMB template for SMB NTTransaction responses
747
764
  SMB_NTTRANS_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
748
- [ 'template', 'SMB', SMB_HDR ],
749
- [ 'uint8', 'Reserved1', 0 ],
750
- [ 'uint16v', 'Reserved2', 0 ],
751
- [ 'uint32v', 'ParamCountTotal', 0 ],
752
- [ 'uint32v', 'DataCountTotal', 0 ],
753
- [ 'uint32v', 'ParamCount', 0 ],
754
- [ 'uint32v', 'ParamOffset', 0 ],
755
- [ 'uint32v', 'ParamDisplace', 0 ],
756
- [ 'uint32v', 'DataCount', 0 ],
757
- [ 'uint32v', 'DataOffset', 0 ],
758
- [ 'uint32v', 'DataDisplace', 0 ],
759
- [ 'uint8', 'Reserved3', 0 ],
760
- [ 'uint16v', 'ByteCount', 0 ],
761
- [ 'string', 'Payload', nil, '' ]
765
+ [ 'template', 'SMB', SMB_HDR ],
766
+ [ 'uint8', 'Reserved1', 0 ],
767
+ [ 'uint16v', 'Reserved2', 0 ],
768
+ [ 'uint32v', 'ParamCountTotal', 0 ],
769
+ [ 'uint32v', 'DataCountTotal', 0 ],
770
+ [ 'uint32v', 'ParamCount', 0 ],
771
+ [ 'uint32v', 'ParamOffset', 0 ],
772
+ [ 'uint32v', 'ParamDisplace', 0 ],
773
+ [ 'uint32v', 'DataCount', 0 ],
774
+ [ 'uint32v', 'DataOffset', 0 ],
775
+ [ 'uint32v', 'DataDisplace', 0 ],
776
+ [ 'uint8', 'Reserved3', 0 ],
777
+ [ 'uint16v', 'ByteCount', 0 ],
778
+ [ 'string', 'Payload', nil, '' ]
762
779
  ).create_restraints(
763
- [ 'Payload', 'ByteCount', nil, true ]
780
+ [ 'Payload', 'ByteCount', nil, true ]
764
781
  )
765
782
  SMB_NTTRANS_RES_PKT = self.make_nbs(SMB_NTTRANS_RES_HDR_PKT)
766
783
 
767
784
  # A SMB template for SMB NTTransaction_Secondary requests
768
785
  SMB_NTTRANS_SECONDARY_HDR_PKT = Rex::Struct2::CStructTemplate.new(
769
- [ 'template', 'SMB', SMB_HDR ],
770
- [ 'uint8', 'Reserved1', 0 ],
771
- [ 'uint16v', 'Reserved2', 0 ],
772
- [ 'uint32v', 'ParamCountTotal', 0 ],
773
- [ 'uint32v', 'DataCountTotal', 0 ],
774
- [ 'uint32v', 'ParamCount', 0 ],
775
- [ 'uint32v', 'ParamOffset', 0 ],
776
- [ 'uint32v', 'ParamDisplace', 0 ],
777
- [ 'uint32v', 'DataCount', 0 ],
778
- [ 'uint32v', 'DataOffset', 0 ],
779
- [ 'uint32v', 'DataDisplace', 0 ],
780
- [ 'uint8', 'SetupCount', 0 ],
781
- [ 'string', 'SetupData', nil, '' ],
782
- [ 'uint16v', 'ByteCount', 0 ],
783
- [ 'string', 'Payload', nil, '' ]
786
+ [ 'template', 'SMB', SMB_HDR ],
787
+ [ 'uint8', 'Reserved1', 0 ],
788
+ [ 'uint16v', 'Reserved2', 0 ],
789
+ [ 'uint32v', 'ParamCountTotal', 0 ],
790
+ [ 'uint32v', 'DataCountTotal', 0 ],
791
+ [ 'uint32v', 'ParamCount', 0 ],
792
+ [ 'uint32v', 'ParamOffset', 0 ],
793
+ [ 'uint32v', 'ParamDisplace', 0 ],
794
+ [ 'uint32v', 'DataCount', 0 ],
795
+ [ 'uint32v', 'DataOffset', 0 ],
796
+ [ 'uint32v', 'DataDisplace', 0 ],
797
+ [ 'uint8', 'SetupCount', 0 ],
798
+ [ 'string', 'SetupData', nil, '' ],
799
+ [ 'uint16v', 'ByteCount', 0 ],
800
+ [ 'string', 'Payload', nil, '' ]
784
801
  ).create_restraints(
785
- [ 'Payload', 'ByteCount', nil, true ]
802
+ [ 'Payload', 'ByteCount', nil, true ]
786
803
  )
787
804
  SMB_NTTRANS_SECONDARY_PKT = self.make_nbs(SMB_NTTRANS_SECONDARY_HDR_PKT)
788
805
 
789
806
  # A SMB template for SMB Create requests
790
807
  SMB_CREATE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
791
- [ 'template', 'SMB', SMB_HDR ],
792
- [ 'uint8', 'AndX', 0 ],
793
- [ 'uint8', 'Reserved1', 0 ],
794
- [ 'uint16v', 'AndXOffset', 0 ],
795
- [ 'uint8', 'Reserved2', 0 ],
796
- [ 'uint16v', 'FileNameLen', 0 ],
797
- [ 'uint32v', 'CreateFlags', 0 ],
798
- [ 'uint32v', 'RootFileID', 0 ],
799
- [ 'uint32v', 'AccessMask', 0 ],
800
- [ 'uint32v', 'AllocLow', 0 ],
801
- [ 'uint32v', 'AllocHigh', 0 ],
802
- [ 'uint32v', 'Attributes', 0 ],
803
- [ 'uint32v', 'ShareAccess', 0 ],
804
- [ 'uint32v', 'Disposition', 0 ],
805
- [ 'uint32v', 'CreateOptions', 0 ],
806
- [ 'uint32v', 'Impersonation', 0 ],
807
- [ 'uint8', 'SecurityFlags', 0 ],
808
- [ 'uint16v', 'ByteCount', 0 ],
809
- [ 'string', 'Payload', nil, '' ]
808
+ [ 'template', 'SMB', SMB_HDR ],
809
+ [ 'uint8', 'AndX', 0 ],
810
+ [ 'uint8', 'Reserved1', 0 ],
811
+ [ 'uint16v', 'AndXOffset', 0 ],
812
+ [ 'uint8', 'Reserved2', 0 ],
813
+ [ 'uint16v', 'FileNameLen', 0 ],
814
+ [ 'uint32v', 'CreateFlags', 0 ],
815
+ [ 'uint32v', 'RootFileID', 0 ],
816
+ [ 'uint32v', 'AccessMask', 0 ],
817
+ [ 'uint32v', 'AllocLow', 0 ],
818
+ [ 'uint32v', 'AllocHigh', 0 ],
819
+ [ 'uint32v', 'Attributes', 0 ],
820
+ [ 'uint32v', 'ShareAccess', 0 ],
821
+ [ 'uint32v', 'Disposition', 0 ],
822
+ [ 'uint32v', 'CreateOptions', 0 ],
823
+ [ 'uint32v', 'Impersonation', 0 ],
824
+ [ 'uint8', 'SecurityFlags', 0 ],
825
+ [ 'uint16v', 'ByteCount', 0 ],
826
+ [ 'string', 'Payload', nil, '' ]
810
827
  ).create_restraints(
811
- [ 'Payload', 'ByteCount', nil, true ]
828
+ [ 'Payload', 'ByteCount', nil, true ]
812
829
  )
813
830
  SMB_CREATE_PKT = self.make_nbs(SMB_CREATE_HDR_PKT)
814
831
 
815
832
 
816
833
  # A SMB template for SMB Create responses
817
834
  SMB_CREATE_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
818
- [ 'template', 'SMB', SMB_HDR ],
819
- [ 'uint8', 'AndX', 0 ],
820
- [ 'uint8', 'Reserved1', 0 ],
821
- [ 'uint16v', 'AndXOffset', 0 ],
822
- [ 'uint8', 'OpLock', 0 ],
823
- [ 'uint16v', 'FileID', 0 ],
824
- [ 'uint32v', 'Action', 0 ],
825
- [ 'uint32v', 'CreateTimeLow', 0 ],
826
- [ 'uint32v', 'CreateTimeHigh', 0 ],
827
- [ 'uint32v', 'AccessTimeLow', 0 ],
828
- [ 'uint32v', 'AccessTimeHigh', 0 ],
829
- [ 'uint32v', 'WriteTimeLow', 0 ],
830
- [ 'uint32v', 'WriteTimeHigh', 0 ],
831
- [ 'uint32v', 'ChangeTimeLow', 0 ],
832
- [ 'uint32v', 'ChangeTimeHigh', 0 ],
833
- [ 'uint32v', 'Attributes', 0 ],
834
- [ 'uint32v', 'AllocLow', 0 ],
835
- [ 'uint32v', 'AllocHigh', 0 ],
836
- [ 'uint32v', 'EOFLow', 0 ],
837
- [ 'uint32v', 'EOFHigh', 0 ],
838
- [ 'uint16v', 'FileType', 0 ],
839
- [ 'uint16v', 'IPCState', 0 ],
840
- [ 'uint8', 'IsDirectory', 0 ],
841
- [ 'uint16v', 'ByteCount', 0 ],
842
- [ 'string', 'Payload', nil, '' ]
835
+ [ 'template', 'SMB', SMB_HDR ],
836
+ [ 'uint8', 'AndX', 0 ],
837
+ [ 'uint8', 'Reserved1', 0 ],
838
+ [ 'uint16v', 'AndXOffset', 0 ],
839
+ [ 'uint8', 'OpLock', 0 ],
840
+ [ 'uint16v', 'FileID', 0 ],
841
+ [ 'uint32v', 'Action', 0 ],
842
+ [ 'uint32v', 'CreateTimeLow', 0 ],
843
+ [ 'uint32v', 'CreateTimeHigh', 0 ],
844
+ [ 'uint32v', 'AccessTimeLow', 0 ],
845
+ [ 'uint32v', 'AccessTimeHigh', 0 ],
846
+ [ 'uint32v', 'WriteTimeLow', 0 ],
847
+ [ 'uint32v', 'WriteTimeHigh', 0 ],
848
+ [ 'uint32v', 'ChangeTimeLow', 0 ],
849
+ [ 'uint32v', 'ChangeTimeHigh', 0 ],
850
+ [ 'uint32v', 'Attributes', 0 ],
851
+ [ 'uint32v', 'AllocLow', 0 ],
852
+ [ 'uint32v', 'AllocHigh', 0 ],
853
+ [ 'uint32v', 'EOFLow', 0 ],
854
+ [ 'uint32v', 'EOFHigh', 0 ],
855
+ [ 'uint16v', 'FileType', 0 ],
856
+ [ 'uint16v', 'IPCState', 0 ],
857
+ [ 'uint8', 'IsDirectory', 0 ],
858
+ [ 'uint16v', 'ByteCount', 0 ],
859
+ [ 'string', 'Payload', nil, '' ]
843
860
  ).create_restraints(
844
- [ 'Payload', 'ByteCount', nil, true ]
861
+ [ 'Payload', 'ByteCount', nil, true ]
845
862
  )
846
863
  SMB_CREATE_RES_PKT = self.make_nbs(SMB_CREATE_RES_HDR_PKT)
847
864
 
848
865
 
849
866
  # A SMB template for SMB Write requests
850
867
  SMB_WRITE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
851
- [ 'template', 'SMB', SMB_HDR ],
852
- [ 'uint8', 'AndX', 0 ],
853
- [ 'uint8', 'Reserved1', 0 ],
854
- [ 'uint16v', 'AndXOffset', 0 ],
855
- [ 'uint16v', 'FileID', 0 ],
856
- [ 'uint32v', 'Offset', 0 ],
857
- [ 'uint32v', 'Reserved2', 0 ],
858
- [ 'uint16v', 'WriteMode', 0 ],
859
- [ 'uint16v', 'Remaining', 0 ],
860
- [ 'uint16v', 'DataLenHigh', 0 ],
861
- [ 'uint16v', 'DataLenLow', 0 ],
862
- [ 'uint16v', 'DataOffset', 0 ],
863
- [ 'uint32v', 'DataOffsetHigh', 0 ],
864
- [ 'uint16v', 'ByteCount', 0 ],
865
- [ 'string', 'Payload', nil, '' ]
868
+ [ 'template', 'SMB', SMB_HDR ],
869
+ [ 'uint8', 'AndX', 0 ],
870
+ [ 'uint8', 'Reserved1', 0 ],
871
+ [ 'uint16v', 'AndXOffset', 0 ],
872
+ [ 'uint16v', 'FileID', 0 ],
873
+ [ 'uint32v', 'Offset', 0 ],
874
+ [ 'uint32v', 'Reserved2', 0 ],
875
+ [ 'uint16v', 'WriteMode', 0 ],
876
+ [ 'uint16v', 'Remaining', 0 ],
877
+ [ 'uint16v', 'DataLenHigh', 0 ],
878
+ [ 'uint16v', 'DataLenLow', 0 ],
879
+ [ 'uint16v', 'DataOffset', 0 ],
880
+ [ 'uint32v', 'DataOffsetHigh', 0 ],
881
+ [ 'uint16v', 'ByteCount', 0 ],
882
+ [ 'string', 'Payload', nil, '' ]
866
883
  ).create_restraints(
867
- [ 'Payload', 'ByteCount', nil, true ]
884
+ [ 'Payload', 'ByteCount', nil, true ]
868
885
  )
869
886
  SMB_WRITE_PKT = self.make_nbs(SMB_WRITE_HDR_PKT)
870
887
 
871
888
 
872
889
  # A SMB template for SMB Write responses
873
890
  SMB_WRITE_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
874
- [ 'template', 'SMB', SMB_HDR ],
875
- [ 'uint8', 'AndX', 0 ],
876
- [ 'uint8', 'Reserved1', 0 ],
877
- [ 'uint16v', 'AndXOffset', 0 ],
878
- [ 'uint16v', 'CountLow', 0 ],
879
- [ 'uint16v', 'Remaining', 0 ],
880
- [ 'uint16v', 'CountHigh', 0 ],
881
- [ 'uint16v', 'Reserved2', 0 ],
882
- [ 'uint16v', 'ByteCount', 0 ],
883
- [ 'string', 'Payload', nil, '' ]
891
+ [ 'template', 'SMB', SMB_HDR ],
892
+ [ 'uint8', 'AndX', 0 ],
893
+ [ 'uint8', 'Reserved1', 0 ],
894
+ [ 'uint16v', 'AndXOffset', 0 ],
895
+ [ 'uint16v', 'CountLow', 0 ],
896
+ [ 'uint16v', 'Remaining', 0 ],
897
+ [ 'uint16v', 'CountHigh', 0 ],
898
+ [ 'uint16v', 'Reserved2', 0 ],
899
+ [ 'uint16v', 'ByteCount', 0 ],
900
+ [ 'string', 'Payload', nil, '' ]
884
901
  ).create_restraints(
885
- [ 'Payload', 'ByteCount', nil, true ]
902
+ [ 'Payload', 'ByteCount', nil, true ]
886
903
  )
887
904
  SMB_WRITE_RES_PKT = self.make_nbs(SMB_WRITE_RES_HDR_PKT)
888
905
 
889
906
 
890
907
  # A SMB template for SMB OPEN requests
891
908
  SMB_OPEN_HDR_PKT = Rex::Struct2::CStructTemplate.new(
892
- [ 'template', 'SMB', SMB_HDR ],
893
- [ 'uint8', 'AndX', 0 ],
894
- [ 'uint8', 'Reserved1', 0 ],
895
- [ 'uint16v', 'AndXOffset', 0 ],
896
- [ 'uint16v', 'Flags', 0 ],
897
- [ 'uint16v', 'Access', 0 ],
898
- [ 'uint16v', 'SearchAttributes', 0 ],
899
- [ 'uint16v', 'FileAttributes', 0 ],
900
- [ 'uint32v', 'CreateTime', 0 ],
901
- [ 'uint16v', 'OpenFunction', 0 ],
902
- [ 'uint32v', 'AllocSize', 0 ],
903
- [ 'uint32v', 'Reserved2', 0 ],
904
- [ 'uint32v', 'Reserved3', 0 ],
905
- [ 'uint16v', 'ByteCount', 0 ],
906
- [ 'string', 'Payload', nil, '' ]
909
+ [ 'template', 'SMB', SMB_HDR ],
910
+ [ 'uint8', 'AndX', 0 ],
911
+ [ 'uint8', 'Reserved1', 0 ],
912
+ [ 'uint16v', 'AndXOffset', 0 ],
913
+ [ 'uint16v', 'Flags', 0 ],
914
+ [ 'uint16v', 'Access', 0 ],
915
+ [ 'uint16v', 'SearchAttributes', 0 ],
916
+ [ 'uint16v', 'FileAttributes', 0 ],
917
+ [ 'uint32v', 'CreateTime', 0 ],
918
+ [ 'uint16v', 'OpenFunction', 0 ],
919
+ [ 'uint32v', 'AllocSize', 0 ],
920
+ [ 'uint32v', 'Reserved2', 0 ],
921
+ [ 'uint32v', 'Reserved3', 0 ],
922
+ [ 'uint16v', 'ByteCount', 0 ],
923
+ [ 'string', 'Payload', nil, '' ]
907
924
  ).create_restraints(
908
- [ 'Payload', 'ByteCount', nil, true ]
925
+ [ 'Payload', 'ByteCount', nil, true ]
909
926
  )
910
927
  SMB_OPEN_PKT = self.make_nbs(SMB_OPEN_HDR_PKT)
911
928
 
912
929
 
913
930
  # A SMB template for SMB OPEN responses
914
931
  SMB_OPEN_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
915
- [ 'template', 'SMB', SMB_HDR ],
916
- [ 'uint8', 'AndX', 0 ],
917
- [ 'uint8', 'Reserved1', 0 ],
918
- [ 'uint16v', 'AndXOffset', 0 ],
919
- [ 'uint16v', 'FileID', 0 ],
920
- [ 'uint16v', 'FileAttributes', 0 ],
921
- [ 'uint32v', 'WriteTime', 0 ],
922
- [ 'uint32v', 'FileSize', 0 ],
923
- [ 'uint16v', 'FileAccess', 0 ],
924
- [ 'uint16v', 'FileType', 0 ],
925
- [ 'uint16v', 'IPCState', 0 ],
926
- [ 'uint16v', 'Action', 0 ],
927
- [ 'uint32v', 'ServerFileID', 0 ],
928
- [ 'uint16v', 'Reserved2', 0 ],
929
- [ 'uint16v', 'ByteCount', 0 ],
930
- [ 'string', 'Payload', nil, '' ]
932
+ [ 'template', 'SMB', SMB_HDR ],
933
+ [ 'uint8', 'AndX', 0 ],
934
+ [ 'uint8', 'Reserved1', 0 ],
935
+ [ 'uint16v', 'AndXOffset', 0 ],
936
+ [ 'uint16v', 'FileID', 0 ],
937
+ [ 'uint16v', 'FileAttributes', 0 ],
938
+ [ 'uint32v', 'WriteTime', 0 ],
939
+ [ 'uint32v', 'FileSize', 0 ],
940
+ [ 'uint16v', 'FileAccess', 0 ],
941
+ [ 'uint16v', 'FileType', 0 ],
942
+ [ 'uint16v', 'IPCState', 0 ],
943
+ [ 'uint16v', 'Action', 0 ],
944
+ [ 'uint32v', 'ServerFileID', 0 ],
945
+ [ 'uint16v', 'Reserved2', 0 ],
946
+ [ 'uint16v', 'ByteCount', 0 ],
947
+ [ 'string', 'Payload', nil, '' ]
931
948
  ).create_restraints(
932
- [ 'Payload', 'ByteCount', nil, true ]
949
+ [ 'Payload', 'ByteCount', nil, true ]
933
950
  )
934
951
  SMB_OPEN_RES_PKT = self.make_nbs(SMB_OPEN_RES_HDR_PKT)
935
952
 
936
953
 
937
954
  # A SMB template for SMB Close requests
938
955
  SMB_CLOSE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
939
- [ 'template', 'SMB', SMB_HDR ],
940
- [ 'uint16v', 'FileID', 0 ],
941
- [ 'uint32v', 'LastWrite', 0 ],
942
- [ 'uint16v', 'ByteCount', 0 ],
943
- [ 'string', 'Payload', nil, '' ]
956
+ [ 'template', 'SMB', SMB_HDR ],
957
+ [ 'uint16v', 'FileID', 0 ],
958
+ [ 'uint32v', 'LastWrite', 0 ],
959
+ [ 'uint16v', 'ByteCount', 0 ],
960
+ [ 'string', 'Payload', nil, '' ]
944
961
  ).create_restraints(
945
- [ 'Payload', 'ByteCount', nil, true ]
962
+ [ 'Payload', 'ByteCount', nil, true ]
946
963
  )
947
964
  SMB_CLOSE_PKT = self.make_nbs(SMB_CLOSE_HDR_PKT)
948
965
 
949
966
 
950
967
  # A SMB template for SMB Close responses
951
968
  SMB_CLOSE_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
952
- [ 'template', 'SMB', SMB_HDR ],
953
- [ 'uint16v', 'ByteCount', 0 ],
954
- [ 'string', 'Payload', nil, '' ]
969
+ [ 'template', 'SMB', SMB_HDR ],
970
+ [ 'uint16v', 'ByteCount', 0 ],
971
+ [ 'string', 'Payload', nil, '' ]
955
972
  ).create_restraints(
956
- [ 'Payload', 'ByteCount', nil, true ]
973
+ [ 'Payload', 'ByteCount', nil, true ]
957
974
  )
958
975
  SMB_CLOSE_RES_PKT = self.make_nbs(SMB_CLOSE_RES_HDR_PKT)
959
976
 
960
977
 
961
978
  # A SMB template for SMB Delete requests
962
979
  SMB_DELETE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
963
- [ 'template', 'SMB', SMB_HDR ],
964
- [ 'uint16v', 'SearchAttribute', 0 ],
965
- [ 'uint16v', 'ByteCount', 0 ],
966
- [ 'uint8', 'BufferFormat', 0 ],
967
- [ 'string', 'Payload', nil, '' ]
980
+ [ 'template', 'SMB', SMB_HDR ],
981
+ [ 'uint16v', 'SearchAttribute', 0 ],
982
+ [ 'uint16v', 'ByteCount', 0 ],
983
+ [ 'uint8', 'BufferFormat', 0 ],
984
+ [ 'string', 'Payload', nil, '' ]
968
985
  ).create_restraints(
969
- [ 'Payload', 'ByteCount', nil, true ]
986
+ [ 'Payload', 'ByteCount', nil, true ]
970
987
  )
971
988
  SMB_DELETE_PKT = self.make_nbs(SMB_DELETE_HDR_PKT)
972
989
 
973
990
 
974
991
  # A SMB template for SMB Delete responses
975
992
  SMB_DELETE_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
976
- [ 'template', 'SMB', SMB_HDR ],
977
- [ 'uint16v', 'ByteCount', 0 ],
978
- [ 'string', 'Payload', nil, '' ]
993
+ [ 'template', 'SMB', SMB_HDR ],
994
+ [ 'uint16v', 'ByteCount', 0 ],
995
+ [ 'string', 'Payload', nil, '' ]
979
996
  ).create_restraints(
980
- [ 'Payload', 'ByteCount', nil, true ]
997
+ [ 'Payload', 'ByteCount', nil, true ]
981
998
  )
982
999
  SMB_DELETE_RES_PKT = self.make_nbs(SMB_DELETE_RES_HDR_PKT)
983
1000
 
@@ -985,43 +1002,43 @@ SMB_DELETE_RES_PKT = self.make_nbs(SMB_DELETE_RES_HDR_PKT)
985
1002
 
986
1003
  # A SMB template for SMB Read requests
987
1004
  SMB_READ_HDR_PKT = Rex::Struct2::CStructTemplate.new(
988
- [ 'template', 'SMB', SMB_HDR ],
989
- [ 'uint8', 'AndX', 0 ],
990
- [ 'uint8', 'Reserved1', 0 ],
991
- [ 'uint16v', 'AndXOffset', 0 ],
992
- [ 'uint16v', 'FileID', 0 ],
993
- [ 'uint32v', 'Offset', 0 ],
994
- [ 'uint16v', 'MaxCountLow', 0 ],
995
- [ 'uint16v', 'MinCount', 0 ],
996
- [ 'uint32v', 'Reserved2', 0 ],
997
- [ 'uint16v', 'Remaining', 0 ],
998
- [ 'uint32v', 'MaxCountHigh', 0 ],
999
- [ 'uint16v', 'ByteCount', 0 ],
1000
- [ 'string', 'Payload', nil, '' ]
1005
+ [ 'template', 'SMB', SMB_HDR ],
1006
+ [ 'uint8', 'AndX', 0 ],
1007
+ [ 'uint8', 'Reserved1', 0 ],
1008
+ [ 'uint16v', 'AndXOffset', 0 ],
1009
+ [ 'uint16v', 'FileID', 0 ],
1010
+ [ 'uint32v', 'Offset', 0 ],
1011
+ [ 'uint16v', 'MaxCountLow', 0 ],
1012
+ [ 'uint16v', 'MinCount', 0 ],
1013
+ [ 'uint32v', 'Reserved2', 0 ],
1014
+ [ 'uint16v', 'Remaining', 0 ],
1015
+ [ 'uint32v', 'MaxCountHigh', 0 ],
1016
+ [ 'uint16v', 'ByteCount', 0 ],
1017
+ [ 'string', 'Payload', nil, '' ]
1001
1018
  ).create_restraints(
1002
- [ 'Payload', 'ByteCount', nil, true ]
1019
+ [ 'Payload', 'ByteCount', nil, true ]
1003
1020
  )
1004
1021
  SMB_READ_PKT = self.make_nbs(SMB_READ_HDR_PKT)
1005
1022
 
1006
1023
 
1007
1024
  # A SMB template for SMB Read responses
1008
1025
  SMB_READ_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
1009
- [ 'template', 'SMB', SMB_HDR ],
1010
- [ 'uint8', 'AndX', 0 ],
1011
- [ 'uint8', 'Reserved1', 0 ],
1012
- [ 'uint16v', 'AndXOffset', 0 ],
1013
- [ 'uint16v', 'Remaining', 0 ],
1014
- [ 'uint16v', 'DataCompaction', 0 ],
1015
- [ 'uint16v', 'Reserved2', 0 ],
1016
- [ 'uint16v', 'DataLenLow', 0 ],
1017
- [ 'uint16v', 'DataOffset', 0 ],
1018
- [ 'uint32v', 'DataLenHigh', 0 ],
1019
- [ 'uint32v', 'Reserved3', 0 ],
1020
- [ 'uint16v', 'Reserved4', 0 ],
1021
- [ 'uint16v', 'ByteCount', 0 ],
1022
- [ 'string', 'Payload', nil, '' ]
1026
+ [ 'template', 'SMB', SMB_HDR ],
1027
+ [ 'uint8', 'AndX', 0 ],
1028
+ [ 'uint8', 'Reserved1', 0 ],
1029
+ [ 'uint16v', 'AndXOffset', 0 ],
1030
+ [ 'uint16v', 'Remaining', 0 ],
1031
+ [ 'uint16v', 'DataCompaction', 0 ],
1032
+ [ 'uint16v', 'Reserved2', 0 ],
1033
+ [ 'uint16v', 'DataLenLow', 0 ],
1034
+ [ 'uint16v', 'DataOffset', 0 ],
1035
+ [ 'uint32v', 'DataLenHigh', 0 ],
1036
+ [ 'uint32v', 'Reserved3', 0 ],
1037
+ [ 'uint16v', 'Reserved4', 0 ],
1038
+ [ 'uint16v', 'ByteCount', 0 ],
1039
+ [ 'string', 'Payload', nil, '' ]
1023
1040
  ).create_restraints(
1024
- [ 'Payload', 'ByteCount', nil, true ]
1041
+ [ 'Payload', 'ByteCount', nil, true ]
1025
1042
  )
1026
1043
  SMB_READ_RES_PKT = self.make_nbs(SMB_READ_RES_HDR_PKT)
1027
1044
 
@@ -1029,13 +1046,13 @@ SMB_READ_RES_PKT = self.make_nbs(SMB_READ_RES_HDR_PKT)
1029
1046
 
1030
1047
  # A SMB template for SMB Search requests
1031
1048
  SMB_SEARCH_HDR_PKT = Rex::Struct2::CStructTemplate.new(
1032
- [ 'template', 'SMB', SMB_HDR ],
1033
- [ 'uint16v', 'MaxCount', 0 ],
1034
- [ 'uint16v', 'Attributes', 0 ],
1035
- [ 'uint16v', 'ByteCount', 0 ],
1036
- [ 'string', 'Payload', nil, '' ]
1049
+ [ 'template', 'SMB', SMB_HDR ],
1050
+ [ 'uint16v', 'MaxCount', 0 ],
1051
+ [ 'uint16v', 'Attributes', 0 ],
1052
+ [ 'uint16v', 'ByteCount', 0 ],
1053
+ [ 'string', 'Payload', nil, '' ]
1037
1054
  ).create_restraints(
1038
- [ 'Payload', 'ByteCount', nil, true ]
1055
+ [ 'Payload', 'ByteCount', nil, true ]
1039
1056
  )
1040
1057
  SMB_SEARCH_PKT = self.make_nbs(SMB_SEARCH_HDR_PKT)
1041
1058