librex 0.0.44 → 0.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  A non-official re-packaging of the Rex library as a gem for easy of usage of the Metasploit REX framework in a non Metasploit application. I received permission from HDM to create this package.
4
4
 
5
5
  Currently based on:
6
- SVN Revision: 13354
6
+ SVN Revision: 13557
7
7
 
8
8
  # Credits
9
9
  The Metasploit development team <http://www.metasploit.com>
@@ -37,7 +37,7 @@ ENABLE_PROCESSED_INPUT = 1
37
37
 
38
38
  def self.is_windows
39
39
  return @@is_windows if @@is_windows
40
- @@is_windows = (RUBY_PLATFORM =~ /mswin32|mingw32/) ? true : false
40
+ @@is_windows = (RUBY_PLATFORM =~ /mswin(32|64)|mingw(32|64)/) ? true : false
41
41
  end
42
42
 
43
43
  def self.is_cygwin
@@ -170,11 +170,9 @@ end
170
170
 
171
171
  ###
172
172
  #
173
- # This exception is raised when a connection attempt fails because the remote
174
- # side refused the connection.
173
+ # This is a generic exception for errors that cause a connection to fail.
175
174
  #
176
175
  ###
177
-
178
176
  class ConnectionError < ::IOError
179
177
  include SocketError
180
178
  include HostCommunicationError
@@ -220,10 +218,12 @@ end
220
218
  #
221
219
  # This exception is raised when an attempt to use an address or port that is
222
220
  # already in use occurs, such as binding to a host on a given port that is
223
- # already in use.
221
+ # already in use. Note that Windows raises this in some cases when attempting
222
+ # to connect to addresses that it can't handle, e.g. "0.0.0.0". Thus, this is
223
+ # a ConnectionError.
224
224
  #
225
225
  ###
226
- class AddressInUse < ::RuntimeError
226
+ class AddressInUse < ConnectionError
227
227
  include SocketError
228
228
  include HostCommunicationError
229
229
 
