rex 2.0.8 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rex.rb +1 -0
- data/lib/rex/arch.rb +5 -0
- data/lib/rex/arch/x86.rb +19 -5
- data/lib/rex/arch/zarch.rb +17 -0
- data/lib/rex/compat.rb +5 -4
- data/lib/rex/constants.rb +3 -1
- data/lib/rex/encoder/alpha2/alpha_mixed.rb +70 -9
- data/lib/rex/encoder/alpha2/alpha_upper.rb +67 -8
- data/lib/rex/exploitation/cmdstager.rb +1 -0
- data/lib/rex/exploitation/cmdstager/certutil.rb +115 -0
- data/lib/rex/exploitation/cmdstager/echo.rb +6 -3
- data/lib/rex/exploitation/egghunter.rb +1 -1
- data/lib/rex/google/geolocation.rb +68 -0
- data/lib/rex/io/bidirectional_pipe.rb +0 -4
- data/lib/rex/java/serialization.rb +2 -0
- data/lib/rex/java/serialization/decode_error.rb +11 -0
- data/lib/rex/java/serialization/encode_error.rb +11 -0
- data/lib/rex/java/serialization/model.rb +2 -0
- data/lib/rex/java/serialization/model/annotation.rb +3 -3
- data/lib/rex/java/serialization/model/block_data.rb +3 -3
- data/lib/rex/java/serialization/model/block_data_long.rb +3 -3
- data/lib/rex/java/serialization/model/class_desc.rb +6 -6
- data/lib/rex/java/serialization/model/contents.rb +17 -10
- data/lib/rex/java/serialization/model/field.rb +12 -11
- data/lib/rex/java/serialization/model/long_utf.rb +3 -3
- data/lib/rex/java/serialization/model/new_array.rb +22 -23
- data/lib/rex/java/serialization/model/new_class.rb +57 -0
- data/lib/rex/java/serialization/model/new_class_desc.rb +15 -16
- data/lib/rex/java/serialization/model/new_enum.rb +5 -5
- data/lib/rex/java/serialization/model/new_object.rb +22 -17
- data/lib/rex/java/serialization/model/proxy_class_desc.rb +109 -0
- data/lib/rex/java/serialization/model/reference.rb +4 -4
- data/lib/rex/java/serialization/model/stream.rb +7 -7
- data/lib/rex/java/serialization/model/utf.rb +3 -3
- data/lib/rex/json_hash_file.rb +94 -0
- data/lib/rex/logging/log_sink.rb +1 -0
- data/lib/rex/logging/sinks/timestamp_flatfile.rb +21 -0
- data/lib/rex/parser/appscan_nokogiri.rb +13 -23
- data/lib/rex/parser/fs/ntfs.rb +10 -5
- data/lib/rex/parser/nmap_nokogiri.rb +3 -1
- data/lib/rex/parser/openvas_nokogiri.rb +70 -73
- data/lib/rex/parser/winscp.rb +108 -0
- data/lib/rex/parser/x509_certificate.rb +92 -0
- data/lib/rex/payloads.rb +0 -1
- data/lib/rex/payloads/meterpreter/config.rb +154 -0
- data/lib/rex/payloads/meterpreter/uri_checksum.rb +136 -0
- data/lib/rex/post/meterpreter.rb +1 -1
- data/lib/rex/post/meterpreter/client.rb +26 -3
- data/lib/rex/post/meterpreter/client_core.rb +387 -75
- data/lib/rex/post/meterpreter/extensions/android/android.rb +127 -37
- data/lib/rex/post/meterpreter/extensions/android/tlv.rb +46 -25
- data/lib/rex/post/meterpreter/extensions/extapi/extapi.rb +4 -0
- data/lib/rex/post/meterpreter/extensions/extapi/ntds/ntds.rb +39 -0
- data/lib/rex/post/meterpreter/extensions/extapi/pageant/pageant.rb +44 -0
- data/lib/rex/post/meterpreter/extensions/extapi/tlv.rb +9 -0
- data/lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb +16 -1
- data/lib/rex/post/meterpreter/extensions/priv/priv.rb +1 -1
- data/lib/rex/post/meterpreter/extensions/python/python.rb +114 -0
- data/lib/rex/post/meterpreter/extensions/python/tlv.rb +21 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb +17 -14
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +33 -12
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/mount.rb +57 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb +3 -3
- data/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb +3 -1
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +2 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb +16 -3
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry.rb +29 -6
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_key.rb +5 -1
- data/lib/rex/post/meterpreter/extensions/stdapi/tlv.rb +18 -6
- data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +2 -2
- data/lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb +34 -36
- data/lib/rex/post/meterpreter/packet.rb +29 -0
- data/lib/rex/post/meterpreter/packet_dispatcher.rb +20 -7
- data/lib/rex/post/meterpreter/ui/console.rb +1 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb +230 -72
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +544 -34
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/adsi.rb +188 -57
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/kiwi.rb +115 -93
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb +1 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/mimikatz.rb +1 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/elevate.rb +49 -15
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb +11 -2
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/python.rb +187 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +324 -133
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +52 -2
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +68 -65
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +9 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb +113 -118
- data/lib/rex/post/meterpreter/ui/console/interactive_channel.rb +3 -0
- data/lib/rex/powershell.rb +62 -0
- data/lib/rex/powershell/command.rb +359 -0
- data/lib/rex/{exploitation/powershell → powershell}/function.rb +0 -2
- data/lib/rex/{exploitation/powershell → powershell}/obfu.rb +0 -2
- data/lib/rex/{exploitation/powershell → powershell}/output.rb +11 -5
- data/lib/rex/{exploitation/powershell → powershell}/param.rb +0 -2
- data/lib/rex/powershell/parser.rb +182 -0
- data/lib/rex/powershell/payload.rb +78 -0
- data/lib/rex/{exploitation/powershell → powershell}/psh_methods.rb +16 -2
- data/lib/rex/{exploitation/powershell → powershell}/script.rb +2 -4
- data/lib/rex/proto/dcerpc/client.rb +6 -6
- data/lib/rex/proto/dcerpc/exceptions.rb +26 -0
- data/lib/rex/proto/http/client.rb +3 -3
- data/lib/rex/proto/http/client_request.rb +0 -5
- data/lib/rex/proto/http/response.rb +86 -0
- data/lib/rex/proto/ipmi/utils.rb +30 -26
- data/lib/rex/proto/kerberos/client.rb +1 -1
- data/lib/rex/proto/kerberos/model/kdc_request.rb +2 -2
- data/lib/rex/proto/rfb/client.rb +8 -3
- data/lib/rex/proto/rfb/constants.rb +1 -1
- data/lib/rex/proto/rmi.rb +2 -0
- data/lib/rex/proto/rmi/decode_error.rb +10 -0
- data/lib/rex/proto/rmi/exception.rb +10 -0
- data/lib/rex/proto/rmi/model.rb +5 -0
- data/lib/rex/proto/rmi/model/call.rb +4 -4
- data/lib/rex/proto/rmi/model/call_data.rb +137 -0
- data/lib/rex/proto/rmi/model/dgc_ack.rb +2 -2
- data/lib/rex/proto/rmi/model/element.rb +26 -11
- data/lib/rex/proto/rmi/model/output_header.rb +4 -4
- data/lib/rex/proto/rmi/model/ping.rb +2 -2
- data/lib/rex/proto/rmi/model/ping_ack.rb +2 -2
- data/lib/rex/proto/rmi/model/protocol_ack.rb +2 -2
- data/lib/rex/proto/rmi/model/return_data.rb +5 -5
- data/lib/rex/proto/rmi/model/return_value.rb +124 -0
- data/lib/rex/proto/rmi/model/unique_identifier.rb +77 -0
- data/lib/rex/proto/steam.rb +3 -0
- data/lib/rex/proto/steam/message.rb +125 -0
- data/lib/rex/proto/tftp/client.rb +35 -14
- data/lib/rex/random_identifier_generator.rb +2 -0
- data/lib/rex/ropbuilder.rb +1 -1
- data/lib/rex/socket/parameters.rb +9 -0
- data/lib/rex/socket/ssl_tcp.rb +25 -41
- data/lib/rex/socket/ssl_tcp_server.rb +10 -21
- data/lib/rex/sslscan/result.rb +20 -1
- data/lib/rex/text.rb +241 -55
- data/lib/rex/ui/output.rb +0 -3
- data/lib/rex/ui/subscriber.rb +0 -10
- data/lib/rex/ui/text/color.rb +9 -0
- data/lib/rex/ui/text/dispatcher_shell.rb +1 -0
- data/lib/rex/ui/text/output.rb +15 -4
- data/lib/rex/ui/text/output/file.rb +1 -0
- data/lib/rex/ui/text/output/stdio.rb +0 -16
- data/lib/rex/ui/text/shell.rb +3 -0
- data/lib/rex/ui/text/table.rb +85 -19
- data/lib/rex/user_agent.rb +118 -0
- data/rex.gemspec +2 -2
- metadata +41 -14
- data/lib/rex/exploitation/powershell.rb +0 -62
- data/lib/rex/exploitation/powershell/parser.rb +0 -183
- data/lib/rex/payloads/meterpreter.rb +0 -2
- data/lib/rex/payloads/meterpreter/patch.rb +0 -136
@@ -0,0 +1,109 @@
|
|
1
|
+
# -*- coding: binary -*-
|
2
|
+
|
3
|
+
module Rex
|
4
|
+
module Java
|
5
|
+
module Serialization
|
6
|
+
module Model
|
7
|
+
# This class provides a ProxyClassDesc representation
|
8
|
+
class ProxyClassDesc < Element
|
9
|
+
|
10
|
+
include Rex::Java::Serialization
|
11
|
+
|
12
|
+
# @!attribute interfaces
|
13
|
+
# @return [Array] An array of interface names
|
14
|
+
attr_accessor :interfaces
|
15
|
+
# @!attribute class_annotation
|
16
|
+
# @return [Rex::Java::Serialization::Model::Annotation] The java class annotations
|
17
|
+
attr_accessor :class_annotation
|
18
|
+
# @!attribute super_class
|
19
|
+
# @return [Rex::Java::Serialization::Model::ClassDesc] The java class superclass description
|
20
|
+
attr_accessor :super_class
|
21
|
+
|
22
|
+
# @param stream [Rex::Java::Serialization::Model::Stream] the stream where it belongs to
|
23
|
+
def initialize(stream = nil)
|
24
|
+
super(stream)
|
25
|
+
self.interfaces = []
|
26
|
+
self.class_annotation = nil
|
27
|
+
self.super_class = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
# Deserializes a Rex::Java::Serialization::Model::ProxyClassDesc
|
31
|
+
#
|
32
|
+
# @param io [IO] the io to read from
|
33
|
+
# @return [self] if deserialization succeeds
|
34
|
+
# @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
|
35
|
+
def decode(io)
|
36
|
+
stream.add_reference(self) unless stream.nil?
|
37
|
+
|
38
|
+
interfaces_length = decode_interfaces_length(io)
|
39
|
+
interfaces_length.times do
|
40
|
+
interface = Utf.decode(io, stream)
|
41
|
+
self.interfaces << interface
|
42
|
+
end
|
43
|
+
self.class_annotation = Annotation.decode(io, stream)
|
44
|
+
self.super_class = ClassDesc.decode(io, stream)
|
45
|
+
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
# Serializes the Rex::Java::Serialization::Model::ProxyClassDesc
|
50
|
+
#
|
51
|
+
# @return [String] if serialization succeeds
|
52
|
+
# @raise [Rex::Java::Serialization::EncodeError] if serialization doesn't succeed
|
53
|
+
def encode
|
54
|
+
unless class_annotation.class == Rex::Java::Serialization::Model::Annotation ||
|
55
|
+
super_class.class == Rex::Java::Serialization::Model::ClassDesc
|
56
|
+
raise Rex::Java::Serialization::EncodeError, 'Failed to serialize ProxyClassDesc'
|
57
|
+
end
|
58
|
+
encoded = ''
|
59
|
+
encoded << [interfaces.length].pack('N')
|
60
|
+
interfaces.each do |interface|
|
61
|
+
encoded << interface.encode
|
62
|
+
end
|
63
|
+
encoded << class_annotation.encode
|
64
|
+
encoded << super_class.encode
|
65
|
+
|
66
|
+
encoded
|
67
|
+
end
|
68
|
+
|
69
|
+
# Creates a print-friendly string representation
|
70
|
+
#
|
71
|
+
# @return [String]
|
72
|
+
def to_s
|
73
|
+
str = '[ '
|
74
|
+
interfaces_str = []
|
75
|
+
interfaces.each do |interface|
|
76
|
+
interfaces_str << interface.to_s
|
77
|
+
end
|
78
|
+
str << "#{interfaces_str.join(', ')} ]"
|
79
|
+
|
80
|
+
case super_class.description
|
81
|
+
when NewClassDesc
|
82
|
+
str << ", @super_class: #{super_class.description.class_name.to_s}"
|
83
|
+
when Reference
|
84
|
+
str << ", @super_class: #{super_class.description.to_s}"
|
85
|
+
end
|
86
|
+
|
87
|
+
str
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
# Deserializes the number of interface names
|
93
|
+
#
|
94
|
+
# @param io [IO] the io to read from
|
95
|
+
# @return [Fixnum] if deserialization is possible
|
96
|
+
# @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
|
97
|
+
def decode_interfaces_length(io)
|
98
|
+
fields_length = io.read(4)
|
99
|
+
if fields_length.nil? || fields_length.length != 4
|
100
|
+
raise Rex::Java::Serialization::DecodeError, 'Failed to unserialize ProxyClassDesc'
|
101
|
+
end
|
102
|
+
|
103
|
+
fields_length.unpack('N')[0]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -21,11 +21,11 @@ module Rex
|
|
21
21
|
#
|
22
22
|
# @param io [IO] the io to read from
|
23
23
|
# @return [self] if deserialization succeeds
|
24
|
-
# @raise [
|
24
|
+
# @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
|
25
25
|
def decode(io)
|
26
26
|
handle_raw = io.read(4)
|
27
27
|
unless handle_raw && handle_raw.length == 4
|
28
|
-
raise ::
|
28
|
+
raise Rex::Java::Serialization::DecodeError, 'Failed to unserialize Reference'
|
29
29
|
end
|
30
30
|
|
31
31
|
self.handle = handle_raw.unpack('N')[0]
|
@@ -36,10 +36,10 @@ module Rex
|
|
36
36
|
# Serializes the Rex::Java::Serialization::Model::Reference
|
37
37
|
#
|
38
38
|
# @return [String] if serialization succeeds
|
39
|
-
# @raise [
|
39
|
+
# @raise [Rex::Java::Serialization::EncodeError] if serialization doesn't succeed
|
40
40
|
def encode
|
41
41
|
if handle < BASE_WIRE_HANDLE
|
42
|
-
raise ::
|
42
|
+
raise Rex::Java::Serialization::EncodeError, 'Failed to serialize Reference'
|
43
43
|
end
|
44
44
|
|
45
45
|
encoded = ''
|
@@ -34,7 +34,7 @@ module Rex
|
|
34
34
|
#
|
35
35
|
# @param io [IO] the io to read from
|
36
36
|
# @return [self] if deserialization succeeds
|
37
|
-
# @raise [
|
37
|
+
# @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
|
38
38
|
def decode(io)
|
39
39
|
self.magic = decode_magic(io)
|
40
40
|
self.version = decode_version(io)
|
@@ -50,7 +50,7 @@ module Rex
|
|
50
50
|
# Serializes the Rex::Java::Serialization::Model::Stream
|
51
51
|
#
|
52
52
|
# @return [String] if serialization succeeds
|
53
|
-
# @raise [
|
53
|
+
# @raise [Rex::Java::Serialization::EncodeError] if serialization doesn't succeed
|
54
54
|
def encode
|
55
55
|
encoded = ''
|
56
56
|
encoded << [magic].pack('n')
|
@@ -63,7 +63,7 @@ module Rex
|
|
63
63
|
|
64
64
|
# Adds an element to the references array
|
65
65
|
#
|
66
|
-
# @param
|
66
|
+
# @param ref [Rex::Java::Serialization::Model::Element] the object to save as reference dst
|
67
67
|
def add_reference(ref)
|
68
68
|
self.references.push(ref)
|
69
69
|
end
|
@@ -92,12 +92,12 @@ module Rex
|
|
92
92
|
#
|
93
93
|
# @param io [IO] the io to read from
|
94
94
|
# @return [String] if deserialization succeeds
|
95
|
-
# @raise [
|
95
|
+
# @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
|
96
96
|
def decode_magic(io)
|
97
97
|
magic = io.read(2)
|
98
98
|
|
99
99
|
unless magic && magic.length == 2 && magic.unpack('n')[0] == STREAM_MAGIC
|
100
|
-
raise ::
|
100
|
+
raise Rex::Java::Serialization::DecodeError, 'Failed to unserialize Stream'
|
101
101
|
end
|
102
102
|
|
103
103
|
STREAM_MAGIC
|
@@ -107,11 +107,11 @@ module Rex
|
|
107
107
|
#
|
108
108
|
# @param io [IO] the io to read from
|
109
109
|
# @return [Fixnum] if deserialization succeeds
|
110
|
-
# @raise [
|
110
|
+
# @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
|
111
111
|
def decode_version(io)
|
112
112
|
version = io.read(2)
|
113
113
|
unless version && version.unpack('n')[0] == STREAM_VERSION
|
114
|
-
raise ::
|
114
|
+
raise Rex::Java::Serialization::DecodeError, 'Failed to unserialize Stream'
|
115
115
|
end
|
116
116
|
|
117
117
|
STREAM_VERSION
|
@@ -26,11 +26,11 @@ module Rex
|
|
26
26
|
#
|
27
27
|
# @param io [IO] the io to read from
|
28
28
|
# @return [self] if deserialization succeeds
|
29
|
-
# @raise [
|
29
|
+
# @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
|
30
30
|
def decode(io)
|
31
31
|
raw_length = io.read(2)
|
32
32
|
if raw_length.nil? || raw_length.length != 2
|
33
|
-
raise ::
|
33
|
+
raise Rex::Java::Serialization::DecodeError, 'Failed to unserialize Utf'
|
34
34
|
end
|
35
35
|
self.length = raw_length.unpack('n')[0]
|
36
36
|
|
@@ -39,7 +39,7 @@ module Rex
|
|
39
39
|
else
|
40
40
|
self.contents = io.read(length)
|
41
41
|
if contents.nil? || contents.length != length
|
42
|
-
raise ::
|
42
|
+
raise Rex::Java::Serialization::DecodeError, 'Failed to unserialize Utf'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# -*- coding => binary -*-
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
#
|
7
|
+
# This class provides a thread-friendly hash file store in JSON format
|
8
|
+
#
|
9
|
+
module Rex
|
10
|
+
class JSONHashFile
|
11
|
+
|
12
|
+
attr_accessor :path
|
13
|
+
|
14
|
+
def initialize(path)
|
15
|
+
self.path = path
|
16
|
+
@lock = Mutex.new
|
17
|
+
@hash = {}
|
18
|
+
@last = 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](k)
|
22
|
+
synced_update
|
23
|
+
@hash[k]
|
24
|
+
end
|
25
|
+
|
26
|
+
def []=(k,v)
|
27
|
+
synced_update do
|
28
|
+
@hash[k] = v
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def keys
|
33
|
+
synced_update
|
34
|
+
@hash.keys
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete(k)
|
38
|
+
synced_update do
|
39
|
+
@hash.delete(k)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def clear
|
44
|
+
synced_update do
|
45
|
+
@hash.clear
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# Save the file, but prevent thread & process contention
|
52
|
+
def synced_update(&block)
|
53
|
+
@lock.synchronize do
|
54
|
+
::FileUtils.mkdir_p(::File.dirname(path))
|
55
|
+
::File.open(path, ::File::RDWR|::File::CREAT) do |fd|
|
56
|
+
fd.flock(::File::LOCK_EX)
|
57
|
+
|
58
|
+
# Reload and merge if the file has changed recently
|
59
|
+
if fd.stat.mtime.to_f > @last
|
60
|
+
parse_data(fd.read).merge(@hash).each_pair do |k,v|
|
61
|
+
@hash[k] = v
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
res = nil
|
66
|
+
|
67
|
+
# Update the file on disk if new data is written
|
68
|
+
if block_given?
|
69
|
+
res = block.call
|
70
|
+
fd.rewind
|
71
|
+
fd.write(JSON.pretty_generate(@hash))
|
72
|
+
fd.sync
|
73
|
+
fd.truncate(fd.pos)
|
74
|
+
end
|
75
|
+
|
76
|
+
@last = fd.stat.mtime.to_f
|
77
|
+
|
78
|
+
res
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def parse_data(data)
|
84
|
+
return {} if data.to_s.strip.length == 0
|
85
|
+
begin
|
86
|
+
JSON.parse(data)
|
87
|
+
rescue JSON::ParserError => e
|
88
|
+
# elog("JSONHashFile @ #{path} was corrupt: #{e.class} #{e}"
|
89
|
+
{}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
data/lib/rex/logging/log_sink.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- coding: binary -*-
|
2
|
+
module Rex
|
3
|
+
module Logging
|
4
|
+
module Sinks
|
5
|
+
|
6
|
+
###
|
7
|
+
#
|
8
|
+
# This class implements the LogSink interface and backs it against a
|
9
|
+
# file on disk with a Timestamp.
|
10
|
+
#
|
11
|
+
###
|
12
|
+
class TimestampFlatfile < Flatfile
|
13
|
+
|
14
|
+
def log(sev, src, level, msg, from) # :nodoc:
|
15
|
+
msg = msg.chop.gsub(/\x1b\[[0-9;]*[mG]/,'').gsub(/[\x01-\x02]/, " ")
|
16
|
+
fd.write("[#{get_current_timestamp}] #{msg}\n")
|
17
|
+
fd.flush
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end end end
|
@@ -141,9 +141,9 @@ module Rex
|
|
141
141
|
|
142
142
|
def report_web_page(&block)
|
143
143
|
return unless(in_issue && has_text)
|
144
|
-
return unless @state[:web_site]
|
145
|
-
return unless @state[:response_headers]
|
146
|
-
return unless @state[:uri]
|
144
|
+
return unless @state[:web_site].present?
|
145
|
+
return unless @state[:response_headers].present?
|
146
|
+
return unless @state[:uri].present?
|
147
147
|
web_page_info = {}
|
148
148
|
web_page_info[:web_site] = @state[:web_site]
|
149
149
|
web_page_info[:path] = @state[:uri].path
|
@@ -187,31 +187,21 @@ module Rex
|
|
187
187
|
|
188
188
|
def record_request_and_response
|
189
189
|
return unless(in_issue && has_text)
|
190
|
-
return unless @state[:web_site]
|
190
|
+
return unless @state[:web_site].present?
|
191
191
|
really_original_traffic = unindent_and_crlf(@text)
|
192
|
-
|
193
|
-
|
194
|
-
content_length = 0
|
195
|
-
if request_headers_text =~ /\ncontent-length:\s+([0-9]+)/mni
|
196
|
-
content_length = $1.to_i
|
197
|
-
end
|
198
|
-
if(content_length > 0) and (split_traffic[1].to_s.size >= content_length)
|
199
|
-
request_body_text = split_traffic[1].to_s[0,content_length]
|
200
|
-
else
|
201
|
-
request_body_text = nil
|
202
|
-
end
|
203
|
-
response_headers_text = split_traffic[1].to_s[content_length,split_traffic[1].to_s.size].lstrip
|
204
|
-
request = request_headers_text
|
205
|
-
return unless(request && response_headers_text)
|
206
|
-
response_body_text = split_traffic[2]
|
192
|
+
request_headers, request_body, response_headers, response_body = really_original_traffic.split(/\r\n\r\n/)
|
193
|
+
return unless(request_headers && response_headers)
|
207
194
|
req_header = Rex::Proto::Http::Packet::Header.new
|
208
195
|
res_header = Rex::Proto::Http::Packet::Header.new
|
209
|
-
req_header.from_s
|
210
|
-
res_header.from_s
|
196
|
+
req_header.from_s request_headers.lstrip
|
197
|
+
res_header.from_s response_headers.lstrip
|
198
|
+
if response_body.blank?
|
199
|
+
response_body = ''
|
200
|
+
end
|
211
201
|
@state[:request_headers] = req_header
|
212
|
-
@state[:request_body] =
|
202
|
+
@state[:request_body] = request_body.lstrip
|
213
203
|
@state[:response_headers] = res_header
|
214
|
-
@state[:response_body] =
|
204
|
+
@state[:response_body] = response_body.lstrip
|
215
205
|
end
|
216
206
|
|
217
207
|
# Appscan tab-indents which makes parsing a little difficult. They
|
data/lib/rex/parser/fs/ntfs.rb
CHANGED
@@ -181,7 +181,8 @@ module Rex
|
|
181
181
|
|
182
182
|
data = ''
|
183
183
|
while data.length < size_wanted
|
184
|
-
|
184
|
+
# Use a 4Mb block size to avoid target memory consumption
|
185
|
+
data << @file_handler.read([size_wanted - data.length, 2**22].min)
|
185
186
|
end
|
186
187
|
attribut << data
|
187
188
|
end
|
@@ -196,8 +197,11 @@ module Rex
|
|
196
197
|
#
|
197
198
|
# return the attribute list from the MFT record
|
198
199
|
# deal with resident and non resident attributes (but not $DATA due to performance issue)
|
200
|
+
# if lazy = True, this function only gather essential non resident attributes
|
201
|
+
# (INDEX_ALLOCATION). Non resident attributes can still be gathered later with
|
202
|
+
# cluster_from_attribute_non_resident function.
|
199
203
|
#
|
200
|
-
def mft_record_attribute(mft_record)
|
204
|
+
def mft_record_attribute(mft_record, lazy=true)
|
201
205
|
attribute_list_offset = mft_record[20, 2].unpack('C')[0]
|
202
206
|
curs = attribute_list_offset
|
203
207
|
attribute_identifier = mft_record[curs, 4].unpack('V')[0]
|
@@ -213,10 +217,11 @@ module Rex
|
|
213
217
|
res[attribute_identifier] = mft_record[curs + content_offset, content_size]
|
214
218
|
else
|
215
219
|
# non resident
|
216
|
-
if attribute_identifier ==
|
217
|
-
|
218
|
-
else
|
220
|
+
if attribute_identifier == INDEX_ALLOCATION_ID or
|
221
|
+
(!lazy and attribute_identifier != DATA_ATTRIBUTE_ID)
|
219
222
|
res[attribute_identifier] = cluster_from_attribute_non_resident(mft_record[curs, attribute_size])
|
223
|
+
else
|
224
|
+
res[attribute_identifier] = mft_record[curs, attribute_size]
|
220
225
|
end
|
221
226
|
end
|
222
227
|
if attribute_identifier == DATA_ATTRIBUTE_ID
|
@@ -17,7 +17,7 @@ module Rex
|
|
17
17
|
Msf::ServiceState::Closed
|
18
18
|
when "filtered"
|
19
19
|
Msf::ServiceState::Filtered
|
20
|
-
|
20
|
+
else
|
21
21
|
Msf::ServiceState::Unknown
|
22
22
|
end
|
23
23
|
end
|
@@ -277,6 +277,8 @@ module Rex
|
|
277
277
|
port_hash[:state] = determine_port_state(v)
|
278
278
|
when "name"
|
279
279
|
port_hash[:name] = v
|
280
|
+
when "tunnel"
|
281
|
+
port_hash[:name] = "#{v}/#{port_hash[:name] || 'unknown'}"
|
280
282
|
when "reason"
|
281
283
|
port_hash[:reason] = v
|
282
284
|
when "product"
|