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


113
114
115
116
117
118
119
120
121
# File 'lib/msf/core/payload/transport_config.rb', line 113

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


33
34
35
36
37
38
39
40
# File 'lib/msf/core/payload/transport_config.rb', line 33

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


71
72
73
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
# File 'lib/msf/core/payload/transport_config.rb', line 71

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


42
43
44
45
46
47
48
49
# File 'lib/msf/core/payload/transport_config.rb', line 42

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


25
26
27
28
29
30
31
# File 'lib/msf/core/payload/transport_config.rb', line 25

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


104
105
106
107
108
109
110
111
# File 'lib/msf/core/payload/transport_config.rb', line 104

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


12
13
14
15
16
17
# File 'lib/msf/core/payload/transport_config.rb', line 12

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


19
20
21
22
23
# File 'lib/msf/core/payload/transport_config.rb', line 19

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

#transport_uri_components(opts = {}) ⇒ Object


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

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