Write AQL Query for threat hunting hypothesys on "Clear Command History"
- User
Write AQL Query for threat hunting hypothesys on "Clear Command History"
- Assistant
To create an AQL (Arista Query Language) query for threat hunting that focuses on the activity of clearing command history, it's crucial to consider different methods that might be used. The most common scenarios include modifying or deleting history files in Unix-like systems or using certain commands to manipulate the history.
Here are some potential approaches and corresponding AQL queries:
1. Detect Deletion of
.bash_historyor Similar Files:sqlSELECT * FROM file WHERE filename="/home/*/.bash_history" AND action="DELETE"This query checks for deletion events of the
.bash_historyfile, which is commonly used to store command history in Linux environments.2. Detect Commands That Clear History:
Unix-like systems commonly use commands such as
history -corunset HISTFILEto clear history. We can look for such patterns in command execution events.sqlSELECT * FROM process WHERE command_line="history -c" OR command_line="unset HISTFILE"This query searches for processes that involve either
history -corunset HISTFILEcommands being run, which are indicative of clearing command history.3. Detect Modifications to
.bash_history:sqlSELECT * FROM file WHERE filename="/home/*/.bash_history" AND action="MODIFY"This query catches any modifications to the
.bash_historyfile, which might involve attempts to manipulate history entries.4. Detect Truncation of History Files:
In some cases, the
truncatecommand is used to clear history files.sqlSELECT * FROM process WHERE command_line LIKE "%truncate%" AND command_line LIKE "%/.bash_history"This query captures any use of the
truncatecommand specifying.bash_history.General Considerations:
- File Paths: Ensure that the paths are correct and reflective of your specific environment, as different users may have different home directories.
- User Privileges: Think about how user privileges might affect which types of actions are possible or likely.
- Other Shells: Depending on the environment, other shells (e.g.,
zsh,ksh) may be in use, and you should include their history file locations as well.
Remember that the format or syntax may change based on specific systems or modifications to the environment, so test and adjust the queries to suit your specific needs and context.