KhazarikOURecu

Untitled

Aug 18th, 2025
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.20 KB | Fixit | 0 0
  1. # Step 1: Create a temp working directory and move into it
  2. mkdir ~/intent_demo && cd ~/intent_demo
  3.  
  4. # Step 2: Create a fake sensitive file
  5. echo "root:x:0:0:root:/root:/bin/bash" | sudo tee /tmp/shadow_backup.txt > /dev/null
  6.  
  7. # Step 3: Simulate suspicious behavior BEFORE rule (optional, just to show what won't get logged)
  8. cat /tmp/shadow_backup.txt
  9. sudo chmod 777 /tmp/shadow_backup.txt
  10.  
  11. # Step 4: Create and install the audit rule to watch the file
  12. echo "-a always,exit -F path=/tmp/shadow_backup.txt -F perm=rwxa -F auid>=1000 -F auid!=4294967295 -k intent_test" | sudo tee /etc/audit/rules.d/intent.rules > /dev/null
  13.  
  14. # Step 5: Load the audit rules and restart auditd
  15. sudo augenrules --load
  16. sudo systemctl restart auditd
  17.  
  18. # Step 6: Confirm rule is active
  19. sudo auditctl -l
  20.  
  21. # Step 7: Perform suspicious actions AGAIN (after rule is active — these WILL be logged)
  22. cat /tmp/shadow_backup.txt
  23. sudo chmod 000 /tmp/shadow_backup.txt
  24.  
  25. # Step 8: Search audit logs for intent evidence
  26. sudo ausearch -k intent_test
  27.  
  28. # Step 9: (Optional) Save evidence to a log file for reporting
  29. sudo ausearch -k intent_test > ~/intent_evidence.log
  30.  
  31. # Step 10: (Optional) View the saved evidence
  32. cat ~/intent_evidence.log
  33.  
Advertisement
Add Comment
Please, Sign In to add comment