Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save t-book/623baed3fed413c2e7c3040b782287b4 to your computer and use it in GitHub Desktop.
Save t-book/623baed3fed413c2e7c3040b782287b4 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