@@ -0,0 +1,192 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)),"nokogiri_doc_mixin")
2
+
3
+ require 'msf/core'
4
+
5
+ module Rex
6
+ module Parser
7
+
8
+ # If Nokogiri is available, define the document class.
9
+ load_nokogiri && class CIDocument < Nokogiri::XML::SAX::Document
10
+
11
+ include NokogiriDocMixin
12
+
13
+ attr_reader :text
14
+
15
+ def initialize(*args)
16
+ super(*args)
17
+ @state[:has_text] = true
18
+ end
19
+
20
+ # Triggered every time a new element is encountered. We keep state
21
+ # ourselves with the @state variable, turning things on when we
22
+ # get here (and turning things off when we exit in end_element()).
23
+ def start_element(name=nil,attrs=[])
24
+ attrs = normalize_attrs(attrs)
25
+ block = @block
26
+
27
+ r = { :e => name }
28
+ attrs.each { |pair| r[pair[0]] = pair[1] }
29
+
30
+ if @state[:path]
31
+ @state[:path].push r
32
+ end
33
+
34
+ case name
35
+ when "entity"
36
+ @state[:path] = [ r ]
37
+ record_device(r)
38
+ when "property"
39
+ return if not @state[:address]
40
+ return if not @state[:props]
41
+ @state[:props] << [ r["type"], r["key"]]
42
+ end
43
+ end
44
+
45
+ # When we exit a tag, this is triggered.
46
+ def end_element(name=nil)
47
+ block = @block
48
+ case name
49
+ when "entity" # Wrap it up
50
+ if @state[:address]
51
+ host_object = report_host &block
52
+ report_services(host_object)
53
+ report_vulns(host_object)
54
+ end
55
+ # Reset the state once we close a host
56
+ @report_data = {:wspace => @args[:wspace]}
57
+ @state[:root] = {}
58
+ when "property"
59
+ if @state[:props]
60
+ @text.strip! if @text
61
+ process_property
62
+ @state[:props].pop
63
+ end
64
+ end
65
+ @state[:path].pop
66
+ @text = nil
67
+ end
68
+
69
+ def record_device(info)
70
+ if info["class"] and info["class"] == "host" and info["name"]
71
+ address = info["name"].to_s.gsub(/^.*\//, '')
72
+ return if address !~ /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/
73
+ @state[:address] = address
74
+ @state[:props] = []
75
+ end
76
+ end
77
+
78
+ def process_property
79
+ return if not @state[:props]
80
+ return if not @state[:props].length > 0
81
+ @state[:root] ||= {}
82
+ @cobj = @state[:root]
83
+ property_parser(0)
84
+ end
85
+
86
+ def property_parser(idx)
87
+ return if not @state[:props][idx]
88
+ case @state[:props][idx][0]
89
+ when "container", "ports", "entity", "properties"
90
+ @cobj[ @state[:props][idx][1] ] ||= {}
91
+ @cobj = @cobj[ @state[:props][idx][1] ]
92
+ else
93
+ @cobj[ state[:props][idx][1] ] = @text
94
+ end
95
+ property_parser(idx + 1)
96
+ end
97
+
98
+ def report_host(&block)
99
+ @report_data = {
100
+ :ports => [:ignore],
101
+ :state => Msf::HostState::Alive,
102
+ :host => @state[:address]
103
+ }
104
+
105
+ if @state[:root]["dns names"] and @state[:root]["dns names"].keys.length > 0
106
+ @report_data[:name] = @state[:root]["dns names"].keys.first
107
+ end
108
+
109
+ if host_is_okay
110
+ @report_data.delete(:ports)
111
+
112
+ db.emit(:address, @report_data[:host],&block) if block
113
+ host_object = db_report(:host, @report_data.merge(
114
+ :workspace => @args[:wspace] ) )
115
+ if host_object
116
+ db.report_import_note(host_object.workspace, host_object)
117
+ end
118
+ host_object
119
+ end
120
+ end
121
+
122
+ def report_services(host_object)
123
+ return unless host_object.kind_of? ::Msf::DBManager::Host
124
+
125
+ snames = {}
126
+ ( @state[:root]["services"] || {} ).each_pair do |sname, sinfo|
127
+ sinfo.each_pair do |pinfo,pdata|
128
+ snames[pinfo] = sname.dup
129
+ end
130
+ end
131
+
132
+ reported = []
133
+ if @state[:root]["tcp_ports"]
134
+ @state[:root]["tcp_ports"].each_pair do |pn, ps|
135
+ ps = "open" if ps == "listen"
136
+ svc = { :port => pn.to_i, :state => ps, :proto => 'tcp'}
137
+ if @state[:root]["Banners"] and @state[:root]["Banners"][pn.to_s]
138
+ svc[:info] = @state[:root]["Banners"][pn.to_s]
139
+ end
140
+ svc[:name] = snames["#{pn}-tcp"] if snames["#{pn}-tcp"]
141
+ reported << db_report(:service, svc.merge(:host => host_object))
142
+ end
143
+ end
144
+
145
+ if @state[:root]["udp_ports"]
146
+ @state[:root]["udp_ports"].each_pair do |pn, ps|
147
+ ps = "open" if ps == "listen"
148
+ svc = { :port => pn.to_i, :state => ps, :proto => 'udp'}
149
+ svc[:name] = snames["#{pn}-udp"] if snames["#{pn}-tcp"]
150
+ reported << db_report(:service, svc.merge(:host => host_object))
151
+ end
152
+ end
153
+
154
+ ( @state[:root]["services"] || {} ).each_pair do |sname, sinfo|
155
+ sinfo.each_pair do |pinfo,pdata|
156
+ sport,sproto = pinfo.split("-")
157
+ db_report(:note, {
158
+ :host => host_object,
159
+ :port => sport.to_i,
160
+ :proto => sproto,
161
+ :ntype => "ci.#{sname}.fingerprint",
162
+ :data => pdata
163
+ })
164
+ end
165
+ end
166
+
167
+ reported
168
+ end
169
+
170
+ def report_vulns(host_object)
171
+ vuln_count = 0
172
+ block = @block
173
+ return unless host_object.kind_of? Msf::DBManager::Host
174
+ return unless @state[:root]["Vulnerabilities"]
175
+ @state[:root]["Vulnerabilities"].each_pair do |cve, vinfo|
176
+ vinfo.each_pair do |vname, vdesc|
177
+ data = {
178
+ :workspace => host_object.workspace,
179
+ :host => host_object,
180
+ :name => vname,
181
+ :info => vdesc,
182
+ :refs => [ cve ]
183
+ }
184
+ db_report(:vuln, data)
185
+ end
186
+ end
187
+ end
188
+
189
+ end
190
+ end
191
+ end
192
+
@@ -284,7 +284,10 @@ module Rex
284
284
  info << @state[:service_fingerprint]["version"] if @state[:service_fingerprint]["version"]
285
285
  port_hash[:info] = info.join(" ") if info[0]
286
286
  end
287
- @report_data[:ports] << port_hash
287
+ @report_data[:ports] << port_hash.clone
288
+ @state.delete :service_fingerprint
289
+ @state.delete :service
290
+ @report_data[:ports]
288
291
  end
289
292
 
290
293
  def actually_vulnerable(test)
@@ -296,7 +296,10 @@ module Rex
296
296
  if @state[:service_fingerprint]
297
297
  port_hash[:info] = "#{@state[:service_fingerprint]}"
298
298
  end
299
- @report_data[:ports] << port_hash
299
+ @report_data[:ports] << port_hash.clone
300
+ @state.delete :service_fingerprint
301
+ @state.delete :service
302
+ @report_data[:ports]
300
303
  end
301
304
 
302
305
  def collect_service_fingerprint_description
@@ -54,7 +54,7 @@ module Analyze
54
54
  config(param)
55
55
 
56
56
  epa = pe.hdr.opt.AddressOfEntryPoint
57
- buf = pe.read_rva(epa, 256)
57
+ buf = pe.read_rva(epa, 256) || ""
58
58
 
59
59
  @sigs.each_pair do |name, data|
60
60
  begin
@@ -151,7 +151,8 @@ class Client
151
151
  ctx = generate_ssl_context()
152
152
  ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
153
153
 
154
- if not ssl.respond_to?(:accept_nonblock)
154
+ # Use non-blocking OpenSSL operations on Windows
155
+ if not ( ssl.respond_to?(:accept_nonblock) and Rex::Compat.is_windows )
155
156
  ssl.accept
156
157
  else
157
158
  begin
@@ -311,8 +311,17 @@ class ClientCore < Extension
311
311
  #
312
312
  def shutdown
313
313
  request = Packet.create_request('core_shutdown')
314
- # Don't wait for the response since the server will be dead
315
- self.client.send_packet(request)
314
+
315
+ # If this is a standard TCP session, send and return
316
+ if not client.passive_service
317
+ self.client.send_packet(request)
318
+ else
319
+ # If this is a HTTP/HTTPS session we need to wait a few seconds
320
+ # otherwise the session may not receive the command before we
321
+ # kill the handler. This could be improved by the server side
322
+ # sending a reply to shutdown first.
323
+ self.client.send_packet_wait_response(request, 10)
324
+ end
316
325
  true
317
326
  end
318
327
 
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rex/post/meterpreter/extensions/lanattacks/tlv'
4
+
5
+ module Rex
6
+ module Post
7
+ module Meterpreter
8
+ module Extensions
9
+ module Lanattacks
10
+
11
+ ###
12
+ #
13
+ # This meterpreter extension can currently run DHCP and TFTP servers
14
+ #
15
+ ###
16
+ class Lanattacks < Extension
17
+
18
+ def initialize(client)
19
+ super(client, 'lanattacks')
20
+
21
+ client.register_extension_aliases(
22
+ [{
23
+ 'name' => 'lanattacks',
24
+ 'ext' => self
25
+ },])
26
+ end
27
+
28
+ def start_dhcp
29
+ client.send_request(Packet.create_request('lanattacks_start_dhcp'))
30
+ true
31
+ end
32
+
33
+ def reset_dhcp
34
+ client.send_request(Packet.create_request('lanattacks_reset_dhcp'))
35
+ true
36
+ end
37
+
38
+ def set_dhcp_option(name, value)
39
+ request = Packet.create_request('lanattacks_set_dhcp_option')
40
+ request.add_tlv(TLV_TYPE_LANATTACKS_OPTION_NAME, name)
41
+ request.add_tlv(TLV_TYPE_LANATTACKS_OPTION, value)
42
+ client.send_request(request)
43
+ true
44
+ end
45
+
46
+ def load_dhcp_options(datastore)
47
+ datastore.each do |name, value|
48
+ if Regexp.new('DHCPIPSTART|DHCPIPEND|NETMASK|ROUTER|DNSSERVER|BROADCAST|'+
49
+ 'SERVEONCE|PXE|HOSTNAME|HOSTSTART|FILENAME|PXECONF|SRVHOST') =~ name
50
+ set_dhcp_option(name,value)
51
+ end
52
+ end
53
+ end
54
+
55
+ def stop_dhcp
56
+ client.send_request(Packet.create_request('lanattacks_stop_dhcp'))
57
+ true
58
+ end
59
+
60
+ def start_tftp
61
+ client.send_request(Packet.create_request('lanattacks_start_tftp'))
62
+ true
63
+ end
64
+
65
+ def reset_tftp
66
+ client.send_request(Packet.create_request('lanattacks_reset_tftp'))
67
+ true
68
+ end
69
+
70
+ def add_tftp_file(filename, data)
71
+ request = Packet.create_request('lanattacks_add_tftp_file')
72
+ request.add_tlv(TLV_TYPE_LANATTACKS_OPTION_NAME, filename)
73
+ request.add_tlv(TLV_TYPE_LANATTACKS_RAW, data, false, true) #compress it
74
+ client.send_request(request)
75
+ true
76
+ end
77
+
78
+ def stop_tftp
79
+ client.send_request(Packet.create_request('lanattacks_stop_tftp'))
80
+ true
81
+ end
82
+ end
83
+
84
+ end; end; end; end; end
@@ -0,0 +1,16 @@
1
+ module Rex
2
+ module Post
3
+ module Meterpreter
4
+ module Extensions
5
+ module Lanattacks
6
+
7
+ TLV_TYPE_LANATTACKS_OPTION = TLV_META_TYPE_RAW| (TLV_EXTENSIONS + 1)
8
+ TLV_TYPE_LANATTACKS_OPTION_NAME = TLV_META_TYPE_STRING| (TLV_EXTENSIONS + 2)
9
+ TLV_TYPE_LANATTACKS_UINT = TLV_META_TYPE_UINT| (TLV_EXTENSIONS + 3)
10
+ TLV_TYPE_LANATTACKS_RAW = TLV_META_TYPE_RAW| (TLV_EXTENSIONS + 4)
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -138,6 +138,374 @@ module MockMagic
138
138
  "cchReferencedDomainName"=>12
139
139
  },
