Skip to content

Instantly share code, notes, and snippets.

@brianroth
Created May 4, 2010 18:37
Show Gist options
  • Save brianroth/389780 to your computer and use it in GitHub Desktop.
Save brianroth/389780 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'socket'
hostname = ARGV[0]
control_port = ARGV[1]
filename = ARGV[2]
begin
control_socket = TCPSocket.new( hostname, control_port )
control_socket.send( "STREAM\n", 0)
port = control_socket.gets.chomp.split[1]
stream_socket = TCPSocket.new( hostname, port )
File.open(filename, 'r') do |f|
while data = f.read(4000)
stream_socket.send( data, 0)
end
end
stream_socket.close
response = control_socket.gets
control_socket.close
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