Skip to content

Commit a41fd9d

Browse files
authored
Land #18532, Fix db2 scanner module crashes
2 parents e011fbe + fc988c2 commit a41fd9d

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

lib/metasploit/framework/login_scanner/db2.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def send_probe(database_name)
9292

9393
response_data = {}
9494
if valid_response?(response)
95-
packet = Rex::Proto::DRDA::SERVER_PACKET.new.read(response)
95+
packet = Rex::Proto::DRDA::Packet::SERVER_PACKET.new.read(response)
9696
response_data = Rex::Proto::DRDA::Utils.server_packet_info(packet)
9797
end
9898
response_data
@@ -115,7 +115,7 @@ def set_sane_defaults
115115
# @param response [String] The unprocessed response packet
116116
# @return [Boolean] Whether the authentication was successful
117117
def successful_login?(response)
118-
packet = Rex::Proto::DRDA::SERVER_PACKET.new.read(response)
118+
packet = Rex::Proto::DRDA::Packet::SERVER_PACKET.new.read(response)
119119
packet_info = Rex::Proto::DRDA::Utils.server_packet_info(packet)
120120
if packet_info[:db_login_success]
121121
true

lib/msf/core/exploit/remote/db2.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def db2_probe(timeout=5)
4444

4545
return {} if not resp
4646
return {} if resp.length == 0
47-
pkt = Rex::Proto::DRDA::SERVER_PACKET.new.read(resp)
47+
pkt = Rex::Proto::DRDA::Packet::SERVER_PACKET.new.read(resp)
4848
return Rex::Proto::DRDA::Utils.server_packet_info(pkt)
4949
end
5050

@@ -58,7 +58,7 @@ def db2_check_login(timeout=5)
5858
resp = sock.get_once
5959
return {} if not resp
6060
return {} if resp.length == 0
61-
pkt = Rex::Proto::DRDA::SERVER_PACKET.new.read(resp)
61+
pkt = Rex::Proto::DRDA::Packet::SERVER_PACKET.new.read(resp)
6262
return Rex::Proto::DRDA::Utils.server_packet_info(pkt)
6363
end
6464

lib/rex/proto/drda/packet.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class RespError < Error; end
1212
# http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.drda/db2z_excsat.htm
1313
class MGRLVLLS_PARAM < Struct.new(:length, :codepoint, :payload)
1414
def initialize(args={})
15-
self[:codepoint] = Constants::MGRLVLLS
15+
self[:codepoint] = Rex::Proto::DRDA::Constants::MGRLVLLS
1616
self[:payload] = "\x14\x03\x00\x0a\x24\x07\x00\x0a" +
1717
"\x14\x74\x00\x05\x24\x0f\x00\x08" +
1818
"\x14\x40\x00\x09\x1c\x08\x04\xb8"
@@ -32,7 +32,7 @@ def initialize(args={})
3232
self[:magic] = 0xd0
3333
self[:format] = 0x41
3434
self[:correlid] = 1
35-
self[:codepoint] = Constants::EXCSAT
35+
self[:codepoint] = Rex::Proto::DRDA::Constants::EXCSAT
3636
self[:mgrlvlls] = args[:mgrlvlls] || MGRLVLLS_PARAM.new.to_s
3737
self[:length] = (10 + self[:mgrlvlls].to_s.size)
3838
self[:length2] = self[:length]-6
@@ -50,7 +50,7 @@ def to_s
5050
class SECMEC_PARAM < Struct.new(:length, :codepoint, :payload)
5151
def initialize(args={})
5252
self[:length] = 6
53-
self[:codepoint] = Constants::SECMEC
53+
self[:codepoint] = Rex::Proto::DRDA::Constants::SECMEC
5454
self[:payload] = 3 # Plaintext username and password.
5555
end
5656
def to_s
@@ -62,7 +62,7 @@ def to_s
6262
class RDBNAM_PARAM < Struct.new(:length, :codepoint, :payload)
6363
def initialize(args={})
6464
self[:length] = 22 # Since the database name is padded out.
65-
self[:codepoint] = Constants::RDBNAM
65+
self[:codepoint] = Rex::Proto::DRDA::Constants::RDBNAM
6666
self[:payload] = encode(args[:payload].to_s)
6767
end
6868

