librex 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rex/LICENSE +29 -0
- data/lib/rex/arch.rb +103 -0
- data/lib/rex/arch/sparc.rb +75 -0
- data/lib/rex/arch/sparc.rb.ut.rb +18 -0
- data/lib/rex/arch/x86.rb +513 -0
- data/lib/rex/arch/x86.rb.ut.rb +93 -0
- data/lib/rex/assembly/nasm.rb +104 -0
- data/lib/rex/assembly/nasm.rb.ut.rb +22 -0
- data/lib/rex/codepage.map +104 -0
- data/lib/rex/compat.rb +311 -0
- data/lib/rex/constants.rb +113 -0
- data/lib/rex/elfparsey.rb +11 -0
- data/lib/rex/elfparsey/elf.rb +123 -0
- data/lib/rex/elfparsey/elfbase.rb +258 -0
- data/lib/rex/elfparsey/exceptions.rb +27 -0
- data/lib/rex/elfscan.rb +12 -0
- data/lib/rex/elfscan/scanner.rb +207 -0
- data/lib/rex/elfscan/search.rb +46 -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 +114 -0
- data/lib/rex/encoder/alpha2/unicode_mixed.rb +117 -0
- data/lib/rex/encoder/alpha2/unicode_upper.rb +129 -0
- data/lib/rex/encoder/ndr.rb +89 -0
- data/lib/rex/encoder/ndr.rb.ut.rb +44 -0
- data/lib/rex/encoder/nonalpha.rb +61 -0
- data/lib/rex/encoder/nonupper.rb +64 -0
- data/lib/rex/encoder/xdr.rb +106 -0
- data/lib/rex/encoder/xdr.rb.ut.rb +29 -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/encoders/xor_dword_additive.rb.ut.rb +12 -0
- data/lib/rex/encoding/xor.rb +20 -0
- data/lib/rex/encoding/xor.rb.ts.rb +14 -0
- data/lib/rex/encoding/xor/byte.rb +15 -0
- data/lib/rex/encoding/xor/byte.rb.ut.rb +21 -0
- data/lib/rex/encoding/xor/dword.rb +21 -0
- data/lib/rex/encoding/xor/dword.rb.ut.rb +15 -0
- data/lib/rex/encoding/xor/dword_additive.rb +92 -0
- data/lib/rex/encoding/xor/dword_additive.rb.ut.rb +15 -0
- data/lib/rex/encoding/xor/exceptions.rb +17 -0
- data/lib/rex/encoding/xor/generic.rb +146 -0
- data/lib/rex/encoding/xor/generic.rb.ut.rb +120 -0
- data/lib/rex/encoding/xor/qword.rb +15 -0
- data/lib/rex/encoding/xor/word.rb +21 -0
- data/lib/rex/encoding/xor/word.rb.ut.rb +13 -0
- data/lib/rex/exceptions.rb +275 -0
- data/lib/rex/exceptions.rb.ut.rb +44 -0
- data/lib/rex/exploitation/cmdstager.rb +9 -0
- data/lib/rex/exploitation/cmdstager/base.rb +175 -0
- data/lib/rex/exploitation/cmdstager/debug_asm.rb +142 -0
- data/lib/rex/exploitation/cmdstager/debug_write.rb +136 -0
- data/lib/rex/exploitation/cmdstager/tftp.rb +63 -0
- data/lib/rex/exploitation/cmdstager/vbs.rb +128 -0
- data/lib/rex/exploitation/egghunter.rb +277 -0
- data/lib/rex/exploitation/egghunter.rb.ut.rb +25 -0
- data/lib/rex/exploitation/encryptjs.rb +77 -0
- data/lib/rex/exploitation/heaplib.js.b64 +331 -0
- data/lib/rex/exploitation/heaplib.rb +94 -0
- data/lib/rex/exploitation/javascriptosdetect.rb +897 -0
- data/lib/rex/exploitation/obfuscatejs.rb +335 -0
- data/lib/rex/exploitation/omelet.rb +320 -0
- data/lib/rex/exploitation/omelet.rb.ut.rb +13 -0
- data/lib/rex/exploitation/opcodedb.rb +818 -0
- data/lib/rex/exploitation/opcodedb.rb.ut.rb +279 -0
- data/lib/rex/exploitation/seh.rb +92 -0
- data/lib/rex/exploitation/seh.rb.ut.rb +19 -0
- data/lib/rex/file.rb +112 -0
- data/lib/rex/file.rb.ut.rb +16 -0
- data/lib/rex/image_source.rb +12 -0
- data/lib/rex/image_source/disk.rb +60 -0
- data/lib/rex/image_source/image_source.rb +46 -0
- data/lib/rex/image_source/memory.rb +37 -0
- data/lib/rex/io/bidirectional_pipe.rb +157 -0
- data/lib/rex/io/datagram_abstraction.rb +35 -0
- data/lib/rex/io/ring_buffer.rb +364 -0
- data/lib/rex/io/stream.rb +319 -0
- data/lib/rex/io/stream_abstraction.rb +197 -0
- data/lib/rex/io/stream_server.rb +211 -0
- data/lib/rex/job_container.rb +187 -0
- data/lib/rex/logging.rb +4 -0
- data/lib/rex/logging/log_dispatcher.rb +179 -0
- data/lib/rex/logging/log_sink.rb +42 -0
- data/lib/rex/logging/sinks/flatfile.rb +55 -0
- data/lib/rex/logging/sinks/stderr.rb +43 -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 +9 -0
- data/lib/rex/mime/header.rb +77 -0
- data/lib/rex/mime/message.rb +144 -0
- data/lib/rex/mime/part.rb +20 -0
- data/lib/rex/nop/opty2.rb +108 -0
- data/lib/rex/nop/opty2.rb.ut.rb +23 -0
- data/lib/rex/nop/opty2_tables.rb +300 -0
- data/lib/rex/ole.rb +205 -0
- data/lib/rex/ole/clsid.rb +47 -0
- data/lib/rex/ole/difat.rb +141 -0
- data/lib/rex/ole/directory.rb +231 -0
- data/lib/rex/ole/direntry.rb +240 -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 +99 -0
- data/lib/rex/ole/header.rb +204 -0
- data/lib/rex/ole/minifat.rb +77 -0
- data/lib/rex/ole/propset.rb +144 -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 +395 -0
- data/lib/rex/ole/stream.rb +53 -0
- data/lib/rex/ole/substorage.rb +49 -0
- data/lib/rex/ole/util.rb +157 -0
- data/lib/rex/parser/arguments.rb +97 -0
- data/lib/rex/parser/arguments.rb.ut.rb +67 -0
- data/lib/rex/parser/ini.rb +185 -0
- data/lib/rex/parser/ini.rb.ut.rb +29 -0
- data/lib/rex/parser/ip360_aspl_xml.rb +102 -0
- data/lib/rex/parser/ip360_xml.rb +97 -0
- data/lib/rex/parser/nessus_xml.rb +118 -0
- data/lib/rex/parser/netsparker_xml.rb +94 -0
- data/lib/rex/parser/nexpose_xml.rb +136 -0
- data/lib/rex/parser/nmap_xml.rb +137 -0
- data/lib/rex/parser/retina_xml.rb +109 -0
- data/lib/rex/payloads.rb +1 -0
- data/lib/rex/payloads/win32.rb +2 -0
- data/lib/rex/payloads/win32/common.rb +26 -0
- data/lib/rex/payloads/win32/kernel.rb +53 -0
- data/lib/rex/payloads/win32/kernel/common.rb +54 -0
- data/lib/rex/payloads/win32/kernel/migration.rb +12 -0
- data/lib/rex/payloads/win32/kernel/recovery.rb +50 -0
- data/lib/rex/payloads/win32/kernel/stager.rb +194 -0
- data/lib/rex/peparsey.rb +12 -0
- data/lib/rex/peparsey/exceptions.rb +32 -0
- data/lib/rex/peparsey/pe.rb +212 -0
- data/lib/rex/peparsey/pe_memdump.rb +63 -0
- data/lib/rex/peparsey/pebase.rb +1680 -0
- data/lib/rex/peparsey/section.rb +136 -0
- data/lib/rex/pescan.rb +13 -0
- data/lib/rex/pescan/analyze.rb +309 -0
- data/lib/rex/pescan/scanner.rb +206 -0
- data/lib/rex/pescan/search.rb +56 -0
- data/lib/rex/platforms.rb +1 -0
- data/lib/rex/platforms/windows.rb +51 -0
- data/lib/rex/poly.rb +132 -0
- data/lib/rex/poly/block.rb +477 -0
- data/lib/rex/poly/register.rb +100 -0
- data/lib/rex/poly/register/x86.rb +40 -0
- data/lib/rex/post.rb +8 -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 +4 -0
- data/lib/rex/post/meterpreter/channel.rb +445 -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 +364 -0
- data/lib/rex/post/meterpreter/client_core.rb +274 -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/espia/espia.rb +58 -0
- data/lib/rex/post/meterpreter/extensions/espia/tlv.rb +16 -0
- data/lib/rex/post/meterpreter/extensions/incognito/incognito.rb +94 -0
- data/lib/rex/post/meterpreter/extensions/incognito/tlv.rb +21 -0
- data/lib/rex/post/meterpreter/extensions/networkpug/networkpug.rb +57 -0
- data/lib/rex/post/meterpreter/extensions/networkpug/tlv.rb +15 -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 +111 -0
- data/lib/rex/post/meterpreter/extensions/priv/tlv.rb +28 -0
- data/lib/rex/post/meterpreter/extensions/sniffer/sniffer.rb +101 -0
- data/lib/rex/post/meterpreter/extensions/sniffer/tlv.rb +26 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/constants.rb +333 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb +282 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +266 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb +103 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/io.rb +48 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/config.rb +144 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb +73 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/route.rb +56 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb +137 -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 +167 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb +208 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun.rb.ts.rb +6 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb +38106 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb.ut.rb +31 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb +47 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb.ut.rb +36 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_advapi32.rb +1818 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_iphlpapi.rb +96 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb +3848 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_netapi32.rb +26 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ntdll.rb +153 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_shell32.rb +21 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_user32.rb +3169 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ws2_32.rb +599 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb +318 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb +100 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb.ut.rb +42 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb +148 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb.ut.rb +127 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/multicall.rb +309 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb +204 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/tlv.rb +51 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/util.rb +630 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb +75 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb.ut.rb +103 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb +149 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +97 -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 +61 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb +370 -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 +279 -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/thread.rb +180 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/tlv.rb +211 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +227 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb +63 -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 +688 -0
- data/lib/rex/post/meterpreter/packet_dispatcher.rb +431 -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 +137 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher.rb +62 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +730 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/espia.rb +108 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/incognito.rb +241 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/networkpug.rb +231 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv.rb +61 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/elevate.rb +98 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/passwd.rb +51 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb +132 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/sniffer.rb +187 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi.rb +65 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +442 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +298 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +486 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +315 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb +157 -0
- data/lib/rex/post/meterpreter/ui/console/interactive_channel.rb +95 -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 +13 -0
- data/lib/rex/proto.rb.ts.rb +8 -0
- data/lib/rex/proto/dcerpc.rb +6 -0
- data/lib/rex/proto/dcerpc.rb.ts.rb +9 -0
- data/lib/rex/proto/dcerpc/client.rb +361 -0
- data/lib/rex/proto/dcerpc/client.rb.ut.rb +491 -0
- data/lib/rex/proto/dcerpc/exceptions.rb +150 -0
- data/lib/rex/proto/dcerpc/handle.rb +47 -0
- data/lib/rex/proto/dcerpc/handle.rb.ut.rb +85 -0
- data/lib/rex/proto/dcerpc/ndr.rb +72 -0
- data/lib/rex/proto/dcerpc/ndr.rb.ut.rb +41 -0
- data/lib/rex/proto/dcerpc/packet.rb +253 -0
- data/lib/rex/proto/dcerpc/packet.rb.ut.rb +56 -0
- data/lib/rex/proto/dcerpc/response.rb +187 -0
- data/lib/rex/proto/dcerpc/response.rb.ut.rb +15 -0
- data/lib/rex/proto/dcerpc/uuid.rb +84 -0
- data/lib/rex/proto/dcerpc/uuid.rb.ut.rb +46 -0
- data/lib/rex/proto/dhcp.rb +7 -0
- data/lib/rex/proto/dhcp/constants.rb +33 -0
- data/lib/rex/proto/dhcp/server.rb +292 -0
- data/lib/rex/proto/drda.rb +5 -0
- data/lib/rex/proto/drda.rb.ts.rb +17 -0
- data/lib/rex/proto/drda/constants.rb +49 -0
- data/lib/rex/proto/drda/constants.rb.ut.rb +23 -0
- data/lib/rex/proto/drda/packet.rb +252 -0
- data/lib/rex/proto/drda/packet.rb.ut.rb +109 -0
- data/lib/rex/proto/drda/utils.rb +123 -0
- data/lib/rex/proto/drda/utils.rb.ut.rb +84 -0
- data/lib/rex/proto/http.rb +5 -0
- data/lib/rex/proto/http.rb.ts.rb +12 -0
- data/lib/rex/proto/http/client.rb +821 -0
- data/lib/rex/proto/http/client.rb.ut.rb +95 -0
- data/lib/rex/proto/http/handler.rb +46 -0
- data/lib/rex/proto/http/handler/erb.rb +128 -0
- data/lib/rex/proto/http/handler/erb.rb.ut.rb +21 -0
- data/lib/rex/proto/http/handler/erb.rb.ut.rb.rhtml +1 -0
- data/lib/rex/proto/http/handler/proc.rb +60 -0
- data/lib/rex/proto/http/handler/proc.rb.ut.rb +24 -0
- data/lib/rex/proto/http/header.rb +161 -0
- data/lib/rex/proto/http/header.rb.ut.rb +46 -0
- data/lib/rex/proto/http/packet.rb +407 -0
- data/lib/rex/proto/http/packet.rb.ut.rb +165 -0
- data/lib/rex/proto/http/request.rb +356 -0
- data/lib/rex/proto/http/request.rb.ut.rb +214 -0
- data/lib/rex/proto/http/response.rb +90 -0
- data/lib/rex/proto/http/response.rb.ut.rb +149 -0
- data/lib/rex/proto/http/server.rb +369 -0
- data/lib/rex/proto/http/server.rb.ut.rb +79 -0
- data/lib/rex/proto/ntlm.rb +7 -0
- data/lib/rex/proto/ntlm.rb.ut.rb +177 -0
- data/lib/rex/proto/ntlm/base.rb +326 -0
- data/lib/rex/proto/ntlm/constants.rb +74 -0
- data/lib/rex/proto/ntlm/crypt.rb +415 -0
- data/lib/rex/proto/ntlm/exceptions.rb +16 -0
- data/lib/rex/proto/ntlm/message.rb +536 -0
- data/lib/rex/proto/ntlm/utils.rb +764 -0
- data/lib/rex/proto/proxy/socks4a.rb +440 -0
- data/lib/rex/proto/rfb.rb +19 -0
- data/lib/rex/proto/rfb.rb.ut.rb +37 -0
- data/lib/rex/proto/rfb/cipher.rb +84 -0
- data/lib/rex/proto/rfb/client.rb +207 -0
- data/lib/rex/proto/rfb/constants.rb +52 -0
- data/lib/rex/proto/smb.rb +7 -0
- data/lib/rex/proto/smb.rb.ts.rb +8 -0
- data/lib/rex/proto/smb/client.rb +1952 -0
- data/lib/rex/proto/smb/client.rb.ut.rb +223 -0
- data/lib/rex/proto/smb/constants.rb +1047 -0
- data/lib/rex/proto/smb/constants.rb.ut.rb +18 -0
- data/lib/rex/proto/smb/crypt.rb +36 -0
- data/lib/rex/proto/smb/evasions.rb +66 -0
- data/lib/rex/proto/smb/exceptions.rb +858 -0
- data/lib/rex/proto/smb/simpleclient.rb +306 -0
- data/lib/rex/proto/smb/simpleclient.rb.ut.rb +128 -0
- data/lib/rex/proto/smb/utils.rb +103 -0
- data/lib/rex/proto/smb/utils.rb.ut.rb +20 -0
- data/lib/rex/proto/sunrpc.rb +1 -0
- data/lib/rex/proto/sunrpc/client.rb +195 -0
- data/lib/rex/proto/tftp.rb +12 -0
- data/lib/rex/proto/tftp/constants.rb +39 -0
- data/lib/rex/proto/tftp/server.rb +497 -0
- data/lib/rex/proto/tftp/server.rb.ut.rb +28 -0
- data/lib/rex/script.rb +42 -0
- data/lib/rex/script/base.rb +59 -0
- data/lib/rex/script/meterpreter.rb +15 -0
- data/lib/rex/script/shell.rb +9 -0
- data/lib/rex/service.rb +48 -0
- data/lib/rex/service_manager.rb +141 -0
- data/lib/rex/service_manager.rb.ut.rb +32 -0
- data/lib/rex/services/local_relay.rb +423 -0
- data/lib/rex/socket.rb +684 -0
- data/lib/rex/socket.rb.ut.rb +107 -0
- data/lib/rex/socket/comm.rb +119 -0
- data/lib/rex/socket/comm/local.rb +412 -0
- data/lib/rex/socket/comm/local.rb.ut.rb +75 -0
- data/lib/rex/socket/ip.rb +130 -0
- data/lib/rex/socket/parameters.rb +345 -0
- data/lib/rex/socket/parameters.rb.ut.rb +51 -0
- data/lib/rex/socket/range_walker.rb +346 -0
- data/lib/rex/socket/range_walker.rb.ut.rb +55 -0
- data/lib/rex/socket/ssl_tcp.rb +184 -0
- data/lib/rex/socket/ssl_tcp.rb.ut.rb +39 -0
- data/lib/rex/socket/ssl_tcp_server.rb +122 -0
- data/lib/rex/socket/ssl_tcp_server.rb.ut.rb +61 -0
- data/lib/rex/socket/subnet_walker.rb +75 -0
- data/lib/rex/socket/subnet_walker.rb.ut.rb +28 -0
- data/lib/rex/socket/switch_board.rb +278 -0
- data/lib/rex/socket/switch_board.rb.ut.rb +52 -0
- data/lib/rex/socket/tcp.rb +76 -0
- data/lib/rex/socket/tcp.rb.ut.rb +64 -0
- data/lib/rex/socket/tcp_server.rb +66 -0
- data/lib/rex/socket/tcp_server.rb.ut.rb +44 -0
- data/lib/rex/socket/udp.rb +164 -0
- data/lib/rex/socket/udp.rb.ut.rb +44 -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 +94 -0
- data/lib/rex/sync/read_write_lock.rb +176 -0
- data/lib/rex/sync/ref.rb +57 -0
- data/lib/rex/sync/thread_safe.rb +82 -0
- data/lib/rex/test.rb +35 -0
- data/lib/rex/text.rb +1163 -0
- data/lib/rex/text.rb.ut.rb +190 -0
- data/lib/rex/thread_factory.rb +42 -0
- data/lib/rex/time.rb +65 -0
- data/lib/rex/transformer.rb +115 -0
- data/lib/rex/transformer.rb.ut.rb +38 -0
- data/lib/rex/ui.rb +21 -0
- data/lib/rex/ui/interactive.rb +298 -0
- data/lib/rex/ui/output.rb +78 -0
- data/lib/rex/ui/output/none.rb +18 -0
- data/lib/rex/ui/progress_tracker.rb +96 -0
- data/lib/rex/ui/subscriber.rb +149 -0
- data/lib/rex/ui/text/color.rb +97 -0
- data/lib/rex/ui/text/color.rb.ut.rb +18 -0
- data/lib/rex/ui/text/dispatcher_shell.rb +467 -0
- data/lib/rex/ui/text/input.rb +117 -0
- data/lib/rex/ui/text/input/buffer.rb +75 -0
- data/lib/rex/ui/text/input/readline.rb +129 -0
- data/lib/rex/ui/text/input/socket.rb +95 -0
- data/lib/rex/ui/text/input/stdio.rb +45 -0
- data/lib/rex/ui/text/irb_shell.rb +57 -0
- data/lib/rex/ui/text/output.rb +80 -0
- data/lib/rex/ui/text/output/buffer.rb +61 -0
- data/lib/rex/ui/text/output/file.rb +43 -0
- data/lib/rex/ui/text/output/socket.rb +43 -0
- data/lib/rex/ui/text/output/stdio.rb +40 -0
- data/lib/rex/ui/text/progress_tracker.rb +56 -0
- data/lib/rex/ui/text/progress_tracker.rb.ut.rb +34 -0
- data/lib/rex/ui/text/shell.rb +328 -0
- data/lib/rex/ui/text/table.rb +279 -0
- data/lib/rex/ui/text/table.rb.ut.rb +55 -0
- data/lib/rex/zip.rb +93 -0
- data/lib/rex/zip/archive.rb +184 -0
- data/lib/rex/zip/blocks.rb +182 -0
- data/lib/rex/zip/entry.rb +104 -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 +434 -1
@@ -0,0 +1,240 @@
|
|
1
|
+
##
|
2
|
+
# $Id: direntry.rb 8457 2010-02-11 18:36:38Z jduck $
|
3
|
+
# Version: $Revision: 8457 $
|
4
|
+
##
|
5
|
+
|
6
|
+
##
|
7
|
+
# Rex::OLE - an OLE implementation
|
8
|
+
# written in 2010 by Joshua J. Drake <jduck [at] metasploit.com>
|
9
|
+
##
|
10
|
+
|
11
|
+
module Rex
|
12
|
+
module OLE
|
13
|
+
|
14
|
+
#
|
15
|
+
# This class serves as the base class for SubStorage, Stream, and Directory head
|
16
|
+
#
|
17
|
+
class DirEntry
|
18
|
+
|
19
|
+
attr_accessor :sid
|
20
|
+
attr_accessor :_sidChild, :_sidLeftSib, :_sidRightSib
|
21
|
+
|
22
|
+
def initialize(stg)
|
23
|
+
@stg = stg
|
24
|
+
|
25
|
+
# default to a root entry :)
|
26
|
+
@sid = 0
|
27
|
+
@_ab = "Root Entry"
|
28
|
+
@_cb = nil # NOTE: this is not used until pack
|
29
|
+
@_mse = STGTY_ROOT
|
30
|
+
@_bflags = 0
|
31
|
+
@_sidLeftSib = SECT_FREE
|
32
|
+
@_sidRightSib = SECT_FREE
|
33
|
+
@_sidChild = SECT_FREE
|
34
|
+
@_clsId = CLSID.new
|
35
|
+
@_dwUserFlags = 0
|
36
|
+
@_ctime = "\x00" * 8
|
37
|
+
@_mtime = "\x00" * 8
|
38
|
+
@_sectStart = SECT_END
|
39
|
+
@_ulSize = 0
|
40
|
+
|
41
|
+
# keep track of logical children (in a tree)
|
42
|
+
@children = []
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def length
|
47
|
+
@_ulSize
|
48
|
+
end
|
49
|
+
|
50
|
+
def <<(expr)
|
51
|
+
@children << expr
|
52
|
+
end
|
53
|
+
|
54
|
+
def each
|
55
|
+
@children.each { |de|
|
56
|
+
yield de
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def type
|
62
|
+
@_mse
|
63
|
+
end
|
64
|
+
def type=(arg)
|
65
|
+
@_mse = arg
|
66
|
+
end
|
67
|
+
|
68
|
+
def name
|
69
|
+
@_ab
|
70
|
+
end
|
71
|
+
def name=(arg)
|
72
|
+
# XXX: validate?
|
73
|
+
@_ab = arg
|
74
|
+
end
|
75
|
+
|
76
|
+
def start_sector
|
77
|
+
@_sectStart
|
78
|
+
end
|
79
|
+
def start_sector=(expr)
|
80
|
+
@_sectStart = expr
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
# NOTE: this will not look at children
|
85
|
+
def find_stream_by_name_and_type(name, type)
|
86
|
+
@children.each { |de|
|
87
|
+
next if (de.type != type)
|
88
|
+
|
89
|
+
if (de.name == name)
|
90
|
+
return de
|
91
|
+
end
|
92
|
+
}
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def find_by_sid(sid, de=self)
|
98
|
+
if (de.sid == sid)
|
99
|
+
return de
|
100
|
+
end
|
101
|
+
@children.each { |cde|
|
102
|
+
ret = find_by_sid(cde, sid)
|
103
|
+
if (ret)
|
104
|
+
return ret
|
105
|
+
end
|
106
|
+
}
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
#
|
112
|
+
# low-level functions
|
113
|
+
#
|
114
|
+
def from_s(sid, buf)
|
115
|
+
@sid = sid
|
116
|
+
@_ab = Util.getUnicodeString(buf[0x00,64])
|
117
|
+
@_cb = Util.get16(buf, 0x40)
|
118
|
+
|
119
|
+
# too big?
|
120
|
+
if (@_cb > 0x40)
|
121
|
+
raise RuntimeError, 'Invalid directory entry name length %#x' % @_cb
|
122
|
+
end
|
123
|
+
|
124
|
+
# mismatch?
|
125
|
+
if (@_ab.length > 0)
|
126
|
+
declen = ((@_cb) / 2) - 1
|
127
|
+
if (declen != @_ab.length)
|
128
|
+
raise RuntimeError, 'Directory entry name and length mismatch (%d != %d)' % [declen, @_ab.length]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
@_mse = Util.get8(buf, 0x42)
|
133
|
+
@_bflags = Util.get8(buf, 0x43)
|
134
|
+
@_sidLeftSib = Util.get32(buf, 0x44)
|
135
|
+
@_sidRightSib = Util.get32(buf, 0x48)
|
136
|
+
@_sidChild = Util.get32(buf, 0x4c)
|
137
|
+
|
138
|
+
# only used for storages..
|
139
|
+
@_clsId = CLSID.new(buf[0x50,16])
|
140
|
+
@_dwUserFlags = Util.get32(buf, 0x60)
|
141
|
+
@_ctime = buf[0x64,8]
|
142
|
+
@_mtime = buf[0x6c,8]
|
143
|
+
|
144
|
+
# only used for streams...
|
145
|
+
@_sectStart = Util.get32(buf, 0x74)
|
146
|
+
if (@stg.header._uMajorVersion == 4)
|
147
|
+
@_ulSize = Util.get64(buf, 0x78)
|
148
|
+
else
|
149
|
+
@_ulSize = Util.get32(buf, 0x78)
|
150
|
+
end
|
151
|
+
|
152
|
+
# ignore _dptPropType and pad
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
def pack
|
157
|
+
@_sectStart ||= SECT_END
|
158
|
+
@_cb = (@_ab.length + 1) * 2
|
159
|
+
|
160
|
+
data = ""
|
161
|
+
data << Util.putUnicodeString(@_ab) # gets padded/truncated to 0x40 bytes
|
162
|
+
data << Util.pack16(@_cb)
|
163
|
+
data << Util.pack8(@_mse)
|
164
|
+
data << Util.pack8(@_bflags)
|
165
|
+
data << Util.pack32(@_sidLeftSib)
|
166
|
+
data << Util.pack32(@_sidRightSib)
|
167
|
+
data << Util.pack32(@_sidChild)
|
168
|
+
data << @_clsId.pack
|
169
|
+
data << Util.pack32(@_dwUserFlags)
|
170
|
+
data << @_ctime
|
171
|
+
data << @_mtime
|
172
|
+
data << Util.pack32(@_sectStart)
|
173
|
+
data << Util.pack64(@_ulSize)
|
174
|
+
data
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
def to_s(extra_spaces=0)
|
179
|
+
@_sectStart ||= SECT_END
|
180
|
+
@_cb = (@_ab.length + 1) * 2
|
181
|
+
|
182
|
+
spstr = " " * extra_spaces
|
183
|
+
|
184
|
+
ret = "%s{\n" % spstr
|
185
|
+
ret << "%s sid => 0x%x" % [spstr, @sid]
|
186
|
+
ret << ",\n"
|
187
|
+
ret << "%s _ab => \"%s\"" % [spstr, Util.Printable(@_ab)]
|
188
|
+
ret << ",\n"
|
189
|
+
ret << "%s _cb => 0x%04x" % [spstr, @_cb]
|
190
|
+
ret << ",\n"
|
191
|
+
ret << "%s _mse => 0x%02x" % [spstr, @_mse]
|
192
|
+
ret << ",\n"
|
193
|
+
ret << "%s _bflags => 0x%02x" % [spstr, @_bflags]
|
194
|
+
ret << ",\n"
|
195
|
+
ret << "%s _sidLeftSib => 0x%08x" % [spstr, @_sidLeftSib]
|
196
|
+
ret << ",\n"
|
197
|
+
ret << "%s _sidRightSib => 0x%08x" % [spstr, @_sidRightSib]
|
198
|
+
ret << ",\n"
|
199
|
+
ret << "%s _sidChild => 0x%08x" % [spstr, @_sidChild]
|
200
|
+
ret << ",\n"
|
201
|
+
ret << "%s _clsId => %s" % [spstr, @_clsId.to_s]
|
202
|
+
ret << ",\n"
|
203
|
+
ret << "%s _dwUserFlags => 0x%08x" % [spstr, @_dwUserFlags]
|
204
|
+
ret << ",\n"
|
205
|
+
ret << "%s _ctime => %s" % [spstr, Rex::Text.to_hex_dump(@_ctime).strip]
|
206
|
+
ret << "\n"
|
207
|
+
ret << "%s _mtime => %s" % [spstr, Rex::Text.to_hex_dump(@_mtime).strip]
|
208
|
+
ret << "\n"
|
209
|
+
ret << "%s _sectStart => 0x%08x" % [spstr, @_sectStart]
|
210
|
+
ret << ",\n"
|
211
|
+
ret << "%s _ulSize => 0x%016x" % [spstr, @_ulSize]
|
212
|
+
if (@_mse == STGTY_STREAM)
|
213
|
+
ret << ",\n"
|
214
|
+
ret << "%s data =>\n" % spstr
|
215
|
+
if (@data)
|
216
|
+
#ret << Util.Printable(@data)
|
217
|
+
ret << Rex::Text.to_hex_dump(@data).strip
|
218
|
+
else
|
219
|
+
if (@_ulSize > 0)
|
220
|
+
ret << "--NOT OPENED YET--"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
elsif (@_mse == STGTY_STORAGE) or (@_mse == STGTY_ROOT)
|
224
|
+
if (@children.length > 0)
|
225
|
+
ret << ",\n"
|
226
|
+
ret << "%s *children* =>\n" % spstr
|
227
|
+
@children.each { |de|
|
228
|
+
ret << de.to_s(extra_spaces+2)
|
229
|
+
ret << "\n"
|
230
|
+
}
|
231
|
+
end
|
232
|
+
end
|
233
|
+
ret << "\n"
|
234
|
+
ret << "%s}" % spstr
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
[MS-CFB].pdf
|
data/lib/rex/ole/fat.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
##
|
2
|
+
# $Id: fat.rb 8457 2010-02-11 18:36:38Z jduck $
|
3
|
+
# Version: $Revision: 8457 $
|
4
|
+
##
|
5
|
+
|
6
|
+
##
|
7
|
+
# Rex::OLE - an OLE implementation
|
8
|
+
# written in 2010 by Joshua J. Drake <jduck [at] metasploit.com>
|
9
|
+
##
|
10
|
+
|
11
|
+
module Rex
|
12
|
+
module OLE
|
13
|
+
|
14
|
+
class FAT < DIFAT
|
15
|
+
|
16
|
+
#
|
17
|
+
# low-level functions
|
18
|
+
#
|
19
|
+
def read(difat)
|
20
|
+
@entries = []
|
21
|
+
cnt = left = @stg.header._csectFat
|
22
|
+
difat.each { |fs|
|
23
|
+
break if (left == 0)
|
24
|
+
|
25
|
+
if (fs != SECT_FREE)
|
26
|
+
buf = @stg.read_sector(fs, @stg.header.sector_size)
|
27
|
+
arr = Util.get32array(buf)
|
28
|
+
|
29
|
+
# hax!
|
30
|
+
if (@entries[fs] == SECT_DIF)
|
31
|
+
# chop the next ptr
|
32
|
+
@entries += arr.slice!(0, arr.length - 1)
|
33
|
+
else
|
34
|
+
@entries += arr
|
35
|
+
end
|
36
|
+
left -= 1
|
37
|
+
end
|
38
|
+
}
|
39
|
+
|
40
|
+
if (left != 0)
|
41
|
+
raise RuntimeError, 'Only found %u of %u sectors' % [(cnt - left), cnt]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def allocate_sector(type=nil)
|
46
|
+
idx = @entries.index(SECT_FREE)
|
47
|
+
if (not idx)
|
48
|
+
# add a sector worth
|
49
|
+
idx = @entries.length
|
50
|
+
@stg.header.idx_per_sect.times {
|
51
|
+
@entries << SECT_FREE
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# mark the sector as in use
|
56
|
+
if (type)
|
57
|
+
@entries[idx] = type
|
58
|
+
else
|
59
|
+
# default normal sectors to end of chain
|
60
|
+
@entries[idx] = SECT_END
|
61
|
+
end
|
62
|
+
idx
|
63
|
+
end
|
64
|
+
|
65
|
+
def write(difat)
|
66
|
+
# we build the difat as we write these..
|
67
|
+
difat.reset
|
68
|
+
|
69
|
+
# allocate the sectors
|
70
|
+
fat_sects = []
|
71
|
+
left = @entries.length
|
72
|
+
while (left > 0)
|
73
|
+
if (left > @stg.header.idx_per_sect)
|
74
|
+
left -= @stg.header.idx_per_sect
|
75
|
+
else
|
76
|
+
left = 0
|
77
|
+
end
|
78
|
+
fat_sects << allocate_sector(SECT_FAT)
|
79
|
+
end
|
80
|
+
|
81
|
+
# write the fat into the difat/allocated sectors
|
82
|
+
copy = @entries.dup
|
83
|
+
fat_sects.each { |fs|
|
84
|
+
part = copy.slice!(0, @stg.header.idx_per_sect)
|
85
|
+
sbuf = Util.pack32array(part)
|
86
|
+
|
87
|
+
if (sbuf.length != @stg.header.sector_size)
|
88
|
+
raise RuntimeError, 'Unsupported number of fat sectors (not multiple of idx per sect)'
|
89
|
+
end
|
90
|
+
|
91
|
+
@stg.write_sector_raw(fs, sbuf)
|
92
|
+
difat << fs
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
##
|
2
|
+
# $Id: header.rb 10394 2010-09-20 08:06:27Z jduck $
|
3
|
+
# Version: $Revision: 10394 $
|
4
|
+
##
|
5
|
+
|
6
|
+
##
|
7
|
+
# Rex::OLE - an OLE implementation
|
8
|
+
# written in 2010 by Joshua J. Drake <jduck [at] metasploit.com>
|
9
|
+
##
|
10
|
+
|
11
|
+
#
|
12
|
+
# Should we support major == 4 && sectorshift == 0xc ?
|
13
|
+
#
|
14
|
+
|
15
|
+
module Rex
|
16
|
+
module OLE
|
17
|
+
|
18
|
+
require 'rex/ole/util'
|
19
|
+
|
20
|
+
class Header
|
21
|
+
|
22
|
+
attr_accessor :_csectFat, :_sectFat
|
23
|
+
attr_accessor :_csectMiniFat, :_sectMiniFatStart
|
24
|
+
attr_accessor :_ulMiniSectorCutoff, :_uMiniSectorShift
|
25
|
+
attr_accessor :_csectDif, :_sectDifStart
|
26
|
+
attr_accessor :_sectDirStart
|
27
|
+
attr_accessor :_uMajorVersion
|
28
|
+
|
29
|
+
attr_accessor :sector_size, :idx_per_sect
|
30
|
+
attr_accessor :mini_sector_size
|
31
|
+
|
32
|
+
def initialize
|
33
|
+
set_defaults
|
34
|
+
|
35
|
+
# calculate some numbers (save a little math)
|
36
|
+
@sector_size = 1 << @_uSectorShift
|
37
|
+
@mini_sector_size = 1 << @_uMiniSectorShift
|
38
|
+
@idx_per_sect = @sector_size / 4
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_defaults
|
42
|
+
@_abSig = SIG
|
43
|
+
@_clid = CLSID.new
|
44
|
+
@_uByteOrder = LITTLE_ENDIAN
|
45
|
+
|
46
|
+
@_uMinorVersion = 0x3e
|
47
|
+
@_uMajorVersion = 0x03
|
48
|
+
|
49
|
+
@_uSectorShift = 9 # 512 byte sectors
|
50
|
+
@_uMiniSectorShift = 6 # 64 byte mini-sectors
|
51
|
+
|
52
|
+
@_csectDir = nil # TBD (v4 only, 1 required)
|
53
|
+
|
54
|
+
@_csectFat = nil # TBD (one required)
|
55
|
+
@_sectDirStart = nil # TBD (one required)
|
56
|
+
|
57
|
+
@_signature = 0 # no transactions support
|
58
|
+
|
59
|
+
@_ulMiniSectorCutoff = 0x1000 # 4k
|
60
|
+
@_sectMiniFatStart = SECT_END # TBD
|
61
|
+
@_csectMiniFat = 0 # TBD
|
62
|
+
|
63
|
+
@_sectDifStart = SECT_END # TBD (default to none)
|
64
|
+
@_csectDif = 0 # TBD (default to none)
|
65
|
+
|
66
|
+
@_sectFat = [] # TBD
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_s
|
70
|
+
ret = "{\n"
|
71
|
+
ret << " _abSig => \"%s\"" % Util.Printable(@_abSig)
|
72
|
+
ret << ",\n"
|
73
|
+
ret << " _clid => %s" % @_clid.to_s
|
74
|
+
ret << ",\n"
|
75
|
+
ret << " _uMinorVersion => 0x%04x" % @_uMinorVersion
|
76
|
+
ret << ",\n"
|
77
|
+
ret << " _uMajorVersion => 0x%04x" % @_uMajorVersion
|
78
|
+
ret << ",\n"
|
79
|
+
ret << " _uByteOrder => 0x%04x" % @_uByteOrder
|
80
|
+
ret << ",\n"
|
81
|
+
ret << " _uSectorShift => 0x%04x" % @_uSectorShift
|
82
|
+
ret << ",\n"
|
83
|
+
ret << " _uMiniSectorShift => 0x%04x" % @_uMiniSectorShift
|
84
|
+
ret << ",\n"
|
85
|
+
|
86
|
+
if (@_csectDir)
|
87
|
+
ret << " _csectDir => 0x%08x" % @_csectDir
|
88
|
+
else
|
89
|
+
ret << " _csectDir => UNALLOCATED" % @_csectDir
|
90
|
+
end
|
91
|
+
ret << ",\n"
|
92
|
+
|
93
|
+
if (@_csectFat)
|
94
|
+
ret << " _csectFat => 0x%08x" % @_csectFat
|
95
|
+
else
|
96
|
+
ret << " _csectFat => UNALLOCATED"
|
97
|
+
end
|
98
|
+
ret << ",\n"
|
99
|
+
|
100
|
+
if (@_sectDirStart)
|
101
|
+
ret << " _sectDirStart => 0x%08x" % @_sectDirStart
|
102
|
+
else
|
103
|
+
ret << " _sectDirStart => UNALLOCATED"
|
104
|
+
end
|
105
|
+
ret << ",\n"
|
106
|
+
|
107
|
+
ret << " _signature => 0x%08x" % @_signature
|
108
|
+
ret << ",\n"
|
109
|
+
ret << " _uMiniSectorCutoff => 0x%08x" % @_ulMiniSectorCutoff
|
110
|
+
ret << ",\n"
|
111
|
+
ret << " _sectMiniFatStart => 0x%08x" % @_sectMiniFatStart
|
112
|
+
ret << ",\n"
|
113
|
+
ret << " _csectMiniFat => 0x%08x" % @_csectMiniFat
|
114
|
+
ret << ",\n"
|
115
|
+
ret << " _sectDifStart => 0x%08x" % @_sectDifStart
|
116
|
+
ret << ",\n"
|
117
|
+
ret << " _csectDif => 0x%08x" % @_csectDif
|
118
|
+
#ret << ",\n"
|
119
|
+
#ret << " _sectFat => "
|
120
|
+
#ret << Rex::Text.to_hex_dump32array(@_sectFat)
|
121
|
+
ret << "\n}"
|
122
|
+
ret
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# low-level functions
|
127
|
+
#
|
128
|
+
def read(fd)
|
129
|
+
buf = fd.read(HDR_SZ)
|
130
|
+
|
131
|
+
@_abSig = buf[0x00,8]
|
132
|
+
if (@_abSig != SIG) and (@_abSig != SIG_BETA)
|
133
|
+
raise RuntimeError, 'Invalid signature for OLE file'
|
134
|
+
end
|
135
|
+
@_clid = CLSID.new(buf[0x08,16])
|
136
|
+
|
137
|
+
@_uByteOrder = Util.get16(buf, 0x1c)
|
138
|
+
Util.set_endian(@_uByteOrder)
|
139
|
+
|
140
|
+
@_uMinorVersion = Util.get16(buf, 0x18)
|
141
|
+
@_uMajorVersion = Util.get16(buf, 0x1a)
|
142
|
+
|
143
|
+
@_uSectorShift = Util.get16(buf, 0x1e)
|
144
|
+
@_uMiniSectorShift = Util.get16(buf, 0x20)
|
145
|
+
|
146
|
+
# ignore reserved bytes
|
147
|
+
|
148
|
+
@_csectDir = Util.get32(buf, 0x28) # NOTE: only for v4 files
|
149
|
+
|
150
|
+
@_csectFat = Util.get32(buf, 0x2c)
|
151
|
+
@_sectDirStart = Util.get32(buf, 0x30)
|
152
|
+
|
153
|
+
@_signature = Util.get32(buf, 0x34)
|
154
|
+
|
155
|
+
@_ulMiniSectorCutoff = Util.get32(buf, 0x38)
|
156
|
+
@_sectMiniFatStart = Util.get32(buf, 0x3c)
|
157
|
+
@_csectMiniFat = Util.get32(buf, 0x40)
|
158
|
+
|
159
|
+
@_sectDifStart = Util.get32(buf, 0x44)
|
160
|
+
@_csectDif = Util.get32(buf, 0x48)
|
161
|
+
|
162
|
+
@_sectFat = Util.get32array(buf[0x4c, (109 * 4)])
|
163
|
+
end
|
164
|
+
|
165
|
+
def write(fd)
|
166
|
+
hdr = ""
|
167
|
+
hdr << @_abSig
|
168
|
+
hdr << @_clid.pack
|
169
|
+
hdr << Util.pack16(@_uMinorVersion)
|
170
|
+
hdr << Util.pack16(@_uMajorVersion)
|
171
|
+
hdr << Util.pack16(@_uByteOrder)
|
172
|
+
hdr << Util.pack16(@_uSectorShift)
|
173
|
+
hdr << Util.pack16(@_uMiniSectorShift)
|
174
|
+
if (@_uMajorVersion == 0x04)
|
175
|
+
hdr << "\x00" * 6 # reserved bytes
|
176
|
+
hdr << Util.pack32(@_csectDir)
|
177
|
+
else
|
178
|
+
hdr << "\x00" * 10 # reserved bytes
|
179
|
+
end
|
180
|
+
|
181
|
+
fs_count = @_csectFat
|
182
|
+
fs_count ||= 0
|
183
|
+
hdr << Util.pack32(fs_count)
|
184
|
+
|
185
|
+
dir_start = @_sectDirStart
|
186
|
+
dir_start ||= SECT_END
|
187
|
+
hdr << Util.pack32(dir_start)
|
188
|
+
|
189
|
+
hdr << Util.pack32(@_signature)
|
190
|
+
hdr << Util.pack32(@_ulMiniSectorCutoff)
|
191
|
+
hdr << Util.pack32(@_sectMiniFatStart)
|
192
|
+
hdr << Util.pack32(@_csectMiniFat)
|
193
|
+
hdr << Util.pack32(@_sectDifStart)
|
194
|
+
hdr << Util.pack32(@_csectDif)
|
195
|
+
hdr << Util.pack32array(@_sectFat)
|
196
|
+
|
197
|
+
fd.seek(0, ::IO::SEEK_SET)
|
198
|
+
fd.write(hdr)
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
end
|