librex 0.0.65 → 0.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +1 -1
- data/lib/rex/arch.rb +1 -0
- data/lib/rex/arch/sparc.rb +16 -15
- data/lib/rex/arch/sparc.rb.ut.rb +2 -1
- data/lib/rex/arch/x86.rb +1 -0
- data/lib/rex/arch/x86.rb.ut.rb +2 -1
- data/lib/rex/assembly/nasm.rb +1 -0
- data/lib/rex/assembly/nasm.rb.ut.rb +2 -1
- data/lib/rex/compat.rb +13 -0
- data/lib/rex/constants.rb +5 -4
- data/lib/rex/elfparsey.rb +3 -2
- data/lib/rex/elfparsey/elf.rb +2 -1
- data/lib/rex/elfparsey/elfbase.rb +8 -7
- data/lib/rex/elfparsey/exceptions.rb +3 -2
- data/lib/rex/elfscan.rb +3 -2
- data/lib/rex/elfscan/scanner.rb +2 -1
- data/lib/rex/elfscan/search.rb +2 -1
- data/lib/rex/encoder/alpha2.rb +2 -1
- data/lib/rex/encoder/alpha2/alpha_mixed.rb +3 -2
- data/lib/rex/encoder/alpha2/alpha_upper.rb +5 -4
- data/lib/rex/encoder/alpha2/generic.rb +37 -60
- data/lib/rex/encoder/alpha2/unicode_mixed.rb +4 -9
- data/lib/rex/encoder/alpha2/unicode_upper.rb +4 -9
- data/lib/rex/encoder/ndr.rb +1 -0
- data/lib/rex/encoder/ndr.rb.ut.rb +2 -1
- data/lib/rex/encoder/nonalpha.rb +1 -0
- data/lib/rex/encoder/nonupper.rb +1 -0
- data/lib/rex/encoder/xdr.rb +9 -8
- data/lib/rex/encoder/xdr.rb.ut.rb +2 -1
- data/lib/rex/encoder/xor.rb +1 -0
- data/lib/rex/encoder/xor/dword.rb +2 -1
- data/lib/rex/encoder/xor/dword_additive.rb +2 -1
- data/lib/rex/encoders/xor_dword.rb +1 -0
- data/lib/rex/encoders/xor_dword_additive.rb +2 -1
- data/lib/rex/encoders/xor_dword_additive.rb.ut.rb +2 -1
- data/lib/rex/encoding/xor.rb +2 -1
- data/lib/rex/encoding/xor.rb.ts.rb +2 -1
- data/lib/rex/encoding/xor/byte.rb +2 -1
- data/lib/rex/encoding/xor/byte.rb.ut.rb +2 -1
- data/lib/rex/encoding/xor/dword.rb +2 -1
- data/lib/rex/encoding/xor/dword.rb.ut.rb +2 -1
- data/lib/rex/encoding/xor/dword_additive.rb +1 -0
- data/lib/rex/encoding/xor/dword_additive.rb.ut.rb +2 -1
- data/lib/rex/encoding/xor/exceptions.rb +1 -0
- data/lib/rex/encoding/xor/generic.rb +1 -0
- data/lib/rex/encoding/xor/generic.rb.ut.rb +2 -1
- data/lib/rex/encoding/xor/qword.rb +2 -1
- data/lib/rex/encoding/xor/word.rb +2 -1
- data/lib/rex/encoding/xor/word.rb.ut.rb +2 -1
- data/lib/rex/exceptions.rb +1 -0
- data/lib/rex/exceptions.rb.ut.rb +2 -1
- data/lib/rex/exploitation/cmdstager.rb +2 -1
- data/lib/rex/exploitation/cmdstager/base.rb +1 -0
- data/lib/rex/exploitation/cmdstager/debug_asm.rb +2 -1
- data/lib/rex/exploitation/cmdstager/debug_write.rb +2 -1
- data/lib/rex/exploitation/cmdstager/tftp.rb +2 -1
- data/lib/rex/exploitation/cmdstager/vbs.rb +2 -1
- data/lib/rex/exploitation/egghunter.rb +12 -11
- data/lib/rex/exploitation/egghunter.rb.ut.rb +2 -1
- data/lib/rex/exploitation/encryptjs.rb +1 -0
- data/lib/rex/exploitation/heaplib.rb +1 -0
- data/lib/rex/exploitation/javascriptosdetect.js +1014 -0
- data/lib/rex/exploitation/javascriptosdetect.rb +4 -857
- data/lib/rex/exploitation/jsobfu.rb +2 -1
- data/lib/rex/exploitation/obfuscatejs.rb +1 -0
- data/lib/rex/exploitation/omelet.rb +1 -0
- data/lib/rex/exploitation/omelet.rb.ut.rb +1 -0
- data/lib/rex/exploitation/opcodedb.rb +12 -11
- data/lib/rex/exploitation/opcodedb.rb.ut.rb +2 -1
- data/lib/rex/exploitation/seh.rb +3 -2
- data/lib/rex/exploitation/seh.rb.ut.rb +2 -1
- data/lib/rex/file.rb +4 -3
- data/lib/rex/file.rb.ut.rb +2 -1
- data/lib/rex/image_source.rb +3 -2
- data/lib/rex/image_source/disk.rb +3 -2
- data/lib/rex/image_source/image_source.rb +3 -2
- data/lib/rex/image_source/memory.rb +3 -2
- data/lib/rex/io/bidirectional_pipe.rb +1 -0
- data/lib/rex/io/datagram_abstraction.rb +2 -1
- data/lib/rex/io/ring_buffer.rb +49 -44
- data/lib/rex/io/ring_buffer.rb.ut.rb +4 -3
- data/lib/rex/io/stream.rb +1 -0
- data/lib/rex/io/stream_abstraction.rb +1 -0
- data/lib/rex/io/stream_server.rb +1 -0
- data/lib/rex/job_container.rb +1 -0
- data/lib/rex/logging.rb +2 -1
- data/lib/rex/logging/log_dispatcher.rb +5 -4
- data/lib/rex/logging/log_sink.rb +2 -1
- data/lib/rex/logging/sinks/flatfile.rb +4 -3
- data/lib/rex/logging/sinks/stderr.rb +2 -1
- data/lib/rex/machparsey.rb +2 -1
- data/lib/rex/machparsey/exceptions.rb +2 -1
- data/lib/rex/machparsey/mach.rb +20 -19
- data/lib/rex/machparsey/machbase.rb +27 -26
- data/lib/rex/machscan.rb +2 -1
- data/lib/rex/machscan/scanner.rb +1 -0
- data/lib/rex/mime.rb +2 -1
- data/lib/rex/mime/header.rb +1 -0
- data/lib/rex/mime/message.rb +4 -1
- data/lib/rex/mime/part.rb +2 -1
- data/lib/rex/nop/opty2.rb +2 -1
- data/lib/rex/nop/opty2.rb.ut.rb +2 -1
- data/lib/rex/nop/opty2_tables.rb +1 -0
- data/lib/rex/ole.rb +3 -2
- data/lib/rex/ole/clsid.rb +3 -2
- data/lib/rex/ole/difat.rb +3 -2
- data/lib/rex/ole/directory.rb +3 -2
- data/lib/rex/ole/direntry.rb +3 -2
- data/lib/rex/ole/fat.rb +3 -2
- data/lib/rex/ole/header.rb +3 -2
- data/lib/rex/ole/minifat.rb +3 -2
- data/lib/rex/ole/propset.rb +4 -3
- data/lib/rex/ole/samples/create_ole.rb +1 -0
- data/lib/rex/ole/samples/dir.rb +1 -0
- data/lib/rex/ole/samples/dump_stream.rb +1 -0
- data/lib/rex/ole/samples/ole_info.rb +1 -0
- data/lib/rex/ole/storage.rb +3 -2
- data/lib/rex/ole/stream.rb +3 -2
- data/lib/rex/ole/substorage.rb +3 -2
- data/lib/rex/ole/util.rb +3 -2
- data/lib/rex/parser/acunetix_nokogiri.rb +13 -12
- data/lib/rex/parser/apple_backup_manifestdb.rb +20 -19
- data/lib/rex/parser/appscan_nokogiri.rb +17 -16
- data/lib/rex/parser/arguments.rb +2 -1
- data/lib/rex/parser/arguments.rb.ut.rb +2 -1
- data/lib/rex/parser/burp_session_nokogiri.rb +8 -7
- data/lib/rex/parser/ci_nokogiri.rb +4 -3
- data/lib/rex/parser/foundstone_nokogiri.rb +18 -17
- data/lib/rex/parser/fusionvm_nokogiri.rb +109 -0
- data/lib/rex/parser/ini.rb +1 -0
- data/lib/rex/parser/ini.rb.ut.rb +2 -1
- data/lib/rex/parser/ip360_aspl_xml.rb +1 -0
- data/lib/rex/parser/ip360_xml.rb +4 -3
- data/lib/rex/parser/mbsa_nokogiri.rb +8 -7
- data/lib/rex/parser/nessus_xml.rb +3 -2
- data/lib/rex/parser/netsparker_xml.rb +10 -9
- data/lib/rex/parser/nexpose_raw_nokogiri.rb +372 -52
- data/lib/rex/parser/nexpose_simple_nokogiri.rb +8 -7
- data/lib/rex/parser/nexpose_xml.rb +1 -0
- data/lib/rex/parser/nmap_nokogiri.rb +63 -33
- data/lib/rex/parser/nmap_xml.rb +1 -0
- data/lib/rex/parser/nokogiri_doc_mixin.rb +35 -15
- data/lib/rex/parser/openvas_nokogiri.rb +172 -0
- data/lib/rex/parser/retina_xml.rb +1 -0
- data/lib/rex/parser/wapiti_nokogiri.rb +105 -0
- data/lib/rex/payloads.rb +2 -1
- data/lib/rex/payloads/win32.rb +2 -1
- data/lib/rex/payloads/win32/common.rb +2 -1
- data/lib/rex/payloads/win32/kernel.rb +2 -1
- data/lib/rex/payloads/win32/kernel/common.rb +4 -3
- data/lib/rex/payloads/win32/kernel/migration.rb +2 -1
- data/lib/rex/payloads/win32/kernel/recovery.rb +2 -1
- data/lib/rex/payloads/win32/kernel/stager.rb +21 -20
- data/lib/rex/peparsey.rb +3 -2
- data/lib/rex/peparsey/exceptions.rb +2 -1
- data/lib/rex/peparsey/pe.rb +3 -2
- data/lib/rex/peparsey/pe_memdump.rb +2 -1
- data/lib/rex/peparsey/pebase.rb +2 -1
- data/lib/rex/peparsey/section.rb +2 -1
- data/lib/rex/pescan.rb +3 -2
- data/lib/rex/pescan/analyze.rb +1 -0
- data/lib/rex/pescan/scanner.rb +1 -0
- data/lib/rex/pescan/search.rb +1 -0
- data/lib/rex/platforms.rb +2 -1
- data/lib/rex/platforms/windows.rb +2 -1
- data/lib/rex/poly.rb +2 -1
- data/lib/rex/poly/block.rb +16 -15
- data/lib/rex/poly/register.rb +2 -1
- data/lib/rex/poly/register/x86.rb +2 -1
- data/lib/rex/post.rb +2 -2
- data/lib/rex/post/dir.rb +2 -1
- data/lib/rex/post/file.rb +1 -0
- data/lib/rex/post/file_stat.rb +1 -0
- data/lib/rex/post/io.rb +2 -1
- data/lib/rex/post/meterpreter.rb +2 -1
- data/lib/rex/post/meterpreter/channel.rb +1 -0
- data/lib/rex/post/meterpreter/channel_container.rb +2 -1
- data/lib/rex/post/meterpreter/channels/pool.rb +1 -0
- data/lib/rex/post/meterpreter/channels/pools/file.rb +1 -0
- data/lib/rex/post/meterpreter/channels/pools/stream_pool.rb +3 -2
- data/lib/rex/post/meterpreter/channels/stream.rb +1 -0
- data/lib/rex/post/meterpreter/client.rb +23 -1
- data/lib/rex/post/meterpreter/client_core.rb +10 -5
- data/lib/rex/post/meterpreter/dependencies.rb +2 -1
- data/lib/rex/post/meterpreter/extension.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/espia/espia.rb +7 -6
- data/lib/rex/post/meterpreter/extensions/espia/tlv.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/incognito/incognito.rb +5 -4
- data/lib/rex/post/meterpreter/extensions/incognito/tlv.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/lanattacks/tlv.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/networkpug/networkpug.rb +7 -6
- data/lib/rex/post/meterpreter/extensions/networkpug/tlv.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/priv/fs.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/priv/passwd.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/priv/priv.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/priv/tlv.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/sniffer/sniffer.rb +28 -11
- data/lib/rex/post/meterpreter/extensions/sniffer/tlv.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/constants.rb +6 -5
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +3 -2
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/io.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/stdapi/net/config.rb +39 -5
- data/lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb +75 -18
- data/lib/rex/post/meterpreter/extensions/stdapi/net/route.rb +18 -6
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_server_channel.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun.rb.ts.rb +4 -1
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb.ut.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb.ut.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_advapi32.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_crypt32.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_iphlpapi.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_netapi32.rb +12 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ntdll.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_shell32.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_user32.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_wlanapi.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ws2_32.rb +7 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb.ut.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb.ut.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb.ut.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_wrapper.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_wrapper.rb.ut.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/mock_magic.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/multicall.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/platform_util.rb +23 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/platform_util.rb.ut.rb +29 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb +10 -5
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb +9 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/tlv.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb +106 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb.ut.rb +128 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/util.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb +27 -6
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb.ut.rb +21 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log_subsystem/event_record.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb +43 -4
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/image.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/io.rb +2 -1
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/memory.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/thread.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_key.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/thread.rb +1 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/tlv.rb +7 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +14 -13
- data/lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb +1 -0
- data/lib/rex/post/meterpreter/inbound_packet_handler.rb +2 -1
- data/lib/rex/post/meterpreter/object_aliases.rb +6 -5
- data/lib/rex/post/meterpreter/packet.rb +26 -6
- data/lib/rex/post/meterpreter/packet_dispatcher.rb +1 -0
- data/lib/rex/post/meterpreter/packet_parser.rb +1 -0
- data/lib/rex/post/meterpreter/packet_response_waiter.rb +1 -0
- data/lib/rex/post/meterpreter/ui/console.rb +1 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher.rb +1 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +103 -28
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/espia.rb +1 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/incognito.rb +1 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/networkpug.rb +1 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv.rb +3 -2
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/elevate.rb +12 -11
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/passwd.rb +2 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb +2 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/sniffer.rb +53 -36
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi.rb +3 -2
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +87 -44
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +80 -18
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +77 -48
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +72 -41
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb +24 -5
- data/lib/rex/post/meterpreter/ui/console/interactive_channel.rb +2 -1
- data/lib/rex/post/permission.rb +2 -1
- data/lib/rex/post/process.rb +2 -1
- data/lib/rex/post/thread.rb +2 -1
- data/lib/rex/post/ui.rb +2 -1
- data/lib/rex/proto.rb +1 -0
- data/lib/rex/proto.rb.ts.rb +2 -1
- data/lib/rex/proto/dcerpc.rb +2 -1
- data/lib/rex/proto/dcerpc.rb.ts.rb +2 -1
- data/lib/rex/proto/dcerpc/client.rb +1 -0
- data/lib/rex/proto/dcerpc/client.rb.ut.rb +1 -0
- data/lib/rex/proto/dcerpc/exceptions.rb +2 -1
- data/lib/rex/proto/dcerpc/handle.rb +1 -0
- data/lib/rex/proto/dcerpc/handle.rb.ut.rb +2 -1
- data/lib/rex/proto/dcerpc/ndr.rb +2 -1
- data/lib/rex/proto/dcerpc/ndr.rb.ut.rb +2 -1
- data/lib/rex/proto/dcerpc/packet.rb +52 -45
- data/lib/rex/proto/dcerpc/packet.rb.ut.rb +12 -11
- data/lib/rex/proto/dcerpc/response.rb +1 -0
- data/lib/rex/proto/dcerpc/response.rb.ut.rb +2 -1
- data/lib/rex/proto/dcerpc/uuid.rb +13 -12
- data/lib/rex/proto/dcerpc/uuid.rb.ut.rb +2 -1
- data/lib/rex/proto/dhcp.rb +2 -1
- data/lib/rex/proto/dhcp/constants.rb +2 -1
- data/lib/rex/proto/dhcp/server.rb +4 -3
- data/lib/rex/proto/drda.rb +1 -0
- data/lib/rex/proto/drda.rb.ts.rb +1 -0
- data/lib/rex/proto/drda/constants.rb +1 -0
- data/lib/rex/proto/drda/constants.rb.ut.rb +1 -0
- data/lib/rex/proto/drda/packet.rb +11 -10
- data/lib/rex/proto/drda/packet.rb.ut.rb +5 -4
- data/lib/rex/proto/drda/utils.rb +4 -3
- data/lib/rex/proto/drda/utils.rb.ut.rb +3 -2
- data/lib/rex/proto/http.rb +2 -1
- data/lib/rex/proto/http.rb.ts.rb +2 -1
- data/lib/rex/proto/http/client.rb +29 -5
- data/lib/rex/proto/http/client.rb.ut.rb +1 -0
- data/lib/rex/proto/http/handler.rb +2 -1
- data/lib/rex/proto/http/handler/erb.rb +5 -4
- data/lib/rex/proto/http/handler/erb.rb.ut.rb +2 -1
- data/lib/rex/proto/http/handler/proc.rb +1 -0
- data/lib/rex/proto/http/handler/proc.rb.ut.rb +2 -1
- data/lib/rex/proto/http/header.rb +3 -3
- data/lib/rex/proto/http/header.rb.ut.rb +2 -1
- data/lib/rex/proto/http/packet.rb +1 -0
- data/lib/rex/proto/http/packet.rb.ut.rb +15 -14
- data/lib/rex/proto/http/request.rb +23 -22
- data/lib/rex/proto/http/request.rb.ut.rb +2 -1
- data/lib/rex/proto/http/response.rb +6 -5
- data/lib/rex/proto/http/response.rb.ut.rb +7 -6
- data/lib/rex/proto/http/server.rb +1 -0
- data/lib/rex/proto/http/server.rb.ut.rb +6 -5
- data/lib/rex/proto/iax2.rb +1 -0
- data/lib/rex/proto/iax2/call.rb +48 -47
- data/lib/rex/proto/iax2/client.rb +23 -22
- data/lib/rex/proto/iax2/codecs.rb +1 -0
- data/lib/rex/proto/iax2/codecs/alaw.rb +1 -0
- data/lib/rex/proto/iax2/codecs/g711.rb +4 -3
- data/lib/rex/proto/iax2/codecs/mulaw.rb +1 -0
- data/lib/rex/proto/iax2/constants.rb +1 -0
- data/lib/rex/proto/natpmp.rb +11 -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 +1 -0
- data/lib/rex/proto/ntlm.rb.ut.rb +1 -0
- data/lib/rex/proto/ntlm/base.rb +38 -37
- data/lib/rex/proto/ntlm/constants.rb +1 -0
- data/lib/rex/proto/ntlm/crypt.rb +45 -44
- data/lib/rex/proto/ntlm/exceptions.rb +1 -0
- data/lib/rex/proto/ntlm/message.rb +30 -29
- data/lib/rex/proto/ntlm/utils.rb +116 -115
- data/lib/rex/proto/proxy/socks4a.rb +1 -0
- data/lib/rex/proto/rfb.rb +1 -0
- data/lib/rex/proto/rfb.rb.ut.rb +1 -0
- data/lib/rex/proto/rfb/cipher.rb +1 -0
- data/lib/rex/proto/rfb/client.rb +1 -0
- data/lib/rex/proto/rfb/constants.rb +1 -0
- data/lib/rex/proto/smb.rb +2 -1
- data/lib/rex/proto/smb.rb.ts.rb +2 -1
- data/lib/rex/proto/smb/client.rb +23 -22
- data/lib/rex/proto/smb/client.rb.ut.rb +1 -0
- data/lib/rex/proto/smb/constants.rb +1 -0
- data/lib/rex/proto/smb/constants.rb.ut.rb +2 -1
- data/lib/rex/proto/smb/crypt.rb +3 -2
- data/lib/rex/proto/smb/evasions.rb +1 -0
- data/lib/rex/proto/smb/exceptions.rb +6 -5
- data/lib/rex/proto/smb/simpleclient.rb +1 -0
- data/lib/rex/proto/smb/simpleclient.rb.ut.rb +1 -0
- data/lib/rex/proto/smb/utils.rb +1 -0
- data/lib/rex/proto/smb/utils.rb.ut.rb +2 -1
- data/lib/rex/proto/sunrpc.rb +1 -0
- data/lib/rex/proto/sunrpc/client.rb +1 -0
- data/lib/rex/proto/tftp.rb +3 -1
- data/lib/rex/proto/tftp/client.rb +344 -0
- data/lib/rex/proto/tftp/constants.rb +2 -1
- data/lib/rex/proto/tftp/server.rb +2 -1
- data/lib/rex/proto/tftp/server.rb.ut.rb +3 -2
- 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 +2 -1
- data/lib/rex/ropbuilder/rop.rb +3 -2
- data/lib/rex/script.rb +1 -0
- data/lib/rex/script/base.rb +1 -0
- data/lib/rex/script/meterpreter.rb +1 -0
- data/lib/rex/script/shell.rb +1 -0
- data/lib/rex/service.rb +2 -1
- data/lib/rex/service_manager.rb +6 -5
- data/lib/rex/service_manager.rb.ut.rb +2 -1
- data/lib/rex/services/local_relay.rb +1 -0
- data/lib/rex/socket.rb +72 -36
- data/lib/rex/socket.rb.ut.rb +1 -0
- data/lib/rex/socket/comm.rb +1 -0
- data/lib/rex/socket/comm/local.rb +60 -13
- data/lib/rex/socket/comm/local.rb.ut.rb +2 -1
- data/lib/rex/socket/ip.rb +1 -0
- data/lib/rex/socket/parameters.rb +15 -14
- data/lib/rex/socket/parameters.rb.ut.rb +2 -1
- data/lib/rex/socket/range_walker.rb +71 -26
- data/lib/rex/socket/range_walker.rb.ut.rb +2 -1
- data/lib/rex/socket/ssl_tcp.rb +1 -0
- data/lib/rex/socket/ssl_tcp.rb.ut.rb +2 -1
- data/lib/rex/socket/ssl_tcp_server.rb +1 -0
- data/lib/rex/socket/ssl_tcp_server.rb.ut.rb +1 -0
- data/lib/rex/socket/subnet_walker.rb +1 -0
- data/lib/rex/socket/subnet_walker.rb.ut.rb +2 -1
- data/lib/rex/socket/switch_board.rb +1 -0
- data/lib/rex/socket/switch_board.rb.ut.rb +2 -1
- data/lib/rex/socket/tcp.rb +4 -3
- data/lib/rex/socket/tcp.rb.ut.rb +2 -1
- data/lib/rex/socket/tcp_server.rb +1 -0
- data/lib/rex/socket/tcp_server.rb.ut.rb +2 -1
- data/lib/rex/socket/udp.rb +2 -1
- data/lib/rex/socket/udp.rb.ut.rb +2 -1
- data/lib/rex/struct2.rb +2 -1
- data/lib/rex/struct2/c_struct.rb +2 -1
- data/lib/rex/struct2/c_struct_template.rb +2 -1
- data/lib/rex/struct2/constant.rb +2 -1
- data/lib/rex/struct2/element.rb +2 -1
- data/lib/rex/struct2/generic.rb +1 -0
- data/lib/rex/struct2/restraint.rb +2 -1
- data/lib/rex/struct2/s_string.rb +1 -0
- data/lib/rex/struct2/s_struct.rb +1 -0
- data/lib/rex/sync.rb +2 -1
- data/lib/rex/sync/event.rb +1 -0
- data/lib/rex/sync/read_write_lock.rb +1 -0
- data/lib/rex/sync/ref.rb +2 -1
- data/lib/rex/sync/thread_safe.rb +2 -1
- data/lib/rex/test.rb +2 -1
- data/lib/rex/text.rb +136 -19
- data/lib/rex/text.rb.ut.rb +1 -0
- data/lib/rex/thread_factory.rb +5 -4
- data/lib/rex/time.rb +2 -1
- data/lib/rex/transformer.rb +1 -0
- data/lib/rex/transformer.rb.ut.rb +2 -1
- data/lib/rex/ui.rb +2 -1
- data/lib/rex/ui/interactive.rb +10 -9
- data/lib/rex/ui/output.rb +1 -0
- data/lib/rex/ui/output/none.rb +2 -1
- data/lib/rex/ui/progress_tracker.rb +2 -1
- data/lib/rex/ui/subscriber.rb +9 -8
- data/lib/rex/ui/text/color.rb +1 -0
- data/lib/rex/ui/text/color.rb.ut.rb +1 -0
- data/lib/rex/ui/text/dispatcher_shell.rb +63 -23
- data/lib/rex/ui/text/input.rb +1 -0
- data/lib/rex/ui/text/input/buffer.rb +7 -6
- data/lib/rex/ui/text/input/readline.rb +14 -13
- data/lib/rex/ui/text/input/socket.rb +1 -0
- data/lib/rex/ui/text/input/stdio.rb +2 -1
- data/lib/rex/ui/text/irb_shell.rb +1 -0
- data/lib/rex/ui/text/output.rb +1 -0
- data/lib/rex/ui/text/output/buffer.rb +1 -0
- data/lib/rex/ui/text/output/file.rb +1 -0
- data/lib/rex/ui/text/output/socket.rb +1 -0
- data/lib/rex/ui/text/output/stdio.rb +1 -0
- data/lib/rex/ui/text/output/tee.rb +1 -0
- data/lib/rex/ui/text/progress_tracker.rb +2 -1
- data/lib/rex/ui/text/progress_tracker.rb.ut.rb +2 -1
- data/lib/rex/ui/text/shell.rb +1 -0
- data/lib/rex/ui/text/table.rb +20 -14
- data/lib/rex/ui/text/table.rb.ut.rb +3 -2
- data/lib/rex/zip.rb +1 -0
- data/lib/rex/zip/archive.rb +2 -1
- data/lib/rex/zip/blocks.rb +3 -2
- data/lib/rex/zip/entry.rb +6 -7
- data/lib/rex/zip/jar.rb +4 -3
- data/lib/rex/zip/samples/comment.rb +1 -0
- data/lib/rex/zip/samples/mkwar.rb +1 -0
- data/lib/rex/zip/samples/mkzip.rb +1 -0
- data/lib/rex/zip/samples/recursive.rb +1 -0
- metadata +433 -435
data/lib/rex/script/base.rb
CHANGED
data/lib/rex/script/shell.rb
CHANGED
data/lib/rex/service.rb
CHANGED
data/lib/rex/service_manager.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
1
2
|
require 'singleton'
|
|
2
3
|
require 'rex'
|
|
3
4
|
require 'rex/service'
|
|
@@ -23,7 +24,7 @@ class ServiceManager < Hash
|
|
|
23
24
|
def self.start(klass, *args)
|
|
24
25
|
self.instance.start(klass, *args)
|
|
25
26
|
end
|
|
26
|
-
|
|
27
|
+
|
|
27
28
|
#
|
|
28
29
|
# Calls the instance method to stop a service.
|
|
29
30
|
#
|
|
@@ -75,7 +76,7 @@ class ServiceManager < Hash
|
|
|
75
76
|
# Re-aliases the instance.
|
|
76
77
|
inst.alias = als
|
|
77
78
|
|
|
78
|
-
# Fire up the engines. If an error occurs an exception will be
|
|
79
|
+
# Fire up the engines. If an error occurs an exception will be
|
|
79
80
|
# raised.
|
|
80
81
|
inst.start
|
|
81
82
|
|
|
@@ -138,16 +139,16 @@ class ServiceManager < Hash
|
|
|
138
139
|
end
|
|
139
140
|
list.each(&block)
|
|
140
141
|
end
|
|
141
|
-
|
|
142
|
+
|
|
142
143
|
protected
|
|
143
144
|
|
|
144
|
-
#
|
|
145
|
+
#
|
|
145
146
|
# Returns the alias for a given service instance.
|
|
146
147
|
#
|
|
147
148
|
def hardcore_alias(klass, *args)
|
|
148
149
|
"__#{klass.name}#{args}"
|
|
149
150
|
end
|
|
150
|
-
|
|
151
|
+
|
|
151
152
|
end
|
|
152
153
|
|
|
153
154
|
end
|
data/lib/rex/socket.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
1
2
|
require 'socket'
|
|
2
3
|
require 'thread'
|
|
3
4
|
require 'resolv'
|
|
@@ -73,16 +74,16 @@ module Socket
|
|
|
73
74
|
def self.create_ip(opts = {})
|
|
74
75
|
return create_param(Rex::Socket::Parameters.from_hash(opts.merge('Proto' => 'ip')))
|
|
75
76
|
end
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
|
|
78
|
+
|
|
78
79
|
#
|
|
79
80
|
# Common Regular Expressions
|
|
80
81
|
#
|
|
81
|
-
|
|
82
|
+
|
|
82
83
|
MATCH_IPV6 = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/
|
|
83
84
|
|
|
84
85
|
MATCH_IPV4 = /^\s*(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))\s*$/
|
|
85
|
-
|
|
86
|
+
|
|
86
87
|
MATCH_IPV4_PRIVATE = /^\s*(?:10\.|192\.168|172.(?:1[6-9]|2[0-9]|3[01])\.|169\.254)/
|
|
87
88
|
|
|
88
89
|
##
|
|
@@ -119,32 +120,26 @@ module Socket
|
|
|
119
120
|
# Determine whether this is an IPv4 address
|
|
120
121
|
#
|
|
121
122
|
def self.is_ipv4?(addr)
|
|
122
|
-
|
|
123
|
-
return true if addr =~ MATCH_IPV4
|
|
124
|
-
res = Rex::Socket.getaddress(addr)
|
|
125
|
-
res.match(/:/) ? false : true
|
|
123
|
+
( addr =~ MATCH_IPV4 ) ? true : false
|
|
126
124
|
end
|
|
127
125
|
|
|
128
126
|
#
|
|
129
127
|
# Determine whether this is an IPv6 address
|
|
130
128
|
#
|
|
131
129
|
def self.is_ipv6?(addr)
|
|
132
|
-
|
|
133
|
-
return false if addr =~ MATCH_IPV4
|
|
134
|
-
res = Rex::Socket.getaddress(addr)
|
|
135
|
-
res.match(/:/) ? true : false
|
|
130
|
+
( addr =~ MATCH_IPV6 ) ? true : false
|
|
136
131
|
end
|
|
137
132
|
|
|
138
133
|
#
|
|
139
|
-
# Checks to see if the supplied address is in "dotted" form
|
|
134
|
+
# Checks to see if the supplied address is in "dotted" form
|
|
140
135
|
#
|
|
141
136
|
def self.dotted_ip?(addr)
|
|
142
137
|
# Match IPv6
|
|
143
138
|
return true if (support_ipv6? and addr =~ MATCH_IPV6)
|
|
144
|
-
|
|
139
|
+
|
|
145
140
|
# Match IPv4
|
|
146
141
|
return true if (addr =~ MATCH_IPV4)
|
|
147
|
-
|
|
142
|
+
|
|
148
143
|
false
|
|
149
144
|
end
|
|
150
145
|
|
|
@@ -169,7 +164,7 @@ module Socket
|
|
|
169
164
|
#
|
|
170
165
|
def self.getaddress(addr, accept_ipv6 = true)
|
|
171
166
|
begin
|
|
172
|
-
if
|
|
167
|
+
if addr =~ MATCH_IPV4 or (accept_ipv6 and addr =~ MATCH_IPV6)
|
|
173
168
|
return addr
|
|
174
169
|
end
|
|
175
170
|
|
|
@@ -181,6 +176,19 @@ module Socket
|
|
|
181
176
|
ralias = res.shift
|
|
182
177
|
rtype = res.shift
|
|
183
178
|
|
|
179
|
+
# Rubinius has a bug where gethostbyname returns dotted quads instead of
|
|
180
|
+
# NBO, but that's what we want anyway, so just short-circuit here.
|
|
181
|
+
if res[0] =~ MATCH_IPV4 || res[0] =~ MATCH_IPV6
|
|
182
|
+
res.each { |r|
|
|
183
|
+
# if the caller doesn't mind ipv6, just return whatever we have
|
|
184
|
+
return r if accept_ipv6
|
|
185
|
+
# otherwise, take the first v4 address
|
|
186
|
+
return r if r =~ MATCH_IPV4
|
|
187
|
+
}
|
|
188
|
+
# didn't find one
|
|
189
|
+
return nil
|
|
190
|
+
end
|
|
191
|
+
|
|
184
192
|
# Reject IPv6 addresses if we don't accept them
|
|
185
193
|
if not accept_ipv6
|
|
186
194
|
res.reject!{|nbo| nbo.length != 4}
|
|
@@ -205,12 +213,12 @@ module Socket
|
|
|
205
213
|
#
|
|
206
214
|
def self.getaddresses(addr, accept_ipv6 = true)
|
|
207
215
|
begin
|
|
208
|
-
if
|
|
209
|
-
return addr
|
|
216
|
+
if addr =~ MATCH_IPV4 or (accept_ipv6 and addr =~ MATCH_IPV6)
|
|
217
|
+
return [addr]
|
|
210
218
|
end
|
|
211
219
|
|
|
212
220
|
res = ::Socket.gethostbyname(addr)
|
|
213
|
-
return
|
|
221
|
+
return [] if not res
|
|
214
222
|
|
|
215
223
|
# Shift the first three elements out
|
|
216
224
|
rname = res.shift
|
|
@@ -223,15 +231,15 @@ module Socket
|
|
|
223
231
|
end
|
|
224
232
|
|
|
225
233
|
# Make sure we have at least one name
|
|
226
|
-
return
|
|
234
|
+
return [] if res.length == 0
|
|
227
235
|
|
|
228
236
|
# Return an array of all addresses
|
|
229
237
|
res.map{ |addr| self.addr_ntoa(addr) }
|
|
230
238
|
rescue ::ArgumentError # Win32 bug
|
|
231
|
-
|
|
239
|
+
[]
|
|
232
240
|
end
|
|
233
241
|
end
|
|
234
|
-
|
|
242
|
+
|
|
235
243
|
#
|
|
236
244
|
# Wrapper for Socket.gethostbyname which takes into account whether or not
|
|
237
245
|
# an IP address is supplied. If it is, then reverse DNS resolution does
|
|
@@ -239,10 +247,12 @@ module Socket
|
|
|
239
247
|
# on Windows.
|
|
240
248
|
#
|
|
241
249
|
def self.gethostbyname(host)
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
250
|
+
if (is_ipv4?(host))
|
|
251
|
+
return [ host, [], 2, host.split('.').map{ |c| c.to_i }.pack("C4") ]
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
if is_ipv6?(host)
|
|
255
|
+
host, scope_id = host.split('%', 2)
|
|
246
256
|
end
|
|
247
257
|
|
|
248
258
|
::Socket.gethostbyname(host)
|
|
@@ -278,7 +288,7 @@ module Socket
|
|
|
278
288
|
# Resolves a host to raw network-byte order.
|
|
279
289
|
#
|
|
280
290
|
def self.resolv_nbo(host)
|
|
281
|
-
self.gethostbyname(Rex::Socket.getaddress(host))[3]
|
|
291
|
+
self.gethostbyname( Rex::Socket.getaddress(host, true) )[3]
|
|
282
292
|
end
|
|
283
293
|
|
|
284
294
|
#
|
|
@@ -301,7 +311,7 @@ module Socket
|
|
|
301
311
|
def self.resolv_nbo_i_list(host)
|
|
302
312
|
resolv_nbo_list(host).map{|addr| addr_ntoi(addr) }
|
|
303
313
|
end
|
|
304
|
-
|
|
314
|
+
|
|
305
315
|
#
|
|
306
316
|
# Converts an ASCII IP address to a CIDR mask. Returns
|
|
307
317
|
# nil if it's not convertable.
|
|
@@ -347,7 +357,7 @@ module Socket
|
|
|
347
357
|
def self.addr_atoi_list(addr)
|
|
348
358
|
resolv_nbo_i_list(addr)
|
|
349
359
|
end
|
|
350
|
-
|
|
360
|
+
|
|
351
361
|
#
|
|
352
362
|
# Converts an integer address into ascii
|
|
353
363
|
#
|
|
@@ -357,10 +367,10 @@ module Socket
|
|
|
357
367
|
|
|
358
368
|
# IPv4
|
|
359
369
|
if (addr < 0x100000000 and not v6)
|
|
360
|
-
nboa
|
|
370
|
+
addr_ntoa(nboa)
|
|
361
371
|
# IPv6
|
|
362
372
|
else
|
|
363
|
-
nboa
|
|
373
|
+
addr_ntoa(nboa)
|
|
364
374
|
end
|
|
365
375
|
end
|
|
366
376
|
|
|
@@ -375,7 +385,6 @@ module Socket
|
|
|
375
385
|
# Converts a network byte order address to ascii
|
|
376
386
|
#
|
|
377
387
|
def self.addr_ntoa(addr)
|
|
378
|
-
|
|
379
388
|
# IPv4
|
|
380
389
|
if (addr.length == 4)
|
|
381
390
|
return addr.unpack('C4').join('.')
|
|
@@ -383,12 +392,33 @@ module Socket
|
|
|
383
392
|
|
|
384
393
|
# IPv6
|
|
385
394
|
if (addr.length == 16)
|
|
386
|
-
return addr.unpack('n8').map{ |c| "
|
|
395
|
+
return compress_address(addr.unpack('n8').map{ |c| "%x" % c }.join(":"))
|
|
387
396
|
end
|
|
388
397
|
|
|
389
398
|
raise RuntimeError, "Invalid address format"
|
|
390
399
|
end
|
|
391
400
|
|
|
401
|
+
#
|
|
402
|
+
# Implement zero compression for IPv6 addresses.
|
|
403
|
+
# Uses the compression method from Marco Ceresa's IPAddress GEM
|
|
404
|
+
# https://github.com/bluemonk/ipaddress/blob/master/lib/ipaddress/ipv6.rb
|
|
405
|
+
#
|
|
406
|
+
def self.compress_address(addr)
|
|
407
|
+
return addr unless is_ipv6?(addr)
|
|
408
|
+
addr = addr.dup
|
|
409
|
+
while true
|
|
410
|
+
break if addr.sub!(/\A0:0:0:0:0:0:0:0\Z/, '::')
|
|
411
|
+
break if addr.sub!(/\b0:0:0:0:0:0:0\b/, ':')
|
|
412
|
+
break if addr.sub!(/\b0:0:0:0:0:0\b/, ':')
|
|
413
|
+
break if addr.sub!(/\b0:0:0:0:0\b/, ':')
|
|
414
|
+
break if addr.sub!(/\b0:0:0:0\b/, ':')
|
|
415
|
+
break if addr.sub!(/\b0:0:0\b/, ':')
|
|
416
|
+
break if addr.sub!(/\b0:0\b/, ':')
|
|
417
|
+
break
|
|
418
|
+
end
|
|
419
|
+
addr.sub(/:{3,}/, '::')
|
|
420
|
+
end
|
|
421
|
+
|
|
392
422
|
#
|
|
393
423
|
# Converts a network byte order address to an integer
|
|
394
424
|
#
|
|
@@ -477,10 +507,15 @@ module Socket
|
|
|
477
507
|
|
|
478
508
|
#
|
|
479
509
|
# Converts a bitmask (28) into a netmask (255.255.255.240)
|
|
480
|
-
# TODO: IPv6 (use is ambiguous right now)
|
|
481
510
|
#
|
|
482
|
-
def self.bit2netmask(bitmask)
|
|
483
|
-
|
|
511
|
+
def self.bit2netmask(bitmask, ipv6=false)
|
|
512
|
+
if bitmask > 32 or ipv6
|
|
513
|
+
i = ((~((2 ** (128 - bitmask)) - 1)) & (2**128-1))
|
|
514
|
+
n = Rex::Socket.addr_iton(i, true)
|
|
515
|
+
return Rex::Socket.addr_ntoa(n)
|
|
516
|
+
else
|
|
517
|
+
[ (~((2 ** (32 - bitmask)) - 1)) & 0xffffffff ].pack('N').unpack('CCCC').join('.')
|
|
518
|
+
end
|
|
484
519
|
end
|
|
485
520
|
|
|
486
521
|
|
|
@@ -656,6 +691,7 @@ module Socket
|
|
|
656
691
|
return [lsock, rsock]
|
|
657
692
|
end
|
|
658
693
|
|
|
694
|
+
|
|
659
695
|
##
|
|
660
696
|
#
|
|
661
697
|
# Class initialization
|
data/lib/rex/socket.rb.ut.rb
CHANGED
data/lib/rex/socket/comm.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
1
2
|
require 'singleton'
|
|
2
3
|
require 'rex/socket'
|
|
3
4
|
require 'rex/socket/tcp'
|
|
@@ -154,7 +155,7 @@ class Rex::Socket::Comm::Local
|
|
|
154
155
|
elsif (local == "\x7f\x00\x00\x01")
|
|
155
156
|
param.localhost = '::1'
|
|
156
157
|
else
|
|
157
|
-
param.localhost = '::ffff:' + Rex::Socket.getaddress(param.localhost)
|
|
158
|
+
param.localhost = '::ffff:' + Rex::Socket.getaddress(param.localhost, true)
|
|
158
159
|
end
|
|
159
160
|
end
|
|
160
161
|
|
|
@@ -164,7 +165,7 @@ class Rex::Socket::Comm::Local
|
|
|
164
165
|
elsif (peer == "\x7f\x00\x00\x01")
|
|
165
166
|
param.peerhost = '::1'
|
|
166
167
|
else
|
|
167
|
-
param.peerhost = '::ffff:' + Rex::Socket.getaddress(param.peerhost)
|
|
168
|
+
param.peerhost = '::ffff:' + Rex::Socket.getaddress(param.peerhost, true)
|
|
168
169
|
end
|
|
169
170
|
end
|
|
170
171
|
|
|
@@ -187,10 +188,9 @@ class Rex::Socket::Comm::Local
|
|
|
187
188
|
end
|
|
188
189
|
|
|
189
190
|
# Bind to a given local address and/or port if they are supplied
|
|
190
|
-
if
|
|
191
|
+
if param.localport or param.localhost
|
|
191
192
|
begin
|
|
192
193
|
sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_REUSEADDR, true)
|
|
193
|
-
|
|
194
194
|
sock.bind(Rex::Socket.to_sockaddr(param.localhost, param.localport))
|
|
195
195
|
|
|
196
196
|
rescue ::Errno::EADDRNOTAVAIL,::Errno::EADDRINUSE
|
|
@@ -223,16 +223,55 @@ class Rex::Socket::Comm::Local
|
|
|
223
223
|
|
|
224
224
|
# If we were supplied with host information
|
|
225
225
|
if (param.peerhost)
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
226
|
+
|
|
227
|
+
# A flag that indicates whether we need to try multiple scopes
|
|
228
|
+
retry_scopes = false
|
|
229
|
+
|
|
230
|
+
# Always retry with link-local IPv6 addresses
|
|
231
|
+
if Rex::Socket.is_ipv6?( param.peerhost ) and param.peerhost =~ /^fe80::/
|
|
232
|
+
retry_scopes = true
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Prepare a list of scope IDs to try when connecting to
|
|
236
|
+
# link-level addresses. Read from /proc if it is available,
|
|
237
|
+
# otherwise increment through the first 255 IDs.
|
|
238
|
+
@@ip6_lla_scopes ||= []
|
|
239
|
+
|
|
240
|
+
if @@ip6_lla_scopes.length == 0 and retry_scopes
|
|
241
|
+
|
|
242
|
+
# Linux specific interface lookup code
|
|
243
|
+
if ::File.exists?( "/proc/self/net/igmp6" )
|
|
244
|
+
::File.open("/proc/self/net/igmp6") do |fd|
|
|
245
|
+
fd.each_line do |line|
|
|
246
|
+
line = line.strip
|
|
247
|
+
tscope, tint, junk = line.split(/\s+/, 3)
|
|
248
|
+
next if not tint
|
|
249
|
+
|
|
250
|
+
# Specifying lo in any connect call results in the socket
|
|
251
|
+
# being unusable, even if the correct interface is set.
|
|
252
|
+
next if tint == "lo"
|
|
253
|
+
|
|
254
|
+
@@ip6_lla_scopes << tscope
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
else
|
|
258
|
+
# Other Unix-like platforms should support a raw scope ID
|
|
259
|
+
[*(1 .. 255)].map{ |x| @@ip6_lla_scopes << x.to_s }
|
|
235
260
|
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
ip6_scope_idx = 0
|
|
264
|
+
ip = param.peerhost
|
|
265
|
+
port = param.peerport
|
|
266
|
+
|
|
267
|
+
if param.proxies
|
|
268
|
+
chain = param.proxies.dup
|
|
269
|
+
chain.push(['host',param.peerhost,param.peerport])
|
|
270
|
+
ip = chain[0][1]
|
|
271
|
+
port = chain[0][2].to_i
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
begin
|
|
236
275
|
|
|
237
276
|
begin
|
|
238
277
|
Timeout.timeout(param.timeout) do
|
|
@@ -243,6 +282,14 @@ class Rex::Socket::Comm::Local
|
|
|
243
282
|
end
|
|
244
283
|
|
|
245
284
|
rescue ::Errno::EHOSTUNREACH,::Errno::ENETDOWN,::Errno::ENETUNREACH,::Errno::ENETRESET,::Errno::EHOSTDOWN,::Errno::EACCES,::Errno::EINVAL
|
|
285
|
+
|
|
286
|
+
# Rescue errors caused by a bad Scope ID for a link-local address
|
|
287
|
+
if retry_scopes and @@ip6_lla_scopes[ ip6_scope_idx ]
|
|
288
|
+
ip = param.peerhost + "%" + @@ip6_lla_scopes[ ip6_scope_idx ]
|
|
289
|
+
ip6_scope_idx += 1
|
|
290
|
+
retry
|
|
291
|
+
end
|
|
292
|
+
|
|
246
293
|
sock.close
|
|
247
294
|
raise Rex::HostUnreachable.new(param.peerhost, param.peerport), caller
|
|
248
295
|
|