@@ -90,7 +90,7 @@ def initialize(args={})
9090
self[:magic] = 0xd0
9191
self[:format] = args[:format] || 0x01
9292
self[:correlid] = 2
93-
self[:codepoint] = Constants::ACCSEC
93+
self[:codepoint] = Rex::Proto::DRDA::Constants::ACCSEC
9494
self[:secmec] = SECMEC_PARAM.new.to_s
9595
if args[:dbname] # Include a database name if we're given one.
9696
self[:rdbnam] = RDBNAM_PARAM.new(:payload => args[:dbname]).to_s
@@ -144,7 +144,7 @@ def read(str="")
144144
rest = str[10,self[:length2]-4]
145145
i = 0
146146
while (i < rest.size)
147-
if self[:codepoint] == Constants::SQLCARD # These aren't DDM's.
147+
if self[:codepoint] == Rex::Proto::DRDA::Constants::SQLCARD # These aren't DDM's.
148148
this_param = rest[i,self[:length]-10]
149149
else
150150
this_param = DDM_PARAM.new.read(rest[i,rest.size])
@@ -193,7 +193,7 @@ def sz; self.to_s.size; end
193193

194194
class PASSWORD_PARAM < Struct.new(:length, :codepoint, :payload)
195195
def initialize(args={})
196-
self[:codepoint] = Constants::PASSWORD
196+
self[:codepoint] = Rex::Proto::DRDA::Constants::PASSWORD
197197
self[:payload] = Rex::Text.to_ebcdic(args[:payload].to_s)
198198
self[:length] = self[:payload].size + 4
199199
end
@@ -207,7 +207,7 @@ def to_s
207207

208208
class USERID_PARAM < Struct.new(:length, :codepoint, :payload)
209209
def initialize(args={})
210-
self[:codepoint] = Constants::USERID
210+
self[:codepoint] = Rex::Proto::DRDA::Constants::USERID
211211
self[:payload] = Rex::Text.to_ebcdic(args[:payload].to_s)
212212
self[:length] = self[:payload].size + 4
213213
end
@@ -225,7 +225,7 @@ def initialize(args={}) # Takes :dbname, :dbpass, :dbuser
225225
self[:magic] = 0xd0
226226
self[:format] = 0x01
227227
self[:correlid] = 2
228-
self[:codepoint] = Constants::SECCHK
228+
self[:codepoint] = Rex::Proto::DRDA::Constants::SECCHK
229229
self[:secmec] = SECMEC_PARAM.new.to_s
230230
if args[:dbname] # Include a database name if we're given one.
231231
self[:rdbnam] = RDBNAM_PARAM.new(:payload => args[:dbname]).to_s

lib/rex/proto/drda/utils.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class Utils
1010
# a reponse from the target server.
1111
def self.client_probe(dbname=nil)
1212
pkt = [
13-
EXCSAT_DDM.new,
14-
ACCSEC_DDM.new(:dbname => dbname)
13+
Rex::Proto::DRDA::Packet::EXCSAT_DDM.new,
14+
Rex::Proto::DRDA::Packet::ACCSEC_DDM.new(:dbname => dbname)
1515
]
1616
pkt.map {|x| x.to_s}.join
1717
end
@@ -23,15 +23,15 @@ def self.client_auth(args={})
2323
dbuser = args[:dbuser]
2424
dbpass = args[:dbpass]
2525
pkt = [
26-
ACCSEC_DDM.new(:format => 0x41),
27-
SECCHK_DDM.new(:dbname => dbname, :dbuser => dbuser, :dbpass => dbpass)
26+
Rex::Proto::DRDA::Packet::ACCSEC_DDM.new(:format => 0x41),
27+
Rex::Proto::DRDA::Packet::SECCHK_DDM.new(:dbname => dbname, :dbuser => dbuser, :dbpass => dbpass)
2828
]
2929
pkt.map {|x| x.to_s}.join
3030
end
3131

3232
def self.server_packet_info(obj)
3333
info_hash = {}
34-
return info_hash unless obj.kind_of? Rex::Proto::DRDA::SERVER_PACKET
34+
return info_hash unless obj.kind_of? Rex::Proto::DRDA::Packet::SERVER_PACKET
3535
obj.each do |ddm|
3636
case ddm.codepoint
3737
when Constants::EXCSATRD

0 commit comments

Comments
 (0)