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/file.rb.ut.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..'))
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
|
-
require 'rex/file'
|
7
|
-
|
8
|
-
class Rex::FileUtils::UnitTest < ::Test::Unit::TestCase
|
9
|
-
Klass = Rex::FileUtils
|
10
|
-
|
11
|
-
def test_find_full_path
|
12
|
-
assert_not_nil(Klass.find_full_path("ls"))
|
13
|
-
assert_nil(Klass.find_full_path("cookie monster cake"))
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
data/lib/rex/image_source.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# $Id: disk.rb 5401 2008-02-09 04:35:21Z ramon $
|
4
|
-
|
5
|
-
require 'rex/image_source/image_source'
|
6
|
-
require 'rex/struct2'
|
7
|
-
|
8
|
-
module Rex
|
9
|
-
module ImageSource
|
10
|
-
class Disk < ImageSource
|
11
|
-
|
12
|
-
attr_accessor :file, :file_offset, :size
|
13
|
-
|
14
|
-
WINDOW_SIZE = 4096
|
15
|
-
WINDOW_OVERLAP = 64
|
16
|
-
|
17
|
-
def initialize(_file, _offset = 0, _len = nil)
|
18
|
-
_len = _file.stat.size if !_len
|
19
|
-
|
20
|
-
self.file = _file
|
21
|
-
self.file_offset = _offset
|
22
|
-
self.size = _len
|
23
|
-
end
|
24
|
-
|
25
|
-
def read(offset, len)
|
26
|
-
if offset < 0 || offset+len > size
|
27
|
-
raise RangeError, "Offset #{offset} outside of image source", caller
|
28
|
-
end
|
29
|
-
|
30
|
-
file.seek(file_offset + offset)
|
31
|
-
file.read(len)
|
32
|
-
end
|
33
|
-
|
34
|
-
def index(search, offset = 0)
|
35
|
-
# do a sliding window search across the disk
|
36
|
-
while offset < size
|
37
|
-
|
38
|
-
# get a full window size if we can, we
|
39
|
-
# don't want to read past our boundaries
|
40
|
-
wsize = size - offset
|
41
|
-
wsize = WINDOW_SIZE if wsize > WINDOW_SIZE
|
42
|
-
|
43
|
-
window = self.read(offset, wsize)
|
44
|
-
res = window.index(search)
|
45
|
-
return res + offset if res
|
46
|
-
offset += WINDOW_SIZE - WINDOW_OVERLAP
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def subsource(offset, len)
|
51
|
-
self.class.new(file, file_offset+offset, len)
|
52
|
-
end
|
53
|
-
|
54
|
-
def close
|
55
|
-
file.close
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# $Id: image_source.rb 5401 2008-02-09 04:35:21Z ramon $
|
4
|
-
|
5
|
-
module Rex
|
6
|
-
module ImageSource
|
7
|
-
class ImageSource
|
8
|
-
|
9
|
-
#
|
10
|
-
# Um, just some abstract class stuff I guess, this is the interface
|
11
|
-
# that any image sources should subscribe to...
|
12
|
-
#
|
13
|
-
|
14
|
-
def subsource(offset, len)
|
15
|
-
raise "do something"
|
16
|
-
end
|
17
|
-
|
18
|
-
def size
|
19
|
-
raise "do something"
|
20
|
-
end
|
21
|
-
|
22
|
-
def file_offset
|
23
|
-
raise "do something"
|
24
|
-
end
|
25
|
-
|
26
|
-
def close
|
27
|
-
raise "do something"
|
28
|
-
end
|
29
|
-
|
30
|
-
def read_asciiz(offset)
|
31
|
-
# FIXME, make me better
|
32
|
-
string = ''
|
33
|
-
loop do
|
34
|
-
char = read(offset, 1)
|
35
|
-
break if char == "\x00"
|
36
|
-
offset += 1
|
37
|
-
string << char
|
38
|
-
end
|
39
|
-
return string
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# $Id: memory.rb 5401 2008-02-09 04:35:21Z ramon $
|
4
|
-
|
5
|
-
require 'rex/image_source/image_source'
|
6
|
-
require 'rex/struct2'
|
7
|
-
|
8
|
-
module Rex
|
9
|
-
module ImageSource
|
10
|
-
class Memory < ImageSource
|
11
|
-
|
12
|
-
attr_accessor :rawdata, :size, :file_offset
|
13
|
-
|
14
|
-
def initialize(_rawdata, _file_offset = 0)
|
15
|
-
self.rawdata = _rawdata
|
16
|
-
self.size = _rawdata.length
|
17
|
-
self.file_offset = _file_offset
|
18
|
-
end
|
19
|
-
|
20
|
-
def read(offset, len)
|
21
|
-
rawdata[offset, len]
|
22
|
-
end
|
23
|
-
|
24
|
-
def subsource(offset, len)
|
25
|
-
self.class.new(rawdata[offset, len], offset + file_offset)
|
26
|
-
end
|
27
|
-
|
28
|
-
def close
|
29
|
-
end
|
30
|
-
|
31
|
-
def index(*args)
|
32
|
-
rawdata.index(*args)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
@@ -1,157 +0,0 @@
|
|
1
|
-
module Rex
|
2
|
-
module IO
|
3
|
-
|
4
|
-
require 'rex/ui/text/output'
|
5
|
-
require 'rex/ui/text/output/buffer'
|
6
|
-
require 'rex/ui/text/input/buffer'
|
7
|
-
|
8
|
-
class BidirectionalPipe < Rex::Ui::Text::Input
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@subscribers_out = {}
|
12
|
-
@subscribers_ref = {}
|
13
|
-
@subscribers_idx = 0
|
14
|
-
@pipe_input = Rex::Ui::Text::Input::Buffer.new
|
15
|
-
|
16
|
-
# We are the shell, the input, and the output
|
17
|
-
self.output = self
|
18
|
-
self.input = self
|
19
|
-
end
|
20
|
-
|
21
|
-
def pipe_input
|
22
|
-
@pipe_input
|
23
|
-
end
|
24
|
-
|
25
|
-
def close
|
26
|
-
@pipe_input.close
|
27
|
-
end
|
28
|
-
|
29
|
-
def has_subscriber?(id)
|
30
|
-
@subscribers_out.has_key?(id)
|
31
|
-
end
|
32
|
-
|
33
|
-
def create_subscriber(id=nil)
|
34
|
-
id ||= (@subscribers_idx += 1).to_s
|
35
|
-
@subscribers_out[id] = Rex::Ui::Text::Output::Buffer.new
|
36
|
-
return id
|
37
|
-
end
|
38
|
-
|
39
|
-
def create_subscriber_proc(id=nil, &block)
|
40
|
-
id = create_subscriber(id)
|
41
|
-
@subscribers_ref[id] = block
|
42
|
-
end
|
43
|
-
|
44
|
-
def remove_subscriber(id)
|
45
|
-
@subscribers_out.delete(id)
|
46
|
-
@subscribers_ref.delete(id)
|
47
|
-
end
|
48
|
-
|
49
|
-
def write_input(buf)
|
50
|
-
@pipe_input.put(buf)
|
51
|
-
end
|
52
|
-
|
53
|
-
def read_subscriber(id)
|
54
|
-
output = @subscribers_out[id]
|
55
|
-
|
56
|
-
return '' if output.nil?
|
57
|
-
|
58
|
-
buf = output.buf
|
59
|
-
|
60
|
-
output.reset
|
61
|
-
|
62
|
-
buf
|
63
|
-
end
|
64
|
-
|
65
|
-
def print(msg='')
|
66
|
-
@subscribers_out.each_pair { |id, buf|
|
67
|
-
begin
|
68
|
-
@subscribers_ref[id] ? @subscribers_ref[id].call(msg) : buf.print(msg)
|
69
|
-
rescue ::Exception => e
|
70
|
-
# $stderr.puts "Error handling subscriber #{id}: #{e} #{e.backtrace.inspect}"
|
71
|
-
raise e
|
72
|
-
end
|
73
|
-
}
|
74
|
-
msg
|
75
|
-
end
|
76
|
-
|
77
|
-
def print_error(msg='')
|
78
|
-
print_line('[-] ' + msg)
|
79
|
-
end
|
80
|
-
|
81
|
-
def print_line(msg='')
|
82
|
-
print(msg + "\n")
|
83
|
-
end
|
84
|
-
|
85
|
-
def print_good(msg='')
|
86
|
-
print_line('[+] ' + msg)
|
87
|
-
end
|
88
|
-
|
89
|
-
def print_debug(msg='')
|
90
|
-
print_line('[!] ' + msg)
|
91
|
-
end
|
92
|
-
|
93
|
-
def flush
|
94
|
-
end
|
95
|
-
|
96
|
-
def print_status(msg='')
|
97
|
-
print_line('[*] ' + msg)
|
98
|
-
end
|
99
|
-
|
100
|
-
#
|
101
|
-
# Wrappers for the pipe_input methods
|
102
|
-
#
|
103
|
-
|
104
|
-
def close
|
105
|
-
@pipe_input.close
|
106
|
-
end
|
107
|
-
|
108
|
-
def sysread(len = 1)
|
109
|
-
@pipe_input.sysread(len)
|
110
|
-
end
|
111
|
-
|
112
|
-
def put(msg)
|
113
|
-
@pipe_input.put(msg)
|
114
|
-
end
|
115
|
-
|
116
|
-
def gets
|
117
|
-
@pipe_input.gets
|
118
|
-
end
|
119
|
-
|
120
|
-
def eof?
|
121
|
-
@pipe_input.eof?
|
122
|
-
end
|
123
|
-
|
124
|
-
def fd
|
125
|
-
@pipe_input.fd
|
126
|
-
end
|
127
|
-
|
128
|
-
#
|
129
|
-
# Wrappers for shell methods
|
130
|
-
#
|
131
|
-
|
132
|
-
attr_accessor :output, :prompt, :input
|
133
|
-
|
134
|
-
def intrinsic_shell?
|
135
|
-
true
|
136
|
-
end
|
137
|
-
|
138
|
-
def supports_readline
|
139
|
-
false
|
140
|
-
end
|
141
|
-
|
142
|
-
def supports_color?
|
143
|
-
false
|
144
|
-
end
|
145
|
-
|
146
|
-
def pgets
|
147
|
-
gets
|
148
|
-
end
|
149
|
-
|
150
|
-
|
151
|
-
protected
|
152
|
-
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'socket'
|
4
|
-
|
5
|
-
module Rex
|
6
|
-
module IO
|
7
|
-
|
8
|
-
###
|
9
|
-
#
|
10
|
-
# This class provides an abstraction to a datagram based
|
11
|
-
# connection through the use of a datagram socketpair.
|
12
|
-
#
|
13
|
-
###
|
14
|
-
module DatagramAbstraction
|
15
|
-
|
16
|
-
#
|
17
|
-
# Creates a streaming socket pair
|
18
|
-
#
|
19
|
-
def initialize_abstraction
|
20
|
-
self.lsock, self.rsock = Rex::Socket.udp_socket_pair()
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
# The left side of the stream (local)
|
25
|
-
attr_reader :lsock
|
26
|
-
# The right side of the stream (remote)
|
27
|
-
attr_reader :rsock
|
28
|
-
|
29
|
-
protected
|
30
|
-
attr_writer :lsock
|
31
|
-
attr_writer :rsock
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end; end
|
data/lib/rex/io/stream.rb
DELETED
@@ -1,319 +0,0 @@
|
|
1
|
-
require 'rex/sync/thread_safe'
|
2
|
-
|
3
|
-
module Rex
|
4
|
-
module IO
|
5
|
-
|
6
|
-
###
|
7
|
-
#
|
8
|
-
# This mixin is an abstract representation of a streaming connection. Streams
|
9
|
-
# extend classes that must implement the following methods:
|
10
|
-
#
|
11
|
-
# syswrite(buffer)
|
12
|
-
# sysread(length)
|
13
|
-
# shutdown(how)
|
14
|
-
# close
|
15
|
-
# peerinfo
|
16
|
-
# localinfo
|
17
|
-
#
|
18
|
-
###
|
19
|
-
module Stream
|
20
|
-
|
21
|
-
##
|
22
|
-
#
|
23
|
-
# Abstract methods
|
24
|
-
#
|
25
|
-
##
|
26
|
-
|
27
|
-
#
|
28
|
-
# This method writes the supplied buffer to the stream. This method
|
29
|
-
# intelligent reduces the size of supplied buffers so that ruby doesn't get
|
30
|
-
# into a potential global thread blocking state when used on blocking
|
31
|
-
# sockets. That is, this method will send the supplied buffer in chunks
|
32
|
-
# of, at most, 32768 bytes.
|
33
|
-
#
|
34
|
-
def write(buf, opts = {})
|
35
|
-
total_sent = 0
|
36
|
-
total_length = buf.length
|
37
|
-
block_size = 32768
|
38
|
-
begin
|
39
|
-
while( total_sent < total_length )
|
40
|
-
s = Rex::ThreadSafe.select( nil, [ fd ], nil, 0.2 )
|
41
|
-
if( s == nil || s[0] == nil )
|
42
|
-
next
|
43
|
-
end
|
44
|
-
data = buf[0, block_size]
|
45
|
-
sent = fd.write_nonblock( data )
|
46
|
-
if sent > 0
|
47
|
-
total_sent += sent
|
48
|
-
buf[0, sent] = ""
|
49
|
-
end
|
50
|
-
end
|
51
|
-
rescue ::Errno::EAGAIN
|
52
|
-
# Sleep for a half a second, or until we can write again
|
53
|
-
Rex::ThreadSafe.select( nil, [ fd ], nil, 0.5 )
|
54
|
-
# Decrement the block size to handle full sendQs better
|
55
|
-
block_size = 1024
|
56
|
-
# Try to write the data again
|
57
|
-
retry
|
58
|
-
rescue ::IOError, ::Errno::EPIPE
|
59
|
-
return nil if (fd.abortive_close == true)
|
60
|
-
raise $!
|
61
|
-
end
|
62
|
-
total_sent
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# This method reads data of the supplied length from the stream.
|
67
|
-
#
|
68
|
-
def read(length = nil, opts = {})
|
69
|
-
# XXX handle length being nil
|
70
|
-
begin
|
71
|
-
fd.readpartial(length)
|
72
|
-
rescue ::IOError, ::EOFError, ::Errno::EPIPE
|
73
|
-
return nil if (fd.abortive_close == true)
|
74
|
-
raise $!
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# Polls the stream to see if there is any read data available. Returns
|
80
|
-
# true if data is available for reading, otherwise false is returned.
|
81
|
-
#
|
82
|
-
def has_read_data?(timeout = nil)
|
83
|
-
|
84
|
-
# Allow a timeout of "0" that waits almost indefinitely for input, this
|
85
|
-
# mimics the behavior of Rex::ThreadSafe.select() and fixes some corner
|
86
|
-
# cases of unintentional no-wait timeouts.
|
87
|
-
timeout = 3600 if (timeout and timeout == 0)
|
88
|
-
|
89
|
-
begin
|
90
|
-
if ((rv = ::IO.select([ fd ], nil, nil, timeout)) and
|
91
|
-
(rv[0]) and
|
92
|
-
(rv[0][0] == fd))
|
93
|
-
true
|
94
|
-
else
|
95
|
-
false
|
96
|
-
end
|
97
|
-
rescue ::Errno::EBADF, ::Errno::ENOTSOCK
|
98
|
-
raise ::EOFError
|
99
|
-
rescue StreamClosedError, ::IOError, ::EOFError, ::Errno::EPIPE
|
100
|
-
# If the thing that lead to the closure was an abortive close, then
|
101
|
-
# don't raise the stream closed error.
|
102
|
-
return false if (fd.abortive_close == true)
|
103
|
-
|
104
|
-
raise $!
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
#
|
109
|
-
# This method returns the selectable file descriptor, or self by default.
|
110
|
-
#
|
111
|
-
def fd
|
112
|
-
self
|
113
|
-
end
|
114
|
-
|
115
|
-
##
|
116
|
-
#
|
117
|
-
# Common methods
|
118
|
-
#
|
119
|
-
##
|
120
|
-
|
121
|
-
#
|
122
|
-
# This method writes the supplied buffer to the stream by calling the write
|
123
|
-
# routine.
|
124
|
-
#
|
125
|
-
def <<(buf)
|
126
|
-
return write(buf.to_s)
|
127
|
-
end
|
128
|
-
|
129
|
-
#
|
130
|
-
# This method calls get_once() to read pending data from the socket
|
131
|
-
#
|
132
|
-
def >>
|
133
|
-
get_once
|
134
|
-
end
|
135
|
-
|
136
|
-
#
|
137
|
-
# This method writes to the stream, optionally timing out after a period of
|
138
|
-
# time.
|
139
|
-
#
|
140
|
-
def timed_write(buf, wait = def_write_timeout, opts = {})
|
141
|
-
if (wait and wait > 0)
|
142
|
-
Timeout.timeout(wait) {
|
143
|
-
return write(buf, opts)
|
144
|
-
}
|
145
|
-
else
|
146
|
-
return write(buf, opts)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
#
|
151
|
-
# This method reads from the stream, optionally timing out after a period
|
152
|
-
# of time.
|
153
|
-
#
|
154
|
-
def timed_read(length = nil, wait = def_read_timeout, opts = {})
|
155
|
-
if (wait and wait > 0)
|
156
|
-
Timeout.timeout(wait) {
|
157
|
-
return read(length, opts)
|
158
|
-
}
|
159
|
-
else
|
160
|
-
return read(length, opts)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
#
|
165
|
-
# This method writes the full contents of the supplied buffer, optionally
|
166
|
-
# with a timeout.
|
167
|
-
#
|
168
|
-
def put(buf, opts = {})
|
169
|
-
return 0 if (buf == nil or buf.length == 0)
|
170
|
-
|
171
|
-
send_len = buf.length
|
172
|
-
send_idx = 0
|
173
|
-
wait = opts['Timeout'] || 0
|
174
|
-
|
175
|
-
# Keep writing until our send length drops to zero
|
176
|
-
while (send_idx < send_len)
|
177
|
-
curr_len = timed_write(buf[send_idx, buf.length-send_idx], wait, opts)
|
178
|
-
|
179
|
-
# If the write operation failed due to an IOError, then we fail.
|
180
|
-
return buf.length - send_len if (curr_len == nil)
|
181
|
-
|
182
|
-
send_len -= curr_len
|
183
|
-
send_idx += curr_len
|
184
|
-
end
|
185
|
-
|
186
|
-
return buf.length - send_len
|
187
|
-
end
|
188
|
-
|
189
|
-
|
190
|
-
#
|
191
|
-
# This method emulates the behavior of Pex::Socket::Recv in MSF2
|
192
|
-
#
|
193
|
-
def get_once(length = -1, timeout = def_read_timeout)
|
194
|
-
|
195
|
-
if (has_read_data?(timeout) == false)
|
196
|
-
return nil
|
197
|
-
end
|
198
|
-
|
199
|
-
bsize = (length == -1) ? def_block_size : length
|
200
|
-
|
201
|
-
begin
|
202
|
-
return read(bsize)
|
203
|
-
rescue Exception
|
204
|
-
end
|
205
|
-
|
206
|
-
return ''
|
207
|
-
end
|
208
|
-
|
209
|
-
#
|
210
|
-
# This method reads as much data as it can from the wire given a maximum
|
211
|
-
# timeout.
|
212
|
-
#
|
213
|
-
def get(timeout = nil, ltimeout = def_read_loop_timeout, opts = {})
|
214
|
-
# For those people who are used to being able to use a negative timeout!
|
215
|
-
if (timeout and timeout.to_i < 0)
|
216
|
-
timeout = nil
|
217
|
-
end
|
218
|
-
|
219
|
-
# No data in the first place? bust.
|
220
|
-
if (has_read_data?(timeout) == false)
|
221
|
-
return nil
|
222
|
-
end
|
223
|
-
|
224
|
-
buf = ""
|
225
|
-
lps = 0
|
226
|
-
eof = false
|
227
|
-
|
228
|
-
# Keep looping until there is no more data to be gotten..
|
229
|
-
while (has_read_data?(ltimeout) == true)
|
230
|
-
# Catch EOF errors so that we can handle them properly.
|
231
|
-
begin
|
232
|
-
temp = read(def_block_size)
|
233
|
-
rescue EOFError
|
234
|
-
eof = true
|
235
|
-
end
|
236
|
-
|
237
|
-
# If we read zero bytes and we had data, then we've hit EOF
|
238
|
-
if (temp and temp.length == 0)
|
239
|
-
eof = true
|
240
|
-
end
|
241
|
-
|
242
|
-
# If we reached EOF and there are no bytes in the buffer we've been
|
243
|
-
# reading into, then throw an EOF error.
|
244
|
-
if (eof)
|
245
|
-
# If we've already read at least some data, then it's time to
|
246
|
-
# break out and let it be processed before throwing an EOFError.
|
247
|
-
if (buf.length > 0)
|
248
|
-
break
|
249
|
-
else
|
250
|
-
raise EOFError
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
break if (temp == nil or temp.empty? == true)
|
255
|
-
|
256
|
-
buf += temp
|
257
|
-
lps += 1
|
258
|
-
|
259
|
-
break if (lps >= def_max_loops)
|
260
|
-
end
|
261
|
-
|
262
|
-
# Return the entire buffer we read in
|
263
|
-
return buf
|
264
|
-
end
|
265
|
-
|
266
|
-
##
|
267
|
-
#
|
268
|
-
# Defaults
|
269
|
-
#
|
270
|
-
##
|
271
|
-
|
272
|
-
#
|
273
|
-
# The default number of seconds to wait for a write operation to timeout.
|
274
|
-
#
|
275
|
-
def def_write_timeout
|
276
|
-
10
|
277
|
-
end
|
278
|
-
|
279
|
-
#
|
280
|
-
# The default number of seconds to wait for a read operation to timeout.
|
281
|
-
#
|
282
|
-
def def_read_timeout
|
283
|
-
10
|
284
|
-
end
|
285
|
-
|
286
|
-
#
|
287
|
-
# The default number of seconds to wait while in a read loop after read
|
288
|
-
# data has been found.
|
289
|
-
#
|
290
|
-
def def_read_loop_timeout
|
291
|
-
0.1
|
292
|
-
end
|
293
|
-
|
294
|
-
#
|
295
|
-
# The maximum number of read loops to perform before returning to the
|
296
|
-
# caller.
|
297
|
-
#
|
298
|
-
def def_max_loops
|
299
|
-
1024
|
300
|
-
end
|
301
|
-
|
302
|
-
#
|
303
|
-
# The default block size to read in chunks from the wire.
|
304
|
-
#
|
305
|
-
def def_block_size
|
306
|
-
16384
|
307
|
-
end
|
308
|
-
|
309
|
-
#
|
310
|
-
# This flag indicates whether or not an abortive close has been issued.
|
311
|
-
#
|
312
|
-
attr_accessor :abortive_close
|
313
|
-
|
314
|
-
protected
|
315
|
-
|
316
|
-
end
|
317
|
-
|
318
|
-
end end
|
319
|
-
|