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,165 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'rex/proto/http'
|
7
|
+
|
8
|
+
class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
Klass = Rex::Proto::Http::Packet
|
11
|
+
|
12
|
+
def test_junk_headers
|
13
|
+
srand(0)
|
14
|
+
h = Klass.new
|
15
|
+
h.headers.cmd_string = "GET / HTTP/1.0\r\n"
|
16
|
+
h.headers['TestMe'] = 'bob'
|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upRvb2vJTHHlrsuuihK3FcugTnefvvBgox3t3u2AlVWbFtjtj8oDcb7JrDrLzWqqEd8sCeFvMRP4pYVoD8uwfGzhvLnID3r2np2ZtGHodFmDHyrXYydzR4rhwOqqQv1Bq1Az4PQIpU92rZA7xnCGDeNU0LLFwQNIbGs2qEopP8AnlGzd6vZMA0yxc6HBswyHoao9wuWOfV0HkQGqUmEQiv47vOvnPYOK2EUpo0L81dD0sa8bC8C9Xtc51Sv7BEkRYZrMiV4yJkrpGRf6yvsGyQecLgmZmdCTMSApWRqEESFOKydTiDIaSEHqdjPutD6DGClY37jDHbyCwHKt7w5F0oW0rBGcFoKHdkSv87Cpdgx80ZkTg1ba44ctXSFBViBdtiOqeJ2bHMdkmcxVXlUNtoyp2BI\r\nContent-Length: 0\r\nTestMe: bob\r\n\r\n"
|
19
|
+
assert_equal(expected, h.to_s, 'junk headers')
|
20
|
+
h.headers.cmd_string = "HTTP/1.0 OK\r\n"
|
21
|
+
h.headers.fold = 1
|
22
|
+
expected = "HTTP/1.0 OK\r\nX-nsJxRxZX5o5zKaNf8VhtBgr3Gieuamk:\r\n\twM0v0nww3ZA8mepvkmcqXPmmWwHlyCNUudg03Tss4WWsl8i92mVcwi9B2tuR0irNRfVitBFvymfcm6ywElHD2VV5aCcvglhj6gnRJjsWFWJ2B9rFqEH2Tyzm13NLXm21Lo1fD39CHCZuFQyIR4ycO4GN4cDs7mvEALmGzU4GQAD7Fv9n7QZ5ebLoAhZ0Owi0oyyr3mTqimVUajbDZ8HEE1JEhxKX5wgNVcXwF9CAJHdVQOTlaMPTSqCQ4LjJ5JeWqUpTEuPhAvPNJxqKxninwssqBIALaerqTVvB68ScL7x0nJYEa0r2VOdBOAPhg9zlFe2pvy6J1HeVepIBtVI5tx0AbywZdHafO5TIndXNoBZYepQ8LnHmVYlr7kgJxoQj3Dnl6Do6jBDLDu7MgnyA22vXH7BiN4eVRXjhGYi3o5mJYdFwwZEumA7OJkvycPCkHRfrpPc202q4fW5yX8EAR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F9XGWXB33afT9ZoHL753R2oALkjN8ImKZpJ2UE7nQSuOXu0j7weDKgVp6uhShzM0CZqezcpRO78NhW09YeKDfxgNxnAuYUrpabXaJhapvfofIxkReB6d1QUI3kd7rsPNZlQyLuChcapBaITb5jWZYsUk1YeM03q4cyEBFsV6xYI4s6w6egVD51URRLS5j6VtrizhJbXpz7kwhLtIrudhvOeufXrVCakuJB4DRBweihvwK5GFqGpmF8e7IR3WDPmu0eGdWKcHbwTCzHMzTzeebPvX6eTINmmCqzEmF71uyhYscV9sOy0EpRPZkMm7deiTqTfpkpLHFNiuggcMdzKq3Jzx7TWXe80Nyf68QSBPgOJGzvDG2PdVzK6NbaapE7dwc98Pu5bogtxOEZgMsp7q0N0y4yxFXl0ec2VTY5vXtKegVo2eGZF3fvubZhbQQPei7FIQmzncFATX8e0umoiRPKSobz8qmOvR83psDw1ZYsfX9PV8dWYDJmAPspOFR6pDwTSrxxBHIf8OOUSvjsonfBa5Ympf4Lw7jLxvxxyvytdky5Kqa8L5pH90gbH3U\r\nContent-Length:\r\n\t0\r\nTestMe:\r\n\tbob\r\n\r\n"
|
23
|
+
assert_equal(expected, h.to_s, 'junk headers')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_pipeline
|
27
|
+
req_normalized =
|
28
|
+
"GET / HTTP/1.0\r\n" +
|
29
|
+
"Foo: Bar\r\n" +
|
30
|
+
"Content-Length: 10\r\n" +
|
31
|
+
"\r\n" +
|
32
|
+
"Super body"
|
33
|
+
|
34
|
+
req = req_normalized + req_normalized
|
35
|
+
|
36
|
+
req_base = req.dup
|
37
|
+
req_fold = req.gsub(/:/, ':' + Rex::Text.rand_base(rand(10) + 1,'',"\s","\t") + "\r\n" + Rex::Text.rand_base(rand(10) + 1,'',"\s","\t"))
|
38
|
+
req_nocr = req.gsub(/\r\n/, "\n")
|
39
|
+
req_junk = req + "junk"
|
40
|
+
|
41
|
+
{ 'base' => req_base, 'fold' => req_fold, 'no cr' => req_nocr, 'extra junk' => req_junk }.each_pair { |name, test|
|
42
|
+
h = Klass.new
|
43
|
+
h.auto_cl = false
|
44
|
+
assert_equal(Klass::ParseCode::Completed, h.parse(test), "parse #{name}")
|
45
|
+
assert_equal(req_normalized, h.to_s, "to string #{name}")
|
46
|
+
assert_equal(true, h.completed?, "completed parsing #{name}")
|
47
|
+
assert_equal('Bar', h.headers['Foo'], "first header #{name}")
|
48
|
+
assert_equal('10', h.headers['Content-Length'], "second header #{name}")
|
49
|
+
assert_equal("Super body", h.body, "body #{name}")
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def test_chunked
|
55
|
+
req_start =
|
56
|
+
"GET / HTTP/1.0\r\n" +
|
57
|
+
"Transfer-Encoding: chunked\r\n" +
|
58
|
+
"Foo: Bar\r\n" +
|
59
|
+
"\r\n"
|
60
|
+
|
61
|
+
req_normalized = req_start + "Super body"
|
62
|
+
|
63
|
+
req = req_start + "1\r\nS\r\n1\r\nu\r\n1\r\np\r\n1\r\ne\r\n1\r\nr\r\n1\r\n \r\n1\r\nb\r\n1\r\no\r\n1\r\nd\r\n1\r\ny\r\n0\r\n\r\n"
|
64
|
+
|
65
|
+
req_base = req.dup
|
66
|
+
req_fold = req.gsub(/:/, ':' + Rex::Text.rand_base(rand(10) + 1,'',"\s","\t") + "\r\n" + Rex::Text.rand_base(rand(10) + 1,'',"\s","\t"))
|
67
|
+
req_nocr = req.gsub(/\r\n/, "\n")
|
68
|
+
req_junk = req + "junk"
|
69
|
+
|
70
|
+
{ 'base' => req_base, 'fold' => req_fold, 'no cr' => req_nocr, 'extra junk' => req_junk }.each_pair { |name, test|
|
71
|
+
h = Klass.new
|
72
|
+
h.auto_cl = false
|
73
|
+
assert_equal(Klass::ParseCode::Completed, h.parse(test), "parse #{name}")
|
74
|
+
assert_equal(req_normalized, h.to_s, "to string #{name}")
|
75
|
+
assert_equal(true, h.completed?, "completed parsing #{name}")
|
76
|
+
assert_equal('Bar', h.headers['Foo'], "first header #{name}")
|
77
|
+
assert_equal('chunked', h.headers['Transfer-Encoding'], "second header #{name}")
|
78
|
+
assert_equal("Super body", h.body, "body #{name}")
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_content_length
|
83
|
+
req =
|
84
|
+
"GET / HTTP/1.0\r\n" +
|
85
|
+
"Foo: Bar\r\n" +
|
86
|
+
"Content-Length: 10\r\n" +
|
87
|
+
"\r\n" +
|
88
|
+
"Super body"
|
89
|
+
|
90
|
+
req_base = req.dup
|
91
|
+
req_fold = req.gsub(/:/, ':' + Rex::Text.rand_base(rand(10) + 1,'',"\s","\t") + "\r\n" + Rex::Text.rand_base(rand(10) + 1,'',"\s","\t"))
|
92
|
+
req_nocr = req.gsub(/\r\n/, "\n")
|
93
|
+
req_junk = req + "junk"
|
94
|
+
|
95
|
+
{ 'base' => req_base, 'fold' => req_fold, 'no cr' => req_nocr, 'extra junk' => req_junk }.each_pair { |name, test|
|
96
|
+
h = Klass.new
|
97
|
+
h.auto_cl = false
|
98
|
+
assert_equal(Klass::ParseCode::Completed, h.parse(test), "parse #{name}")
|
99
|
+
assert_equal(req, h.to_s, "to string #{name}")
|
100
|
+
assert_equal(true, h.completed?, "completed parsing #{name}")
|
101
|
+
assert_equal('Bar', h.headers['Foo'], "first header #{name}")
|
102
|
+
assert_equal('10', h.headers['Content-Length'], "second header #{name}")
|
103
|
+
assert_equal("Super body", h.body, "body #{name}")
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_parse_connection_close
|
108
|
+
req =
|
109
|
+
"GET / HTTP/1.0\r\n" +
|
110
|
+
"Foo: Bar\r\n" +
|
111
|
+
"Connection: close\r\n" +
|
112
|
+
"\r\n" +
|
113
|
+
"Super body"
|
114
|
+
|
115
|
+
req_base = req.dup
|
116
|
+
req_fold = req.gsub(/:/, ':' + Rex::Text.rand_base(rand(10) + 1,'',"\s","\t") + "\r\n" + Rex::Text.rand_base(rand(10) + 1,'',"\s","\t"))
|
117
|
+
req_nocr = req.gsub(/\r\n/, "\n")
|
118
|
+
|
119
|
+
{ 'base' => req_base, 'fold' => req_fold, 'no cr' => req_nocr }.each_pair { |name, test|
|
120
|
+
h = Klass.new
|
121
|
+
h.auto_cl = false
|
122
|
+
assert_equal(Klass::ParseCode::Completed, h.parse(test), "parse #{name}")
|
123
|
+
assert_equal(req, h.to_s, "to string #{name}")
|
124
|
+
assert_equal(true, h.completed?, "completed parsing #{name}")
|
125
|
+
assert_equal('Bar', h.headers['Foo'], "first header #{name}")
|
126
|
+
assert_equal('close', h.headers['Connection'], "second header #{name}")
|
127
|
+
assert_equal("Super body", h.body, "body #{name}")
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_to_s
|
132
|
+
h = Klass.new
|
133
|
+
|
134
|
+
h.headers['Foo'] = 'Fishing'
|
135
|
+
h.headers['Chicken'] = 47
|
136
|
+
|
137
|
+
assert_equal(
|
138
|
+
"Foo: Fishing\r\n" +
|
139
|
+
"Content-Length: 0\r\n" +
|
140
|
+
"Chicken: 47\r\n\r\n", h.to_s)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_from_s
|
144
|
+
h = Klass.new
|
145
|
+
|
146
|
+
h.from_s(
|
147
|
+
"HTTP/1.0 200 OK\r\n" +
|
148
|
+
"Lucifer: Beast\r\n" +
|
149
|
+
"HoHo: Satan\r\n" +
|
150
|
+
"Eat: Babies\r\n" +
|
151
|
+
"\r\n")
|
152
|
+
|
153
|
+
assert_equal('Babies', h['Eat'])
|
154
|
+
h['Eat'] = "fish"
|
155
|
+
assert_equal('fish', h['Eat'])
|
156
|
+
end
|
157
|
+
|
158
|
+
# XXX
|
159
|
+
def test_no_headers
|
160
|
+
h = Klass.new
|
161
|
+
h.from_s("GET / HTTP/1.0\r\n\r\n")
|
162
|
+
assert_equal("GET / HTTP/1.0\r\n", h.headers.cmd_string, 'cmd string')
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
@@ -0,0 +1,356 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'rex/proto/http'
|
3
|
+
|
4
|
+
module Rex
|
5
|
+
module Proto
|
6
|
+
module Http
|
7
|
+
|
8
|
+
###
|
9
|
+
#
|
10
|
+
# HTTP request class.
|
11
|
+
#
|
12
|
+
###
|
13
|
+
class Request < Packet
|
14
|
+
|
15
|
+
PostRequests = ['POST', 'SEARCH']
|
16
|
+
|
17
|
+
##
|
18
|
+
#
|
19
|
+
# Some individual request types.
|
20
|
+
#
|
21
|
+
##
|
22
|
+
|
23
|
+
#
|
24
|
+
# HTTP GET request class wrapper.
|
25
|
+
#
|
26
|
+
class Get < Request
|
27
|
+
def initialize(uri = '/', proto = DefaultProtocol)
|
28
|
+
super('GET', uri, proto)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# HTTP POST request class wrapper.
|
34
|
+
#
|
35
|
+
class Post < Request
|
36
|
+
def initialize(uri = '/', proto = DefaultProtocol)
|
37
|
+
super('POST', uri, proto)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# HTTP PUT request class wrapper.
|
43
|
+
#
|
44
|
+
class Put < Request
|
45
|
+
def initialize(uri = '/', proto = DefaultProtocol)
|
46
|
+
super('PUT', uri, proto)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Initializes an instance of an HTTP request with the supplied method, URI,
|
52
|
+
# and protocol.
|
53
|
+
#
|
54
|
+
def initialize(method = 'GET', uri = '/', proto = DefaultProtocol)
|
55
|
+
super()
|
56
|
+
|
57
|
+
self.method = method
|
58
|
+
self.raw_uri = uri
|
59
|
+
self.uri_parts = {}
|
60
|
+
self.proto = proto || DefaultProtocol
|
61
|
+
self.chunk_min_size = 1
|
62
|
+
self.chunk_max_size = 10
|
63
|
+
self.uri_encode_mode = 'hex-normal'
|
64
|
+
|
65
|
+
update_uri_parts
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Updates the command parts for this specific packet type.
|
70
|
+
#
|
71
|
+
def update_cmd_parts(str)
|
72
|
+
if (md = str.match(/^(.+?)\s+(.+?)\s+HTTP\/(.+?)\r?\n?$/))
|
73
|
+
self.method = md[1]
|
74
|
+
self.raw_uri = URI.decode(md[2])
|
75
|
+
self.proto = md[3]
|
76
|
+
|
77
|
+
update_uri_parts
|
78
|
+
else
|
79
|
+
raise RuntimeError, "Invalid request command string", caller
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# Split the URI into the resource being requested and its query string.
|
85
|
+
#
|
86
|
+
def update_uri_parts
|
87
|
+
# If it has a query string, get the parts.
|
88
|
+
if ((self.raw_uri) and (md = self.raw_uri.match(/(.+?)\?(.*)$/)))
|
89
|
+
self.uri_parts['QueryString'] = parse_cgi_qstring(md[2])
|
90
|
+
self.uri_parts['Resource'] = md[1]
|
91
|
+
# Otherwise, just assume that the URI is equal to the resource being
|
92
|
+
# requested.
|
93
|
+
else
|
94
|
+
self.uri_parts['QueryString'] = {}
|
95
|
+
self.uri_parts['Resource'] = self.raw_uri
|
96
|
+
end
|
97
|
+
|
98
|
+
self.normalize!(resource)
|
99
|
+
# Set the relative resource to the actual resource.
|
100
|
+
self.relative_resource = resource
|
101
|
+
end
|
102
|
+
|
103
|
+
# normalize out multiple slashes, directory traversal, and self referrential directories
|
104
|
+
def normalize!(str)
|
105
|
+
i = 0
|
106
|
+
while (str.gsub!(/(\/\.\/|\/\w+\/\.\.\/|\/\/)/,'/')); i += 1; end
|
107
|
+
i
|
108
|
+
end
|
109
|
+
|
110
|
+
# Puts a URI back together based on the URI parts
|
111
|
+
def uri
|
112
|
+
str = self.uri_parts['Resource'].dup || '/'
|
113
|
+
|
114
|
+
# /././././
|
115
|
+
if self.junk_self_referring_directories
|
116
|
+
str.gsub!(/\//) {
|
117
|
+
'/.' * (rand(3) + 1) + '/'
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
# /%3faaa=bbbbb
|
122
|
+
# which could possibly decode to "/?aaa=bbbbb", which if the IDS normalizes first, then splits the URI on ?, then it can be bypassed
|
123
|
+
if self.junk_param_start
|
124
|
+
str.sub!(/\//, '/%3f' + Rex::Text.rand_text_alpha(rand(5) + 1) + '=' + Rex::Text.rand_text_alpha(rand(10) + 1) + '/../')
|
125
|
+
end
|
126
|
+
|
127
|
+
# /RAND/../RAND../
|
128
|
+
if self.junk_directories
|
129
|
+
str.gsub!(/\//) {
|
130
|
+
dirs = ''
|
131
|
+
(rand(5)+5).times {
|
132
|
+
dirs << '/' + Rex::Text.rand_text_alpha(rand(5) + 1) + '/..'
|
133
|
+
}
|
134
|
+
dirs + '/'
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
# ////
|
139
|
+
#
|
140
|
+
# NOTE: this must be done after all other odd directory junk, since they would cancel this out, except junk_end_of_uri, since that a specific slash in a specific place
|
141
|
+
if self.junk_slashes
|
142
|
+
str.gsub!(/\//) {
|
143
|
+
'/' * (rand(3) + 2)
|
144
|
+
}
|
145
|
+
str.sub!(/^[\/]+/, '/') # only one beginning slash!
|
146
|
+
end
|
147
|
+
|
148
|
+
# /%20HTTP/1.0%0d%0a/../../
|
149
|
+
# which decodes to "/ HTTP/1.0\r\n"
|
150
|
+
if self.junk_end_of_uri
|
151
|
+
str.sub!(/^\//, '/%20HTTP/1.0%0d%0a/../../')
|
152
|
+
end
|
153
|
+
|
154
|
+
Rex::Text.uri_encode(str, self.uri_encode_mode)
|
155
|
+
|
156
|
+
if !PostRequests.include?(self.method)
|
157
|
+
if param_string.size > 0
|
158
|
+
str << '?' + param_string
|
159
|
+
end
|
160
|
+
end
|
161
|
+
str
|
162
|
+
end
|
163
|
+
|
164
|
+
def param_string
|
165
|
+
params=[]
|
166
|
+
self.uri_parts['QueryString'].each_pair { |param, value|
|
167
|
+
# inject a random number of params in between each param
|
168
|
+
if self.junk_params
|
169
|
+
rand(10)+5.times {
|
170
|
+
params.push(Rex::Text.rand_text_alpha(rand(16) + 5) + '=' + Rex::Text.rand_text_alpha(rand(10) + 1))
|
171
|
+
}
|
172
|
+
end
|
173
|
+
if value.kind_of?(Array)
|
174
|
+
value.each { |subvalue|
|
175
|
+
params.push(Rex::Text.uri_encode(param, self.uri_encode_mode) + '=' + Rex::Text.uri_encode(subvalue, self.uri_encode_mode))
|
176
|
+
}
|
177
|
+
else
|
178
|
+
if !value.nil?
|
179
|
+
params.push(Rex::Text.uri_encode(param, self.uri_encode_mode) + '=' + Rex::Text.uri_encode(value, self.uri_encode_mode))
|
180
|
+
else
|
181
|
+
params.push(Rex::Text.uri_encode(param, self.uri_encode_mode))
|
182
|
+
end
|
183
|
+
end
|
184
|
+
}
|
185
|
+
|
186
|
+
# inject some junk params at the end of the param list, just to be sure :P
|
187
|
+
if self.junk_params
|
188
|
+
rand(10)+5.times {
|
189
|
+
params.push(Rex::Text.rand_text_alpha(rand(32) + 5) + '=' + Rex::Text.rand_text_alpha(rand(64) + 5))
|
190
|
+
}
|
191
|
+
end
|
192
|
+
params.join('&')
|
193
|
+
end
|
194
|
+
|
195
|
+
# Updates the underlying URI structure
|
196
|
+
def uri=(str)
|
197
|
+
self.raw_uri = str
|
198
|
+
update_uri_parts
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns a request packet
|
202
|
+
def to_s
|
203
|
+
str = ''
|
204
|
+
if self.junk_pipeline
|
205
|
+
host = ''
|
206
|
+
if self.headers['Host']
|
207
|
+
host = "Host: #{self.headers['Host']}\r\n"
|
208
|
+
end
|
209
|
+
str << "GET / HTTP/1.1\r\n#{host}Connection: Keep-Alive\r\n\r\n" * self.junk_pipeline
|
210
|
+
self.headers['Connection'] = 'Closed'
|
211
|
+
end
|
212
|
+
str + super
|
213
|
+
end
|
214
|
+
|
215
|
+
def body
|
216
|
+
str = super || ''
|
217
|
+
if str.length > 0
|
218
|
+
return str
|
219
|
+
end
|
220
|
+
|
221
|
+
if PostRequests.include?(self.method)
|
222
|
+
return param_string
|
223
|
+
end
|
224
|
+
''
|
225
|
+
end
|
226
|
+
|
227
|
+
#
|
228
|
+
# Returns the command string derived from the three values.
|
229
|
+
#
|
230
|
+
def cmd_string
|
231
|
+
proto_str = (self.proto =~ /^\d/) ? "HTTP/#{self.proto}" : self.proto
|
232
|
+
|
233
|
+
"#{self.method} #{self.uri} #{proto_str}\r\n"
|
234
|
+
end
|
235
|
+
|
236
|
+
#
|
237
|
+
# Returns the resource that is being requested.
|
238
|
+
#
|
239
|
+
def resource
|
240
|
+
self.uri_parts['Resource']
|
241
|
+
end
|
242
|
+
|
243
|
+
#
|
244
|
+
# Changes the resource URI. This is used when making a request relative to
|
245
|
+
# a given mount point.
|
246
|
+
#
|
247
|
+
def resource=(rsrc)
|
248
|
+
self.uri_parts['Resource'] = rsrc
|
249
|
+
end
|
250
|
+
|
251
|
+
#
|
252
|
+
# If there were CGI parameters in the URI, this will hold a hash of each
|
253
|
+
# variable to value. If there is more than one value for a given variable,
|
254
|
+
# an array of each value is returned.
|
255
|
+
#
|
256
|
+
def qstring
|
257
|
+
self.uri_parts['QueryString']
|
258
|
+
end
|
259
|
+
|
260
|
+
#
|
261
|
+
# Returns a hash of variables that contain information about the request,
|
262
|
+
# such as the remote host information.
|
263
|
+
#
|
264
|
+
# TODO
|
265
|
+
#
|
266
|
+
def meta_vars
|
267
|
+
end
|
268
|
+
|
269
|
+
#
|
270
|
+
# The method being used for the request (e.g. GET).
|
271
|
+
#
|
272
|
+
attr_accessor :method
|
273
|
+
#
|
274
|
+
# The raw URI being requested, before any mucking gets to it
|
275
|
+
#
|
276
|
+
attr_accessor :raw_uri
|
277
|
+
|
278
|
+
#
|
279
|
+
# The split up parts of the URI.
|
280
|
+
#
|
281
|
+
attr_accessor :uri_parts
|
282
|
+
#
|
283
|
+
# The protocol to be sent with the request.
|
284
|
+
#
|
285
|
+
attr_accessor :proto
|
286
|
+
|
287
|
+
#
|
288
|
+
# The resource path relative to the root of a server mount point.
|
289
|
+
#
|
290
|
+
attr_accessor :relative_resource
|
291
|
+
|
292
|
+
# add junk directories
|
293
|
+
attr_accessor :junk_directories
|
294
|
+
|
295
|
+
# add junk slashes
|
296
|
+
attr_accessor :junk_slashes
|
297
|
+
|
298
|
+
# add junk self referring directories (aka /././././)
|
299
|
+
attr_accessor :junk_self_referring_directories
|
300
|
+
|
301
|
+
# add junk params
|
302
|
+
attr_accessor :junk_params
|
303
|
+
|
304
|
+
# add junk pipeline requests
|
305
|
+
attr_accessor :junk_pipeline
|
306
|
+
|
307
|
+
# add junk start of params
|
308
|
+
attr_accessor :junk_param_start
|
309
|
+
|
310
|
+
# add junk end of URI
|
311
|
+
attr_accessor :junk_end_of_uri
|
312
|
+
|
313
|
+
# encoding uri
|
314
|
+
attr_accessor :uri_encode_mode
|
315
|
+
|
316
|
+
|
317
|
+
protected
|
318
|
+
|
319
|
+
#
|
320
|
+
# Parses a CGI query string into the var/val combinations.
|
321
|
+
#
|
322
|
+
def parse_cgi_qstring(str)
|
323
|
+
qstring = {}
|
324
|
+
|
325
|
+
# Delimit on each variable
|
326
|
+
str.split(/[;&]/).each { |vv|
|
327
|
+
var = vv
|
328
|
+
val = ''
|
329
|
+
|
330
|
+
if (md = vv.match(/(.+?)=(.*)/))
|
331
|
+
var = md[1]
|
332
|
+
val = md[2]
|
333
|
+
end
|
334
|
+
|
335
|
+
# Add the item to the hash with logic to convert values to an array
|
336
|
+
# if so desired.
|
337
|
+
if (qstring.include?(var))
|
338
|
+
if (qstring[var].kind_of?(Array))
|
339
|
+
qstring[var] << val
|
340
|
+
else
|
341
|
+
curr = self.qstring[var]
|
342
|
+
qstring[var] = [ curr, val ]
|
343
|
+
end
|
344
|
+
else
|
345
|
+
qstring[var] = val
|
346
|
+
end
|
347
|
+
}
|
348
|
+
|
349
|
+
return qstring
|
350
|
+
end
|
351
|
+
|
352
|
+
end
|
353
|
+
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|