processes:list_all_non-kernel_processes
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
processes:list_all_non-kernel_processes [2016/10/17 13:55] – created peter | processes:list_all_non-kernel_processes [2019/12/01 22:37] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Processes - List all non-kernel processes ====== | ||
- | |||
- | Usually kernel processes are safe and clean. | ||
- | |||
- | <code bash> | ||
- | ps --ppid 2 -p 2 -p 1 \ | ||
- | | ||
- | </ | ||
- | |||
- | Returns: | ||
- | |||
- | < | ||
- | UID | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | ... ... | ||
- | ... ... | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | ... ... | ||
- | ... ... | ||
- | </ | ||
- | |||
- | **NOTE**: | ||
- | |||
- | * **rss** (resident set size): real RAM usage. | ||
- | * **-deselect**: | ||
- | |||
- | | ||
- | ===== Rule out trusted procsses ===== | ||
- | |||
- | We may have many processes running, which are expected and trusted. e.g apache2, tomcat7, mysqld, etc. To avoid distraction, | ||
- | |||
- | ===== Sort processes by memory and cpu ===== | ||
- | |||
- | We’re more concerned about suspicious processes using noticeable resource. | ||
- | |||
- | <code bash> | ||
- | # Sort by memory first, then cpu | ||
- | ps --ppid 2 -p 2 -p 1 --deselect \ | ||
- | -o uid, | ||
- | --sort -rss,-cpu | ||
- | </ | ||
- | |||
- | |||
- | ===== Automate Detection Process and Get Alerts ===== | ||
- | |||
- | We hide all the complexities and white list configuration in a python script (detect_suspicious_process.py). | ||
- | |||
- | If the number is not 0 or it changes, send alerts. | ||
- | |||
- | <code bash> | ||
- | wget -O / | ||
- | https:// | ||
- | DennyZhang/ | ||
- | detect_suspicious_process/ | ||
- | detect_suspicious_process.py | ||
- | |||
- | # Detect suspicious process | ||
- | python / | ||
- | |||
- | # Detect by customized whitelist | ||
- | python / | ||
- | | ||
- | </ | ||
processes/list_all_non-kernel_processes.1476712522.txt.gz · Last modified: 2020/07/15 09:30 (external edit)