I'm having trouble with this code (again).
I'm trying to get Ruby to check if tree is equal to any of the items in $do_not_scan and all I'm getting is a "cannot convert Array into String" error. Any way to fix such a thing?
My code:
#filesniffer by Touka, ©2015
$filecount = 0
$trees = Dir.entries("C:\\")
$do_not_scan = ["bootmgr", "BOOTNXT", "USER", ".", "Documents and Settings", "PerfLogs", "System Recovery", "System Volume Information", "$RECYCLE.BIN"]
def scan
$trees.each do |tree|
unless tree.include?($do_not_scan[0...8])
puts "scanning #{tree}"
entries = Dir.entries("c:\\#{tree}")
entries.each do |filename|
if filename == "**\*.dll"
puts "Found #{filename} in #{tree}"
end
end
end
end
end
def scan_loop
$trees.each do |tree|
scan
unless tree.include?($do_not_scan[0...8])
subtrees = Dir.entries("#{tree}")
subtrees.each do |tree|
scan
scan_loop
end
end
end
end
scan_loop
sleep
$trees. You could get rid of the global variable$treesall together by passing it as an argument to the#scanand#scan_loopmethods$globalvariables. They just aren't used in ruby. Normal variables do not need a$Dir.glob('**/*.dll')as it's an alternate path.