Created
May 11, 2010 13:55
-
-
Save brianroth/397334 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] | |
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