Forked from brianroth/ClamAV virus scan using INSTREAM
Created
February 13, 2021 19:49
-
-
Save t-book/623baed3fed413c2e7c3040b782287b4 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