diff --git a/lib/rex/proto/acpp/message.rb b/lib/rex/proto/acpp/message.rb index 1675027d60..0538a38431 100644 --- a/lib/rex/proto/acpp/message.rb +++ b/lib/rex/proto/acpp/message.rb @@ -36,8 +36,9 @@ module ACPP # checksum. Adler32 is used to compute the checksum. # # The message payload is a bit of an unknown right now, as it *seems* like - # the payload always comes in a subsequent request. - + # the payload always comes in a subsequent request. Simply appending + # a payload to the existing message does not appear to work (but this needs + # more testing) # This was taken from airport-util's AirportInforRecord for ease of copying, but can # also be obtained by XOR'ing the null-padded known plain text with the appropriate 32-byte @@ -103,6 +104,12 @@ module ACPP other.payload == @payload end + # Decodes the provided data into a Message + # + # @param data [String] the data to parse as a Message + # @param validate_checksum [Boolean] true to validate the message and + # payload checksums, false to not. Defaults to true. + # @return [Message] the decoded Message def self.decode(data, validate_checksum = true) data = data.dup fail "Incorrect ACPP message size #{data.size} -- must be 128" unless data.size == 128 @@ -146,7 +153,7 @@ module ACPP 'acpp' + [ 1, # unknown1 message_checksum, - Zlib::adler32(payload), + Zlib::adler32(@payload), @payload.size, 0, 0, # unknown2 @type, diff --git a/spec/lib/rex/proto/acpp/message_spec.rb b/spec/lib/rex/proto/acpp/message_spec.rb index bfde67aa3b..b10b7a0d60 100644 --- a/spec/lib/rex/proto/acpp/message_spec.rb +++ b/spec/lib/rex/proto/acpp/message_spec.rb @@ -60,10 +60,11 @@ describe Rex::Proto::ACPP::Message do it 'decodes properly when the non-required checksum is correct' do expect(retrieve_public_message).to eq(described_class.decode(retrieve_public_bin, false)) end - it 'fails to decode the required message checksum is incorrect' do + it 'decodes properly when the message checksum is incorrect' do retrieve_public_bin[7,4] = "\x01\x02\x03\x04" expect { described_class.decode(retrieve_public_bin) }.to raise_error(/message checksum/i) expect { described_class.decode(retrieve_public_bin, true) }.to raise_error(/message checksum/i) + expect(retrieve_public_message).to eq(described_class.decode(retrieve_public_bin, false)) end end end