Created
May 4, 2010 18:37
-
-
Save brianroth/389780 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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