140
140
  },
141
+ {
142
+ :platform => 'x86/win32',
143
+ :name => 'CryptAcquireContextW',
144
+ :params => [["PDWORD", "phProv", "out"], ["PWCHAR", "pszContainer", "in"], ["PWCHAR", "pszProvider", "in"], ["DWORD", "dwProvType", "in"], ["DWORD", "dwflags", "in"]],
145
+ :return_type => 'BOOL',
146
+ :dll_name => 'advapi32',
147
+ :ruby_args => [4, nil, "Microsoft Enhanced Cryptographic Provider v1.0", 1, 4026531840],
148
+ :request_to_client => {
149
+ TLV_TYPE_RAILGUN_SIZE_OUT => 4,
150
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0",
151
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "M\x00i\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00 \x00E\x00n\x00h\x00a\x00n\x00c\x00e\x00d\x00 \x00C\x00r\x00y\x00p\x00t\x00o\x00g\x00r\x00a\x00p\x00h\x00i\x00c\x00 \x00P\x00r\x00o\x00v\x00i\x00d\x00e\x00r\x00 \x00v\x001\x00.\x000\x00\x00\x00\x00\x00",
152
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
153
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
154
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptAcquireContextW',
155
+ },
156
+ :response_from_client => {
157
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
158
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "\xC8\xEB\x14\x00",
159
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
160
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
161
+ },
162
+ :returned_hash => {"GetLastError"=>0, "return"=>true, "phProv"=>1371080},
163
+ },
164
+ {
165
+ :platform => 'x86/win32',
166
+ :name => 'CryptCreateHash',
167
+ :params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hKey", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phHash", "out"]],
168
+ :return_type => 'BOOL',
169
+ :dll_name => 'advapi32',
170
+ :ruby_args => [1371080, 32771, 0, 0, 4],
171
+ :request_to_client => {
172
+ TLV_TYPE_RAILGUN_SIZE_OUT => 4,
173
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\xC8\xEB\x14\x00\x00\x00\x00\x00\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00",
174
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
175
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
176
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
177
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptCreateHash',
178
+ },
179
+ :response_from_client => {
180
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
181
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "p\xEA\x14\x00",
182
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
183
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
184
+ },
185
+ :returned_hash => {"GetLastError"=>0, "return"=>true, "phHash"=>1370736},
186
+ },
187
+ {
188
+ :platform => 'x86/win32',
189
+ :name => 'CryptHashData',
190
+ :params => [["LPVOID", "hHash", "in"], ["PWCHAR", "pbData", "in"], ["DWORD", "dwDataLen", "in"], ["DWORD", "dwFlags", "in"]],
191
+ :return_type => 'BOOL',
192
+ :dll_name => 'advapi32',
193
+ :ruby_args => [1370736, "SmartFTP", 16, 0],
194
+ :request_to_client => {
195
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
196
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00p\xEA\x14\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
197
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "S\x00m\x00a\x00r\x00t\x00F\x00T\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00",
198
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
199
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
200
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptHashData',
201
+ },
202
+ :response_from_client => {
203
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
204
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
205
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
206
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
207
+ },
208
+ :returned_hash => {"GetLastError"=>0, "return"=>true},
209
+ },
210
+ {
211
+ :platform => 'x86/win32',
212
+ :name => 'CryptDeriveKey',
213
+ :params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hBaseData", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phKey", "inout"]],
214
+ :return_type => 'BOOL',
215
+ :dll_name => 'advapi32',
216
+ :ruby_args => [1371080, 26625, 1370736, 8388608, 4],
217
+ :request_to_client => {
218
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
219
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\xC8\xEB\x14\x00\x00\x00\x00\x00\x01h\x00\x00\x00\x00\x00\x00p\xEA\x14\x00\x00\x00\x00\x00\x00\x00\x80\x00\x03\x00\x00\x00\x00\x00\x00\x00",
220
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
221
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "\x04\x00\x00\x00\x00\x00\x00\x00",
222
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
223
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptDeriveKey',
224
+ },
225
+ :response_from_client => {
226
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "\xA0\x9C\x15\x00\x00\x00\x00\x00",
227
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
228
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
229
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
230
+ },
231
+ :returned_hash => {"GetLastError"=>0, "return"=>true, "phKey"=>1416352},
232
+ },
233
+ {
234
+ :platform => 'x86/win32',
235
+ :name => 'CryptDecrypt',
236
+ :params => [["LPVOID", "hKey", "in"], ["LPVOID", "hHash", "in"], ["BOOL", "Final", "in"], ["DWORD", "dwFlags", "in"], ["PBLOB", "pbData", "inout"], ["PDWORD", "pdwDataLen", "inout"]],
237
+ :return_type => 'BOOL',
238
+ :dll_name => 'advapi32',
239
+ :ruby_args => [1416352, 0, true, 0, "\x96\"\x83/\xCE|", 6],
240
+ :request_to_client => {
241
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
242
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\xA0\x9C\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\b\x00\x00\x00",
243
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
244
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "\x96\"\x83/\xCE|\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00",
245
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
246
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptDecrypt',
247
+ },
248
+ :response_from_client => {
249
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "q\x00u\x00x\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00",
250
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
251
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
252
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
253
+ },
254
+ :returned_hash => {"GetLastError"=>0, "return"=>true, "pbData"=>"q\x00u\x00x\x00", "pdwDataLen"=>6},
255
+ },
256
+ {
257
+ :platform => 'x86/win32',
258
+ :name => 'CryptDestroyHash',
259
+ :params => [["LPVOID", "hHash", "in"]],
260
+ :return_type => 'BOOL',
261
+ :dll_name => 'advapi32',
262
+ :ruby_args => [1370736],
263
+ :request_to_client => {
264
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
265
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00p\xEA\x14\x00",
266
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
267
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
268
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
269
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptDestroyHash',
270
+ },
271
+ :response_from_client => {
272
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
273
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
274
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
275
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
276
+ },
277
+ :returned_hash => {"GetLastError"=>0, "return"=>true},
278
+ },
279
+ {
280
+ :platform => 'x86/win32',
281
+ :name => 'CryptDestroyKey',
282
+ :params => [["LPVOID", "hKey", "in"]],
283
+ :return_type => 'BOOL',
284
+ :dll_name => 'advapi32',
285
+ :ruby_args => [1416352],
286
+ :request_to_client => {
287
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
288
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\xA0\x9C\x15\x00",
289
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
290
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
291
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
292
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptDestroyKey',
293
+ },
294
+ :response_from_client => {
295
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
296
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
297
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
298
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
299
+ },
300
+ :returned_hash => {"GetLastError"=>0, "return"=>true},
301
+ },
302
+ {
303
+ :platform => 'x86/win32',
304
+ :name => 'CryptReleaseContext',
305
+ :params => [["LPVOID", "hProv", "in"], ["DWORD", "dwFlags", "in"]],
306
+ :return_type => 'BOOL',
307
+ :dll_name => 'advapi32',
308
+ :ruby_args => [1371080, 0],
309
+ :request_to_client => {
310
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
311
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\xC8\xEB\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00",
312
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
313
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
314
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
315
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptReleaseContext',
316
+ },
317
+ :response_from_client => {
318
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
319
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
320
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
321
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
322
+ },
323
+ :returned_hash => {"GetLastError"=>0, "return"=>true},
324
+ },
325
+ {
326
+ :platform => 'x64/win64',
327
+ :name => 'CryptAcquireContextW',
328
+ :params => [["PDWORD", "phProv", "out"], ["PWCHAR", "pszContainer", "in"], ["PWCHAR", "pszProvider", "in"], ["DWORD", "dwProvType", "in"], ["DWORD", "dwflags", "in"]],
329
+ :return_type => 'BOOL',
330
+ :dll_name => 'advapi32',
331
+ :ruby_args => [8, nil, "Microsoft Enhanced Cryptographic Provider v1.0", 1, 4026531840],
332
+ :request_to_client => {
333
+ TLV_TYPE_RAILGUN_SIZE_OUT => 8,
334
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0\x00\x00\x00\x00",
335
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "M\x00i\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00 \x00E\x00n\x00h\x00a\x00n\x00c\x00e\x00d\x00 \x00C\x00r\x00y\x00p\x00t\x00o\x00g\x00r\x00a\x00p\x00h\x00i\x00c\x00 \x00P\x00r\x00o\x00v\x00i\x00d\x00e\x00r\x00 \x00v\x001\x00.\x000\x00\x00\x00\x00\x00",
336
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
337
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
338
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptAcquireContextW',
339
+ },
340
+ :response_from_client => {
341
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
342
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "\x80\xCE\x1A\x00\x00\x00\x00\x00",
343
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
344
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
345
+ },
346
+ :returned_hash => {"GetLastError"=>0, "return"=>true, "phProv"=>1756800},
347
+ },
348
+ {
349
+ :platform => 'x64/win64',
350
+ :name => 'CryptCreateHash',
351
+ :params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hKey", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phHash", "out"]],
352
+ :return_type => 'BOOL',
353
+ :dll_name => 'advapi32',
354
+ :ruby_args => [1756800, 32771, 0, 0, 8],
355
+ :request_to_client => {
356
+ TLV_TYPE_RAILGUN_SIZE_OUT => 8,
357
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\x00\x00\x00\x00\x80\xCE\x1A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
358
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
359
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
360
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
361
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptCreateHash',
362
+ },
363
+ :response_from_client => {
364
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
365
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "\x00\xA3\x19\x00\x00\x00\x00\x00",
366
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
367
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
368
+ },
369
+ :returned_hash => {"GetLastError"=>0, "return"=>true, "phHash"=>1680128},
370
+ },
371
+ {
372
+ :platform => 'x64/win64',
373
+ :name => 'CryptHashData',
374
+ :params => [["LPVOID", "hHash", "in"], ["PWCHAR", "pbData", "in"], ["DWORD", "dwDataLen", "in"], ["DWORD", "dwFlags", "in"]],
375
+ :return_type => 'BOOL',
376
+ :dll_name => 'advapi32',
377
+ :ruby_args => [1680128, "SmartFTP", 16, 0],
378
+ :request_to_client => {
379
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
380
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xA3\x19\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
381
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "S\x00m\x00a\x00r\x00t\x00F\x00T\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00",
382
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
383
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
384
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptHashData',
385
+ },
386
+ :response_from_client => {
387
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
388
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
389
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
390
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
391
+ },
392
+ :returned_hash => {"GetLastError"=>0, "return"=>true},
393
+ },
394
+ {
395
+ :platform => 'x64/win64',
396
+ :name => 'CryptDeriveKey',
397
+ :params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hBaseData", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phKey", "inout"]],
398
+ :return_type => 'BOOL',
399
+ :dll_name => 'advapi32',
400
+ :ruby_args => [1756800, 26625, 1680128, 8388608, 4],
401
+ :request_to_client => {
402
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
403
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\x00\x00\x00\x00\x80\xCE\x1A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01h\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xA3\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
404
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
405
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "\x04\x00\x00\x00\x00\x00\x00\x00",
406
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
407
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptDeriveKey',
408
+ },
409
+ :response_from_client => {
410
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "p\xA3\x19\x00\x00\x00\x00\x00",
411
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
412
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
413
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
414
+ },
415
+ :returned_hash => {"GetLastError"=>0, "return"=>true, "phKey"=>1680240},
416
+ },
417
+ {
418
+ :platform => 'x64/win64',
419
+ :name => 'CryptDecrypt',
420
+ :params => [["LPVOID", "hKey", "in"], ["LPVOID", "hHash", "in"], ["BOOL", "Final", "in"], ["DWORD", "dwFlags", "in"], ["PBLOB", "pbData", "inout"], ["PDWORD", "pdwDataLen", "inout"]],
421
+ :return_type => 'BOOL',
422
+ :dll_name => 'advapi32',
423
+ :ruby_args => [1680240, 0, true, 0, "\x85\"\x97/\xCC|", 6],
424
+ :request_to_client => {
425
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
426
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\x00\x00\x00\x00p\xA3\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\b\x00\x00\x00\x00\x00\x00\x00",
427
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
428
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "\x85\"\x97/\xCC|\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00",
429
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
430
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptDecrypt',
431
+ },
432
+ :response_from_client => {
433
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "b\x00a\x00z\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00",
434
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
435
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
436
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
437
+ },
438
+ :returned_hash => {"GetLastError"=>0, "return"=>true, "pbData"=>"b\x00a\x00z\x00", "pdwDataLen"=>6},
439
+ },
440
+ {
441
+ :platform => 'x64/win64',
442
+ :name => 'CryptDestroyHash',
443
+ :params => [["LPVOID", "hHash", "in"]],
444
+ :return_type => 'BOOL',
445
+ :dll_name => 'advapi32',
446
+ :ruby_args => [1680128],
447
+ :request_to_client => {
448
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
449
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xA3\x19\x00\x00\x00\x00\x00",
450
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
451
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
452
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
453
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptDestroyHash',
454
+ },
455
+ :response_from_client => {
456
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
457
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
458
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
459
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
460
+ },
461
+ :returned_hash => {"GetLastError"=>0, "return"=>true},
462
+ },
463
+ {
464
+ :platform => 'x64/win64',
465
+ :name => 'CryptDestroyKey',
466
+ :params => [["LPVOID", "hKey", "in"]],
467
+ :return_type => 'BOOL',
468
+ :dll_name => 'advapi32',
469
+ :ruby_args => [1680240],
470
+ :request_to_client => {
471
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
472
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\x00\x00\x00\x00p\xA3\x19\x00\x00\x00\x00\x00",
473
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
474
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
475
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
476
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptDestroyKey',
477
+ },
478
+ :response_from_client => {
479
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
480
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
481
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
482
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
483
+ },
484
+ :returned_hash => {"GetLastError"=>0, "return"=>true},
485
+ },
486
+ {
487
+ :platform => 'x64/win64',
488
+ :name => 'CryptReleaseContext',
489
+ :params => [["LPVOID", "hProv", "in"], ["DWORD", "dwFlags", "in"]],
490
+ :return_type => 'BOOL',
491
+ :dll_name => 'advapi32',
492
+ :ruby_args => [1756800, 0],
493
+ :request_to_client => {
494
+ TLV_TYPE_RAILGUN_SIZE_OUT => 0,
495
+ TLV_TYPE_RAILGUN_STACKBLOB => "\x00\x00\x00\x00\x00\x00\x00\x00\x80\xCE\x1A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
496
+ TLV_TYPE_RAILGUN_BUFFERBLOB_IN => "",
497
+ TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT => "",
498
+ TLV_TYPE_RAILGUN_DLLNAME => 'advapi32',
499
+ TLV_TYPE_RAILGUN_FUNCNAME => 'CryptReleaseContext',
500
+ },
501
+ :response_from_client => {
502
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT => "",
503
+ TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT => "",
504
+ TLV_TYPE_RAILGUN_BACK_RET => 1,
505
+ TLV_TYPE_RAILGUN_BACK_ERR => 0,
506
+ },
507
+ :returned_hash => {"GetLastError"=>0, "return"=>true},
508
+ },
141
509
  ]
142
510
  end
143
511