Module: Msf::Payload::UUID::Options
- Includes:
- Rex::Payloads::Meterpreter::UriChecksum
- Included in:
- Android, Android::MeterpreterLoader, Android::ReverseHttp, Java::BindTcp, Java::MeterpreterLoader, Java::ReverseHttp, Java::ReverseTcp, Multi::ReverseHttp, Php::ReverseTcp, Python::MeterpreterLoader, Python::ReverseHttp, TransportConfig, Windows::EncryptedPayloadOpts, Windows::EncryptedReverseTcp, Windows::ReverseHttp, Windows::ReverseHttp_x64
- Defined in:
- lib/msf/core/payload/uuid/options.rb
Overview
This module provides datastore option definitions and helper methods for payload modules that support UUIDs
Constant Summary
Constants included from Rex::Payloads::Meterpreter::UriChecksum
Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_CONN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_CONN_MAX_LEN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITJ, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITP, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITW, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INIT_CONN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_MIN_LEN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_MODES, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_UUID_MIN_LEN
Instance Method Summary collapse
-
#generate_payload_uuid ⇒ Object
Generate a Payload UUID.
-
#generate_uri_uuid_mode(mode, len = nil, uuid: nil) ⇒ String
Generates a URI with a given checksum and optionally with an embedded UUID if the desired length can accommodate it.
- #initialize(info = {}) ⇒ Object
-
#record_payload_uuid(uuid, info = {}) ⇒ Object
Store a UUID in the JSON database if tracking is enabled.
-
#record_payload_uuid_url(uuid, url) ⇒ Object
Store a UUID URL in the database if tracking is enabled.
Methods included from Rex::Payloads::Meterpreter::UriChecksum
#generate_uri_checksum, #generate_uri_uuid, #process_uri_resource, #uri_checksum_lookup
Instance Method Details
#generate_payload_uuid ⇒ Object
Generate a Payload UUID
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/msf/core/payload/uuid/options.rb', line 53 def generate_payload_uuid conf = { arch: self.arch, platform: self.platform } # Handle user-specified seed values if datastore['PayloadUUIDSeed'].to_s.length > 0 conf[:seed] = datastore['PayloadUUIDSeed'].to_s end # Handle user-specified raw payload UID values if datastore['PayloadUUIDRaw'].to_s.length > 0 puid_raw = [datastore['PayloadUUIDRaw'].to_s].pack("H*") if puid_raw.length != 8 raise ArgumentError, "The PayloadUUIDRaw value must be exactly 16 bytes of hex" end conf.delete(:seed) conf[:puid] = puid_raw end if datastore['PayloadUUIDName'].to_s.length > 0 && ! datastore['PayloadUUIDTracking'] raise ArgumentError, "The PayloadUUIDName value is ignored unless PayloadUUIDTracking is enabled" end # Generate the UUID object uuid = Msf::Payload::UUID.new(conf) record_payload_uuid(uuid) uuid end |
#generate_uri_uuid_mode(mode, len = nil, uuid: nil) ⇒ String
Generates a URI with a given checksum and optionally with an embedded UUID if the desired length can accommodate it.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/msf/core/payload/uuid/options.rb', line 33 def generate_uri_uuid_mode(mode, len = nil, uuid: nil) sum = uri_checksum_lookup(mode) # The URI length may not have room for an embedded UUID if len && len < URI_CHECKSUM_UUID_MIN_LEN # Throw an error if the user set a seed, but there is no room for it if datastore['PayloadUUIDSeed'].to_s.length > 0 || datastore['PayloadUUIDRaw'].to_s.length > 0 raise ArgumentError, "A PayloadUUIDSeed or PayloadUUIDRaw value was specified, but this payload doesn't have enough room for a UUID" end return "/" + generate_uri_checksum(sum, len, prefix="") end uuid ||= generate_payload_uuid uri = generate_uri_uuid(sum, uuid, len) record_payload_uuid_url(uuid, uri) uri end |
#initialize(info = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/msf/core/payload/uuid/options.rb', line 14 def initialize(info = {}) super ( [ Msf::OptString.new('PayloadUUIDSeed', [ false, 'A string to use when generating the payload UUID (deterministic)']), Msf::OptString.new('PayloadUUIDRaw', [ false, 'A hex string representing the raw 8-byte PUID value for the UUID']), Msf::OptString.new('PayloadUUIDName', [ false, 'A human-friendly name to reference this unique payload (requires tracking)']), Msf::OptBool.new('PayloadUUIDTracking', [ true, 'Whether or not to automatically register generated UUIDs', false]), ], self.class) end |
#record_payload_uuid(uuid, info = {}) ⇒ Object
Store a UUID in the JSON database if tracking is enabled
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/msf/core/payload/uuid/options.rb', line 87 def record_payload_uuid(uuid, info={}) return unless datastore['PayloadUUIDTracking'] # skip if there is no active database return if !(framework.db && framework.db.active) uuid_info = info.merge({ uuid: uuid.puid_hex, arch: uuid.arch, platform: uuid.platform, timestamp: uuid., }) if datastore['PayloadUUIDSeed'].to_s.length > 0 uuid_info[:seed] = datastore['PayloadUUIDSeed'] end if datastore['PayloadUUIDName'].to_s.length > 0 uuid_info[:name] = datastore['PayloadUUIDName'] end framework.db.create_payload(uuid_info) end |
#record_payload_uuid_url(uuid, url) ⇒ Object
Store a UUID URL in the database if tracking is enabled
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/msf/core/payload/uuid/options.rb', line 111 def record_payload_uuid_url(uuid, url) return unless datastore['PayloadUUIDTracking'] # skip if there is no active database return if !(framework.db && framework.db.active) payload_info = { uuid: uuid.puid_hex, } payload = framework.db.get_payload(payload_info) unless payload.nil? urls = payload.urls.nil? ? [] : payload.urls urls << url urls.uniq! framework.db.update_payload({id: payload.id, urls: urls}) end end |