Techniques
Sample rules
Linux Compiled C Source To Tmp
- source: splunk
- technicques:
Description
The following analytic detects a C/C++ compiler compiling a C source file with the output binary written to /tmp, executed as a non-root user. This is a compile-after-delivery privilege escalation pattern. Kernel exploit PoCs and local privilege escalation tools commonly drop a C source file use compilers at runtime to produce a platform-specific binary in /tmp. This avoids architecture mismatches and allows the exploit to adapt to the running kernel’s symbol offsets.
Detection logic
`sysmon_linux`
EventID=1
process_name IN (
"*clang*",
"*g++*",
"*gcc*",
"cc",
"cc1",
"cc1plus",
"tcc"
)
process IN (
"*.c *",
"*.c",
"*.c++",
"*.cc*",
"*.cpp*",
"*.cxx*"
)
User!="root"
| regex process="(?i)(?:^
|\s)(?:-o
|--output)(?:\s+
|\=)[\x22\x27]?(?:\/tmp
|\/var\/tmp
|\/dev\/shm)(?:\/[^\/\\\s\x00\x22\x27\>\<\
|\:\&]+){0,}\/[^\/\\\s\x00\x22\x27\>\<\
|\:\&\.]+(?:\s
|\x22
|\;
|\x27
|$)"
| fillnull
| stats count min(_time) as firstTime
max(_time) as lastTime
BY process_name process User dest
| rename User as user
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `linux_compiled_c_source_to_tmp_filter`