Adds -u to the connect command

git-svn-id: file:///home/svn/framework3/trunk@9788 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2010-07-12 03:15:45 +00:00
parent a5786cdc64
commit 37f4783d55
1 changed files with 16 additions and 9 deletions

View File

@ -55,6 +55,7 @@ class Core
"-P" => [ true, "Specify source port." ], "-P" => [ true, "Specify source port." ],
"-S" => [ true, "Specify source address." ], "-S" => [ true, "Specify source address." ],
"-s" => [ false, "Connect with SSL." ], "-s" => [ false, "Connect with SSL." ],
"-u" => [ false, "Switch to a UDP socket." ],
"-w" => [ true, "Specify connect timeout." ], "-w" => [ true, "Specify connect timeout." ],
"-z" => [ false, "Just try to connect, then return." ]) "-z" => [ false, "Just try to connect, then return." ])
@ -151,7 +152,7 @@ class Core
"Run the commands stored in the supplied files.\n") "Run the commands stored in the supplied files.\n")
return false return false
end end
args.each do |res| args.each do |res|
if not File.file? res if not File.file? res
print_error("#{res} is not a valid resource file") print_error("#{res} is not a valid resource file")
next next
@ -258,6 +259,7 @@ class Core
srcaddr = nil srcaddr = nil
srcport = nil srcport = nil
ssl = false ssl = false
udp = false
cto = nil cto = nil
justconn = false justconn = false
aidx = 0 aidx = 0
@ -288,6 +290,9 @@ class Core
when "-w" when "-w"
cto = val.to_i cto = val.to_i
aidx = idx + 2 aidx = idx + 2
when "-u"
udp = true
aidx = idx + 1
when "-z" when "-z"
justconn = true justconn = true
aidx = idx + 1 aidx = idx + 1
@ -341,7 +346,8 @@ class Core
end end
begin begin
sock = Rex::Socket::Tcp.create({ klass = udp ? ::Rex::Socket::Udp : ::Rex::Socket::Tcp
sock = klass.create({
'Comm' => comm, 'Comm' => comm,
'Proxies' => proxies, 'Proxies' => proxies,
'SSL' => ssl, 'SSL' => ssl,
@ -388,7 +394,7 @@ class Core
end end
# Network -> Console # Network -> Console
n2c = Thread.new(sock, cout, c2n) do |input, output, cthr| n2c = ::Thread.new(sock, cout, c2n) do |input, output, cthr|
while true while true
begin begin
res = input.read(65535) res = input.read(65535)
@ -404,12 +410,13 @@ class Core
c2n.join c2n.join
rescue Interrupt rescue ::Interrupt
c2n.kill c2n.kill
n2c.kill n2c.kill
end end
sock.close if not sock.closed?
sock.close rescue nil
infile.close if infile infile.close if infile
true true
@ -1087,7 +1094,7 @@ class Core
# Run a command on all sessions # Run a command on all sessions
when "-c" when "-c"
method = 'cmd' method = 'cmd'
if (val) if (val)
cmds << val cmds << val
end end
@ -1120,8 +1127,8 @@ class Core
method = 'scriptall' method = 'scriptall'
script = val script = val
end end
# Upload and exec to the specific command session # Upload and exec to the specific command session
when "-u" when "-u"
method = 'upexec' method = 'upexec'
@ -1257,7 +1264,7 @@ class Core
else else
print_error("No script specified!") print_error("No script specified!")
end end
when 'upexec' when 'upexec'
if ((session = framework.sessions.get(sid))) if ((session = framework.sessions.get(sid)))
if (session.interactive?) if (session.interactive?)