dstruct 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.markdown +23 -0
- data/examples/smb_example.rb +35 -0
- data/lib/rex.rb +108 -0
- data/lib/rex/LICENSE +29 -0
- data/lib/rex/arch.rb +104 -0
- data/lib/rex/arch/sparc.rb +75 -0
- data/lib/rex/arch/x86.rb +524 -0
- data/lib/rex/assembly/nasm.rb +104 -0
- data/lib/rex/codepage.map +104 -0
- data/lib/rex/compat.rb +389 -0
- data/lib/rex/constants.rb +124 -0
- data/lib/rex/elfparsey.rb +9 -0
- data/lib/rex/elfparsey/elf.rb +121 -0
- data/lib/rex/elfparsey/elfbase.rb +256 -0
- data/lib/rex/elfparsey/exceptions.rb +25 -0
- data/lib/rex/elfscan.rb +10 -0
- data/lib/rex/elfscan/scanner.rb +226 -0
- data/lib/rex/elfscan/search.rb +44 -0
- data/lib/rex/encoder/alpha2.rb +31 -0
- data/lib/rex/encoder/alpha2/alpha_mixed.rb +68 -0
- data/lib/rex/encoder/alpha2/alpha_upper.rb +79 -0
- data/lib/rex/encoder/alpha2/generic.rb +90 -0
- data/lib/rex/encoder/alpha2/unicode_mixed.rb +116 -0
- data/lib/rex/encoder/alpha2/unicode_upper.rb +123 -0
- data/lib/rex/encoder/bloxor/bloxor.rb +327 -0
- data/lib/rex/encoder/ndr.rb +90 -0
- data/lib/rex/encoder/nonalpha.rb +61 -0
- data/lib/rex/encoder/nonupper.rb +64 -0
- data/lib/rex/encoder/xdr.rb +107 -0
- data/lib/rex/encoder/xor.rb +69 -0
- data/lib/rex/encoder/xor/dword.rb +13 -0
- data/lib/rex/encoder/xor/dword_additive.rb +13 -0
- data/lib/rex/encoders/xor_dword.rb +35 -0
- data/lib/rex/encoders/xor_dword_additive.rb +53 -0
- data/lib/rex/encoding/xor.rb +20 -0
- data/lib/rex/encoding/xor/byte.rb +15 -0
- data/lib/rex/encoding/xor/dword.rb +21 -0
- data/lib/rex/encoding/xor/dword_additive.rb +92 -0
- data/lib/rex/encoding/xor/exceptions.rb +17 -0
- data/lib/rex/encoding/xor/generic.rb +146 -0
- data/lib/rex/encoding/xor/qword.rb +15 -0
- data/lib/rex/encoding/xor/word.rb +21 -0
- data/lib/rex/exceptions.rb +275 -0
- data/lib/rex/exploitation/cmdstager.rb +10 -0
- data/lib/rex/exploitation/cmdstager/base.rb +190 -0
- data/lib/rex/exploitation/cmdstager/bourne.rb +105 -0
- data/lib/rex/exploitation/cmdstager/debug_asm.rb +140 -0
- data/lib/rex/exploitation/cmdstager/debug_write.rb +134 -0
- data/lib/rex/exploitation/cmdstager/echo.rb +164 -0
- data/lib/rex/exploitation/cmdstager/printf.rb +122 -0
- data/lib/rex/exploitation/cmdstager/tftp.rb +71 -0
- data/lib/rex/exploitation/cmdstager/vbs.rb +126 -0
- data/lib/rex/exploitation/egghunter.rb +425 -0
- data/lib/rex/exploitation/encryptjs.rb +78 -0
- data/lib/rex/exploitation/heaplib.js.b64 +331 -0
- data/lib/rex/exploitation/heaplib.rb +107 -0
- data/lib/rex/exploitation/js.rb +6 -0
- data/lib/rex/exploitation/js/detect.rb +69 -0
- data/lib/rex/exploitation/js/memory.rb +81 -0
- data/lib/rex/exploitation/js/network.rb +84 -0
- data/lib/rex/exploitation/js/utils.rb +33 -0
- data/lib/rex/exploitation/jsobfu.rb +513 -0
- data/lib/rex/exploitation/obfuscatejs.rb +336 -0
- data/lib/rex/exploitation/omelet.rb +321 -0
- data/lib/rex/exploitation/opcodedb.rb +819 -0
- data/lib/rex/exploitation/powershell.rb +62 -0
- data/lib/rex/exploitation/powershell/function.rb +63 -0
- data/lib/rex/exploitation/powershell/obfu.rb +98 -0
- data/lib/rex/exploitation/powershell/output.rb +151 -0
- data/lib/rex/exploitation/powershell/param.rb +23 -0
- data/lib/rex/exploitation/powershell/parser.rb +183 -0
- data/lib/rex/exploitation/powershell/psh_methods.rb +70 -0
- data/lib/rex/exploitation/powershell/script.rb +99 -0
- data/lib/rex/exploitation/ropdb.rb +190 -0
- data/lib/rex/exploitation/seh.rb +93 -0
- data/lib/rex/file.rb +160 -0
- data/lib/rex/image_source.rb +10 -0
- data/lib/rex/image_source/disk.rb +58 -0
- data/lib/rex/image_source/image_source.rb +44 -0
- data/lib/rex/image_source/memory.rb +35 -0
- data/lib/rex/io/bidirectional_pipe.rb +161 -0
- data/lib/rex/io/datagram_abstraction.rb +35 -0
- data/lib/rex/io/ring_buffer.rb +369 -0
- data/lib/rex/io/stream.rb +312 -0
- data/lib/rex/io/stream_abstraction.rb +209 -0
- data/lib/rex/io/stream_server.rb +221 -0
- data/lib/rex/job_container.rb +200 -0
- data/lib/rex/logging.rb +4 -0
- data/lib/rex/logging/log_dispatcher.rb +180 -0
- data/lib/rex/logging/log_sink.rb +43 -0
- data/lib/rex/logging/sinks/flatfile.rb +56 -0
- data/lib/rex/logging/sinks/stderr.rb +44 -0
- data/lib/rex/mac_oui.rb +16581 -0
- data/lib/rex/machparsey.rb +9 -0
- data/lib/rex/machparsey/exceptions.rb +34 -0
- data/lib/rex/machparsey/mach.rb +209 -0
- data/lib/rex/machparsey/machbase.rb +408 -0
- data/lib/rex/machscan.rb +9 -0
- data/lib/rex/machscan/scanner.rb +217 -0
- data/lib/rex/mime.rb +10 -0
- data/lib/rex/mime/encoding.rb +17 -0
- data/lib/rex/mime/header.rb +78 -0
- data/lib/rex/mime/message.rb +150 -0
- data/lib/rex/mime/part.rb +50 -0
- data/lib/rex/nop/opty2.rb +109 -0
- data/lib/rex/nop/opty2_tables.rb +301 -0
- data/lib/rex/ole.rb +202 -0
- data/lib/rex/ole/clsid.rb +44 -0
- data/lib/rex/ole/difat.rb +138 -0
- data/lib/rex/ole/directory.rb +228 -0
- data/lib/rex/ole/direntry.rb +237 -0
- data/lib/rex/ole/docs/dependencies.txt +8 -0
- data/lib/rex/ole/docs/references.txt +1 -0
- data/lib/rex/ole/fat.rb +96 -0
- data/lib/rex/ole/header.rb +201 -0
- data/lib/rex/ole/minifat.rb +74 -0
- data/lib/rex/ole/propset.rb +141 -0
- data/lib/rex/ole/samples/create_ole.rb +27 -0
- data/lib/rex/ole/samples/dir.rb +35 -0
- data/lib/rex/ole/samples/dump_stream.rb +34 -0
- data/lib/rex/ole/samples/ole_info.rb +23 -0
- data/lib/rex/ole/storage.rb +392 -0
- data/lib/rex/ole/stream.rb +50 -0
- data/lib/rex/ole/substorage.rb +46 -0
- data/lib/rex/ole/util.rb +154 -0
- data/lib/rex/parser/acunetix_nokogiri.rb +406 -0
- data/lib/rex/parser/apple_backup_manifestdb.rb +132 -0
- data/lib/rex/parser/appscan_nokogiri.rb +367 -0
- data/lib/rex/parser/arguments.rb +108 -0
- data/lib/rex/parser/burp_session_nokogiri.rb +291 -0
- data/lib/rex/parser/ci_nokogiri.rb +193 -0
- data/lib/rex/parser/foundstone_nokogiri.rb +342 -0
- data/lib/rex/parser/fusionvm_nokogiri.rb +109 -0
- data/lib/rex/parser/group_policy_preferences.rb +185 -0
- data/lib/rex/parser/ini.rb +186 -0
- data/lib/rex/parser/ip360_aspl_xml.rb +103 -0
- data/lib/rex/parser/ip360_xml.rb +98 -0
- data/lib/rex/parser/mbsa_nokogiri.rb +256 -0
- data/lib/rex/parser/nessus_xml.rb +121 -0
- data/lib/rex/parser/netsparker_xml.rb +109 -0
- data/lib/rex/parser/nexpose_raw_nokogiri.rb +686 -0
- data/lib/rex/parser/nexpose_simple_nokogiri.rb +330 -0
- data/lib/rex/parser/nexpose_xml.rb +172 -0
- data/lib/rex/parser/nmap_nokogiri.rb +394 -0
- data/lib/rex/parser/nmap_xml.rb +166 -0
- data/lib/rex/parser/nokogiri_doc_mixin.rb +233 -0
- data/lib/rex/parser/openvas_nokogiri.rb +172 -0
- data/lib/rex/parser/outpost24_nokogiri.rb +240 -0
- data/lib/rex/parser/retina_xml.rb +110 -0
- data/lib/rex/parser/unattend.rb +171 -0
- data/lib/rex/parser/wapiti_nokogiri.rb +105 -0
- data/lib/rex/payloads.rb +2 -0
- data/lib/rex/payloads/win32.rb +3 -0
- data/lib/rex/payloads/win32/common.rb +27 -0
- data/lib/rex/payloads/win32/kernel.rb +54 -0
- data/lib/rex/payloads/win32/kernel/common.rb +55 -0
- data/lib/rex/payloads/win32/kernel/migration.rb +13 -0
- data/lib/rex/payloads/win32/kernel/recovery.rb +51 -0
- data/lib/rex/payloads/win32/kernel/stager.rb +195 -0
- data/lib/rex/peparsey.rb +10 -0
- data/lib/rex/peparsey/exceptions.rb +30 -0
- data/lib/rex/peparsey/pe.rb +210 -0
- data/lib/rex/peparsey/pe_memdump.rb +61 -0
- data/lib/rex/peparsey/pebase.rb +1662 -0
- data/lib/rex/peparsey/section.rb +128 -0
- data/lib/rex/pescan.rb +11 -0
- data/lib/rex/pescan/analyze.rb +366 -0
- data/lib/rex/pescan/scanner.rb +230 -0
- data/lib/rex/pescan/search.rb +68 -0
- data/lib/rex/platforms.rb +2 -0
- data/lib/rex/platforms/windows.rb +52 -0
- data/lib/rex/poly.rb +134 -0
- data/lib/rex/poly/block.rb +480 -0
- data/lib/rex/poly/machine.rb +13 -0
- data/lib/rex/poly/machine/machine.rb +830 -0
- data/lib/rex/poly/machine/x86.rb +509 -0
- data/lib/rex/poly/register.rb +101 -0
- data/lib/rex/poly/register/x86.rb +41 -0
- data/lib/rex/post.rb +7 -0
- data/lib/rex/post/dir.rb +51 -0
- data/lib/rex/post/file.rb +172 -0
- data/lib/rex/post/file_stat.rb +220 -0
- data/lib/rex/post/gen.pl +13 -0
- data/lib/rex/post/io.rb +182 -0
- data/lib/rex/post/meterpreter.rb +5 -0
- data/lib/rex/post/meterpreter/channel.rb +446 -0
- data/lib/rex/post/meterpreter/channel_container.rb +54 -0
- data/lib/rex/post/meterpreter/channels/pool.rb +160 -0
- data/lib/rex/post/meterpreter/channels/pools/file.rb +62 -0
- data/lib/rex/post/meterpreter/channels/pools/stream_pool.rb +103 -0
- data/lib/rex/post/meterpreter/channels/stream.rb +87 -0
- data/lib/rex/post/meterpreter/client.rb +483 -0
- data/lib/rex/post/meterpreter/client_core.rb +352 -0
- data/lib/rex/post/meterpreter/dependencies.rb +3 -0
- data/lib/rex/post/meterpreter/extension.rb +32 -0
- data/lib/rex/post/meterpreter/extensions/android/android.rb +128 -0
- data/lib/rex/post/meterpreter/extensions/android/tlv.rb +40 -0
- data/lib/rex/post/meterpreter/extensions/espia/espia.rb +58 -0
- data/lib/rex/post/meterpreter/extensions/espia/tlv.rb +17 -0
- data/lib/rex/post/meterpreter/extensions/extapi/adsi/adsi.rb +71 -0
- data/lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb +169 -0
- data/lib/rex/post/meterpreter/extensions/extapi/extapi.rb +45 -0
- data/lib/rex/post/meterpreter/extensions/extapi/service/service.rb +104 -0
- data/lib/rex/post/meterpreter/extensions/extapi/tlv.rb +77 -0
- data/lib/rex/post/meterpreter/extensions/extapi/window/window.rb +56 -0
- data/lib/rex/post/meterpreter/extensions/extapi/wmi/wmi.rb +75 -0
- data/lib/rex/post/meterpreter/extensions/incognito/incognito.rb +94 -0
- data/lib/rex/post/meterpreter/extensions/incognito/tlv.rb +22 -0
- data/lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb +361 -0
- data/lib/rex/post/meterpreter/extensions/kiwi/tlv.rb +76 -0
- data/lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb +78 -0
- data/lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb +43 -0
- data/lib/rex/post/meterpreter/extensions/lanattacks/tftp/tftp.rb +49 -0
- data/lib/rex/post/meterpreter/extensions/lanattacks/tlv.rb +17 -0
- data/lib/rex/post/meterpreter/extensions/mimikatz/mimikatz.rb +128 -0
- data/lib/rex/post/meterpreter/extensions/mimikatz/tlv.rb +16 -0
- data/lib/rex/post/meterpreter/extensions/networkpug/networkpug.rb +57 -0
- data/lib/rex/post/meterpreter/extensions/networkpug/tlv.rb +16 -0
- data/lib/rex/post/meterpreter/extensions/priv/fs.rb +118 -0
- data/lib/rex/post/meterpreter/extensions/priv/passwd.rb +61 -0
- data/lib/rex/post/meterpreter/extensions/priv/priv.rb +109 -0
- data/lib/rex/post/meterpreter/extensions/priv/tlv.rb +29 -0
- data/lib/rex/post/meterpreter/extensions/sniffer/sniffer.rb +117 -0
- data/lib/rex/post/meterpreter/extensions/sniffer/tlv.rb +27 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/constants.rb +396 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb +284 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +399 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb +104 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/io.rb +48 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb +59 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/config.rb +256 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb +129 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb +97 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/resolve.rb +106 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/route.rb +67 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb +139 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb +180 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_server_channel.rb +168 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb +209 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb +38146 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb +48 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_advapi32.rb +2102 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_crypt32.rb +32 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_iphlpapi.rb +97 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb +3852 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_netapi32.rb +100 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ntdll.rb +168 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_psapi.rb +32 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_shell32.rb +32 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_user32.rb +3170 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_version.rb +41 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_wlanapi.rb +87 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_wldap32.rb +128 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ws2_32.rb +613 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb +388 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb +111 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb +149 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_wrapper.rb +27 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/mock_magic.rb +515 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/multicall.rb +319 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/platform_util.rb +23 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb +301 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/tlv.rb +56 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb +106 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/util.rb +676 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb +96 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb +151 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +128 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log.rb +192 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log_subsystem/event_record.rb +41 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb +60 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb +408 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/image.rb +129 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/io.rb +55 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/memory.rb +336 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/thread.rb +141 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry.rb +328 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_key.rb +193 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb +102 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb +188 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/thread.rb +180 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/tlv.rb +236 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +259 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb +201 -0
- data/lib/rex/post/meterpreter/inbound_packet_handler.rb +30 -0
- data/lib/rex/post/meterpreter/object_aliases.rb +83 -0
- data/lib/rex/post/meterpreter/packet.rb +709 -0
- data/lib/rex/post/meterpreter/packet_dispatcher.rb +543 -0
- data/lib/rex/post/meterpreter/packet_parser.rb +94 -0
- data/lib/rex/post/meterpreter/packet_response_waiter.rb +83 -0
- data/lib/rex/post/meterpreter/ui/console.rb +142 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher.rb +86 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb +383 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +939 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/espia.rb +109 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi.rb +65 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/adsi.rb +198 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/clipboard.rb +444 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb +199 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/window.rb +118 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/wmi.rb +108 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/incognito.rb +242 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/kiwi.rb +509 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks.rb +60 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb +254 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb +159 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/mimikatz.rb +182 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/networkpug.rb +232 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv.rb +62 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/elevate.rb +97 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/passwd.rb +52 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb +133 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/sniffer.rb +204 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi.rb +66 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +527 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +448 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +906 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +318 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb +343 -0
- data/lib/rex/post/meterpreter/ui/console/interactive_channel.rb +99 -0
- data/lib/rex/post/permission.rb +26 -0
- data/lib/rex/post/process.rb +57 -0
- data/lib/rex/post/thread.rb +57 -0
- data/lib/rex/post/ui.rb +52 -0
- data/lib/rex/proto.rb +15 -0
- data/lib/rex/proto/addp.rb +218 -0
- data/lib/rex/proto/dcerpc.rb +7 -0
- data/lib/rex/proto/dcerpc/client.rb +362 -0
- data/lib/rex/proto/dcerpc/exceptions.rb +151 -0
- data/lib/rex/proto/dcerpc/handle.rb +48 -0
- data/lib/rex/proto/dcerpc/ndr.rb +73 -0
- data/lib/rex/proto/dcerpc/packet.rb +264 -0
- data/lib/rex/proto/dcerpc/response.rb +188 -0
- data/lib/rex/proto/dcerpc/uuid.rb +85 -0
- data/lib/rex/proto/dcerpc/wdscp.rb +3 -0
- data/lib/rex/proto/dcerpc/wdscp/constants.rb +89 -0
- data/lib/rex/proto/dcerpc/wdscp/packet.rb +94 -0
- data/lib/rex/proto/dhcp.rb +7 -0
- data/lib/rex/proto/dhcp/constants.rb +34 -0
- data/lib/rex/proto/dhcp/server.rb +334 -0
- data/lib/rex/proto/drda.rb +6 -0
- data/lib/rex/proto/drda/constants.rb +50 -0
- data/lib/rex/proto/drda/packet.rb +253 -0
- data/lib/rex/proto/drda/utils.rb +124 -0
- data/lib/rex/proto/http.rb +7 -0
- data/lib/rex/proto/http/client.rb +722 -0
- data/lib/rex/proto/http/client_request.rb +472 -0
- data/lib/rex/proto/http/handler.rb +47 -0
- data/lib/rex/proto/http/handler/erb.rb +129 -0
- data/lib/rex/proto/http/handler/proc.rb +61 -0
- data/lib/rex/proto/http/header.rb +173 -0
- data/lib/rex/proto/http/packet.rb +414 -0
- data/lib/rex/proto/http/request.rb +354 -0
- data/lib/rex/proto/http/response.rb +151 -0
- data/lib/rex/proto/http/server.rb +385 -0
- data/lib/rex/proto/iax2.rb +2 -0
- data/lib/rex/proto/iax2/call.rb +326 -0
- data/lib/rex/proto/iax2/client.rb +218 -0
- data/lib/rex/proto/iax2/codecs.rb +5 -0
- data/lib/rex/proto/iax2/codecs/alaw.rb +16 -0
- data/lib/rex/proto/iax2/codecs/g711.rb +2176 -0
- data/lib/rex/proto/iax2/codecs/mulaw.rb +17 -0
- data/lib/rex/proto/iax2/constants.rb +262 -0
- data/lib/rex/proto/ipmi.rb +57 -0
- data/lib/rex/proto/ipmi/channel_auth_reply.rb +89 -0
- data/lib/rex/proto/ipmi/open_session_reply.rb +36 -0
- data/lib/rex/proto/ipmi/rakp2.rb +36 -0
- data/lib/rex/proto/ipmi/utils.rb +125 -0
- data/lib/rex/proto/natpmp.rb +7 -0
- data/lib/rex/proto/natpmp/constants.rb +19 -0
- data/lib/rex/proto/natpmp/packet.rb +45 -0
- data/lib/rex/proto/ntlm.rb +8 -0
- data/lib/rex/proto/ntlm/base.rb +327 -0
- data/lib/rex/proto/ntlm/constants.rb +75 -0
- data/lib/rex/proto/ntlm/crypt.rb +412 -0
- data/lib/rex/proto/ntlm/exceptions.rb +17 -0
- data/lib/rex/proto/ntlm/message.rb +534 -0
- data/lib/rex/proto/ntlm/utils.rb +765 -0
- data/lib/rex/proto/ntp.rb +3 -0
- data/lib/rex/proto/ntp/constants.rb +12 -0
- data/lib/rex/proto/ntp/modes.rb +130 -0
- data/lib/rex/proto/pjl.rb +31 -0
- data/lib/rex/proto/pjl/client.rb +163 -0
- data/lib/rex/proto/proxy/socks4a.rb +441 -0
- data/lib/rex/proto/rfb.rb +13 -0
- data/lib/rex/proto/rfb/cipher.rb +82 -0
- data/lib/rex/proto/rfb/client.rb +205 -0
- data/lib/rex/proto/rfb/constants.rb +50 -0
- data/lib/rex/proto/sip.rb +4 -0
- data/lib/rex/proto/sip/response.rb +61 -0
- data/lib/rex/proto/smb.rb +8 -0
- data/lib/rex/proto/smb/client.rb +2064 -0
- data/lib/rex/proto/smb/constants.rb +1064 -0
- data/lib/rex/proto/smb/crypt.rb +37 -0
- data/lib/rex/proto/smb/evasions.rb +67 -0
- data/lib/rex/proto/smb/exceptions.rb +867 -0
- data/lib/rex/proto/smb/simpleclient.rb +173 -0
- data/lib/rex/proto/smb/simpleclient/open_file.rb +106 -0
- data/lib/rex/proto/smb/simpleclient/open_pipe.rb +57 -0
- data/lib/rex/proto/smb/utils.rb +104 -0
- data/lib/rex/proto/sunrpc.rb +2 -0
- data/lib/rex/proto/sunrpc/client.rb +196 -0
- data/lib/rex/proto/tftp.rb +13 -0
- data/lib/rex/proto/tftp/client.rb +344 -0
- data/lib/rex/proto/tftp/constants.rb +39 -0
- data/lib/rex/proto/tftp/server.rb +497 -0
- data/lib/rex/random_identifier_generator.rb +177 -0
- data/lib/rex/registry.rb +14 -0
- data/lib/rex/registry/hive.rb +132 -0
- data/lib/rex/registry/lfkey.rb +51 -0
- data/lib/rex/registry/nodekey.rb +54 -0
- data/lib/rex/registry/regf.rb +25 -0
- data/lib/rex/registry/valuekey.rb +67 -0
- data/lib/rex/registry/valuelist.rb +29 -0
- data/lib/rex/ropbuilder.rb +8 -0
- data/lib/rex/ropbuilder/rop.rb +271 -0
- data/lib/rex/script.rb +42 -0
- data/lib/rex/script/base.rb +61 -0
- data/lib/rex/script/meterpreter.rb +16 -0
- data/lib/rex/script/shell.rb +10 -0
- data/lib/rex/service.rb +49 -0
- data/lib/rex/service_manager.rb +154 -0
- data/lib/rex/services/local_relay.rb +424 -0
- data/lib/rex/socket.rb +788 -0
- data/lib/rex/socket/comm.rb +120 -0
- data/lib/rex/socket/comm/local.rb +526 -0
- data/lib/rex/socket/ip.rb +132 -0
- data/lib/rex/socket/parameters.rb +363 -0
- data/lib/rex/socket/range_walker.rb +470 -0
- data/lib/rex/socket/ssl_tcp.rb +345 -0
- data/lib/rex/socket/ssl_tcp_server.rb +188 -0
- data/lib/rex/socket/subnet_walker.rb +76 -0
- data/lib/rex/socket/switch_board.rb +289 -0
- data/lib/rex/socket/tcp.rb +79 -0
- data/lib/rex/socket/tcp_server.rb +67 -0
- data/lib/rex/socket/udp.rb +165 -0
- data/lib/rex/sslscan/result.rb +201 -0
- data/lib/rex/sslscan/scanner.rb +206 -0
- data/lib/rex/struct2.rb +5 -0
- data/lib/rex/struct2/c_struct.rb +181 -0
- data/lib/rex/struct2/c_struct_template.rb +39 -0
- data/lib/rex/struct2/constant.rb +26 -0
- data/lib/rex/struct2/element.rb +44 -0
- data/lib/rex/struct2/generic.rb +73 -0
- data/lib/rex/struct2/restraint.rb +54 -0
- data/lib/rex/struct2/s_string.rb +72 -0
- data/lib/rex/struct2/s_struct.rb +111 -0
- data/lib/rex/sync.rb +6 -0
- data/lib/rex/sync/event.rb +85 -0
- data/lib/rex/sync/read_write_lock.rb +177 -0
- data/lib/rex/sync/ref.rb +58 -0
- data/lib/rex/sync/thread_safe.rb +83 -0
- data/lib/rex/text.rb +1813 -0
- data/lib/rex/thread_factory.rb +43 -0
- data/lib/rex/time.rb +66 -0
- data/lib/rex/transformer.rb +116 -0
- data/lib/rex/ui.rb +22 -0
- data/lib/rex/ui/interactive.rb +304 -0
- data/lib/rex/ui/output.rb +85 -0
- data/lib/rex/ui/output/none.rb +19 -0
- data/lib/rex/ui/progress_tracker.rb +97 -0
- data/lib/rex/ui/subscriber.rb +160 -0
- data/lib/rex/ui/text/color.rb +98 -0
- data/lib/rex/ui/text/dispatcher_shell.rb +538 -0
- data/lib/rex/ui/text/input.rb +119 -0
- data/lib/rex/ui/text/input/buffer.rb +79 -0
- data/lib/rex/ui/text/input/readline.rb +129 -0
- data/lib/rex/ui/text/input/socket.rb +96 -0
- data/lib/rex/ui/text/input/stdio.rb +46 -0
- data/lib/rex/ui/text/irb_shell.rb +62 -0
- data/lib/rex/ui/text/output.rb +86 -0
- data/lib/rex/ui/text/output/buffer.rb +62 -0
- data/lib/rex/ui/text/output/buffer/stdout.rb +26 -0
- data/lib/rex/ui/text/output/file.rb +44 -0
- data/lib/rex/ui/text/output/socket.rb +44 -0
- data/lib/rex/ui/text/output/stdio.rb +53 -0
- data/lib/rex/ui/text/output/tee.rb +56 -0
- data/lib/rex/ui/text/progress_tracker.rb +57 -0
- data/lib/rex/ui/text/shell.rb +403 -0
- data/lib/rex/ui/text/table.rb +346 -0
- data/lib/rex/zip.rb +96 -0
- data/lib/rex/zip/archive.rb +130 -0
- data/lib/rex/zip/blocks.rb +184 -0
- data/lib/rex/zip/entry.rb +122 -0
- data/lib/rex/zip/jar.rb +283 -0
- data/lib/rex/zip/samples/comment.rb +32 -0
- data/lib/rex/zip/samples/mkwar.rb +138 -0
- data/lib/rex/zip/samples/mkzip.rb +19 -0
- data/lib/rex/zip/samples/recursive.rb +58 -0
- metadata +536 -0
@@ -0,0 +1,1064 @@
|
|
1
|
+
# -*- coding: binary -*-
|
2
|
+
module Rex
|
3
|
+
module Proto
|
4
|
+
module SMB
|
5
|
+
class Constants
|
6
|
+
|
7
|
+
require 'rex/struct2'
|
8
|
+
|
9
|
+
# SMB Commands
|
10
|
+
SMB_COM_CREATE_DIRECTORY = 0x00
|
11
|
+
SMB_COM_DELETE_DIRECTORY = 0x01
|
12
|
+
SMB_COM_OPEN = 0x02
|
13
|
+
SMB_COM_CREATE = 0x03
|
14
|
+
SMB_COM_CLOSE = 0x04
|
15
|
+
SMB_COM_FLUSH = 0x05
|
16
|
+
SMB_COM_DELETE = 0x06
|
17
|
+
SMB_COM_RENAME = 0x07
|
18
|
+
SMB_COM_QUERY_INFORMATION = 0x08
|
19
|
+
SMB_COM_SET_INFORMATION = 0x09
|
20
|
+
SMB_COM_READ = 0x0a
|
21
|
+
SMB_COM_WRITE = 0x0b
|
22
|
+
SMB_COM_LOCK_BYTE_RANGE = 0x0c
|
23
|
+
SMB_COM_UNLOCK_BYTE_RANGE = 0x0d
|
24
|
+
SMB_COM_CREATE_TEMPORARY = 0x0e
|
25
|
+
SMB_COM_CREATE_NEW = 0x0f
|
26
|
+
SMB_COM_CHECK_DIRECTORY = 0x10
|
27
|
+
SMB_COM_PROCESS_EXIT = 0x11
|
28
|
+
SMB_COM_SEEK = 0x12
|
29
|
+
SMB_COM_LOCK_AND_READ = 0x13
|
30
|
+
SMB_COM_WRITE_AND_UNLOCK = 0x14
|
31
|
+
SMB_COM_READ_RAW = 0x1a
|
32
|
+
SMB_COM_READ_MPX = 0x1b
|
33
|
+
SMB_COM_READ_MPX_SECONDARY = 0x1c
|
34
|
+
SMB_COM_WRITE_RAW = 0x1d
|
35
|
+
SMB_COM_WRITE_MPX = 0x1e
|
36
|
+
SMB_COM_WRITE_MPX_SECONDARY = 0x1f
|
37
|
+
SMB_COM_WRITE_COMPLETE = 0x20
|
38
|
+
SMB_COM_QUERY_SERVER = 0x21
|
39
|
+
SMB_COM_SET_INFORMATION2 = 0x22
|
40
|
+
SMB_COM_QUERY_INFORMATION2 = 0x23
|
41
|
+
SMB_COM_LOCKING_ANDX = 0x24
|
42
|
+
SMB_COM_TRANSACTION = 0x25
|
43
|
+
SMB_COM_TRANSACTION_SECONDARY = 0x26
|
44
|
+
SMB_COM_IOCTL = 0x27
|
45
|
+
SMB_COM_IOCTL_SECONDARY = 0x28
|
46
|
+
SMB_COM_COPY = 0x29
|
47
|
+
SMB_COM_MOVE = 0x2a
|
48
|
+
SMB_COM_ECHO = 0x2b
|
49
|
+
SMB_COM_WRITE_AND_CLOSE = 0x2c
|
50
|
+
SMB_COM_OPEN_ANDX = 0x2d
|
51
|
+
SMB_COM_READ_ANDX = 0x2e
|
52
|
+
SMB_COM_WRITE_ANDX = 0x2f
|
53
|
+
SMB_COM_NEW_FILE_SIZE = 0x30
|
54
|
+
SMB_COM_CLOSE_AND_TREE_DISC = 0x31
|
55
|
+
SMB_COM_TRANSACTION2 = 0x32
|
56
|
+
SMB_COM_TRANSACTION2_SECONDARY = 0x33
|
57
|
+
SMB_COM_FIND_CLOSE2 = 0x34
|
58
|
+
SMB_COM_FIND_NOTIFY_CLOSE = 0x35
|
59
|
+
SMB_COM_TREE_CONNECT = 0x70
|
60
|
+
SMB_COM_TREE_DISCONNECT = 0x71
|
61
|
+
SMB_COM_NEGOTIATE = 0x72
|
62
|
+
SMB_COM_SESSION_SETUP_ANDX = 0x73
|
63
|
+
SMB_COM_LOGOFF_ANDX = 0x74
|
64
|
+
SMB_COM_TREE_CONNECT_ANDX = 0x75
|
65
|
+
SMB_COM_QUERY_INFORMATION_DISK = 0x80
|
66
|
+
SMB_COM_SEARCH = 0x81
|
67
|
+
SMB_COM_FIND = 0x82
|
68
|
+
SMB_COM_FIND_UNIQUE = 0x83
|
69
|
+
SMB_COM_FIND_CLOSE = 0x84
|
70
|
+
SMB_COM_NT_TRANSACT = 0xa0
|
71
|
+
SMB_COM_NT_TRANSACT_SECONDARY = 0xa1
|
72
|
+
SMB_COM_NT_CREATE_ANDX = 0xa2
|
73
|
+
SMB_COM_NT_CANCEL = 0xa4
|
74
|
+
SMB_COM_NT_RENAME = 0xa5
|
75
|
+
SMB_COM_OPEN_PRINT_FILE = 0xc0
|
76
|
+
SMB_COM_WRITE_PRINT_FILE = 0xc1
|
77
|
+
SMB_COM_CLOSE_PRINT_FILE = 0xc2
|
78
|
+
SMB_COM_GET_PRINT_QUEUE = 0xc3
|
79
|
+
SMB_COM_READ_BULK = 0xd8
|
80
|
+
SMB_COM_WRITE_BULK = 0xd9
|
81
|
+
SMB_COM_NO_ANDX_COMMAND = 0xff
|
82
|
+
|
83
|
+
|
84
|
+
# SMB Version 2 Commands
|
85
|
+
SMB2_OP_NEGPROT = 0x00
|
86
|
+
SMB2_OP_SESSSETUP = 0x01
|
87
|
+
SMB2_OP_LOGOFF = 0x02
|
88
|
+
SMB2_OP_TCON = 0x03
|
89
|
+
SMB2_OP_TDIS = 0x04
|
90
|
+
SMB2_OP_CREATE = 0x05
|
91
|
+
SMB2_OP_CLOSE = 0x06
|
92
|
+
SMB2_OP_FLUSH = 0x07
|
93
|
+
SMB2_OP_READ = 0x08
|
94
|
+
SMB2_OP_WRITE = 0x09
|
95
|
+
SMB2_OP_LOCK = 0x0a
|
96
|
+
SMB2_OP_IOCTL = 0x0b
|
97
|
+
SMB2_OP_CANCEL = 0x0c
|
98
|
+
SMB2_OP_KEEPALIVE = 0x0d
|
99
|
+
SMB2_OP_FIND = 0x0e
|
100
|
+
SMB2_OP_NOTIFY = 0x0f
|
101
|
+
SMB2_OP_GETINFO = 0x10
|
102
|
+
SMB2_OP_SETINFO = 0x11
|
103
|
+
SMB2_OP_BREAK = 0x12
|
104
|
+
|
105
|
+
|
106
|
+
# SMB_COM_NT_TRANSACT Subcommands
|
107
|
+
NT_TRANSACT_CREATE = 1 # File open/create
|
108
|
+
NT_TRANSACT_IOCTL = 2 # Device IOCTL
|
109
|
+
NT_TRANSACT_SET_SECURITY_DESC = 3 # Set security descriptor
|
110
|
+
NT_TRANSACT_NOTIFY_CHANGE = 4 # Start directory watch
|
111
|
+
NT_TRANSACT_RENAME = 5 # Reserved (Handle-based)
|
112
|
+
NT_TRANSACT_QUERY_SECURITY_DESC = 6 # Retrieve security
|
113
|
+
NT_TRANSACT_GET_USER_QUOTA = 7 # Get quota
|
114
|
+
NT_TRANSACT_SET_USER_QUOTA = 8 # Set quota
|
115
|
+
|
116
|
+
# Open Modes
|
117
|
+
OPEN_MODE_CREAT = 0x10 # Create the file if file does not exists. Otherwise, operation fails.
|
118
|
+
OPEN_MODE_EXCL = 0x00 # When used with SMB_O_CREAT, operation fails if file exists. Cannot be used with SMB_O_OPEN.
|
119
|
+
OPEN_MODE_OPEN = 0x01 # Open the file if the file exists
|
120
|
+
OPEN_MODE_TRUNC = 0x02 # Truncate the file if the file exists
|
121
|
+
|
122
|
+
# Shared Access
|
123
|
+
OPEN_SHARE_COMPAT = 0x00
|
124
|
+
OPEN_SHARE_DENY_EXCL = 0x10
|
125
|
+
OPEN_SHARE_DENY_WRITE = 0x20
|
126
|
+
OPEN_SHARE_DENY_READEXEC = 0x30
|
127
|
+
OPEN_SHARE_DENY_NONE = 0x40
|
128
|
+
|
129
|
+
|
130
|
+
# File Access
|
131
|
+
OPEN_ACCESS_READ = 0x00
|
132
|
+
OPEN_ACCESS_WRITE = 0x01
|
133
|
+
OPEN_ACCESS_READWRITE = 0x02
|
134
|
+
OPEN_ACCESS_EXEC = 0x03
|
135
|
+
|
136
|
+
# Create Disposition
|
137
|
+
CREATE_ACCESS_SUPERSEDE = 0x00 # Replace any previously existing file
|
138
|
+
CREATE_ACCESS_EXIST = 0x01 # Open existing file and fail if it does not exist
|
139
|
+
CREATE_ACCESS_CREATE = 0x02 # Create the file, fail if it already exists
|
140
|
+
CREATE_ACCESS_OPENCREATE = 0x03 # Open existing file or create it if it does not exist
|
141
|
+
CREATE_ACCESS_OVEREXIST = 0x04 # Overwrite existing file and fail if it does not exist
|
142
|
+
CREATE_ACCESS_OVERCREATE = 0x05 # Overwrite existing file or create it if it does not exist
|
143
|
+
|
144
|
+
|
145
|
+
# Wildcard NetBIOS name
|
146
|
+
NETBIOS_REDIR = 'CACACACACACACACACACACACACACACAAA'
|
147
|
+
|
148
|
+
|
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
|
165
|
+
|
166
|
+
|
167
|
+
# SMB_COM_TRANSACTION2 Commands
|
168
|
+
TRANS2_OPEN2 = 0
|
169
|
+
TRANS2_FIND_FIRST2 = 1
|
170
|
+
TRANS2_FIND_NEXT2 = 2
|
171
|
+
TRANS2_QUERY_FS_INFO = 3
|
172
|
+
TRANS2_SET_PATH_INFO = 6
|
173
|
+
|
174
|
+
TRANS2_CREATE_DIRECTORY = 13
|
175
|
+
|
176
|
+
# SMB_COM_TRANSACTION2 QUERY_FS_INFO information levels
|
177
|
+
SMB_INFO_ALLOCATION = 1
|
178
|
+
SMB_INFO_VOLUME = 2
|
179
|
+
SMB_QUERY_FS_VOLUME_INFO = 0x102
|
180
|
+
SMB_QUERY_FS_SIZE_INFO = 0x103
|
181
|
+
SMB_QUERY_FS_DEVICE_INFO = 0x104
|
182
|
+
SMB_QUERY_FS_ATTRIBUTE_INFO = 0x105
|
183
|
+
|
184
|
+
# SMB_COM_TRANSACTION2 QUERY_PATH_INFO information levels
|
185
|
+
SMB_INFO_STANDARD = 1
|
186
|
+
SMB_INFO_QUERY_EA_SIZE = 2
|
187
|
+
SMB_INFO_QUERY_EAS_FROM_LIST = 3
|
188
|
+
SMB_INFO_QUERY_ALL_EAS = 4
|
189
|
+
SMB_INFO_IS_NAME_VALID = 6
|
190
|
+
SMB_QUERY_FILE_BASIC_INFO = 0x101
|
191
|
+
SMB_QUERY_FILE_STANDARD_INFO = 0x102
|
192
|
+
SMB_QUERY_FILE_EA_INFO = 0x103
|
193
|
+
SMB_QUERY_FILE_NAME_INFO = 0x104
|
194
|
+
SMB_QUERY_FILE_ALL_INFO = 0x107
|
195
|
+
SMB_QUERY_FILE_ALT_NAME_INFO = 0x108
|
196
|
+
SMB_QUERY_FILE_STREAM_INFO = 0x109
|
197
|
+
SMB_QUERY_FILE_COMPRESSION_INFO = 0x10B
|
198
|
+
SMB_QUERY_FILE_UNIX_BASIC = 0x200
|
199
|
+
SMB_QUERY_FILE_UNIX_LINK = 0x201
|
200
|
+
SMB_INFO_PASSTHROUGH = 0x1000
|
201
|
+
|
202
|
+
|
203
|
+
# Device Types
|
204
|
+
FILE_DEVICE_BEEP = 0x00000001
|
205
|
+
FILE_DEVICE_CD_ROM = 0x00000002
|
206
|
+
FILE_DEVICE_CD_ROM_FILE_SYSTEM = 0x00000003
|
207
|
+
FILE_DEVICE_CONTROLLER = 0x00000004
|
208
|
+
FILE_DEVICE_DATALINK = 0x00000005
|
209
|
+
FILE_DEVICE_DFS = 0x00000006
|
210
|
+
FILE_DEVICE_DISK = 0x00000007
|
211
|
+
FILE_DEVICE_DISK_FILE_SYSTEM = 0x00000008
|
212
|
+
FILE_DEVICE_FILE_SYSTEM = 0x00000009
|
213
|
+
FILE_DEVICE_INPORT_PORT = 0x0000000A
|
214
|
+
FILE_DEVICE_KEYBOARD = 0x0000000B
|
215
|
+
FILE_DEVICE_MAILSLOT = 0x0000000C
|
216
|
+
FILE_DEVICE_MIDI_IN = 0x0000000D
|
217
|
+
FILE_DEVICE_MIDI_OUT = 0x0000000E
|
218
|
+
FILE_DEVICE_MOUSE = 0x0000000F
|
219
|
+
FILE_DEVICE_MULTI_UNC_PROVIDER = 0x00000010
|
220
|
+
FILE_DEVICE_NAMED_PIPE = 0x00000011
|
221
|
+
FILE_DEVICE_NETWORK = 0x00000012
|
222
|
+
FILE_DEVICE_NETWORK_BROWSER = 0x00000013
|
223
|
+
FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x00000014
|
224
|
+
FILE_DEVICE_NULL = 0x00000015
|
225
|
+
FILE_DEVICE_PARALLEL_PORT = 0x00000016
|
226
|
+
FILE_DEVICE_PHYSICAL_NETCARD = 0x00000017
|
227
|
+
FILE_DEVICE_PRINTER = 0x00000018
|
228
|
+
FILE_DEVICE_SCANNER = 0x00000019
|
229
|
+
FILE_DEVICE_SERIAL_MOUSE_PORT = 0x0000001A
|
230
|
+
FILE_DEVICE_SERIAL_PORT = 0x0000001B
|
231
|
+
FILE_DEVICE_SCREEN = 0x0000001C
|
232
|
+
FILE_DEVICE_SOUND = 0x0000001D
|
233
|
+
FILE_DEVICE_STREAMS = 0x0000001E
|
234
|
+
FILE_DEVICE_TAPE = 0x0000001F
|
235
|
+
FILE_DEVICE_TAPE_FILE_SYSTEM = 0x00000020
|
236
|
+
FILE_DEVICE_TRANSPORT = 0x00000021
|
237
|
+
FILE_DEVICE_UNKNOWN = 0x00000022
|
238
|
+
FILE_DEVICE_VIDEO = 0x00000023
|
239
|
+
FILE_DEVICE_VIRTUAL_DISK = 0x00000024
|
240
|
+
FILE_DEVICE_WAVE_IN = 0x00000025
|
241
|
+
FILE_DEVICE_WAVE_OUT = 0x00000026
|
242
|
+
FILE_DEVICE_8042_PORT = 0x00000027
|
243
|
+
FILE_DEVICE_NETWORK_REDIRECTOR = 0x00000028
|
244
|
+
FILE_DEVICE_BATTERY = 0x00000029
|
245
|
+
FILE_DEVICE_BUS_EXTENDER = 0x0000002A
|
246
|
+
FILE_DEVICE_MODEM = 0x0000002B
|
247
|
+
FILE_DEVICE_VDM = 0x0000002C
|
248
|
+
|
249
|
+
# File and Device Attributes
|
250
|
+
FILE_REMOVABLE_MEDIA = 0x00000001
|
251
|
+
FILE_READ_ONLY_DEVICE = 0x00000002
|
252
|
+
FILE_FLOPPY_DISKETTE = 0x00000004
|
253
|
+
FILE_WRITE_ONE_MEDIA = 0x00000008
|
254
|
+
FILE_REMOTE_DEVICE = 0x00000010
|
255
|
+
FILE_DEVICE_IS_MOUNTED = 0x00000020
|
256
|
+
FILE_VIRTUAL_VOLUME = 0x00000040
|
257
|
+
FILE_CASE_SENSITIVE_SEARCH = 0x00000001
|
258
|
+
FILE_CASE_PRESERVED_NAMES = 0x00000002
|
259
|
+
FILE_PERSISTENT_ACLS = 0x00000004
|
260
|
+
FILE_FILE_COMPRESSION = 0x00000008
|
261
|
+
FILE_VOLUME_QUOTAS = 0x00000010
|
262
|
+
FILE_VOLUME_IS_COMPRESSED = 0x00008000
|
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
|
281
|
+
|
282
|
+
# SMB Error Codes
|
283
|
+
SMB_STATUS_SUCCESS = 0x00000000
|
284
|
+
SMB_ERROR_BUFFER_OVERFLOW = 0x80000005
|
285
|
+
SMB_STATUS_MORE_PROCESSING_REQUIRED = 0xC0000016
|
286
|
+
SMB_STATUS_ACCESS_DENIED = 0xC0000022
|
287
|
+
SMB_STATUS_LOGON_FAILURE = 0xC000006D
|
288
|
+
|
289
|
+
# SMB Dialect Compatibility
|
290
|
+
DIALECT = {}
|
291
|
+
|
292
|
+
DIALECT['PC NETWORK PROGRAM 1.0'] = [
|
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
|
321
|
+
]
|
322
|
+
|
323
|
+
DIALECT['LANMAN 1.0'] = DIALECT['PC NETWORK PROGRAM 1.0'] + [
|
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
|
351
|
+
]
|
352
|
+
|
353
|
+
DIALECT['LM1.2X002'] = DIALECT['LANMAN 1.0'] + [
|
354
|
+
SMB_COM_FIND_CLOSE2,
|
355
|
+
SMB_COM_LOGOFF_ANDX,
|
356
|
+
SMB_COM_TRANSACTION2,
|
357
|
+
SMB_COM_TRANSACTION2_SECONDARY
|
358
|
+
]
|
359
|
+
|
360
|
+
DIALECT['NTLM 0.12'] = DIALECT['LM1.2X002'] + [
|
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
|
366
|
+
]
|
367
|
+
|
368
|
+
# Create a NetBIOS session packet template
|
369
|
+
def self.make_nbs (template)
|
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
|
+
)
|
378
|
+
end
|
379
|
+
|
380
|
+
|
381
|
+
# A raw NetBIOS session template
|
382
|
+
NBRAW_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
383
|
+
[ 'string', 'Payload', nil, '']
|
384
|
+
)
|
385
|
+
NBRAW_PKT = self.make_nbs(NBRAW_HDR_PKT)
|
386
|
+
|
387
|
+
|
388
|
+
# The SMB header template
|
389
|
+
SMB_HDR = Rex::Struct2::CStructTemplate.new(
|
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 ]
|
404
|
+
)
|
405
|
+
|
406
|
+
|
407
|
+
# The SMB2 header template
|
408
|
+
SMB2_HDR = Rex::Struct2::CStructTemplate.new(
|
409
|
+
[ 'uint32n', 'Magic', 0xfe534d42 ],
|
410
|
+
[ 'uint16v', 'HeaderLen', 64 ],
|
411
|
+
[ 'uint16v', 'Reserved0', 0 ],
|
412
|
+
[ 'uint32v', 'NTStatus', 0 ],
|
413
|
+
|
414
|
+
[ 'uint16v', 'Opcode', 0 ],
|
415
|
+
[ 'uint16v', 'Reserved1', 0 ],
|
416
|
+
|
417
|
+
[ 'uint16v', 'Flags1', 0 ],
|
418
|
+
[ 'uint16v', 'Flags2', 0 ],
|
419
|
+
|
420
|
+
[ 'uint32v', 'ChainOffset', 0 ],
|
421
|
+
|
422
|
+
[ 'uint32v', 'SequenceHigh', 0 ],
|
423
|
+
[ 'uint32v', 'SequenceLow', 0 ],
|
424
|
+
|
425
|
+
[ 'uint32v', 'ProcessID', 0 ],
|
426
|
+
[ 'uint32v', 'TreeID', 0 ],
|
427
|
+
[ 'uint32v', 'UserIDHigh', 0 ],
|
428
|
+
[ 'uint32v', 'UserIDLow', 0 ],
|
429
|
+
|
430
|
+
[ 'uint32v', 'SignatureA', 0 ],
|
431
|
+
[ 'uint32v', 'SignatureB', 0 ],
|
432
|
+
[ 'uint32v', 'SignatureC', 0 ],
|
433
|
+
[ 'uint32v', 'SignatureD', 0 ],
|
434
|
+
[ 'string', 'Payload', nil, '']
|
435
|
+
)
|
436
|
+
|
437
|
+
# A basic SMB template to read all responses
|
438
|
+
SMB_BASE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
439
|
+
[ 'template', 'SMB', SMB_HDR ],
|
440
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
441
|
+
[ 'string', 'Payload', nil, '' ]
|
442
|
+
).create_restraints(
|
443
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
444
|
+
)
|
445
|
+
SMB_BASE_PKT = self.make_nbs(SMB_BASE_HDR_PKT)
|
446
|
+
|
447
|
+
|
448
|
+
# A SMB template for SMB Dialect negotiation
|
449
|
+
SMB_NEG_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
450
|
+
|
451
|
+
[ 'template', 'SMB', SMB_HDR ],
|
452
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
453
|
+
[ 'string', 'Payload', nil, '' ]
|
454
|
+
).create_restraints(
|
455
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
456
|
+
)
|
457
|
+
SMB_NEG_PKT = self.make_nbs(SMB_NEG_HDR_PKT)
|
458
|
+
|
459
|
+
|
460
|
+
# A SMB template for SMB Dialect negotiation responses (LANMAN)
|
461
|
+
SMB_NEG_RES_LM_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
477
|
+
).create_restraints(
|
478
|
+
[ 'EncryptionKey', 'ByteCount', nil, true ]
|
479
|
+
)
|
480
|
+
SMB_NEG_RES_LM_PKT = self.make_nbs(SMB_NEG_RES_LM_HDR_PKT)
|
481
|
+
|
482
|
+
|
483
|
+
# A SMB template for SMB Dialect negotiation responses (NTLM)
|
484
|
+
SMB_NEG_RES_NT_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
500
|
+
).create_restraints(
|
501
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
502
|
+
)
|
503
|
+
SMB_NEG_RES_NT_PKT = self.make_nbs(SMB_NEG_RES_NT_HDR_PKT)
|
504
|
+
|
505
|
+
|
506
|
+
# A SMB template for SMB Dialect negotiation responses (ERROR)
|
507
|
+
SMB_NEG_RES_ERR_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
508
|
+
[ 'template', 'SMB', SMB_HDR ],
|
509
|
+
[ 'uint16v', 'Dialect', 0 ],
|
510
|
+
[ 'uint16v', 'ByteCount', 0 ]
|
511
|
+
)
|
512
|
+
SMB_NEG_RES_ERR_PKT = self.make_nbs(SMB_NEG_RES_ERR_HDR_PKT)
|
513
|
+
|
514
|
+
|
515
|
+
# A SMB template for SMB Session Setup responses (LANMAN/NTLMV1)
|
516
|
+
SMB_SETUP_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
524
|
+
).create_restraints(
|
525
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
526
|
+
)
|
527
|
+
SMB_SETUP_RES_PKT = self.make_nbs(SMB_SETUP_RES_HDR_PKT)
|
528
|
+
|
529
|
+
|
530
|
+
# A SMB template for SMB Session Setup requests (LANMAN)
|
531
|
+
SMB_SETUP_LANMAN_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
544
|
+
).create_restraints(
|
545
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
546
|
+
)
|
547
|
+
SMB_SETUP_LANMAN_PKT = self.make_nbs(SMB_SETUP_LANMAN_HDR_PKT)
|
548
|
+
|
549
|
+
|
550
|
+
# A SMB template for SMB Session Setup requests (NTLMV1)
|
551
|
+
SMB_SETUP_NTLMV1_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
566
|
+
).create_restraints(
|
567
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
568
|
+
)
|
569
|
+
SMB_SETUP_NTLMV1_PKT = self.make_nbs(SMB_SETUP_NTLMV1_HDR_PKT)
|
570
|
+
|
571
|
+
|
572
|
+
# A SMB template for SMB Session Setup requests (When extended security is being used)
|
573
|
+
SMB_SETUP_NTLMV2_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
587
|
+
).create_restraints(
|
588
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
589
|
+
)
|
590
|
+
SMB_SETUP_NTLMV2_PKT = self.make_nbs(SMB_SETUP_NTLMV2_HDR_PKT)
|
591
|
+
|
592
|
+
|
593
|
+
# A SMB template for SMB Session Setup responses (When extended security is being used)
|
594
|
+
SMB_SETUP_NTLMV2_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
603
|
+
).create_restraints(
|
604
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
605
|
+
)
|
606
|
+
SMB_SETUP_NTLMV2_RES_PKT = self.make_nbs(SMB_SETUP_NTLMV2_RES_HDR_PKT)
|
607
|
+
|
608
|
+
|
609
|
+
# A SMB template for SMB Tree Connect requests
|
610
|
+
SMB_TREE_CONN_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
619
|
+
).create_restraints(
|
620
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
621
|
+
)
|
622
|
+
SMB_TREE_CONN_PKT = self.make_nbs(SMB_TREE_CONN_HDR_PKT)
|
623
|
+
|
624
|
+
|
625
|
+
# A SMB template for SMB Tree Connect requests
|
626
|
+
SMB_TREE_CONN_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
635
|
+
).create_restraints(
|
636
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
637
|
+
)
|
638
|
+
SMB_TREE_CONN_RES_PKT = self.make_nbs(SMB_TREE_CONN_RES_HDR_PKT)
|
639
|
+
|
640
|
+
|
641
|
+
# A SMB template for SMB Tree Disconnect requests
|
642
|
+
SMB_TREE_DISCONN_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
643
|
+
[ 'template', 'SMB', SMB_HDR ],
|
644
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
645
|
+
[ 'string', 'Payload', nil, '' ]
|
646
|
+
).create_restraints(
|
647
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
648
|
+
)
|
649
|
+
SMB_TREE_DISCONN_PKT = self.make_nbs(SMB_TREE_DISCONN_HDR_PKT)
|
650
|
+
|
651
|
+
|
652
|
+
# A SMB template for SMB Tree Disconnect requests
|
653
|
+
SMB_TREE_DISCONN_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
654
|
+
[ 'template', 'SMB', SMB_HDR ],
|
655
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
656
|
+
[ 'string', 'Payload', nil, '' ]
|
657
|
+
).create_restraints(
|
658
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
659
|
+
)
|
660
|
+
SMB_TREE_DISCONN_RES_PKT = self.make_nbs(SMB_TREE_DISCONN_RES_HDR_PKT)
|
661
|
+
|
662
|
+
|
663
|
+
# A SMB template for SMB Transaction requests
|
664
|
+
SMB_TRANS_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
684
|
+
).create_restraints(
|
685
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
686
|
+
)
|
687
|
+
SMB_TRANS_PKT = self.make_nbs(SMB_TRANS_HDR_PKT)
|
688
|
+
|
689
|
+
|
690
|
+
# A SMB template for SMB Transaction responses
|
691
|
+
SMB_TRANS_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
707
|
+
).create_restraints(
|
708
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
709
|
+
)
|
710
|
+
SMB_TRANS_RES_PKT = self.make_nbs(SMB_TRANS_RES_HDR_PKT)
|
711
|
+
|
712
|
+
# A SMB template for SMB Transaction2 requests
|
713
|
+
SMB_TRANS2_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
733
|
+
).create_restraints(
|
734
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
735
|
+
)
|
736
|
+
SMB_TRANS2_PKT = self.make_nbs(SMB_TRANS2_HDR_PKT)
|
737
|
+
|
738
|
+
|
739
|
+
# A SMB template for SMB NTTransaction requests
|
740
|
+
SMB_NTTRANS_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
757
|
+
).create_restraints(
|
758
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
759
|
+
)
|
760
|
+
SMB_NTTRANS_PKT = self.make_nbs(SMB_NTTRANS_HDR_PKT)
|
761
|
+
|
762
|
+
|
763
|
+
# A SMB template for SMB NTTransaction responses
|
764
|
+
SMB_NTTRANS_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
779
|
+
).create_restraints(
|
780
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
781
|
+
)
|
782
|
+
SMB_NTTRANS_RES_PKT = self.make_nbs(SMB_NTTRANS_RES_HDR_PKT)
|
783
|
+
|
784
|
+
# A SMB template for SMB NTTransaction_Secondary requests
|
785
|
+
SMB_NTTRANS_SECONDARY_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
801
|
+
).create_restraints(
|
802
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
803
|
+
)
|
804
|
+
SMB_NTTRANS_SECONDARY_PKT = self.make_nbs(SMB_NTTRANS_SECONDARY_HDR_PKT)
|
805
|
+
|
806
|
+
# A SMB template for SMB Create requests
|
807
|
+
SMB_CREATE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
827
|
+
).create_restraints(
|
828
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
829
|
+
)
|
830
|
+
SMB_CREATE_PKT = self.make_nbs(SMB_CREATE_HDR_PKT)
|
831
|
+
|
832
|
+
|
833
|
+
# A SMB template for SMB Create responses
|
834
|
+
SMB_CREATE_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
860
|
+
).create_restraints(
|
861
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
862
|
+
)
|
863
|
+
SMB_CREATE_RES_PKT = self.make_nbs(SMB_CREATE_RES_HDR_PKT)
|
864
|
+
|
865
|
+
|
866
|
+
# A SMB template for SMB Write requests
|
867
|
+
SMB_WRITE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
883
|
+
).create_restraints(
|
884
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
885
|
+
)
|
886
|
+
SMB_WRITE_PKT = self.make_nbs(SMB_WRITE_HDR_PKT)
|
887
|
+
|
888
|
+
|
889
|
+
# A SMB template for SMB Write responses
|
890
|
+
SMB_WRITE_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
901
|
+
).create_restraints(
|
902
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
903
|
+
)
|
904
|
+
SMB_WRITE_RES_PKT = self.make_nbs(SMB_WRITE_RES_HDR_PKT)
|
905
|
+
|
906
|
+
|
907
|
+
# A SMB template for SMB OPEN requests
|
908
|
+
SMB_OPEN_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
924
|
+
).create_restraints(
|
925
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
926
|
+
)
|
927
|
+
SMB_OPEN_PKT = self.make_nbs(SMB_OPEN_HDR_PKT)
|
928
|
+
|
929
|
+
|
930
|
+
# A SMB template for SMB OPEN responses
|
931
|
+
SMB_OPEN_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
948
|
+
).create_restraints(
|
949
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
950
|
+
)
|
951
|
+
SMB_OPEN_RES_PKT = self.make_nbs(SMB_OPEN_RES_HDR_PKT)
|
952
|
+
|
953
|
+
|
954
|
+
# A SMB template for SMB Close requests
|
955
|
+
SMB_CLOSE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
956
|
+
[ 'template', 'SMB', SMB_HDR ],
|
957
|
+
[ 'uint16v', 'FileID', 0 ],
|
958
|
+
[ 'uint32v', 'LastWrite', 0 ],
|
959
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
960
|
+
[ 'string', 'Payload', nil, '' ]
|
961
|
+
).create_restraints(
|
962
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
963
|
+
)
|
964
|
+
SMB_CLOSE_PKT = self.make_nbs(SMB_CLOSE_HDR_PKT)
|
965
|
+
|
966
|
+
|
967
|
+
# A SMB template for SMB Close responses
|
968
|
+
SMB_CLOSE_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
969
|
+
[ 'template', 'SMB', SMB_HDR ],
|
970
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
971
|
+
[ 'string', 'Payload', nil, '' ]
|
972
|
+
).create_restraints(
|
973
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
974
|
+
)
|
975
|
+
SMB_CLOSE_RES_PKT = self.make_nbs(SMB_CLOSE_RES_HDR_PKT)
|
976
|
+
|
977
|
+
|
978
|
+
# A SMB template for SMB Delete requests
|
979
|
+
SMB_DELETE_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
980
|
+
[ 'template', 'SMB', SMB_HDR ],
|
981
|
+
[ 'uint16v', 'SearchAttribute', 0 ],
|
982
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
983
|
+
[ 'uint8', 'BufferFormat', 0 ],
|
984
|
+
[ 'string', 'Payload', nil, '' ]
|
985
|
+
).create_restraints(
|
986
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
987
|
+
)
|
988
|
+
SMB_DELETE_PKT = self.make_nbs(SMB_DELETE_HDR_PKT)
|
989
|
+
|
990
|
+
|
991
|
+
# A SMB template for SMB Delete responses
|
992
|
+
SMB_DELETE_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
993
|
+
[ 'template', 'SMB', SMB_HDR ],
|
994
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
995
|
+
[ 'string', 'Payload', nil, '' ]
|
996
|
+
).create_restraints(
|
997
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
998
|
+
)
|
999
|
+
SMB_DELETE_RES_PKT = self.make_nbs(SMB_DELETE_RES_HDR_PKT)
|
1000
|
+
|
1001
|
+
|
1002
|
+
|
1003
|
+
# A SMB template for SMB Read requests
|
1004
|
+
SMB_READ_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
1018
|
+
).create_restraints(
|
1019
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
1020
|
+
)
|
1021
|
+
SMB_READ_PKT = self.make_nbs(SMB_READ_HDR_PKT)
|
1022
|
+
|
1023
|
+
|
1024
|
+
# A SMB template for SMB Read responses
|
1025
|
+
SMB_READ_RES_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
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, '' ]
|
1040
|
+
).create_restraints(
|
1041
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
1042
|
+
)
|
1043
|
+
SMB_READ_RES_PKT = self.make_nbs(SMB_READ_RES_HDR_PKT)
|
1044
|
+
|
1045
|
+
|
1046
|
+
|
1047
|
+
# A SMB template for SMB Search requests
|
1048
|
+
SMB_SEARCH_HDR_PKT = Rex::Struct2::CStructTemplate.new(
|
1049
|
+
[ 'template', 'SMB', SMB_HDR ],
|
1050
|
+
[ 'uint16v', 'MaxCount', 0 ],
|
1051
|
+
[ 'uint16v', 'Attributes', 0 ],
|
1052
|
+
[ 'uint16v', 'ByteCount', 0 ],
|
1053
|
+
[ 'string', 'Payload', nil, '' ]
|
1054
|
+
).create_restraints(
|
1055
|
+
[ 'Payload', 'ByteCount', nil, true ]
|
1056
|
+
)
|
1057
|
+
SMB_SEARCH_PKT = self.make_nbs(SMB_SEARCH_HDR_PKT)
|
1058
|
+
|
1059
|
+
|
1060
|
+
end
|
1061
|
+
end
|
1062
|
+
end
|
1063
|
+
end
|
1064
|
+
|