#!/usr/bin/ruby require 'socket' pass = 'foo:bar' file = File.read('/tmp/foobar') def show_resp s while select([s], nil, nil, 10) print s.read end puts 'fini' end bnd = 'blablaBoundary' content = ['--'+bnd, 'Content-Disposition: form-data; name="filename"; filename="quux"', 'Content-Type: application/octet-stream', '', file, '--'+bnd+'--'].join("\r\n") req = "POST /target.cgi HTTP/1.0\r\n" req += "Authorization: Basic #{pass.pack 'm'}\r\n" req += "Connection: close\r\n" req += "Content-Type: multipart/form-data; boundary=#{bnd}\r\n" req += "Content-Length: #{content.length}\r\n" req += "\r\n" req += content + "\r\n" s = TCPSocket.open( (ARGV[0] or 'site'), 80) s.write req sleep 1 show_resp s