This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Query to check file contents

Hello,

I want to have a query to check for possible PII. There is the query to check for metadata such a password.docx or password.txt. Below is what I have so far and this works as long as you have the exact file path and pattern you are looking for. I tried to use % wildcards for path and %-, %%%-%%%-%%%% and even tried using grep syntax to look for socials in this example. Any help on how to get this to scan directories for files containing specific patterns either with a wildcard or another means. Thank you!

SELECT
*
FROM
grep
WHERE
path = '$$Location$$'
AND pattern = '$$Data$$'



This thread was automatically locked due to age.
Parents Reply
  • I agree, it could be limited to a few extensions (pretty crude), for example:

    select path as file, line as matched_text from grep
    where path in(
          select path from file where path 
          like $$Location$$ 
          and       split(path, '.',1) in ('txt', 'config', 'policy')
    )
    and line like '$$Data$$'
    

    Where the variables are:

    $$Data$$ = %onExec%

    $$Location$$ =  'C:\ProgramData\Sophos\Management Communications System\Endpoint\%\%'

    The extensions searched are txt config and policy

Children