Skip to content

Commit 53af3f2

Browse files
author
Brent Cook
committed
Land rapid7#7863, address tlv enum consistency (and add spec!)
2 parents ff2b8dc + 2c8cd80 commit 53af3f2

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

lib/rex/post/meterpreter/client_core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def migrate(target_pid, writable_dir = nil, opts = {})
509509
end
510510

511511
request.add_tlv( TLV_TYPE_MIGRATE_PID, target_pid )
512-
request.add_tlv( TLV_TYPE_MIGRATE_PAYLOAD_LEN, migrate_payload.length )
512+
request.add_tlv( TLV_TYPE_MIGRATE_LEN, migrate_payload.length )
513513
request.add_tlv( TLV_TYPE_MIGRATE_PAYLOAD, migrate_payload, false, client.capabilities[:zlib])
514514
request.add_tlv( TLV_TYPE_MIGRATE_STUB_LEN, migrate_stub.length )
515515
request.add_tlv( TLV_TYPE_MIGRATE_STUB, migrate_stub, false, client.capabilities[:zlib])

lib/rex/post/meterpreter/packet.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module Meterpreter
8080
TLV_TYPE_LIBRARY_PATH = TLV_META_TYPE_STRING | 400
8181
TLV_TYPE_TARGET_PATH = TLV_META_TYPE_STRING | 401
8282
TLV_TYPE_MIGRATE_PID = TLV_META_TYPE_UINT | 402
83-
TLV_TYPE_MIGRATE_PAYLOAD_LEN = TLV_META_TYPE_UINT | 403
83+
TLV_TYPE_MIGRATE_LEN = TLV_META_TYPE_UINT | 403
8484
TLV_TYPE_MIGRATE_PAYLOAD = TLV_META_TYPE_STRING | 404
8585
TLV_TYPE_MIGRATE_ARCH = TLV_META_TYPE_UINT | 405
8686
TLV_TYPE_MIGRATE_BASE_ADDR = TLV_META_TYPE_UINT | 407
@@ -195,7 +195,7 @@ def inspect
195195
when TLV_TYPE_LIBRARY_PATH; "LIBRARY-PATH"
196196
when TLV_TYPE_TARGET_PATH; "TARGET-PATH"
197197
when TLV_TYPE_MIGRATE_PID; "MIGRATE-PID"
198-
when TLV_TYPE_MIGRATE_PAYLOAD_LEN; "MIGRATE-PAYLOAD-LEN"
198+
when TLV_TYPE_MIGRATE_LEN; "MIGRATE-LEN"
199199
when TLV_TYPE_MIGRATE_PAYLOAD; "MIGRATE-PAYLOAD"
200200
when TLV_TYPE_MIGRATE_ARCH; "MIGRATE-ARCH"
201201
when TLV_TYPE_MIGRATE_BASE_ADDR; "MIGRATE-BASE-ADDR"

spec/lib/rex/post/meterpreter/packet_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,27 @@
8181
end
8282
end
8383

84+
context "Any non group TLV_TYPE" do
85+
subject(:tlv_types){
86+
excludedTypes = ["TLV_TYPE_ANY", "TLV_TYPE_EXCEPTION", "TLV_TYPE_CHANNEL_DATA_GROUP", "TLV_TYPE_TRANS_GROUP", "TLV_TYPE_CIPHER_PARAMETERS"]
87+
typeList = []
88+
Rex::Post::Meterpreter.constants.each do |type|
89+
typeList << type.to_s if type.to_s.include?("TLV_TYPE") && !excludedTypes.include?(type.to_s)
90+
end
91+
typeList
92+
}
93+
94+
it "will not raise error on inspect" do
95+
tlv_types.each do |type|
96+
inspectable = Rex::Post::Meterpreter::Tlv.new(
97+
Rex::Post::Meterpreter.const_get(type),
98+
"test"
99+
)
100+
expect(inspectable.inspect).to be_a_kind_of String
101+
end
102+
end
103+
end
104+
84105
context "#to_r" do
85106
it "should return the raw bytes of the TLV to send over the wire" do
86107
tlv_bytes = "\x00\x00\x00\r\x00\x01\x00\ntest\x00"

0 commit comments

Comments
 (0)