Created fileUtil
This commit is contained in:
@@ -1,27 +1,26 @@
|
||||
require 'FileUtils'
|
||||
require_relative 'searchUtil'
|
||||
require_relative 'filesUtil'
|
||||
|
||||
|
||||
class Cryptowallfinder
|
||||
|
||||
attr_accessor :outputFile, :path
|
||||
|
||||
@search = Searchutil.new
|
||||
def initialize
|
||||
@filesUtil = Filesutil.new
|
||||
end
|
||||
|
||||
def infectedFiles(decryptFile)
|
||||
infectedPath = File.dirname("#{decryptFile}")
|
||||
infectedFiles = Dir["#{infectedPath}/*.*"]
|
||||
infectedPath = @filesUtil.getDirectoryNameByFile(decryptFile)
|
||||
infectedFiles = @filesUtil.getAllFilesByPath(infectedPath)
|
||||
return infectedFiles
|
||||
end
|
||||
|
||||
def infectedFileExpandedPath(file)
|
||||
infectedFileExpandedPath = File.expand_path(file.to_s)
|
||||
return infectedFileExpandedPath
|
||||
return @filesUtil.getExpandedPathByFileName(file)
|
||||
end
|
||||
|
||||
def decryptFiles(path)
|
||||
decryptFiles = Dir["#{path}/**/DECRYPT_INSTRUCTION.TXT"]
|
||||
return decryptFiles
|
||||
return @filesUtil.findFilesByFileName(path,'DECRYPT_INSTRUCTION.txt')
|
||||
end
|
||||
|
||||
def writeMyFile(whatToWrite)
|
||||
@@ -36,7 +35,7 @@ class Cryptowallfinder
|
||||
|
||||
def deleteInstructions(file)
|
||||
if isTorInstructions(file) or isDecryptInstructions(file)
|
||||
FileUtils.rm(File.expand_path(file.to_s))
|
||||
@filesUtil.removeFile(file)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
25
source/filesUtil.rb
Normal file
25
source/filesUtil.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require 'FileUtils'
|
||||
|
||||
class Filesutil
|
||||
def findFilesByFileName(path,filename)
|
||||
files = Dir["#{path}/**/#{filename}"]
|
||||
return files
|
||||
end
|
||||
|
||||
def getExpandedPathByFileName(file)
|
||||
return File.expand_path(file.to_s)
|
||||
end
|
||||
|
||||
def removeFile(file)
|
||||
FileUtils.rm(getExpandedPathByFileName(file))
|
||||
end
|
||||
|
||||
def getDirectoryNameByFile(file)
|
||||
return File.dirname("#{file}")
|
||||
end
|
||||
|
||||
def getAllFilesByPath(path)
|
||||
return Dir["#{path}/*.*"]
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'FileUtils'
|
||||
|
||||
class Searchutil
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user