Modify to reduce rubocop offenses

bug/bundler_fix
Tabish Imran 2017-07-25 17:46:05 +05:30
parent da8cb48639
commit 0b001fdea6
1 changed files with 269 additions and 277 deletions

View File

@ -3,17 +3,15 @@
require 'rex/socket'
module Rex
module Proto
module Ftp
###
#
# Acts as a client to an FTP server
# See the RFC: https://www.w3.org/Protocols/rfc959/
#
###
class Client
module Proto
module Ftp
###
#
# Acts as a client to an FTP server
# See the RFC: https://www.w3.org/Protocols/rfc959/
#
###
class Client
#
# Creates a new client instance.
#
@ -44,13 +42,12 @@ class Client
'SSLVersion' => self.ssl_version,
'Proxies' => self.proxies
)
self.sock=nsock
self.sock = nsock
self.banner = recv_ftp_resp(nsock)
print_status("Connected to target FTP server.") if self.verbose
return nsock
nsock
end
#
# This method reads an FTP response based on FTP continuation
#
@ -64,7 +61,7 @@ class Client
end
while true
data = nsock.get_once(-1, ftp_timeout)
if not data
if !data
@ftpbuff << resp
@ftpbuff << left
return data
@ -75,22 +72,22 @@ class Client
# handle the end w/o newline case
enlidx = got.rindex(0x0a.chr)
if enlidx != (got.length-1)
if not enlidxhttps:
if enlidx != (got.length - 1)
if !enlidx
left << got
next
else
left << got.slice!((enlidx+1)..got.length)
left << got.slice!((enlidx + 1)..got.length)
end
end
# split into lines
rarr = got.split(/\r?\n/)
rarr.each do |ln|
if not found_end
if !found_end
resp << ln
resp << "\r\n"
if ln.length > 3 and ln[3,1] == ' '
if ln.length > 3 && ln[3, 1] == ' '
found_end = true
end
else
@ -143,7 +140,7 @@ class Client
return false
end
if (pass)
if pass
print_status("Sending password...") if self.verbose
res = send_pass(pass, ftpsock)
if (res !~ /^2/)
@ -152,7 +149,7 @@ class Client
end
end
return true
true
end
#
@ -178,7 +175,7 @@ class Client
#
def data_connect(mode = nil, nsock = self.sock)
if mode
res = send_cmd([ 'TYPE' , mode ], true, nsock)
res = send_cmd([ 'TYPE', mode ], true, nsock)
return nil if not res =~ /^200/
end
@ -201,7 +198,6 @@ class Client
self.datasocket
end
#
# This method handles disconnecting our data channel
#
@ -216,13 +212,12 @@ class Client
def send_cmd(args, recv = true, nsock = self.sock)
cmd = args.join(" ") + "\r\n"
ret = raw_send(cmd, nsock)
if (recv)
if recv
return recv_ftp_resp(nsock)
end
return ret
ret
end
#
# This method sends a QUIT command.
#
@ -235,11 +230,11 @@ class Client
# Function implementing 'ls' or list files command
#
def ls
datasocket = data_connect()
datasocket = data_connect
send_cmd(["list"])
output = datasocket.get
data_disconnect()
return output
data_disconnect
output
end
#
@ -253,38 +248,35 @@ class Client
# Function implementing 'cd' or change directory command
#
def cd(path)
send_cmd(["cwd "+path])
send_cmd(["cwd " + path])
end
#
# Function implementing download command
#
def download(filename)
datasocket = data_connect()
send_cmd(["retr",filename])
datasocket = data_connect
send_cmd(["retr", filename])
output = datasocket.get
file = File.open(filename,"wb")
file = File.open(filename, "wb")
file.write(output)
file.close()
data_disconnect()
file.close
data_disconnect
end
#
# Function implementing upload command
#
def upload
datasocket = data_connect()
file=File.open(filename,"rb")
data = file.read()
file.close()
send_cmd(["stor",filename])
datasocket = data_connect
file = File.open(filename, "rb")
data = file.read
file.close
send_cmd(["stor", filename])
datasocket.write(data)
data_disconnect()
data_disconnect
end
end
end
end
end
end
end
end