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/README.markdown
CHANGED
|
@@ -4,7 +4,7 @@ An re-packaging of the Rex library included in the Metasploit Framework for use
|
|
|
4
4
|
made official by the Rapid7 development team. The upstream of this package is the rex subdirectory of https://github.com/rapid7/metasploit-framework
|
|
5
5
|
|
|
6
6
|
Currently based on:
|
|
7
|
-
SVN Revision:
|
|
7
|
+
SVN Revision: 15601
|
|
8
8
|
|
|
9
9
|
# Notes
|
|
10
10
|
|
data/lib/rex/arch.rb
CHANGED
data/lib/rex/arch/sparc.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
4
|
module Rex
|
|
4
5
|
module Arch
|
|
@@ -21,17 +22,17 @@ module Sparc
|
|
|
21
22
|
'l4' => 20, 'l5' => 21, 'l6' => 22, 'l7' => 23,
|
|
22
23
|
'i0' => 24, 'i1' => 25, 'i2' => 26, 'i3' => 27,
|
|
23
24
|
'i4' => 28, 'i5' => 29, 'i6' => 30, 'i7' => 31,
|
|
24
|
-
'sp' => 14, 'fp' => 30,
|
|
25
|
+
'sp' => 14, 'fp' => 30,
|
|
25
26
|
} # :nodoc:
|
|
26
27
|
|
|
27
28
|
#
|
|
28
29
|
# Encodes a SETHI instruction with the value 'constant' being put into 'dst' register
|
|
29
30
|
#
|
|
30
|
-
def self.sethi(constant, dst)
|
|
31
|
-
[
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
def self.sethi(constant, dst)
|
|
32
|
+
[
|
|
33
|
+
(RegisterNumber[dst] << 25) |
|
|
34
|
+
(4 << 22) |
|
|
35
|
+
(constant >> 10)
|
|
35
36
|
].pack('N')
|
|
36
37
|
end
|
|
37
38
|
|
|
@@ -39,18 +40,18 @@ module Sparc
|
|
|
39
40
|
# Encodes an OR instruction with the value 'constant' being OR'ed with the 'src' register into the 'dst' register
|
|
40
41
|
#
|
|
41
42
|
def self.ori(src, constant, dst)
|
|
42
|
-
[
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
[
|
|
44
|
+
(2 << 30) |
|
|
45
|
+
(RegisterNumber[dst] << 25) |
|
|
46
|
+
(2 << 19) |
|
|
47
|
+
(RegisterNumber[src] << 14) |
|
|
48
|
+
(1 << 13) |
|
|
49
|
+
(constant & 0x1fff)
|
|
49
50
|
].pack('N')
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
#
|
|
53
|
-
# Puts 'constant' into the 'dst' register using as few instructions as possible by checking the size of the value.
|
|
54
|
+
# Puts 'constant' into the 'dst' register using as few instructions as possible by checking the size of the value.
|
|
54
55
|
# XXX: signedness support
|
|
55
56
|
#
|
|
56
57
|
def self.set(constant, dst)
|
|
@@ -72,4 +73,4 @@ module Sparc
|
|
|
72
73
|
|
|
73
74
|
end
|
|
74
75
|
|
|
75
|
-
end end
|
|
76
|
+
end end
|
data/lib/rex/arch/sparc.rb.ut.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
4
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..'))
|
|
4
5
|
|
|
@@ -15,4 +16,4 @@ class Rex::Arch::Sparc::UnitTest < ::Test::Unit::TestCase
|
|
|
15
16
|
assert_equal("\x09\x00\x00\x08\x88\x11\x22\x22", Klass.set(0x2222, 'g4'))
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
end
|
|
19
|
+
end
|
data/lib/rex/arch/x86.rb
CHANGED
data/lib/rex/arch/x86.rb.ut.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
4
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..'))
|
|
4
5
|
|
|
@@ -90,4 +91,4 @@ class Rex::Arch::X86::UnitTest < ::Test::Unit::TestCase
|
|
|
90
91
|
assert_equal(s, Klass.searcher("\x04\x03\x02\x01"))
|
|
91
92
|
end
|
|
92
93
|
|
|
93
|
-
end
|
|
94
|
+
end
|
data/lib/rex/assembly/nasm.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
4
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..'))
|
|
4
5
|
|
|
@@ -19,4 +20,4 @@ class Rex::Assembly::Nasm::UnitTest < ::Test::Unit::TestCase
|
|
|
19
20
|
assert_equal("00000000 31C0 xor eax,eax\n", Klass.disassemble("\x31\xc0"))
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
end
|
|
23
|
+
end
|
data/lib/rex/compat.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
1
2
|
module Rex
|
|
2
3
|
|
|
3
4
|
###
|
|
@@ -224,12 +225,24 @@ end
|
|
|
224
225
|
# Verify the Console2 environment
|
|
225
226
|
#
|
|
226
227
|
def self.win32_console2_verify
|
|
228
|
+
return nil if ! (is_windows and @@loaded_win32api)
|
|
227
229
|
buf = "\x00" * 512
|
|
228
230
|
out = Win32API.new("kernel32", "GetStdHandle", ["L"], "L").call(STD_OUTPUT_HANDLE)
|
|
229
231
|
res = Win32API.new("kernel32","GetConsoleTitle", ["PL"], "L").call(buf, buf.length-1) rescue 0
|
|
230
232
|
( res > 0 and buf.index("Console2 command").nil? ) ? false : true
|
|
231
233
|
end
|
|
232
234
|
|
|
235
|
+
#
|
|
236
|
+
# Expand a 8.3 path to a full path
|
|
237
|
+
#
|
|
238
|
+
def self.win32_expand_path(path)
|
|
239
|
+
return nil if ! (is_windows and @@loaded_win32api)
|
|
240
|
+
glp = Win32API.new('kernel32', 'GetLongPathName', 'PPL', 'L')
|
|
241
|
+
buf = "\x00" * 260
|
|
242
|
+
len = glp.call(path, buf, buf.length)
|
|
243
|
+
buf[0, len]
|
|
244
|
+
end
|
|
245
|
+
|
|
233
246
|
#
|
|
234
247
|
# Platform independent socket pair
|
|
235
248
|
#
|
data/lib/rex/constants.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
1
2
|
#
|
|
2
3
|
# Log severities
|
|
3
4
|
#
|
|
@@ -13,7 +14,7 @@ LOG_RAW = 'raw'
|
|
|
13
14
|
#
|
|
14
15
|
##
|
|
15
16
|
|
|
16
|
-
#
|
|
17
|
+
#
|
|
17
18
|
# LEV_0 - Default
|
|
18
19
|
#
|
|
19
20
|
# This log level is the default log level if none is specified. It should be
|
|
@@ -29,7 +30,7 @@ LEV_0 = 0
|
|
|
29
30
|
#
|
|
30
31
|
# This log level should be used when extra information may be needed to
|
|
31
32
|
# understand the cause of an error or warning message or to get debugging
|
|
32
|
-
# information that might give clues as to why something is happening. This
|
|
33
|
+
# information that might give clues as to why something is happening. This
|
|
33
34
|
# log level should be used only when information may be useful to understanding
|
|
34
35
|
# the behavior of something at a basic level. This log level should not be
|
|
35
36
|
# used in an exhaustively verbose fashion.
|
|
@@ -50,10 +51,10 @@ LEV_2 = 2
|
|
|
50
51
|
#
|
|
51
52
|
# LEV_3 - Insanity
|
|
52
53
|
#
|
|
53
|
-
# This log level should contain very verbose information about the
|
|
54
|
+
# This log level should contain very verbose information about the
|
|
54
55
|
# behavior of the framework, such as detailed information about variable
|
|
55
56
|
# states at certain phases including, but not limited to, loop iterations,
|
|
56
|
-
# function calls, and so on. This log level will rarely be displayed,
|
|
57
|
+
# function calls, and so on. This log level will rarely be displayed,
|
|
57
58
|
# but when it is the information provided should make it easy to analyze
|
|
58
59
|
# any problem.
|
|
59
60
|
#
|
data/lib/rex/elfparsey.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
|
-
# $Id: elfparsey.rb
|
|
4
|
+
# $Id: elfparsey.rb 15548 2012-06-29 06:08:20Z rapid7 $
|
|
4
5
|
|
|
5
6
|
module Rex
|
|
6
7
|
module ElfParsey
|
|
@@ -8,4 +9,4 @@ module ElfParsey
|
|
|
8
9
|
end
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
require 'rex/elfparsey/elf'
|
|
12
|
+
require 'rex/elfparsey/elf'
|
data/lib/rex/elfparsey/elf.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
|
-
# $Id: elfbase.rb
|
|
4
|
+
# $Id: elfbase.rb 15548 2012-06-29 06:08:20Z rapid7 $
|
|
4
5
|
|
|
5
6
|
require 'rex/struct2'
|
|
6
7
|
|
|
@@ -127,23 +128,23 @@ class ElfBase
|
|
|
127
128
|
end
|
|
128
129
|
|
|
129
130
|
# The following methods are just pass-throughs for struct
|
|
130
|
-
|
|
131
|
+
|
|
131
132
|
# Access a value
|
|
132
133
|
def v
|
|
133
134
|
struct.v
|
|
134
|
-
|
|
135
|
+
|
|
135
136
|
end
|
|
136
|
-
|
|
137
|
-
# Access a value by array
|
|
137
|
+
|
|
138
|
+
# Access a value by array
|
|
138
139
|
def [](*args)
|
|
139
140
|
struct[*args]
|
|
140
141
|
end
|
|
141
|
-
|
|
142
|
+
|
|
142
143
|
# Obtain an array of all fields
|
|
143
144
|
def keys
|
|
144
145
|
struct.keys
|
|
145
146
|
end
|
|
146
|
-
|
|
147
|
+
|
|
147
148
|
def method_missing(meth, *args)
|
|
148
149
|
v[meth.to_s] || (raise NoMethodError.new, meth)
|
|
149
150
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
|
-
# $Id: exceptions.rb
|
|
4
|
+
# $Id: exceptions.rb 15548 2012-06-29 06:08:20Z rapid7 $
|
|
4
5
|
|
|
5
6
|
module Rex
|
|
6
7
|
module ElfParsey
|
|
@@ -24,4 +25,4 @@ class WtfError < ElfError
|
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
end
|
|
27
|
-
end
|
|
28
|
+
end
|
data/lib/rex/elfscan.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
|
-
# $Id: elfscan.rb
|
|
4
|
+
# $Id: elfscan.rb 15548 2012-06-29 06:08:20Z rapid7 $
|
|
4
5
|
|
|
5
6
|
module Rex
|
|
6
7
|
module ElfScan
|
|
@@ -9,4 +10,4 @@ end
|
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
require 'rex/elfscan/scanner'
|
|
12
|
-
require 'rex/elfscan/search'
|
|
13
|
+
require 'rex/elfscan/search'
|
data/lib/rex/elfscan/scanner.rb
CHANGED
data/lib/rex/elfscan/search.rb
CHANGED
data/lib/rex/encoder/alpha2.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
4
|
#
|
|
4
5
|
# ________________________________________________________________________________
|
|
@@ -28,4 +29,4 @@ require 'rex/encoder/alpha2/generic'
|
|
|
28
29
|
require 'rex/encoder/alpha2/alpha_mixed'
|
|
29
30
|
require 'rex/encoder/alpha2/alpha_upper'
|
|
30
31
|
require 'rex/encoder/alpha2/unicode_mixed'
|
|
31
|
-
require 'rex/encoder/alpha2/unicode_upper'
|
|
32
|
+
require 'rex/encoder/alpha2/unicode_upper'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
4
|
require 'rex/encoder/alpha2/generic'
|
|
4
5
|
|
|
@@ -19,7 +20,7 @@ class AlphaMixed < Generic
|
|
|
19
20
|
mod = 'I' * (16 - offset) + nop + '7QZ' # dec ecx,,, push ecx, pop edx
|
|
20
21
|
edxmod = 'J' * (17 - offset)
|
|
21
22
|
else
|
|
22
|
-
mod = 'A' * (offset - 16)
|
|
23
|
+
mod = 'A' * (offset - 16)
|
|
23
24
|
nop = 'C' * (16 - mod.length)
|
|
24
25
|
mod << nop + '7QZ'
|
|
25
26
|
edxmod = 'B' * (17 - (offset - 16))
|
|
@@ -47,7 +48,7 @@ class AlphaMixed < Generic
|
|
|
47
48
|
gen_decoder_prefix(reg, offset) +
|
|
48
49
|
"jA" + # push 0x41
|
|
49
50
|
"X" + # pop eax
|
|
50
|
-
"P" + # push eax
|
|
51
|
+
"P" + # push eax
|
|
51
52
|
"0A0" + # xor byte [ecx+30], al
|
|
52
53
|
"A" + # inc ecx <---
|
|
53
54
|
"kAAQ" + # imul eax, [ecx+42], 51 -> 10 |
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
4
|
require 'rex/encoder/alpha2/generic'
|
|
4
5
|
|
|
@@ -8,7 +9,7 @@ module Alpha2
|
|
|
8
9
|
|
|
9
10
|
class AlphaUpper < Generic
|
|
10
11
|
def self.default_accepted_chars ; ('B' .. 'Z').to_a + ('0' .. '9').to_a ; end
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
def self.gen_decoder_prefix(reg, offset)
|
|
13
14
|
if (offset > 20)
|
|
14
15
|
raise "Critical: Offset is greater than 20"
|
|
@@ -49,12 +50,12 @@ class AlphaUpper < Generic
|
|
|
49
50
|
gen_decoder_prefix(reg, offset) +
|
|
50
51
|
"V" + # push esi
|
|
51
52
|
"T" + # push esp
|
|
52
|
-
"X" + # pop eax
|
|
53
|
+
"X" + # pop eax
|
|
53
54
|
"30" + # xor esi, [eax]
|
|
54
55
|
"V" + # push esi
|
|
55
56
|
"X" + # pop eax
|
|
56
57
|
"4A" + # xor al, 41
|
|
57
|
-
"P" + # push eax
|
|
58
|
+
"P" + # push eax
|
|
58
59
|
"0A3" + # xor [ecx+33], al
|
|
59
60
|
"H" + # dec eax
|
|
60
61
|
"H" + # dec eax
|
|
@@ -63,7 +64,7 @@ class AlphaUpper < Generic
|
|
|
63
64
|
"A" + # inc ecx <---------------
|
|
64
65
|
"A" + # inc ecx |
|
|
65
66
|
"B" + # inc edx |
|
|
66
|
-
"TAAQ" + # imul eax, [ecx+41], 10 * |
|
|
67
|
+
"TAAQ" + # imul eax, [ecx+41], 10 * |
|
|
67
68
|
"2AB" + # xor al [ecx+42] |
|
|
68
69
|
"2BB" + # xor al, [edx+42] |
|
|
69
70
|
"0BB" + # xor [edx+42], al |
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: binary -*-
|
|
2
3
|
|
|
3
4
|
require 'rex/text'
|
|
4
5
|
|
|
@@ -8,6 +9,7 @@ module Alpha2
|
|
|
8
9
|
|
|
9
10
|
class Generic
|
|
10
11
|
|
|
12
|
+
# Note: 'A' is presumed to be accepted, but excluded from the accepted characters, because it serves as the terminator
|
|
11
13
|
def Generic.default_accepted_chars ; ('a' .. 'z').to_a + ('B' .. 'Z').to_a + ('0' .. '9').to_a ; end
|
|
12
14
|
|
|
13
15
|
def Generic.gen_decoder_prefix(reg, offset)
|
|
@@ -22,14 +24,6 @@ class Generic
|
|
|
22
24
|
return ''
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
def Generic.gen_base_set(ignored_max=0x0f)
|
|
26
|
-
# 0xf is max for XOR encodings - non-unicode
|
|
27
|
-
max = 0x0f
|
|
28
|
-
Rex::Text.shuffle_a(
|
|
29
|
-
[* ( (0..(max)).map { |i| i *= 0x10 } ) ]
|
|
30
|
-
)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
27
|
def Generic.gen_second(block, base)
|
|
34
28
|
# XOR encoder for ascii - unicode uses additive
|
|
35
29
|
(block^base)
|
|
@@ -37,58 +31,41 @@ class Generic
|
|
|
37
31
|
|
|
38
32
|
def Generic.encode_byte(block, badchars)
|
|
39
33
|
accepted_chars = default_accepted_chars.dup
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
34
|
+
|
|
35
|
+
badchars.each_char {|c| accepted_chars.delete(c) } if badchars
|
|
36
|
+
|
|
37
|
+
# No, not nipple.
|
|
38
|
+
nibble_chars = Array.new(0x10) {[]}
|
|
39
|
+
accepted_chars.each {|c| nibble_chars[c.unpack('C')[0] & 0x0F].push(c) }
|
|
40
|
+
|
|
41
|
+
poss_encodings = []
|
|
42
|
+
|
|
43
|
+
block_low_nibble = block & 0x0F
|
|
44
|
+
block_high_nibble = block >> 4
|
|
45
|
+
|
|
46
|
+
# Get list of chars suitable for expressing lower part of byte
|
|
47
|
+
first_chars = nibble_chars[block_low_nibble]
|
|
48
|
+
|
|
49
|
+
# Build a list of possible encodings
|
|
50
|
+
first_chars.each do |first_char|
|
|
51
|
+
first_high_nibble = first_char.unpack('C')[0] >> 4
|
|
52
|
+
|
|
53
|
+
# In the decoding process, the low nibble of the second char gets combined
|
|
54
|
+
# (either ADDed or XORed depending on the encoder) with the high nibble of the first char,
|
|
55
|
+
# and we want the high nibble of our input byte to result
|
|
56
|
+
second_low_nibble = gen_second(block_high_nibble, first_high_nibble) & 0x0F
|
|
57
|
+
|
|
58
|
+
# Find valid second chars for this first char and add each combination to our possible encodings
|
|
59
|
+
second_chars = nibble_chars[second_low_nibble]
|
|
60
|
+
second_chars.each {|second_char| poss_encodings.push(second_char + first_char) }
|
|
62
61
|
end
|
|
63
|
-
|
|
64
|
-
if
|
|
65
|
-
|
|
66
|
-
if not accepted_chars.include?([second].pack('C'))
|
|
67
|
-
msg << ": BadChar to #{second}"
|
|
68
|
-
elsif second < 1
|
|
69
|
-
msg << ": Negative"
|
|
70
|
-
end
|
|
71
|
-
raise RuntimeError, msg
|
|
62
|
+
|
|
63
|
+
if poss_encodings.empty?
|
|
64
|
+
raise RuntimeError, "No encoding of #{"0x%.2X" % block} possible with limited character set"
|
|
72
65
|
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
first = (randbase/0x10) + 0x40
|
|
77
|
-
elsif (randbase == 0x00) || (randbase == 0x10)
|
|
78
|
-
# first num must be 5
|
|
79
|
-
first = (randbase/0x10) + 0x50
|
|
80
|
-
else
|
|
81
|
-
# pick one at "random"
|
|
82
|
-
first = (randbase/0x10)
|
|
83
|
-
if (first % 2) > 0
|
|
84
|
-
first += 0x40
|
|
85
|
-
else
|
|
86
|
-
first += 0x50
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# now add our new bytes :)
|
|
91
|
-
[first.to_i, second].pack('CC')
|
|
66
|
+
|
|
67
|
+
# Return a random encoding
|
|
68
|
+
poss_encodings[rand(poss_encodings.length)]
|
|
92
69
|
end
|
|
93
70
|
|
|
94
71
|
def Generic.encode(buf, reg, offset, badchars = '')
|
|
@@ -97,10 +74,10 @@ class Generic
|
|
|
97
74
|
buf.each_byte {
|
|
98
75
|
|block|
|
|
99
76
|
|
|
100
|
-
encoded
|
|
77
|
+
encoded << encode_byte(block, badchars)
|
|
101
78
|
}
|
|
102
79
|
|
|
103
|
-
encoded
|
|
80
|
+
encoded << add_terminator()
|
|
104
81
|
|
|
105
82
|
return encoded
|
|
106
83
|
end
|