librex 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/Rakefile +1 -0
- metadata +3 -435
- data/lib/rex/LICENSE +0 -29
- data/lib/rex/arch.rb +0 -103
- data/lib/rex/arch/sparc.rb +0 -75
- data/lib/rex/arch/sparc.rb.ut.rb +0 -18
- data/lib/rex/arch/x86.rb +0 -513
- data/lib/rex/arch/x86.rb.ut.rb +0 -93
- data/lib/rex/assembly/nasm.rb +0 -104
- data/lib/rex/assembly/nasm.rb.ut.rb +0 -22
- data/lib/rex/codepage.map +0 -104
- data/lib/rex/compat.rb +0 -311
- data/lib/rex/constants.rb +0 -113
- data/lib/rex/elfparsey.rb +0 -11
- data/lib/rex/elfparsey/elf.rb +0 -123
- data/lib/rex/elfparsey/elfbase.rb +0 -258
- data/lib/rex/elfparsey/exceptions.rb +0 -27
- data/lib/rex/elfscan.rb +0 -12
- data/lib/rex/elfscan/scanner.rb +0 -207
- data/lib/rex/elfscan/search.rb +0 -46
- data/lib/rex/encoder/alpha2.rb +0 -31
- data/lib/rex/encoder/alpha2/alpha_mixed.rb +0 -68
- data/lib/rex/encoder/alpha2/alpha_upper.rb +0 -79
- data/lib/rex/encoder/alpha2/generic.rb +0 -114
- data/lib/rex/encoder/alpha2/unicode_mixed.rb +0 -117
- data/lib/rex/encoder/alpha2/unicode_upper.rb +0 -129
- data/lib/rex/encoder/ndr.rb +0 -89
- data/lib/rex/encoder/ndr.rb.ut.rb +0 -44
- data/lib/rex/encoder/nonalpha.rb +0 -61
- data/lib/rex/encoder/nonupper.rb +0 -64
- data/lib/rex/encoder/xdr.rb +0 -106
- data/lib/rex/encoder/xdr.rb.ut.rb +0 -29
- data/lib/rex/encoder/xor.rb +0 -69
- data/lib/rex/encoder/xor/dword.rb +0 -13
- data/lib/rex/encoder/xor/dword_additive.rb +0 -13
- data/lib/rex/encoders/xor_dword.rb +0 -35
- data/lib/rex/encoders/xor_dword_additive.rb +0 -53
- data/lib/rex/encoders/xor_dword_additive.rb.ut.rb +0 -12
- data/lib/rex/encoding/xor.rb +0 -20
- data/lib/rex/encoding/xor.rb.ts.rb +0 -14
- data/lib/rex/encoding/xor/byte.rb +0 -15
- data/lib/rex/encoding/xor/byte.rb.ut.rb +0 -21
- data/lib/rex/encoding/xor/dword.rb +0 -21
- data/lib/rex/encoding/xor/dword.rb.ut.rb +0 -15
- data/lib/rex/encoding/xor/dword_additive.rb +0 -92
- data/lib/rex/encoding/xor/dword_additive.rb.ut.rb +0 -15
- data/lib/rex/encoding/xor/exceptions.rb +0 -17
- data/lib/rex/encoding/xor/generic.rb +0 -146
- data/lib/rex/encoding/xor/generic.rb.ut.rb +0 -120
- data/lib/rex/encoding/xor/qword.rb +0 -15
- data/lib/rex/encoding/xor/word.rb +0 -21
- data/lib/rex/encoding/xor/word.rb.ut.rb +0 -13
- data/lib/rex/exceptions.rb +0 -275
- data/lib/rex/exceptions.rb.ut.rb +0 -44
- data/lib/rex/exploitation/cmdstager.rb +0 -9
- data/lib/rex/exploitation/cmdstager/base.rb +0 -175
- data/lib/rex/exploitation/cmdstager/debug_asm.rb +0 -142
- data/lib/rex/exploitation/cmdstager/debug_write.rb +0 -136
- data/lib/rex/exploitation/cmdstager/tftp.rb +0 -63
- data/lib/rex/exploitation/cmdstager/vbs.rb +0 -128
- data/lib/rex/exploitation/egghunter.rb +0 -277
- data/lib/rex/exploitation/egghunter.rb.ut.rb +0 -25
- data/lib/rex/exploitation/encryptjs.rb +0 -77
- data/lib/rex/exploitation/heaplib.js.b64 +0 -331
- data/lib/rex/exploitation/heaplib.rb +0 -94
- data/lib/rex/exploitation/javascriptosdetect.rb +0 -897
- data/lib/rex/exploitation/obfuscatejs.rb +0 -335
- data/lib/rex/exploitation/omelet.rb +0 -320
- data/lib/rex/exploitation/omelet.rb.ut.rb +0 -13
- data/lib/rex/exploitation/opcodedb.rb +0 -818
- data/lib/rex/exploitation/opcodedb.rb.ut.rb +0 -279
- data/lib/rex/exploitation/seh.rb +0 -92
- data/lib/rex/exploitation/seh.rb.ut.rb +0 -19
- data/lib/rex/file.rb +0 -112
- data/lib/rex/file.rb.ut.rb +0 -16
- data/lib/rex/image_source.rb +0 -12
- data/lib/rex/image_source/disk.rb +0 -60
- data/lib/rex/image_source/image_source.rb +0 -46
- data/lib/rex/image_source/memory.rb +0 -37
- data/lib/rex/io/bidirectional_pipe.rb +0 -157
- data/lib/rex/io/datagram_abstraction.rb +0 -35
- data/lib/rex/io/stream.rb +0 -319
- data/lib/rex/io/stream_abstraction.rb +0 -197
- data/lib/rex/io/stream_server.rb +0 -211
- data/lib/rex/job_container.rb +0 -187
- data/lib/rex/logging.rb +0 -4
- data/lib/rex/logging/log_dispatcher.rb +0 -179
- data/lib/rex/logging/log_sink.rb +0 -42
- data/lib/rex/logging/sinks/flatfile.rb +0 -55
- data/lib/rex/logging/sinks/stderr.rb +0 -43
- data/lib/rex/machparsey.rb +0 -9
- data/lib/rex/machparsey/exceptions.rb +0 -34
- data/lib/rex/machparsey/mach.rb +0 -209
- data/lib/rex/machparsey/machbase.rb +0 -408
- data/lib/rex/machscan.rb +0 -9
- data/lib/rex/machscan/scanner.rb +0 -217
- data/lib/rex/mime.rb +0 -9
- data/lib/rex/mime/header.rb +0 -77
- data/lib/rex/mime/message.rb +0 -144
- data/lib/rex/mime/part.rb +0 -20
- data/lib/rex/nop/opty2.rb +0 -108
- data/lib/rex/nop/opty2.rb.ut.rb +0 -23
- data/lib/rex/nop/opty2_tables.rb +0 -300
- data/lib/rex/ole.rb +0 -205
- data/lib/rex/ole/clsid.rb +0 -47
- data/lib/rex/ole/difat.rb +0 -141
- data/lib/rex/ole/directory.rb +0 -231
- data/lib/rex/ole/direntry.rb +0 -240
- data/lib/rex/ole/docs/dependencies.txt +0 -8
- data/lib/rex/ole/docs/references.txt +0 -1
- data/lib/rex/ole/fat.rb +0 -99
- data/lib/rex/ole/header.rb +0 -204
- data/lib/rex/ole/minifat.rb +0 -77
- data/lib/rex/ole/propset.rb +0 -144
- data/lib/rex/ole/samples/create_ole.rb +0 -27
- data/lib/rex/ole/samples/dir.rb +0 -35
- data/lib/rex/ole/samples/dump_stream.rb +0 -34
- data/lib/rex/ole/samples/ole_info.rb +0 -23
- data/lib/rex/ole/storage.rb +0 -395
- data/lib/rex/ole/stream.rb +0 -53
- data/lib/rex/ole/substorage.rb +0 -49
- data/lib/rex/ole/util.rb +0 -157
- data/lib/rex/parser/arguments.rb +0 -97
- data/lib/rex/parser/arguments.rb.ut.rb +0 -67
- data/lib/rex/parser/ini.rb +0 -185
- data/lib/rex/parser/ini.rb.ut.rb +0 -29
- data/lib/rex/parser/ip360_aspl_xml.rb +0 -102
- data/lib/rex/parser/ip360_xml.rb +0 -93
- data/lib/rex/parser/nessus_xml.rb +0 -118
- data/lib/rex/parser/netsparker_xml.rb +0 -94
- data/lib/rex/parser/nexpose_xml.rb +0 -131
- data/lib/rex/parser/nmap_xml.rb +0 -121
- data/lib/rex/parser/retina_xml.rb +0 -109
- data/lib/rex/payloads.rb +0 -1
- data/lib/rex/payloads/win32.rb +0 -2
- data/lib/rex/payloads/win32/common.rb +0 -26
- data/lib/rex/payloads/win32/kernel.rb +0 -53
- data/lib/rex/payloads/win32/kernel/common.rb +0 -54
- data/lib/rex/payloads/win32/kernel/migration.rb +0 -12
- data/lib/rex/payloads/win32/kernel/recovery.rb +0 -50
- data/lib/rex/payloads/win32/kernel/stager.rb +0 -194
- data/lib/rex/peparsey.rb +0 -12
- data/lib/rex/peparsey/exceptions.rb +0 -32
- data/lib/rex/peparsey/pe.rb +0 -212
- data/lib/rex/peparsey/pe_memdump.rb +0 -63
- data/lib/rex/peparsey/pebase.rb +0 -1680
- data/lib/rex/peparsey/section.rb +0 -136
- data/lib/rex/pescan.rb +0 -13
- data/lib/rex/pescan/analyze.rb +0 -309
- data/lib/rex/pescan/scanner.rb +0 -206
- data/lib/rex/pescan/search.rb +0 -56
- data/lib/rex/platforms.rb +0 -1
- data/lib/rex/platforms/windows.rb +0 -51
- data/lib/rex/poly.rb +0 -132
- data/lib/rex/poly/block.rb +0 -477
- data/lib/rex/poly/register.rb +0 -100
- data/lib/rex/poly/register/x86.rb +0 -40
- data/lib/rex/post.rb +0 -8
- data/lib/rex/post/dir.rb +0 -51
- data/lib/rex/post/file.rb +0 -172
- data/lib/rex/post/file_stat.rb +0 -220
- data/lib/rex/post/gen.pl +0 -13
- data/lib/rex/post/io.rb +0 -182
- data/lib/rex/post/meterpreter.rb +0 -4
- data/lib/rex/post/meterpreter/channel.rb +0 -445
- data/lib/rex/post/meterpreter/channel_container.rb +0 -54
- data/lib/rex/post/meterpreter/channels/pool.rb +0 -160
- data/lib/rex/post/meterpreter/channels/pools/file.rb +0 -62
- data/lib/rex/post/meterpreter/channels/pools/stream_pool.rb +0 -103
- data/lib/rex/post/meterpreter/channels/stream.rb +0 -87
- data/lib/rex/post/meterpreter/client.rb +0 -364
- data/lib/rex/post/meterpreter/client_core.rb +0 -274
- data/lib/rex/post/meterpreter/dependencies.rb +0 -3
- data/lib/rex/post/meterpreter/extension.rb +0 -32
- data/lib/rex/post/meterpreter/extensions/espia/espia.rb +0 -58
- data/lib/rex/post/meterpreter/extensions/espia/tlv.rb +0 -16
- data/lib/rex/post/meterpreter/extensions/incognito/incognito.rb +0 -94
- data/lib/rex/post/meterpreter/extensions/incognito/tlv.rb +0 -21
- data/lib/rex/post/meterpreter/extensions/networkpug/networkpug.rb +0 -57
- data/lib/rex/post/meterpreter/extensions/networkpug/tlv.rb +0 -15
- data/lib/rex/post/meterpreter/extensions/priv/fs.rb +0 -118
- data/lib/rex/post/meterpreter/extensions/priv/passwd.rb +0 -61
- data/lib/rex/post/meterpreter/extensions/priv/priv.rb +0 -111
- data/lib/rex/post/meterpreter/extensions/priv/tlv.rb +0 -28
- data/lib/rex/post/meterpreter/extensions/sniffer/sniffer.rb +0 -101
- data/lib/rex/post/meterpreter/extensions/sniffer/tlv.rb +0 -26
- data/lib/rex/post/meterpreter/extensions/stdapi/constants.rb +0 -333
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb +0 -282
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +0 -266
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb +0 -103
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/io.rb +0 -48
- data/lib/rex/post/meterpreter/extensions/stdapi/net/config.rb +0 -144
- data/lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb +0 -73
- data/lib/rex/post/meterpreter/extensions/stdapi/net/route.rb +0 -56
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb +0 -137
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb +0 -180
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_server_channel.rb +0 -167
- data/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb +0 -208
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun.rb.ts.rb +0 -6
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb +0 -38106
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb.ut.rb +0 -31
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb +0 -47
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/buffer_item.rb.ut.rb +0 -36
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_advapi32.rb +0 -1818
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_iphlpapi.rb +0 -96
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb +0 -3848
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_netapi32.rb +0 -26
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ntdll.rb +0 -153
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_shell32.rb +0 -21
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_user32.rb +0 -3169
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_ws2_32.rb +0 -599
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb +0 -318
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb +0 -100
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb.ut.rb +0 -42
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb +0 -148
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_helper.rb.ut.rb +0 -127
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/multicall.rb +0 -309
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb +0 -204
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/tlv.rb +0 -51
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/util.rb +0 -630
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb +0 -75
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb.ut.rb +0 -103
- data/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb +0 -149
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +0 -97
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log.rb +0 -192
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/event_log_subsystem/event_record.rb +0 -41
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb +0 -61
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb +0 -370
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/image.rb +0 -129
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/io.rb +0 -55
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/memory.rb +0 -336
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/thread.rb +0 -141
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry.rb +0 -279
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_key.rb +0 -193
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb +0 -102
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/thread.rb +0 -180
- data/lib/rex/post/meterpreter/extensions/stdapi/tlv.rb +0 -211
- data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +0 -227
- data/lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb +0 -63
- data/lib/rex/post/meterpreter/inbound_packet_handler.rb +0 -30
- data/lib/rex/post/meterpreter/object_aliases.rb +0 -83
- data/lib/rex/post/meterpreter/packet.rb +0 -688
- data/lib/rex/post/meterpreter/packet_dispatcher.rb +0 -431
- data/lib/rex/post/meterpreter/packet_parser.rb +0 -94
- data/lib/rex/post/meterpreter/packet_response_waiter.rb +0 -83
- data/lib/rex/post/meterpreter/ui/console.rb +0 -137
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher.rb +0 -62
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +0 -730
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/espia.rb +0 -108
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/incognito.rb +0 -241
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/networkpug.rb +0 -231
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv.rb +0 -61
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/elevate.rb +0 -98
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/passwd.rb +0 -51
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb +0 -132
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/sniffer.rb +0 -187
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi.rb +0 -65
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +0 -442
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +0 -298
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +0 -486
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +0 -315
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb +0 -157
- data/lib/rex/post/meterpreter/ui/console/interactive_channel.rb +0 -95
- data/lib/rex/post/permission.rb +0 -26
- data/lib/rex/post/process.rb +0 -57
- data/lib/rex/post/thread.rb +0 -57
- data/lib/rex/post/ui.rb +0 -52
- data/lib/rex/proto.rb +0 -13
- data/lib/rex/proto.rb.ts.rb +0 -8
- data/lib/rex/proto/dcerpc.rb +0 -6
- data/lib/rex/proto/dcerpc.rb.ts.rb +0 -9
- data/lib/rex/proto/dcerpc/client.rb +0 -361
- data/lib/rex/proto/dcerpc/client.rb.ut.rb +0 -491
- data/lib/rex/proto/dcerpc/exceptions.rb +0 -150
- data/lib/rex/proto/dcerpc/handle.rb +0 -47
- data/lib/rex/proto/dcerpc/handle.rb.ut.rb +0 -85
- data/lib/rex/proto/dcerpc/ndr.rb +0 -72
- data/lib/rex/proto/dcerpc/ndr.rb.ut.rb +0 -41
- data/lib/rex/proto/dcerpc/packet.rb +0 -253
- data/lib/rex/proto/dcerpc/packet.rb.ut.rb +0 -56
- data/lib/rex/proto/dcerpc/response.rb +0 -187
- data/lib/rex/proto/dcerpc/response.rb.ut.rb +0 -15
- data/lib/rex/proto/dcerpc/uuid.rb +0 -84
- data/lib/rex/proto/dcerpc/uuid.rb.ut.rb +0 -46
- data/lib/rex/proto/dhcp.rb +0 -7
- data/lib/rex/proto/dhcp/constants.rb +0 -33
- data/lib/rex/proto/dhcp/server.rb +0 -292
- data/lib/rex/proto/drda.rb +0 -5
- data/lib/rex/proto/drda.rb.ts.rb +0 -17
- data/lib/rex/proto/drda/constants.rb +0 -49
- data/lib/rex/proto/drda/constants.rb.ut.rb +0 -23
- data/lib/rex/proto/drda/packet.rb +0 -252
- data/lib/rex/proto/drda/packet.rb.ut.rb +0 -109
- data/lib/rex/proto/drda/utils.rb +0 -123
- data/lib/rex/proto/drda/utils.rb.ut.rb +0 -84
- data/lib/rex/proto/http.rb +0 -5
- data/lib/rex/proto/http.rb.ts.rb +0 -12
- data/lib/rex/proto/http/client.rb +0 -821
- data/lib/rex/proto/http/client.rb.ut.rb +0 -95
- data/lib/rex/proto/http/handler.rb +0 -46
- data/lib/rex/proto/http/handler/erb.rb +0 -128
- data/lib/rex/proto/http/handler/erb.rb.ut.rb +0 -21
- data/lib/rex/proto/http/handler/erb.rb.ut.rb.rhtml +0 -1
- data/lib/rex/proto/http/handler/proc.rb +0 -60
- data/lib/rex/proto/http/handler/proc.rb.ut.rb +0 -24
- data/lib/rex/proto/http/header.rb +0 -161
- data/lib/rex/proto/http/header.rb.ut.rb +0 -46
- data/lib/rex/proto/http/packet.rb +0 -407
- data/lib/rex/proto/http/packet.rb.ut.rb +0 -165
- data/lib/rex/proto/http/request.rb +0 -356
- data/lib/rex/proto/http/request.rb.ut.rb +0 -214
- data/lib/rex/proto/http/response.rb +0 -90
- data/lib/rex/proto/http/response.rb.ut.rb +0 -149
- data/lib/rex/proto/http/server.rb +0 -369
- data/lib/rex/proto/http/server.rb.ut.rb +0 -79
- data/lib/rex/proto/ntlm.rb +0 -7
- data/lib/rex/proto/ntlm.rb.ut.rb +0 -177
- data/lib/rex/proto/ntlm/base.rb +0 -326
- data/lib/rex/proto/ntlm/constants.rb +0 -74
- data/lib/rex/proto/ntlm/crypt.rb +0 -415
- data/lib/rex/proto/ntlm/exceptions.rb +0 -9
- data/lib/rex/proto/ntlm/message.rb +0 -533
- data/lib/rex/proto/ntlm/utils.rb +0 -763
- data/lib/rex/proto/proxy/socks4a.rb +0 -440
- data/lib/rex/proto/rfb.rb +0 -19
- data/lib/rex/proto/rfb.rb.ut.rb +0 -37
- data/lib/rex/proto/rfb/cipher.rb +0 -84
- data/lib/rex/proto/rfb/client.rb +0 -207
- data/lib/rex/proto/rfb/constants.rb +0 -52
- data/lib/rex/proto/smb.rb +0 -7
- data/lib/rex/proto/smb.rb.ts.rb +0 -8
- data/lib/rex/proto/smb/client.rb +0 -1952
- data/lib/rex/proto/smb/client.rb.ut.rb +0 -223
- data/lib/rex/proto/smb/constants.rb +0 -1047
- data/lib/rex/proto/smb/constants.rb.ut.rb +0 -18
- data/lib/rex/proto/smb/crypt.rb +0 -36
- data/lib/rex/proto/smb/evasions.rb +0 -66
- data/lib/rex/proto/smb/exceptions.rb +0 -858
- data/lib/rex/proto/smb/simpleclient.rb +0 -306
- data/lib/rex/proto/smb/simpleclient.rb.ut.rb +0 -128
- data/lib/rex/proto/smb/utils.rb +0 -103
- data/lib/rex/proto/smb/utils.rb.ut.rb +0 -20
- data/lib/rex/proto/sunrpc.rb +0 -1
- data/lib/rex/proto/sunrpc/client.rb +0 -195
- data/lib/rex/proto/tftp.rb +0 -12
- data/lib/rex/proto/tftp/constants.rb +0 -39
- data/lib/rex/proto/tftp/server.rb +0 -497
- data/lib/rex/proto/tftp/server.rb.ut.rb +0 -28
- data/lib/rex/script.rb +0 -42
- data/lib/rex/script/base.rb +0 -59
- data/lib/rex/script/meterpreter.rb +0 -15
- data/lib/rex/script/shell.rb +0 -9
- data/lib/rex/service.rb +0 -48
- data/lib/rex/service_manager.rb +0 -141
- data/lib/rex/service_manager.rb.ut.rb +0 -32
- data/lib/rex/services/local_relay.rb +0 -423
- data/lib/rex/socket.rb +0 -684
- data/lib/rex/socket.rb.ut.rb +0 -107
- data/lib/rex/socket/comm.rb +0 -119
- data/lib/rex/socket/comm/local.rb +0 -412
- data/lib/rex/socket/comm/local.rb.ut.rb +0 -75
- data/lib/rex/socket/ip.rb +0 -130
- data/lib/rex/socket/parameters.rb +0 -345
- data/lib/rex/socket/parameters.rb.ut.rb +0 -51
- data/lib/rex/socket/range_walker.rb +0 -346
- data/lib/rex/socket/range_walker.rb.ut.rb +0 -55
- data/lib/rex/socket/ssl_tcp.rb +0 -184
- data/lib/rex/socket/ssl_tcp.rb.ut.rb +0 -39
- data/lib/rex/socket/ssl_tcp_server.rb +0 -122
- data/lib/rex/socket/ssl_tcp_server.rb.ut.rb +0 -61
- data/lib/rex/socket/subnet_walker.rb +0 -75
- data/lib/rex/socket/subnet_walker.rb.ut.rb +0 -28
- data/lib/rex/socket/switch_board.rb +0 -278
- data/lib/rex/socket/switch_board.rb.ut.rb +0 -52
- data/lib/rex/socket/tcp.rb +0 -76
- data/lib/rex/socket/tcp.rb.ut.rb +0 -64
- data/lib/rex/socket/tcp_server.rb +0 -67
- data/lib/rex/socket/tcp_server.rb.ut.rb +0 -44
- data/lib/rex/socket/udp.rb +0 -164
- data/lib/rex/socket/udp.rb.ut.rb +0 -44
- data/lib/rex/struct2.rb +0 -5
- data/lib/rex/struct2/c_struct.rb +0 -181
- data/lib/rex/struct2/c_struct_template.rb +0 -39
- data/lib/rex/struct2/constant.rb +0 -26
- data/lib/rex/struct2/element.rb +0 -44
- data/lib/rex/struct2/generic.rb +0 -73
- data/lib/rex/struct2/restraint.rb +0 -54
- data/lib/rex/struct2/s_string.rb +0 -72
- data/lib/rex/struct2/s_struct.rb +0 -111
- data/lib/rex/sync.rb +0 -6
- data/lib/rex/sync/event.rb +0 -94
- data/lib/rex/sync/read_write_lock.rb +0 -176
- data/lib/rex/sync/ref.rb +0 -57
- data/lib/rex/sync/thread_safe.rb +0 -82
- data/lib/rex/test.rb +0 -35
- data/lib/rex/text.rb +0 -1149
- data/lib/rex/text.rb.ut.rb +0 -190
- data/lib/rex/thread_factory.rb +0 -42
- data/lib/rex/time.rb +0 -65
- data/lib/rex/transformer.rb +0 -115
- data/lib/rex/transformer.rb.ut.rb +0 -38
- data/lib/rex/ui.rb +0 -21
- data/lib/rex/ui/interactive.rb +0 -254
- data/lib/rex/ui/output.rb +0 -78
- data/lib/rex/ui/output/none.rb +0 -18
- data/lib/rex/ui/progress_tracker.rb +0 -96
- data/lib/rex/ui/subscriber.rb +0 -149
- data/lib/rex/ui/text/color.rb +0 -97
- data/lib/rex/ui/text/color.rb.ut.rb +0 -18
- data/lib/rex/ui/text/dispatcher_shell.rb +0 -467
- data/lib/rex/ui/text/input.rb +0 -117
- data/lib/rex/ui/text/input/buffer.rb +0 -75
- data/lib/rex/ui/text/input/readline.rb +0 -129
- data/lib/rex/ui/text/input/socket.rb +0 -95
- data/lib/rex/ui/text/input/stdio.rb +0 -45
- data/lib/rex/ui/text/irb_shell.rb +0 -57
- data/lib/rex/ui/text/output.rb +0 -80
- data/lib/rex/ui/text/output/buffer.rb +0 -61
- data/lib/rex/ui/text/output/file.rb +0 -43
- data/lib/rex/ui/text/output/socket.rb +0 -43
- data/lib/rex/ui/text/output/stdio.rb +0 -40
- data/lib/rex/ui/text/progress_tracker.rb +0 -56
- data/lib/rex/ui/text/progress_tracker.rb.ut.rb +0 -34
- data/lib/rex/ui/text/shell.rb +0 -328
- data/lib/rex/ui/text/table.rb +0 -279
- data/lib/rex/ui/text/table.rb.ut.rb +0 -55
- data/lib/rex/zip.rb +0 -93
- data/lib/rex/zip/archive.rb +0 -184
- data/lib/rex/zip/blocks.rb +0 -182
- data/lib/rex/zip/entry.rb +0 -104
- data/lib/rex/zip/samples/comment.rb +0 -32
- data/lib/rex/zip/samples/mkwar.rb +0 -138
- data/lib/rex/zip/samples/mkzip.rb +0 -19
- data/lib/rex/zip/samples/recursive.rb +0 -58
data/lib/rex/socket.rb.ut.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..'))
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
|
-
require 'rex/socket'
|
7
|
-
require 'rex/socket/tcp'
|
8
|
-
|
9
|
-
class Rex::Socket::UnitTest < Test::Unit::TestCase
|
10
|
-
|
11
|
-
def test_ip
|
12
|
-
assert_equal(true,Rex::Socket.dotted_ip?('0.0.0.0'), 'valid IP min')
|
13
|
-
assert_equal(true,Rex::Socket.dotted_ip?('255.255.255.255'), 'valid IP max')
|
14
|
-
assert_equal(false,Rex::Socket.dotted_ip?('0.0.0.0.0'), 'too many sections')
|
15
|
-
assert_equal(false,Rex::Socket.dotted_ip?('0..0.0.0'), 'too many dots')
|
16
|
-
assert_equal(false,Rex::Socket.dotted_ip?('00.0.0'), 'not enough dots')
|
17
|
-
assert_equal(false,Rex::Socket.dotted_ip?('256.256.256.256'), 'numbers too big')
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_create
|
21
|
-
port = 64442
|
22
|
-
serv = TCPServer.new('127.0.0.1', port)
|
23
|
-
|
24
|
-
sock = nil
|
25
|
-
assert_nothing_raised {
|
26
|
-
sock = Rex::Socket.create(
|
27
|
-
'PeerHost' => '127.0.0.1',
|
28
|
-
'PeerPort' => port,
|
29
|
-
'Proto' => 'tcp')
|
30
|
-
}
|
31
|
-
assert_kind_of(Rex::Socket::Tcp, sock, "socket factory creation")
|
32
|
-
|
33
|
-
sock = nil
|
34
|
-
assert_nothing_raised {
|
35
|
-
sock = Rex::Socket.create_tcp(
|
36
|
-
'PeerHost' => '127.0.0.1',
|
37
|
-
'PeerPort' => port)
|
38
|
-
}
|
39
|
-
assert_kind_of(Rex::Socket::Tcp, sock, "tcp socket factory creation")
|
40
|
-
|
41
|
-
serv.close
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_to_sockaddr
|
45
|
-
assert_equal(([2] + [0]*14).pack("sC*"), Rex::Socket.to_sockaddr(0, 0), "null sockaddr")
|
46
|
-
=begin
|
47
|
-
# This is platform dependent, pain to test
|
48
|
-
if (Rex::Socket.support_ipv6?)
|
49
|
-
# Use the constant for AF_INET6 since it is different per platform
|
50
|
-
# (10 on linux and 28 on BSD)
|
51
|
-
inaddr_any_sockaddr = ([::Socket::AF_INET6, 22] + [0]*24).pack('sSC*')
|
52
|
-
else
|
53
|
-
inaddr_any_sockaddr = ([2, 22] + [0]*12).pack('snC*')
|
54
|
-
end
|
55
|
-
=end
|
56
|
-
assert_equal(([2, 0x16, 1, 2, 3, 4] + [0]*8).pack('snC*'), Rex::Socket.to_sockaddr("1.2.3.4", 22), "1.2.3.4 addr, port 22 sockaddr")
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_from_sockaddr
|
60
|
-
# 1.9.1 raises ArgumentError if we don't have an af == AF_INET or AF_INET6
|
61
|
-
af, host, port = Rex::Socket.from_sockaddr(([2, 0] + [0]*12).pack('snC*'))
|
62
|
-
assert_equal(2, af, "af = 2")
|
63
|
-
assert_equal('0.0.0.0', host, "zero host")
|
64
|
-
assert_equal(0, port, "zero port")
|
65
|
-
|
66
|
-
af, host, port = Rex::Socket.from_sockaddr(([2, 22]+[0]*12).pack('snC*'))
|
67
|
-
assert_equal(2, af, "af = 2")
|
68
|
-
assert_equal(22, port, "port = 22")
|
69
|
-
assert_equal('0.0.0.0', host, "zero host")
|
70
|
-
|
71
|
-
af, host, port = Rex::Socket.from_sockaddr(([2, 22, 1, 2, 3, 4] + [0]*8).pack('snC*') )
|
72
|
-
assert_equal(2, af, "af = 2")
|
73
|
-
assert_equal('1.2.3.4', host, "host = '1.2.3.4'")
|
74
|
-
assert_equal(22, port, "port = 22")
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_resolv_nbo
|
78
|
-
assert_equal("\x04\x03\x02\x01", Rex::Socket.resolv_nbo("4.3.2.1"))
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_net2bitmask
|
82
|
-
assert_equal(32, Rex::Socket.net2bitmask('255.255.255.255'))
|
83
|
-
assert_equal(28, Rex::Socket.net2bitmask('255.255.255.240'))
|
84
|
-
assert_equal(24, Rex::Socket.net2bitmask('255.255.255.0'))
|
85
|
-
assert_equal(16, Rex::Socket.net2bitmask('255.255.0.0'))
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_bit2netmask
|
89
|
-
assert_equal("255.255.255.255", Rex::Socket.bit2netmask(32))
|
90
|
-
assert_equal("255.255.255.254", Rex::Socket.bit2netmask(31))
|
91
|
-
assert_equal("255.255.255.240", Rex::Socket.bit2netmask(28))
|
92
|
-
assert_equal("255.255.255.0", Rex::Socket.bit2netmask(24))
|
93
|
-
assert_equal("255.255.0.0", Rex::Socket.bit2netmask(16))
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_is_internal
|
97
|
-
assert( ! Rex::Socket.is_internal?("1.2.3.4"))
|
98
|
-
assert( ! Rex::Socket.is_internal?("172.15.3.4"))
|
99
|
-
assert( ! Rex::Socket.is_internal?("172.32.3.4"))
|
100
|
-
assert(Rex::Socket.is_internal?("10.2.3.4"))
|
101
|
-
assert(Rex::Socket.is_internal?("192.168.3.4"))
|
102
|
-
16.upto(31) do |octet|
|
103
|
-
assert(Rex::Socket.is_internal?("172.#{octet}.3.4"))
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
data/lib/rex/socket/comm.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'rex/socket'
|
2
|
-
|
3
|
-
module Rex
|
4
|
-
module Socket
|
5
|
-
|
6
|
-
###
|
7
|
-
#
|
8
|
-
# This mixin provides the basic interface that a derived class must implement
|
9
|
-
# in order to be a compatible comm class. The base comm class also supports
|
10
|
-
# registering event handlers that can be notified when sockets are being
|
11
|
-
# created and have been created. This allows code to extend sockets on
|
12
|
-
# creation from the single point that they are created.
|
13
|
-
#
|
14
|
-
###
|
15
|
-
module Comm
|
16
|
-
|
17
|
-
###
|
18
|
-
#
|
19
|
-
# This mixin provides stubs for event notification handlers that can be
|
20
|
-
# registered with a Comm factory to be called when various events occur,
|
21
|
-
# such as socket instantiation.
|
22
|
-
#
|
23
|
-
###
|
24
|
-
module Events
|
25
|
-
|
26
|
-
#
|
27
|
-
# This callback is notified when a socket is being created and is passed
|
28
|
-
# the parameters that will be used to create it.
|
29
|
-
#
|
30
|
-
def on_before_socket_create(comm, param)
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# This callback is notified when a new socket is created and the
|
35
|
-
# parameters that were used to create it. This provides the callback
|
36
|
-
# with a chance to extend or otherwise modify the socket before it's
|
37
|
-
# passed on to the actual requestor.
|
38
|
-
#
|
39
|
-
def on_socket_created(comm, sock, param)
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# Creates a compatible socket based on the supplied uniform parameters.
|
46
|
-
#
|
47
|
-
def self.create(param)
|
48
|
-
raise NotImplementedError
|
49
|
-
end
|
50
|
-
|
51
|
-
#
|
52
|
-
# Indicates whether or not this comm can be chained with other chainable
|
53
|
-
# comms. This is particularly important for things like Proxy Comms that
|
54
|
-
# can be proxied through one another. The semantics of this are currently
|
55
|
-
# undefined and will probably need some more thought.
|
56
|
-
#
|
57
|
-
def chainable?
|
58
|
-
false
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
# Registers an event handler that implements the Rex::Socket::Comm::Event
|
63
|
-
# interface in at least some fashion. Event handlers are notified when
|
64
|
-
# sockets are created through the Comm instance that they register against.
|
65
|
-
#
|
66
|
-
def register_event_handler(handler)
|
67
|
-
if (handlers == nil)
|
68
|
-
self.handlers = []
|
69
|
-
end
|
70
|
-
|
71
|
-
self.handlers << handler
|
72
|
-
end
|
73
|
-
|
74
|
-
#
|
75
|
-
# Deregisters a previously registered event handler.
|
76
|
-
#
|
77
|
-
def deregister_event_handler(handler)
|
78
|
-
if (handlers)
|
79
|
-
handlers.delete(handler)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
#
|
84
|
-
# Enumerates each registered event handler so that they can be notified of
|
85
|
-
# an event.
|
86
|
-
#
|
87
|
-
def each_event_handler(&block)
|
88
|
-
if (handlers)
|
89
|
-
handlers.each(&block)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
#
|
94
|
-
# Notifies handlers of the before socket create event.
|
95
|
-
#
|
96
|
-
def notify_before_socket_create(comm, param)
|
97
|
-
each_event_handler() { |handler|
|
98
|
-
handler.on_before_socket_create(comm, param)
|
99
|
-
}
|
100
|
-
end
|
101
|
-
|
102
|
-
#
|
103
|
-
# Notifies handlers of the socket created event.
|
104
|
-
#
|
105
|
-
def notify_socket_created(comm, sock, param)
|
106
|
-
each_event_handler() { |handler|
|
107
|
-
handler.on_socket_created(comm, sock, param)
|
108
|
-
}
|
109
|
-
end
|
110
|
-
|
111
|
-
protected
|
112
|
-
|
113
|
-
attr_accessor :handlers # :nodoc:
|
114
|
-
attr_accessor :handlers_rwlock # :nodoc:
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
end
|
@@ -1,412 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'rex/socket'
|
3
|
-
require 'rex/socket/tcp'
|
4
|
-
require 'rex/socket/ssl_tcp'
|
5
|
-
require 'rex/socket/ssl_tcp_server'
|
6
|
-
require 'rex/socket/udp'
|
7
|
-
require 'rex/socket/ip'
|
8
|
-
require 'timeout'
|
9
|
-
|
10
|
-
###
|
11
|
-
#
|
12
|
-
# Local communication class factory.
|
13
|
-
#
|
14
|
-
###
|
15
|
-
class Rex::Socket::Comm::Local
|
16
|
-
|
17
|
-
include Singleton
|
18
|
-
include Rex::Socket::Comm
|
19
|
-
|
20
|
-
#
|
21
|
-
# Creates an instance of a socket using the supplied parameters.
|
22
|
-
#
|
23
|
-
def self.create(param)
|
24
|
-
|
25
|
-
# Work around jRuby socket implementation issues
|
26
|
-
if(RUBY_PLATFORM == 'java')
|
27
|
-
return self.create_jruby(param)
|
28
|
-
end
|
29
|
-
|
30
|
-
case param.proto
|
31
|
-
when 'tcp'
|
32
|
-
return create_by_type(param, ::Socket::SOCK_STREAM, ::Socket::IPPROTO_TCP)
|
33
|
-
when 'udp'
|
34
|
-
return create_by_type(param, ::Socket::SOCK_DGRAM, ::Socket::IPPROTO_UDP)
|
35
|
-
when 'ip'
|
36
|
-
return create_ip(param)
|
37
|
-
else
|
38
|
-
raise Rex::UnsupportedProtocol.new(param.proto), caller
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
#
|
43
|
-
# Creates an instance of a socket using the supplied parameters.
|
44
|
-
# Use various hacks to make this work with jRuby
|
45
|
-
#
|
46
|
-
def self.create_jruby(param)
|
47
|
-
sock = nil
|
48
|
-
|
49
|
-
# Notify handlers of the before socket create event.
|
50
|
-
self.instance.notify_before_socket_create(self, param)
|
51
|
-
|
52
|
-
case param.proto
|
53
|
-
when 'tcp'
|
54
|
-
if (param.server?)
|
55
|
-
sock = TCPServer.new(param.localport, param.localhost)
|
56
|
-
klass = Rex::Socket::TcpServer
|
57
|
-
if (param.ssl)
|
58
|
-
klass = Rex::Socket::SslTcpServer
|
59
|
-
end
|
60
|
-
sock.extend(klass)
|
61
|
-
|
62
|
-
else
|
63
|
-
sock = TCPSocket.new(param.peerhost, param.peerport)
|
64
|
-
klass = Rex::Socket::Tcp
|
65
|
-
if (param.ssl)
|
66
|
-
klass = Rex::Socket::SslTcp
|
67
|
-
end
|
68
|
-
sock.extend(klass)
|
69
|
-
end
|
70
|
-
when 'udp'
|
71
|
-
if (param.server?)
|
72
|
-
sock = UDPServer.new(param.localport, param.localhost)
|
73
|
-
klass = Rex::Socket::UdpServer
|
74
|
-
sock.extend(klass)
|
75
|
-
else
|
76
|
-
sock = UDPSocket.new(param.peerhost, param.peerport)
|
77
|
-
klass = Rex::Socket::Udp
|
78
|
-
sock.extend(klass)
|
79
|
-
end
|
80
|
-
else
|
81
|
-
raise Rex::UnsupportedProtocol.new(param.proto), caller
|
82
|
-
end
|
83
|
-
|
84
|
-
sock.initsock(param)
|
85
|
-
self.instance.notify_socket_created(self, sock, param)
|
86
|
-
return sock
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
#
|
91
|
-
# Creates a raw IP socket using the supplied Parameter instance.
|
92
|
-
# Special-cased because of how different it is from UDP/TCP
|
93
|
-
#
|
94
|
-
def self.create_ip(param)
|
95
|
-
self.instance.notify_before_socket_create(self, param)
|
96
|
-
|
97
|
-
sock = ::Socket.open(::Socket::PF_INET, ::Socket::SOCK_RAW, ::Socket::IPPROTO_RAW)
|
98
|
-
sock.setsockopt(::Socket::IPPROTO_IP, ::Socket::IP_HDRINCL, 1)
|
99
|
-
|
100
|
-
# Configure broadcast support
|
101
|
-
sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_BROADCAST, true)
|
102
|
-
|
103
|
-
if (param.bare? == false)
|
104
|
-
sock.extend(::Rex::Socket::Ip)
|
105
|
-
sock.initsock(param)
|
106
|
-
end
|
107
|
-
|
108
|
-
self.instance.notify_socket_created(self, sock, param)
|
109
|
-
|
110
|
-
sock
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
#
|
115
|
-
# Creates a socket using the supplied Parameter instance.
|
116
|
-
#
|
117
|
-
def self.create_by_type(param, type, proto = 0)
|
118
|
-
|
119
|
-
# Whether to use IPv6 addressing
|
120
|
-
usev6 = false
|
121
|
-
|
122
|
-
# Detect IPv6 addresses and enable IPv6 accordingly
|
123
|
-
if ( Rex::Socket.support_ipv6?())
|
124
|
-
|
125
|
-
# Allow the caller to force IPv6
|
126
|
-
if (param.v6)
|
127
|
-
usev6 = true
|
128
|
-
end
|
129
|
-
|
130
|
-
# Force IPv6 mode for non-connected UDP sockets
|
131
|
-
if (type == ::Socket::SOCK_DGRAM and not param.peerhost)
|
132
|
-
# FreeBSD allows IPv6 socket creation, but throws an error on sendto()
|
133
|
-
|
134
|
-
if (not Rex::Compat.is_freebsd())
|
135
|
-
usev6 = true
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
local = Rex::Socket.resolv_nbo(param.localhost) if param.localhost
|
140
|
-
peer = Rex::Socket.resolv_nbo(param.peerhost) if param.peerhost
|
141
|
-
|
142
|
-
if (local and local.length == 16)
|
143
|
-
usev6 = true
|
144
|
-
end
|
145
|
-
|
146
|
-
if (peer and peer.length == 16)
|
147
|
-
usev6 = true
|
148
|
-
end
|
149
|
-
|
150
|
-
if (usev6)
|
151
|
-
if (local and local.length == 4)
|
152
|
-
if (local == "\x00\x00\x00\x00")
|
153
|
-
param.localhost = '::'
|
154
|
-
elsif (local == "\x7f\x00\x00\x01")
|
155
|
-
param.localhost = '::1'
|
156
|
-
else
|
157
|
-
param.localhost = '::ffff:' + Rex::Socket.getaddress(param.localhost)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
if (peer and peer.length == 4)
|
162
|
-
if (peer == "\x00\x00\x00\x00")
|
163
|
-
param.peerhost = '::'
|
164
|
-
elsif (peer == "\x7f\x00\x00\x01")
|
165
|
-
param.peerhost = '::1'
|
166
|
-
else
|
167
|
-
param.peerhost = '::ffff:' + Rex::Socket.getaddress(param.peerhost)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
param.v6 = true
|
172
|
-
end
|
173
|
-
else
|
174
|
-
# No IPv6 support
|
175
|
-
param.v6 = false
|
176
|
-
end
|
177
|
-
|
178
|
-
# Notify handlers of the before socket create event.
|
179
|
-
self.instance.notify_before_socket_create(self, param)
|
180
|
-
|
181
|
-
# Create the socket
|
182
|
-
sock = nil
|
183
|
-
if (param.v6)
|
184
|
-
sock = ::Socket.new(::Socket::AF_INET6, type, proto)
|
185
|
-
else
|
186
|
-
sock = ::Socket.new(::Socket::AF_INET, type, proto)
|
187
|
-
end
|
188
|
-
|
189
|
-
# Bind to a given local address and/or port if they are supplied
|
190
|
-
if (param.localhost || param.localport)
|
191
|
-
begin
|
192
|
-
sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_REUSEADDR, true)
|
193
|
-
|
194
|
-
sock.bind(Rex::Socket.to_sockaddr(param.localhost, param.localport))
|
195
|
-
|
196
|
-
rescue ::Errno::EADDRNOTAVAIL,::Errno::EADDRINUSE
|
197
|
-
sock.close
|
198
|
-
raise Rex::AddressInUse.new(param.localhost, param.localport), caller
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
# Configure broadcast support for all datagram sockets
|
203
|
-
if (type == ::Socket::SOCK_DGRAM)
|
204
|
-
sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_BROADCAST, true)
|
205
|
-
end
|
206
|
-
|
207
|
-
# If a server TCP instance is being created...
|
208
|
-
if (param.server?)
|
209
|
-
sock.listen(128)
|
210
|
-
|
211
|
-
if (param.bare? == false)
|
212
|
-
klass = Rex::Socket::TcpServer
|
213
|
-
if (param.ssl)
|
214
|
-
klass = Rex::Socket::SslTcpServer
|
215
|
-
end
|
216
|
-
sock.extend(klass)
|
217
|
-
|
218
|
-
sock.initsock(param)
|
219
|
-
end
|
220
|
-
# Otherwise, if we're creating a client...
|
221
|
-
else
|
222
|
-
chain = []
|
223
|
-
|
224
|
-
# If we were supplied with host information
|
225
|
-
if (param.peerhost)
|
226
|
-
begin
|
227
|
-
ip = param.peerhost
|
228
|
-
port = param.peerport
|
229
|
-
|
230
|
-
if param.proxies
|
231
|
-
chain = param.proxies.dup
|
232
|
-
chain.push(['host',param.peerhost,param.peerport])
|
233
|
-
ip = chain[0][1]
|
234
|
-
port = chain[0][2].to_i
|
235
|
-
end
|
236
|
-
|
237
|
-
begin
|
238
|
-
Timeout.timeout(param.timeout) do
|
239
|
-
sock.connect(Rex::Socket.to_sockaddr(ip, port))
|
240
|
-
end
|
241
|
-
rescue ::Timeout::Error
|
242
|
-
raise ::Errno::ETIMEDOUT
|
243
|
-
end
|
244
|
-
|
245
|
-
rescue ::Errno::EHOSTUNREACH,::Errno::ENETDOWN,::Errno::ENETUNREACH,::Errno::ENETRESET,::Errno::EHOSTDOWN,::Errno::EACCES,::Errno::EINVAL
|
246
|
-
sock.close
|
247
|
-
raise Rex::HostUnreachable.new(param.peerhost, param.peerport), caller
|
248
|
-
|
249
|
-
rescue ::Errno::EADDRNOTAVAIL,::Errno::EADDRINUSE
|
250
|
-
sock.close
|
251
|
-
raise Rex::AddressInUse.new(param.peerhost, param.peerport), caller
|
252
|
-
|
253
|
-
rescue Errno::ETIMEDOUT
|
254
|
-
sock.close
|
255
|
-
raise Rex::ConnectionTimeout.new(param.peerhost, param.peerport), caller
|
256
|
-
|
257
|
-
rescue ::Errno::ECONNRESET,::Errno::ECONNREFUSED,::Errno::ENOTCONN,::Errno::ECONNABORTED
|
258
|
-
sock.close
|
259
|
-
raise Rex::ConnectionRefused.new(param.peerhost, param.peerport), caller
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
if (param.bare? == false)
|
264
|
-
case param.proto
|
265
|
-
when 'tcp'
|
266
|
-
klass = Rex::Socket::Tcp
|
267
|
-
sock.extend(klass)
|
268
|
-
sock.initsock(param)
|
269
|
-
when 'udp'
|
270
|
-
sock.extend(Rex::Socket::Udp)
|
271
|
-
sock.initsock(param)
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
if chain.size > 1
|
276
|
-
chain.each_with_index {
|
277
|
-
|proxy, i|
|
278
|
-
next_hop = chain[i + 1]
|
279
|
-
if next_hop
|
280
|
-
proxy(sock, proxy[0], next_hop[1], next_hop[2])
|
281
|
-
end
|
282
|
-
}
|
283
|
-
end
|
284
|
-
|
285
|
-
# Now extend the socket with SSL and perform the handshake
|
286
|
-
if(param.bare? == false and param.ssl)
|
287
|
-
klass = Rex::Socket::SslTcp
|
288
|
-
sock.extend(klass)
|
289
|
-
sock.initsock(param)
|
290
|
-
end
|
291
|
-
|
292
|
-
|
293
|
-
end
|
294
|
-
|
295
|
-
# Notify handlers that a socket has been created.
|
296
|
-
self.instance.notify_socket_created(self, sock, param)
|
297
|
-
|
298
|
-
sock
|
299
|
-
end
|
300
|
-
|
301
|
-
def self.proxy(sock, type, host, port)
|
302
|
-
|
303
|
-
#$stdout.print("PROXY\n")
|
304
|
-
case type.downcase
|
305
|
-
when 'http'
|
306
|
-
setup = "CONNECT #{host}:#{port} HTTP/1.0\r\n\r\n"
|
307
|
-
size = sock.put(setup)
|
308
|
-
if (size != setup.length)
|
309
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to send the entire request to the proxy"), caller
|
310
|
-
end
|
311
|
-
|
312
|
-
begin
|
313
|
-
ret = sock.get_once(39,30)
|
314
|
-
rescue IOError
|
315
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to receive a response from the proxy"), caller
|
316
|
-
end
|
317
|
-
|
318
|
-
if ret.nil?
|
319
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to receive a response from the proxy"), caller
|
320
|
-
end
|
321
|
-
|
322
|
-
resp = Rex::Proto::Http::Response.new
|
323
|
-
resp.update_cmd_parts(ret.split(/\r?\n/)[0])
|
324
|
-
|
325
|
-
if resp.code != 200
|
326
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "The proxy returned a non-OK response"), caller
|
327
|
-
end
|
328
|
-
when 'socks4'
|
329
|
-
setup = [4,1,port.to_i].pack('CCn') + Socket.gethostbyname(host)[3] + Rex::Text.rand_text_alpha(rand(8)+1) + "\x00"
|
330
|
-
size = sock.put(setup)
|
331
|
-
if (size != setup.length)
|
332
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to send the entire request to the proxy"), caller
|
333
|
-
end
|
334
|
-
|
335
|
-
begin
|
336
|
-
ret = sock.get_once(8, 30)
|
337
|
-
rescue IOError
|
338
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to receive a response from the proxy"), caller
|
339
|
-
end
|
340
|
-
|
341
|
-
if (ret.nil? or ret.length < 8)
|
342
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to receive a complete response from the proxy"), caller
|
343
|
-
end
|
344
|
-
if ret[1,1] != "\x5a"
|
345
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Proxy responded with error code #{ret[0,1].unpack("C")[0]}"), caller
|
346
|
-
end
|
347
|
-
when 'socks5'
|
348
|
-
auth_methods = [5,1,0].pack('CCC')
|
349
|
-
size = sock.put(auth_methods)
|
350
|
-
if (size != auth_methods.length)
|
351
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to send the entire request to the proxy"), caller
|
352
|
-
end
|
353
|
-
ret = sock.get_once(2,30)
|
354
|
-
if (ret[1,1] == "\xff")
|
355
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "The proxy requires authentication"), caller
|
356
|
-
end
|
357
|
-
|
358
|
-
if (Rex::Socket.is_ipv4?(host))
|
359
|
-
addr = Rex::Socket.gethostbyname(host)[3]
|
360
|
-
setup = [5,1,0,1].pack('C4') + addr + [port.to_i].pack('n')
|
361
|
-
elsif (Rex::Socket.support_ipv6? and Rex::Socket.is_ipv6?(host))
|
362
|
-
# IPv6 stuff all untested
|
363
|
-
addr = Rex::Socket.gethostbyname(host)[3]
|
364
|
-
setup = [5,1,0,4].pack('C4') + addr + [port.to_i].pack('n')
|
365
|
-
else
|
366
|
-
# Then it must be a domain name.
|
367
|
-
# Unfortunately, it looks like the host has always been
|
368
|
-
# resolved by the time it gets here, so this code never runs.
|
369
|
-
setup = [5,1,0,3].pack('C4') + [host.length].pack('C') + host + [port.to_i].pack('n')
|
370
|
-
end
|
371
|
-
|
372
|
-
size = sock.put(setup)
|
373
|
-
if (size != setup.length)
|
374
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to send the entire request to the proxy"), caller
|
375
|
-
end
|
376
|
-
|
377
|
-
begin
|
378
|
-
response = sock.get_once(10, 30)
|
379
|
-
rescue IOError
|
380
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to receive a response from the proxy"), caller
|
381
|
-
end
|
382
|
-
|
383
|
-
if (response.nil? or response.length < 10)
|
384
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Failed to receive a complete response from the proxy"), caller
|
385
|
-
end
|
386
|
-
if response[1,1] != "\x00"
|
387
|
-
raise Rex::ConnectionProxyError.new(host, port, type, "Proxy responded with error code #{response[1,1].unpack("C")[0]}"), caller
|
388
|
-
end
|
389
|
-
else
|
390
|
-
raise RuntimeError, "The proxy type specified is not valid", caller
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
##
|
395
|
-
#
|
396
|
-
# Registration
|
397
|
-
#
|
398
|
-
##
|
399
|
-
|
400
|
-
def self.register_event_handler(handler) # :nodoc:
|
401
|
-
self.instance.register_event_handler(handler)
|
402
|
-
end
|
403
|
-
|
404
|
-
def self.deregister_event_handler(handler) # :nodoc:
|
405
|
-
self.instance.deregister_event_handler(handler)
|
406
|
-
end
|
407
|
-
|
408
|
-
def self.each_event_handler(handler) # :nodoc:
|
409
|
-
self.instance.each_event_handler(handler)
|
410
|
-
end
|
411
|
-
|
412
|
-
end
|