Skip to content

Instantly share code, notes, and snippets.

@brianroth
Created May 11, 2010 13:55
Show Gist options
  • Save brianroth/397334 to your computer and use it in GitHub Desktop.
Save brianroth/397334 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'socket'
hostname = ARGV[0]
port = ARGV[1]
filename = ARGV[2]
begin
socket = TCPSocket.new( hostname, port )
socket.send( "zINSTREAM\0", 0)
File.open(filename, 'r') do |f|
while data = f.read(2048)
socket.send( [data.length].pack('N'), 0)
socket.send( data, 0)
end
end
socket.send( [0].pack('N'), 0)
socket.send( "", 0)
response = socket.gets
socket.close
puts response
if response.include?('FOUND')
puts "A virus was found: #{response}"
else
puts "No virus was found"
end
rescue Exception => e
puts "Exception encountered, #{e.inspect}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment