{"id":6399,"date":"2017-01-26T11:58:49","date_gmt":"2017-01-26T19:58:49","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/01\/26\/news-236\/"},"modified":"2017-01-26T11:58:49","modified_gmt":"2017-01-26T19:58:49","slug":"news-236","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2017\/01\/26\/news-236\/","title":{"rendered":"Deep Analysis of Android Rootnik Malware Using Advanced Anti-Debug and Anti-Hook, Part II: Analysis of The Scope of Java"},"content":{"rendered":"<div class=\"entry\">\n<p>In <a href=\"https:\/\/blog.fortinet.com\/2017\/01\/24\/deep-analysis-of-android-rootnik-malware-using-advanced-anti-debug-and-anti-hook-part-i-debugging-in-the-scope-of-native-layer\">part I<\/a> of this blog we finished the analysis of the native layer and got the decrypted secondary dex file. Here in part II we will continue to analyze it. For the&nbsp;sake&nbsp;of&nbsp;continuity, we will maintain continuous section and figure numbers from part I of the blog.<\/p>\n<h3>IV. The secondary dex file<\/h3>\n<p>The following is the decrypted file, which is a jar format file.&nbsp; It is loaded dynamically as the secondary dex via multidex scheme.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2001.png\" style=\"width: 883px; height: 595px;\" \/><\/p>\n<p align=\"center\">Figure 25. The decrypted secondary apk file containing the dex file<\/p>\n<p>After decompressing the file &ldquo;decrypt.dump,&rdquo; you can now see a file named &ldquo;classes.dex&rdquo; located in the folder.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2003.png\" style=\"width: 466px; height: 93px;\" \/><\/p>\n<p>Next, let&rsquo;s analyze the classes.dex.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2005.png\" style=\"width: 1251px; height: 563px;\" \/><\/p>\n<p align=\"center\">Figure 27. Decompile the secondary dex file and AndroidManifest.xml file<\/p>\n<p>From above figure, we can see that classes.dex is the main logic of the malware app named &ldquo;file Helper&rdquo;<\/p>\n<p>The following is the function &ldquo;onCreate&rdquo; in class com.sd.clip.activity. FileManagerActivity.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2007.png\" style=\"width: 885px; height: 142px;\" \/><\/p>\n<p align=\"center\">Figure 28. The function onCreate in class FileManagerActivity<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2009.png\" style=\"width: 648px; height: 59px;\" \/><\/p>\n<p align=\"center\">Figure 29. The function initadv()<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2011.png\" style=\"width: 912px; height: 315px;\" \/><\/p>\n<p align=\"center\">Figure 30. The class Nws<\/p>\n<p>The function getStart in class Nws is then used to start the service com.hg.mer.PG. The following is the definition of class PG.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2013.png\" style=\"width: 1072px; height: 577px;\" \/><\/p>\n<p align=\"center\">Figure 31. The service class com.hg.mer.PG<\/p>\n<p>After the function startService() is invoked, the function onCreate() is then invoked, followed by invoking the function onHandleIntent().&nbsp; In the above figure, we marked four lines of the key code in red, and then analyzed them in order.<\/p>\n<p><strong>1. readDex()<\/strong><\/p>\n<p>The following is the snippet code in function readDex().<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2015.png\" style=\"width: 923px; height: 657px;\" \/><\/p>\n<p align=\"center\">Figure 32. The function readDex()<\/p>\n<p>Based on my analysis, the class Sheu is a base64 implementation class, so the result of Sheu.decode(&quot;S0suYmlu&quot;) is the string &ldquo;KK.bin&rdquo;.&nbsp; Next, the program opens the file KK.bin in its assets folder and reads its content to extract some useful info.<\/p>\n<p>The following is the file content of KK.bin:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2017.png\" style=\"width: 800px; height: 362px;\" \/><\/p>\n<p align=\"center\">Figure 33. The file KK.bin in folder assets<\/p>\n<p>The program could extract some content from the end of the KK.bin file. There are seven strings there encoded using base64 that are stored in an array list. The function getAppid() is then used to decode these strings.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2019.png\" style=\"width: 749px; height: 228px;\" \/><\/p>\n<p align=\"center\">Figure 34. The function getAppid()<\/p>\n<p>The result of decoding these seven strings is shown below:<\/p>\n<blockquote>\n<p style=\"margin-left:.5in;\"><em>Pls.Kbin: wddex.jar<\/em><\/p>\n<p style=\"margin-left:.5in;\"><em>Pls.OI: xdt<\/em><\/p>\n<p style=\"margin-left:.5in;\"><em>Pls.PL: com.svq.cvo.Rtow<\/em><\/p>\n<p style=\"margin-left:.5in;\"><em>Pls.Jr: getDex<\/em><\/p>\n<p style=\"margin-left:.5in;\"><em>Pls.Wv: sgdex<\/em><\/p>\n<p style=\"margin-left:.5in;\"><em>Pls.As: dos.jar<\/em><\/p>\n<p style=\"margin-left:.5in;\"><em>Pls.NQ: KK.bin<\/em><\/p>\n<\/blockquote>\n<p><strong>2 .dxfile()<\/strong><\/p>\n<p>The following is the code snippet of the function dxfile().<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2021.png\" style=\"width: 825px; height: 468px;\" \/><\/p>\n<p align=\"center\">Figure 35. The function dxfile()<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2023.png\" style=\"width: 754px; height: 578px;\" \/><\/p>\n<p align=\"center\">Figure 36. The function UnZipFolder()<\/p>\n<p align=\"center\">&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The function Pls.UnZipFolder() extracts the encrypted content from KK.bin. The content starts at offset 0x20 and ends at offset 0x1CDB in the file KK.bin, and then is saved as \/data\/data\/com.web.sdfile\/files\/wddex.jar. Its content is encrypted using the DES algorithm.<\/p>\n<p>In the function dxfile() the program decrypts the file contents of \/data\/data\/com.web.sdfile\/files\/wddex.jar to file \/data\/data\/com.web.sdfile\/app_sgdex\/dos.jar.<\/p>\n<p><strong>3 .DexClassLoader()<\/strong><\/p>\n<p>Its constructor is shown below:<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2025.png\" style=\"width: 967px; height: 143px;\" \/><\/p>\n<p>In this invocation, the value of dexPath is &ldquo;\/data\/data\/com.web.sdfile\/app_sgdex\/dos.jar,&rdquo; and the value of optimizedDirectory is &ldquo;\/data\/data\/com.web.sdfile\/app_xdt.&rdquo;<\/p>\n<p>This function loads classes from the .jar and .apk files containing a classes.dex entry. This function can be used to execute code not installed as part of an application. The optimized dex files are written in the file dos.dex in the folder data\/data\/com.web.sdfile\/app_xdt.<\/p>\n<p>After loading classes from \/data\/data\/com.web.sdfile\/app_sgdex\/dos.jar, the program deletes this file.<\/p>\n<p><strong>4. Invoke getDex() method in class com.svq.cvo.Rtow dynamically.<\/strong><\/p>\n<p>Next, let&rsquo;s examine dos.dex.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2027.png\" style=\"width: 783px; height: 263px;\" \/><\/p>\n<p align=\"center\">Figure 37. Decompile the dex file dos.dex<\/p>\n<p>The following is the function getDex in class com.svq.cvo.Rtow:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2029.png\" style=\"width: 768px; height: 341px;\" \/><\/p>\n<p align=\"center\">Figure 38. The function getDex in class com.svq.cvo.Rtow<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2031.png\" style=\"width: 785px; height: 516px;\" \/><\/p>\n<p align=\"center\">Figure 39. The constructor of class Dwol<\/p>\n<p>In the constructor of class com.kdw.xoa.Dwol, a new file mda.ico is created in folder \/data\/data\/com.web.sdfile\/files\/. It then invokes the function downloadFile to download a payload from remote server <a href=\"http:\/\/gt%5B.%5Drogsob%5B.%5Dcom\/stmp\/ad.png\">http:\/\/gt[.]rogsob[.]com\/stmp\/ad.png<\/a>, and saves it as \/data\/data\/com.web.sdfile\/files\/mda.ico. The payload is encrypted using the DES algorithm.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2033.png\" style=\"width: 769px; height: 157px;\" \/><\/p>\n<p>&hellip;&hellip;<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2035.png\" style=\"width: 769px; height: 233px;\" \/><\/p>\n<p align=\"center\">Figure 40. The function downloadFile<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2037.png\" style=\"width: 763px; height: 137px;\" \/><\/p>\n<p align=\"center\">Figure 41. The function initData()<\/p>\n<p>The following is the definition of the function silentInstall.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2039.png\" style=\"width: 1101px; height: 584px;\" \/><\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2041.png\" style=\"width: 1124px; height: 276px;\" \/><\/p>\n<p align=\"center\">Figure 42. The function silentInstall<\/p>\n<p>The five parts marked in red in order are explained below.<\/p>\n<ol style=\"list-style-type:lower-alpha;\">\n<li>The function dxfile of class Dwol is used to decrypt the payload \/data\/data\/com.web.sdfile\/files\/mda.ico. The decrypted payload is saved as \/data\/data\/com.web.sdfile\/app_snex\/dkt.jar.<\/li>\n<li>The function upZipFile of class Ngss is used to decompress the decrypted payload dkt.jar into the folder \/data\/data\/com.web.sdfile\/files\/. It contains the following files:<\/li>\n<\/ol>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2043.png\" style=\"width: 577px; height: 204px;\" \/><\/p>\n<p align=\"center\">Figure 43. The payload files<\/p>\n<ol style=\"list-style-type:lower-alpha;\">\n<li value=\"3\">After decompressing, it deletes the files \/data\/data\/com.web.sdfile\/app_snex\/dkt.jar and \/data\/data\/com.web.sdfile\/files\/mda.ico, and deletes the directory \/data\/data\/com.web.sdfile\/app_snex\/.<\/li>\n<li value=\"4\">Renames the file classes.dex to wsh.jar in folder \/data\/data\/com.web.sdfile\/files\/.<\/li>\n<li value=\"5\">Dynamically loads classes from \/data\/data\/com.web.sdfile\/files\/wsh.jar, and the optimized directory app_outdex stores the dex cache file as wsh.dex.<\/li>\n<li value=\"6\">Invokes the function getDex in class com.rootdex.MainActivity.<\/li>\n<\/ol>\n<p>Next, we will look deep into the wsh.dex, which mainly executes the root tool to root the device and install the application in the system app folder.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2045.png\" style=\"width: 799px; height: 406px;\" \/><\/p>\n<p align=\"center\">Figure 44. The decomple the dex file wsh.dex<\/p>\n<p>The following is the definition of the function getDex of class com.rootdex.MainActivity.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2047.png\" style=\"width: 1059px; height: 162px;\" \/><\/p>\n<p align=\"center\">Figure 45. The function getDex in class com.rootdex.MainActivity<\/p>\n<ol style=\"list-style-type:lower-alpha;\">\n<li>The function GetActive is used to collect device information and send it to the remote server. The URL of remote server is <a href=\"http:\/\/grs%5B.%5Dgowdsy%5B.%5Dcom:8092\/active.do\">http:\/\/grs[.]gowdsy[.]com:8092\/active.do<\/a>. The following is a capture of the traffic:<\/li>\n<\/ol>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2049.png\" style=\"width: 980px; height: 232px;\" \/><\/p>\n<p align=\"center\">Figure 46. The traffic of sending collected info to remote server<\/p>\n<ol style=\"list-style-type:lower-alpha;\">\n<li value=\"2\">Checks if some files exist in folder \/data\/data\/com.web.sdfile\/files\/ and adds their file name into an array list it is preparing for the next step of rooting the device.<\/li>\n<li value=\"3\">Executes rooting tools on the device.<\/li>\n<\/ol>\n<p>Next, the function HandleRoot() is invoked in function run().<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2051.png\" style=\"width: 805px; height: 114px;\" \/><\/p>\n<p align=\"center\">Figure 47. The function HandleRoot()<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>The following is a key code snippet of the function copyRootFile.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2053.png\" style=\"width: 810px; height: 572px;\" \/><\/p>\n<p align=\"center\">Figure 48. The function copyRootFile<\/p>\n<p>In this function, there are four steps.<\/p>\n<ol>\n<li>FileUtil.dxfile() is used to decrypt the file \/data\/data\/com.web.sdfile\/files\/png.ico and save it as the file \/data\/data\/com.web.sdfile\/app_dex\/.do.<\/li>\n<li>FileUtil.UnZip() is used to decompress the file \/data\/data\/com.web.sdfile\/app_dex\/.do into folder \/data\/data\/com.web.sdfile\/.rtt, which is a hidden system folder that contains six ELF executables, as shown below. It includes four root exploits r1,r2,r3,r4.<\/li>\n<\/ol>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2055.png\" style=\"width: 715px; height: 136px;\" \/><\/p>\n<p align=\"center\" style=\"margin-left:.75in;\">Figure 49. The root exploit executables<\/p>\n<p align=\"center\" style=\"margin-left:.75in;\">&nbsp;<\/p>\n<ol>\n<li value=\"3\">It deletes the decrypted root tools \/data\/data\/com.web.sdfile\/app_dex\/.do and folder \/data\/data\/com.web.sdfile\/app_dex.<\/li>\n<li value=\"4\">It then creates a new file, psneuter.js, in folder \/data\/data\/com.web.sdfile\/files\/. Its contents are shown below.<\/li>\n<\/ol>\n<p align=\"center\" style=\"margin-left:.75in;\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2057.png\" style=\"width: 796px; height: 262px;\" \/><\/p>\n<p align=\"center\" style=\"margin-left:.75in;\">Figure 50. The file psneuter.js<\/p>\n<p>The function hanleOriMiddle is invoked in function executeRootAct. The following are four code snippets used to execute root exploits via a shell command:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2059.png\" style=\"width: 723px; height: 104px;\" \/><\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2061.png\" style=\"width: 728px; height: 103px;\" \/><\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2063.png\" style=\"width: 735px; height: 101px;\" \/><\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2065.png\" style=\"width: 725px; height: 103px;\" \/><\/p>\n<p align=\"center\">Figure 51. Execute root exploits via shell command<\/p>\n<p>After investigating these executable files, I found that r3 is the MTK root scheme from the dashi root tool, the exploits method in r4 comes from one exploit(<a href=\"https:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2013-6282\">CVE-2013-6282<\/a>) of the open source project <a href=\"https:\/\/github.com\/android-rooting-tools\/android_run_root_shell\">android-rooting-tools<\/a>, and the exploit method in r2 is the <a href=\"https:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2012-6422\">CVE-2012-6422<\/a> which is a root exploit on Samsung Exynos.<\/p>\n<p>The function hanleOriMiddle executes root exploits and some commands via a shell command. All executed shell commands are shown below:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2067(1).png\" style=\"width: 790px; height: 155px;\" \/><\/p>\n<p align=\"center\">Figure 52. All commands executed when rooting device<\/p>\n<p>After successfully gaining root access, the script named psneuter.js is executed with super user privilege. The main purpose of this script is to install root privilege applications in folder \/system\/priv-app\/.<\/p>\n<p>Later, we will investigate these two new APK files. To avoid being caught by common users, these two apps have no icons on a victim&rsquo;s device after being installed.<\/p>\n<p>Additionally, the other script named rsh is then executed via a shell command.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2069.png\" style=\"width: 801px; height: 106px;\" \/><\/p>\n<p align=\"center\">Figure 53. Execute the script rsh via shell command<\/p>\n<p>The script rsh is different, based on the Build.MANUFACTURER property. The script is shown below.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2071.png\" style=\"width: 804px; height: 446px;\" \/><\/p>\n<p align=\"center\">Figure 54. The script rsh(1)<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2073.png\" style=\"width: 829px; height: 521px;\" \/><\/p>\n<p align=\"center\">Figure 55. The script rsh(2)<\/p>\n<h3>V. How BSetting.apk works<\/h3>\n<p>As shown in Figure 50, abc.apk was dropped in the folder \/system\/priv-app\/ and renamed to BSetting.apk, and BSetting.apk was installed via pm.<\/p>\n<p>BSetting.apk serves as a remote control service, and it fetches tasks from the remote server and performs them.<\/p>\n<p>This app runs in the background and does not have a launcher icon on the device. The following is the app information.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2075.png\" style=\"width: 453px; height: 737px;\" \/><\/p>\n<p align=\"center\">Figure 55. App info of BSetting.apk<\/p>\n<p>The app disguises itself as an Android sync service. The decompiled structure of the apk file is shown below:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2077.png\" style=\"width: 599px; height: 287px;\" \/><\/p>\n<p align=\"center\">Figure 56. Decompiled abc.apk<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2079.png\" style=\"width: 1079px; height: 514px;\" \/><\/p>\n<p align=\"center\">Figure 57.&nbsp; The AndroidMainfest.xml in abc.apk<\/p>\n<p>The BroadcastReceiver com.sfy.oyr.R performs the main logic of this app.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2081.png\" style=\"width: 1063px; height: 391px;\" \/><\/p>\n<p align=\"center\">Figure 58. The class R<\/p>\n<p>The program first decrypts jif.png in the folder assets. It&rsquo;s a dex file, and the program uses java reflection to load class and invoke some methods.<\/p>\n<p>We decompiled the decrypted dex file, as shown below:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2083.png\" style=\"width: 712px; height: 389px;\" \/><\/p>\n<p align=\"center\">Figure 59. Decompile classes.dex<\/p>\n<p>The function launchTancTask in class ADService is used to fetch tasks from the remote server and perform them.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2085.png\" style=\"width: 962px; height: 219px;\" \/><\/p>\n<p align=\"center\">Figure 60. Fetching a task from the remote server<\/p>\n<p>The traffic from fetching the task is shown below.&nbsp; The remote server has two domains. One is the main domain grs[.]gowdsy[.]com, and the other is backup domain grs[.]rogsob[.]com. The response from the remote server is an xml file that contains the type of task, the url used to push porn, the url of the downloading apk, and the type of app to install, etc.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2087.png\" style=\"width: 1044px; height: 338px;\" \/><\/p>\n<p align=\"center\">Figure 61. The traffic of fetching the task from the remote server<\/p>\n<p>Depending on the type of task fetched, the app executes the task in a different way. The following is the key code snippet:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2089.png\" style=\"width: 1008px; height: 455px;\" \/><\/p>\n<p align=\"center\">Figure 62. Execute the task depending on the type of task<\/p>\n<p>The remote control service is capable of performing multiple malicious behaviors, including but not limited to the following:<\/p>\n<ol>\n<li><strong>Uninstall app<\/strong><\/li>\n<\/ol>\n<p>It uses the utility &ldquo;pm uninstall&rdquo; of android system to uninstall app.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2091.png\" style=\"width: 1114px; height: 64px;\" \/><\/p>\n<p align=\"center\">Figure 63. Execute pm uninstall to uninstall app via shell command<\/p>\n<ol>\n<li value=\"2\"><strong>Push porn<\/strong><\/li>\n<\/ol>\n<p>The following are some screenshots for pushed porn.<\/p>\n<p align=\"center\"><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2093.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 516px;\" \/>&nbsp;<img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2095.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 526px;\" \/>&nbsp;<img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2097.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 483px;\" \/><\/p>\n<p align=\"center\">Figure 64. Porn pushed to the device by the app<\/p>\n<ol>\n<li value=\"3\"><strong>Create a shortcut on the home screen<\/strong><\/li>\n<\/ol>\n<p>The shortcuts found contain porn, hot app, hot video, etc. The following is the code snippet and some screenshots of the shortcuts created.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2099.png\" style=\"width: 890px; height: 474px;\" \/><\/p>\n<p align=\"center\">Figure 65. The snippet of creating the shortcut on home screen<\/p>\n<p align=\"center\"><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2101.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 535px;\" \/><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2103.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 531px;\" \/><\/p>\n<p align=\"center\">Figure 66. Shortcuts on home screen<\/p>\n<ol>\n<li value=\"4\"><strong>App and ad promotion <\/strong><\/li>\n<\/ol>\n<p>In addition to gaining root privileges on the device, the rootnik malware promotes apps and ads to generate revenue for its creator. Its app and ad promotion is especially aggressive and annoying to the user.<\/p>\n<p>The following are some screenshots of its app promotion:<\/p>\n<p align=\"center\"><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2105.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 532px;\" \/><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2107.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 524px;\" \/>&nbsp;<img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2109.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 534px;\" \/><\/p>\n<p align=\"center\"><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2111.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 531px;\" \/>&nbsp;<img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2113.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 529px;\" \/>&nbsp;<img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2115.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 536px;\" \/>&nbsp;<\/p>\n<p align=\"center\"><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2117.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 532px;\" \/>&nbsp;&nbsp;<img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2119.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 531px;\" \/><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2121.png\" style=\"display: inline; border-width: 0px; border-style: solid; width: 300px; height: 538px;\" \/><\/p>\n<p align=\"center\">Figure 67. App and ad promotion<\/p>\n<ol>\n<li value=\"5\"><strong>Normal app installation and silent app installation<\/strong><\/li>\n<\/ol>\n<p>The malware uses different ways to install an app, depending on the type of task that has been fetched. The following is the code snippet of a normal app installation that has a user-interface view during the installation process.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2123.png\" style=\"width: 805px; height: 133px;\" \/><\/p>\n<p align=\"center\">Figure 68. Normal app installation<\/p>\n<p>The app uses the utility &ldquo;pm install -r&rdquo; of the Android system to silently install non-system apps while it drops APK files into the folder \/system\/priv-app\/ to install system apps.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2125.png\" style=\"width: 1283px; height: 69px;\" \/><\/p>\n<p align=\"center\">Figure 69. Silent non-system app installation<\/p>\n<p>In the folder \/data\/app\/ we found that some apk files (including, but not limited to the following) had been installed.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2127.png\" style=\"width: 824px; height: 489px;\" \/><\/p>\n<p align=\"center\">Figure 70. Apps installed in the folder \/data\/app\/ by the malware<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2129.png\" style=\"width: 1238px; height: 91px;\" \/><\/p>\n<p align=\"center\">Figure 71.Command to install system app<\/p>\n<p>In the folder \/system\/priv-app\/ we found that some apk files (including, but not limited to the following) had also been installed.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2131.png\" style=\"width: 780px; height: 228px;\" \/><\/p>\n<p align=\"center\">Figure 72. Apps installed in folder \/system\/priv-app\/ by the malware<\/p>\n<ol>\n<li value=\"6\"><strong>Push notification<\/strong><\/li>\n<\/ol>\n<p>The malware pushes a notification and induces the user to click it to open the URL in a browser.<\/p>\n<p>The following is the code snippet of the pushed notification.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2133.png\" style=\"width: 818px; height: 322px;\" \/><\/p>\n<p align=\"center\">Figure 73. Snippet of pushed notification<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2135.png\" style=\"width: 461px; height: 810px;\" \/><\/p>\n<p align=\"center\">Figure 74. Push notifications used by the malware<\/p>\n<ol>\n<li value=\"7\"><strong>Download files <\/strong><\/li>\n<\/ol>\n<p>We found that there are many files and folders downloaded in folder \/sdcard\/. They include apk files, jar files, pictures, log files, etc.These files are generated by the installed apps, and some of them perform malicious behaviors.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2137.png\" style=\"width: 861px; height: 466px;\" \/><\/p>\n<p align=\"center\">Figure 75. The files and folders dowonloaded in folder \/sdcard\/<\/p>\n<h2>Solution<\/h2>\n<p>The malware sample is detected by Fortinet Antivirus signature Android\/Rootnik.PAC!tr.<\/p>\n<p>The traffic communicating with remote C2 server can be detected by Fortinet IPS signature Android.Rootnik.Malware.C2.<\/p>\n<h2>Summary<\/h2>\n<p>From the analysis above, we can see that the rootnik malware is very powerful and uses very advanced anti-debugging and anti-hooking techniques to prevent reversing engineering, and different types of encryption for files and strings. Additionally, it also uses a multidex scheme to dynamically load and install the secondary dex file that is the main logic of this malware.&nbsp; The malware uses some open-sourced Android root exploit tools and the MTK root scheme from dashi root tool to gain root access on the Android device.&nbsp; After successfully gaining root privileges on the device, the rootnik malware can perform a variety of malicious, including app and ad promotion, pushing porn, creating shortcuts on the home screen, silent app installation, and pushing notifications, etc.&nbsp;<\/p>\n<h2>Appendix<\/h2>\n<h3>Rootnik Malware Sample<\/h3>\n<p><strong>Package Name: com.web.sdfile<\/strong><\/p>\n<p>SHA256: E5E22B357893BC15A50DC35B702DD5FCDFEAFC6FFEC7DAA0D313C724D72EC854<\/p>\n<p>Additional APK files dropped into system partition by Rootnik malware<\/p>\n<p><strong>Package Name: com.br.srd<\/strong><\/p>\n<p>SHA256: E2BDCFE5796CD377D41F3DA3838865AB062EA7AF9E1E4424B1E34EB084ABEC4A<\/p>\n<p><strong>Package Name: com.oyws.pdu<\/strong><\/p>\n<p>SHA256: CEE6584CD2E01FAB5F075F94AF2A0CE024ED5E4F2D52E3DC39F7655C736A7232<\/p>\n<h3>C&amp;C Server<\/h3>\n<p>gt[.]rogsob[.]com<\/p>\n<p>grs[.]gowdsy[.]com:<\/p>\n<p>qj[.]hoyebs[.]com<\/p>\n<p>qj[.]hoyow[.]com<\/p>\n<p>gt[.]yepodjr[.]com<\/p>\n<p>&nbsp;<\/p>\n<\/div<br \/><a href=\"http:\/\/blog.fortinet.com\/2017\/01\/26\/deep-analysis-of-android-rootnik-malware-using-advanced-anti-debug-and-anti-hook-part-ii-analysis-of-the-scope-of-java\" target=\"bwo\" >https:\/\/blog.fortinet.com\/feed<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Rootnikpt2001.png\"\/><br \/>Deep Analysis of Android Rootnik Malware Using Advanced Anti-Debug and Anti-Hook, Part II: Analysis of The Scope of Java    By Kai Lu    \u00a0    In part I of this blog, we have finished the analysis of native layer and gotten the decrypted secondary dex file. Next, we continue to analysis it. For the\u00a0sake\u00a0of\u00a0continuity, we keep continuous section number and figure number with part I of the blog.    \u00a0    \u00a0      \tThe secondary dex file      The following is the decrypted file, which is a jar format file.\u00a0 It is loaded&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10424,10378],"tags":[],"class_list":["post-6399","post","type-post","status-publish","format-standard","hentry","category-fortinet","category-security"],"_links":{"self":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/6399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=6399"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/6399\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=6399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=6399"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=6399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}