Module: Msf::Payload::TransportConfig

Overview

This module contains helper functions for creating the transport configuration stubs that are used for Meterpreter payloads.

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

Methods included from UUID::Options

#generate_payload_uuid, #generate_uri_uuid_mode, #initialize, #record_payload_uuid, #record_payload_uuid_url

Methods included from Rex::Payloads::Meterpreter::UriChecksum

#generate_uri_checksum, #generate_uri_uuid, #process_uri_resource, #uri_checksum_lookup

Methods included from Pingback::Options

#initialize

Instance Method Details

#transport_config_bind_named_pipe(opts = {}) ⇒ Object


116
117
118
119
120
121
122
123
124
# File 'lib/msf/core/payload/transport_config.rb', line 116

def transport_config_bind_named_pipe(opts={})
  ds = opts[:datastore] || datastore
  {
    scheme:     'pipe',
    lhost:      '.',
    uri:        "/#{ds['PIPENAME']}",
  }.merge(timeout_config(opts))

end

#transport_config_bind_tcp(opts = {}) ⇒ Object


36
37
38
39
40
41
42
43
# File 'lib/msf/core/payload/transport_config.rb', line 36

def transport_config_bind_tcp(opts={})
  ds = opts[:datastore] || datastore
  {
    scheme: 'tcp',
    lhost:  ds['LHOST'],
    lport:  ds['LPORT'].to_i
  }.merge(timeout_config(opts))
end

#transport_config_reverse_http(opts = {}) ⇒ Object


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/msf/core/payload/transport_config.rb', line 74

def transport_config_reverse_http(opts={})
  # most cases we'll have a URI already, but in case we don't
  # we should ask for a connect to happen given that this is
  # going up as part of the stage.
  uri = opts[:uri]
  unless uri
    type = opts[:stageless] == true ? :init_connect : :connect
    sum = uri_checksum_lookup(type)
    uri = luri + generate_uri_uuid(sum, opts[:uuid])
  end

  ds = opts[:datastore] || datastore
  opts[:scheme] ||= 'http'
  scheme, lhost, lport = transport_uri_components(opts)

  {
    scheme:          scheme,
    lhost:           lhost,
    lport:           lport.to_i,
    uri:             uri,
    ua:              ds['HttpUserAgent'],
    proxy_host:      ds['HttpProxyHost'],
    proxy_port:      ds['HttpProxyPort'],
    proxy_type:      ds['HttpProxyType'],
    proxy_user:      ds['HttpProxyUser'],
    proxy_pass:      ds['HttpProxyPass'],
    host:            ds['HttpHostHeader'],
    cookie:          ds['HttpCookie'],
    referer:         ds['HttpReferer'],
    custom_headers:  get_custom_headers(ds)
  }.merge(timeout_config(opts))
end

#transport_config_reverse_https(opts = {}) ⇒ Object


45
46
47
48
49
50
51
52
# File 'lib/msf/core/payload/transport_config.rb', line 45

def transport_config_reverse_https(opts={})
  ds = opts[:datastore] || datastore
  opts[:scheme] ||= 'https'
  config = transport_config_reverse_http(opts)
  config[:ssl_cert_hash] = get_ssl_cert_hash(ds['StagerVerifySSLCert'],
                                             ds['HandlerSSLCert'])
  config
end

#transport_config_reverse_ipv6_tcp(opts = {}) ⇒ Object


28
29
30
31
32
33
34
# File 'lib/msf/core/payload/transport_config.rb', line 28

def transport_config_reverse_ipv6_tcp(opts={})
  ds = opts[:datastore] || datastore
  config = transport_config_reverse_tcp(opts)
  config[:scheme] = 'tcp6'
  config[:scope_id] = ds['SCOPEID']
  config
end

#transport_config_reverse_named_pipe(opts = {}) ⇒ Object


107
108
109
110
111
112
113
114
# File 'lib/msf/core/payload/transport_config.rb', line 107

def transport_config_reverse_named_pipe(opts={})
  ds = opts[:datastore] || datastore
  {
    scheme: 'pipe',
    lhost:  ds[:pipe_host] || ds['PIPEHOST'],
    uri:    "/#{ds[:pipe_host] || ds['PIPENAME']}"
  }.merge(timeout_config(opts))
end

#transport_config_reverse_tcp(opts = {}) ⇒ Object


15
16
17
18
19
20
# File 'lib/msf/core/payload/transport_config.rb', line 15

def transport_config_reverse_tcp(opts={})
  ds = opts[:datastore] || datastore
  config = transport_config_bind_tcp(opts)
  config[:lhost] = ds['LHOST']
  config
end

#transport_config_reverse_udp(opts = {}) ⇒ Object


22
23
24
25
26
# File 'lib/msf/core/payload/transport_config.rb', line 22

def transport_config_reverse_udp(opts={})
  config =transport_config_reverse_tcp(opts)
  config[:scheme] = 'udp'
  config
end

#transport_uri_components(opts = {}) ⇒ Object


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/msf/core/payload/transport_config.rb', line 54

def transport_uri_components(opts={})
  ds = opts[:datastore] || datastore
  if opts[:url]
    u = URI(opts[:url])
    scheme = u.scheme
    lhost = u.host
    lport = u.port
  else
    scheme = opts[:scheme]
    lhost = ds['LHOST']
    lport = ds['LPORT']
  end
  if ds['OverrideRequestHost']
    scheme = ds['OverrideScheme'] || scheme
    lhost = ds['OverrideLHOST'] || lhost
    lport = ds['OverrideLPORT'] || lport
  end
  [scheme, lhost, lport]
end