This will take two inputs the URL for the location of the YARA rule and the path you want to run the YARA search.
Works on LINUX, MAC and WINDOWS
/********************************************************************************************\
| The admin will supply the URL for an online YARA file and path to search |
\********************************************************************************************/
-- YARA SCANNER FROM ON-LINE YARA RULES GIT REPO
-- VARIABLE $$Search File Path$$ FILE PATH
-- VARIABLE $$YARA File URL$$ URL
WITH
-- Get the relevant YARA Signature Rules
Signature_Rules(Yara_Rule_URL, Yara_Sig_Rule ) AS (
SELECT '$$YARA File URL$$' Yara_Rule_URL,
CAST('/*'||'$$YARA File URL$$'||'*/'||result AS TEXT) Yara_Sig_Rule-- Insert the URL for the RULE into the Rule (HACK) We need it for the displayed results
FROM curl
WHERE url = '$$YARA File URL$$'
)
SELECT
replace(replace(path, rtrim(path, replace(path, '/', '')), ''), rtrim(replace(path, rtrim(path, replace(path, '/', '')), ''), replace(replace(path, rtrim(path, replace(path, '/', '')), ''), '\', '')), '') File_Name,
matches,
count,
path,
replace(SPLIT(sigrule,'*\',1), rtrim(SPLIT(sigrule,'*\',1), replace(SPLIT(sigrule,'*\',1), '/', '')), '') YARA_File,
'$$YARA File URL$$' YARA_Rule_URL
FROM yara WHERE Path LIKE '$$Search File Path$$' AND sigrule IN (SELECT Yara_Sig_Rule FROM Signature_Rules)
ORDER BY count DESC, matches ASC, YARA_File ASC, File_Name ASC
This thread was automatically locked due to age.
