Land #7863, address tlv enum consistency (and add spec!)

bug/bundler_fix
Brent Cook 2017-01-23 09:42:57 -06:00
commit 53af3f286e
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
3 changed files with 24 additions and 3 deletions

View File

@ -509,7 +509,7 @@ class ClientCore < Extension
end
request.add_tlv( TLV_TYPE_MIGRATE_PID, target_pid )
request.add_tlv( TLV_TYPE_MIGRATE_PAYLOAD_LEN, migrate_payload.length )
request.add_tlv( TLV_TYPE_MIGRATE_LEN, migrate_payload.length )
request.add_tlv( TLV_TYPE_MIGRATE_PAYLOAD, migrate_payload, false, client.capabilities[:zlib])
request.add_tlv( TLV_TYPE_MIGRATE_STUB_LEN, migrate_stub.length )
request.add_tlv( TLV_TYPE_MIGRATE_STUB, migrate_stub, false, client.capabilities[:zlib])

View File

@ -80,7 +80,7 @@ TLV_TYPE_EXCEPTION_STRING = TLV_META_TYPE_STRING | 301
TLV_TYPE_LIBRARY_PATH = TLV_META_TYPE_STRING | 400
TLV_TYPE_TARGET_PATH = TLV_META_TYPE_STRING | 401
TLV_TYPE_MIGRATE_PID = TLV_META_TYPE_UINT | 402
TLV_TYPE_MIGRATE_PAYLOAD_LEN = TLV_META_TYPE_UINT | 403
TLV_TYPE_MIGRATE_LEN = TLV_META_TYPE_UINT | 403
TLV_TYPE_MIGRATE_PAYLOAD = TLV_META_TYPE_STRING | 404
TLV_TYPE_MIGRATE_ARCH = TLV_META_TYPE_UINT | 405
TLV_TYPE_MIGRATE_BASE_ADDR = TLV_META_TYPE_UINT | 407
@ -195,7 +195,7 @@ class Tlv
when TLV_TYPE_LIBRARY_PATH; "LIBRARY-PATH"
when TLV_TYPE_TARGET_PATH; "TARGET-PATH"
when TLV_TYPE_MIGRATE_PID; "MIGRATE-PID"
when TLV_TYPE_MIGRATE_PAYLOAD_LEN; "MIGRATE-PAYLOAD-LEN"
when TLV_TYPE_MIGRATE_LEN; "MIGRATE-LEN"
when TLV_TYPE_MIGRATE_PAYLOAD; "MIGRATE-PAYLOAD"
when TLV_TYPE_MIGRATE_ARCH; "MIGRATE-ARCH"
when TLV_TYPE_MIGRATE_BASE_ADDR; "MIGRATE-BASE-ADDR"

View File

@ -81,6 +81,27 @@ RSpec.describe Rex::Post::Meterpreter::Tlv do
end
end
context "Any non group TLV_TYPE" do
subject(:tlv_types){
excludedTypes = ["TLV_TYPE_ANY", "TLV_TYPE_EXCEPTION", "TLV_TYPE_CHANNEL_DATA_GROUP", "TLV_TYPE_TRANS_GROUP", "TLV_TYPE_CIPHER_PARAMETERS"]
typeList = []
Rex::Post::Meterpreter.constants.each do |type|
typeList << type.to_s if type.to_s.include?("TLV_TYPE") && !excludedTypes.include?(type.to_s)
end
typeList
}
it "will not raise error on inspect" do
tlv_types.each do |type|
inspectable = Rex::Post::Meterpreter::Tlv.new(
Rex::Post::Meterpreter.const_get(type),
"test"
)
expect(inspectable.inspect).to be_a_kind_of String
end
end
end
context "#to_r" do
it "should return the raw bytes of the TLV to send over the wire" do
tlv_bytes = "\x00\x00\x00\r\x00\x01\x00\ntest\x00"