{"id":8275,"date":"2017-07-09T06:40:12","date_gmt":"2017-07-09T14:40:12","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/07\/09\/news-2049\/"},"modified":"2017-07-09T06:40:12","modified_gmt":"2017-07-09T14:40:12","slug":"news-2049","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2017\/07\/09\/news-2049\/","title":{"rendered":"Unmasking Android Malware: A Deep Dive into a New Rootnik Variant, Part III"},"content":{"rendered":"<p><strong>Credit to Author: Kai Lu| Date: Sun, 09 Jul 2017 14:00:00 +0000<\/strong><\/p>\n<div class=\"entry\">\n<p>In this final blog in the Rootnik series we will finish our analysis of this new variant. <a href=\"http:\/\/blog.fortinet.com\/2017\/07\/06\/unmasking-android-malware-a-deep-dive-into-a-new-rootnik-variant-part-ii?noTracking\">Read Part 2 here<\/a><\/p>\n<p>Let&rsquo;s start by looking into the script shell rsh.<\/p>\n<h2>Analysis of the script shell<\/h2>\n<p>Through our investigation we are able to see how the script shell works:<\/p>\n<ol>\n<li>First, it writes the content of the file .ir into \/system\/etc\/install-recovery.sh. The file install-recovery.sh is a startup script. When the android device is booted, the script can be executed.<\/li>\n<\/ol>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3001.png\" style=\"width: 1428px; height: 64px;\" \/><\/p>\n<p>The following is the content of the file .ir.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3003.png\" style=\"width: 427px; height: 84px;\" \/><\/p>\n<ol>\n<li value=\"2\">Next, it writes some files into the folder files\/.snow\/, and into the system folders \/system\/bin\/ and \/system\/xbin\/.<\/li>\n<\/ol>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3005.png\" style=\"width: 1419px; height: 516px;\" \/><\/p>\n<ol>\n<li value=\"3\">It then installs six system apps in the folder \/system\/priv-app\/.<\/li>\n<\/ol>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3007.png\" style=\"width: 1464px; height: 1108px;\" \/><\/p>\n<ol>\n<li value=\"4\">It then generates busybox into the folder \/system\/bin\/, .rainin into the folder \/system\/xbin\/, and library libsoon.so into the folder \/system\/lib\/.<\/li>\n<\/ol>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3009.png\" style=\"width: 1448px; height: 561px;\" \/><\/p>\n<ol>\n<li value=\"5\">It then replaces the Android system&rsquo;s executable file debuggerd.<\/li>\n<\/ol>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3011.png\" style=\"width: 1355px; height: 178px;\" \/><\/p>\n<p>The following is the content of the file .dg.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3013.png\" style=\"width: 568px; height: 153px;\" \/><\/p>\n<ol>\n<li value=\"6\">Next, it executes some executable files in the folder \/system\/bin\/ and \/system\/xbin\/ and then generates a new device policy file.<\/li>\n<\/ol>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3015.png\" style=\"width: 1472px; height: 69px;\" \/><\/p>\n<p>The following is the content of the file a.xml.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3017.png\" style=\"width: 565px; height: 221px;\" \/><\/p>\n<p>I next analyzed the ELF file .rainin in the folder \/system\/xbin\/. It&rsquo;s used to inject the library libsoon.so into the processes vold, netd, as well as zygote.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3019.png\" style=\"width: 801px; height: 425px;\" \/><\/p>\n<p align=\"center\">Figure 1.&nbsp; The function injecting libsoon.so in process<\/p>\n<p>The following is the key code snippet in the function &nbsp;sub_94C8(int a1, const char *a2, char *a3, char *a4).<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3021.png\" style=\"width: 858px; height: 725px;\" \/><\/p>\n<p align=\"center\">Figure 2. The key code snippet in the function&nbsp; sub_94C8<\/p>\n<p>The following is the log file after executing the ELF file \/system\/xbin\/.rainin<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3023.png\" style=\"width: 941px; height: 373px;\" \/><\/p>\n<p align=\"center\">Figure 3. The log file after executing \/system\/xbin\/.rainin<\/p>\n<p>When the .so injection is successful, it can invoke the function solib_entry in libsoon.so.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3025.png\" style=\"width: 667px; height: 580px;\" \/><\/p>\n<p align=\"center\">Figure 4. The function solib_entry in libsoon.so<\/p>\n<p>The definition of the function checkInstallRecoveryEtc() is shown below.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3027.png\" style=\"width: 1075px; height: 369px;\" \/><\/p>\n<p align=\"center\">Figure 5. The function checkInstallRecoveryEtc()<\/p>\n<p>It checks the mode of some binary files as well as some installed apps. It then restores InstallRecovery script, and checks to see if the SU daemon is running. Finally, it checks to see if the app &ldquo;com.fly.me.ssp.be&rdquo; has been installed. If not, it could run this app.<\/p>\n<p>The ELF file \/system\/bin\/.author is a su binary. The following is its usage:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3029.png\" style=\"width: 724px; height: 225px;\" \/><\/p>\n<p align=\"center\">Figure 6. The usage of \/system\/bin\/.author<\/p>\n<h2>Looking into the installed apps<\/h2>\n<p>As shown in Tables 1 and 2 in Part II of this blog series, the malware app is able to launch some activities in the installed app. Combining them with the installed apps in script shell rsh, we have listed these installed apps as follows:<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3031.png\" style=\"width: 1362px; height: 262px;\" \/><\/p>\n<p align=\"center\">Table 1. The list of installed apps<\/p>\n<p>From column labeled &nbsp;&ldquo;Detection&rdquo; you can see that Fortinet&rsquo;s AV engine has detected and identified them as malware.<\/p>\n<p>You can also see that most of them were installed in the system app folder \/system\/priv-app\/. The other two apps were installed in the folder \/data\/app\/ through the command &ldquo;pm install&rdquo;.<\/p>\n<p>The APK files listed in Table 1 can be generated by two methods: via http request and by being hard-coded. Regardless of whether the hard-coded or http request method is used, the data generated is decrypted. The two decryption algorithms used are shown in the Appendix at the end of this blog.<\/p>\n<p>Additionally, we also found that more apps (including, but not limited to the following) had been installed in the folder \/system\/priv-app\/.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3033.png\" style=\"width: 658px; height: 290px;\" \/><\/p>\n<p align=\"center\">Figure 7. Apps installed in folder \/system\/priv-app\/ by the malware<\/p>\n<p>We also found that a large number of apps (including, but not limited to the following) had been installed in the folder \/data\/app\/.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3035.png\" style=\"width: 769px; height: 369px;\" \/><\/p>\n<p align=\"center\">Figure 8. Apps installed in folder \/data\/app\/ by the malware<\/p>\n<h2>Malicious Behaviors Observed<\/h2>\n<p>The Rootnik malware performed a number of malicious behaviors. These include, but are not limited to the following:<\/p>\n<ol>\n<li><u>App and ad promotion<\/u><\/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. The following are some screenshots of its app promotion:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/9.png\" style=\"width: 933px; height: 854px;\" \/><\/p>\n<p align=\"center\">Figure 9. The screenshots of app promotion<\/p>\n<ol>\n<li value=\"2\"><u>Normal and silent app installation<\/u><\/li>\n<\/ol>\n<p>The following is the screenshot of normal app installation and silent app installation.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/10.png\" \/><\/p>\n<p align=\"center\">Figure 10. The screenshots of normal and silent app installations<\/p>\n<ol>\n<li value=\"3\"><strong><u>Push notifications<\/u><\/strong><\/li>\n<\/ol>\n<p>The malware pushes a notification and induces the user to click it.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/11.png\" style=\"width: 1079px; height: 571px;\" \/><\/p>\n<p align=\"center\">Figure 11. <strong>Push notification<\/strong><\/p>\n<ol>\n<li value=\"4\"><u>Sends SMS messages <\/u><\/li>\n<\/ol>\n<p style=\"margin-left:31.5pt;\">The malware can send SMS messages to aspecific subscription number and then delete it in the SMS box. It can also send an SMS message through adb command.<\/p>\n<ol>\n<li value=\"5\"><u>Downloads files<\/u><\/li>\n<\/ol>\n<p style=\"margin-left:31.5pt;\">We found that many files and folders were also downloaded in folder \/sdcard\/. They include apk 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\" style=\"margin-left:31.5pt;\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3063.png\" style=\"width: 781px; height: 545px;\" \/><\/p>\n<p align=\"center\" style=\"margin-left:31.5pt;\">Figure 12. Files and folders dropped into folder \/sdcard\/<\/p>\n<h2>Workflow of Rootnik<\/h2>\n<p>Finally, I drew the following workflow diagram of how the new Android Rootnik variant works.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/rootnikPART3065.png\" style=\"width: 824px; height: 708px;\" \/><\/p>\n<p align=\"center\">Figure 13. An overview of the Android Rootnik malware&rsquo;s workflow<\/p>\n<h2>Solution<\/h2>\n<p>The malware sample is detected by Fortinet Antivirus signature Android\/Rootnik.AE!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, we can see that this new Rootnik variant is able to disguise itself as a legal app. The developer of the malware app was able to repackage a legal app from Google Play and insert malicious codes into it. This disguise can trick even careful users.<\/p>\n<p>Additionally, this new variant is rather powerful and uses advanced anti-debugging techniques to prevent reversing engineering, as well as different types of encryption for files and strings. The malware also 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;The root exploits can be downloaded from a remote http server. It&rsquo;s also easy for the developer to update the root scheme of this malware and extend its functionality. Finally, after successfully gaining root privileges on the device, the rootnik malware can perform a variety of malicious operations, including app and ad promotion, silent app installation, and pushing notifications and sending SMS messages, etc.&nbsp;<\/p>\n<h2>Appendix<\/h2>\n<p><strong>Rootnik Malware Sample<\/strong><\/p>\n<p style=\"margin-left:.5in;\">Package Name:&nbsp; net.gotsun.android.wifi_configuration<\/p>\n<p style=\"margin-left:.5in;\">SHA256:&nbsp; 42e2e975edc9972c37bfc13742cd83e43eca3d708e5ea087a0a1fcaf63cbae09<\/p>\n<p><strong>Additional APK files dropped into system partition by Rootnik malware<\/strong><\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.para.android.power<\/p>\n<p style=\"margin-left:.5in;\">SHA256: 80e4c74758207df2cf495c4afcfb6aa7e8bd3b67443a7804f43ccc21f9d5b167<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.facebook.application<\/p>\n<p style=\"margin-left:.5in;\">SHA256: e512260cb90aa2bc915d53bd9003a0452a856c1e9694c023baf8de6bd6b7e2ae<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.android.service.power.on<\/p>\n<p style=\"margin-left:.5in;\">SHA256: 1a4534ce4b89bdace361ad6c26e75c06e44d95004a87e8ab990982d5f54c6135<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.android.fk.json.tool<\/p>\n<p style=\"margin-left:.5in;\">SHA256: 2d4caa4a5e26e2cfdb217d9d41c206746b5ff0c0a095d7c2e4858f233d6625c3<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.fly.me.ssp.be<\/p>\n<p style=\"margin-left:.5in;\">SHA256: e72e49fca9a0e3a6de8168f40fc9e4b28c8baf27d00a73127263541c7022cd71<\/p>\n<p style=\"margin-left:.5in;\">Package Name: org.app.info.grate<\/p>\n<p style=\"margin-left:.5in;\">SHA256: 9604f15fb36abf47566269b9c741bc41112dd66c4b06febf21980c2d6e581637<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.android.tools.receiver<\/p>\n<p style=\"margin-left:.5in;\">SHA256: 843603e582f0453acce0de8b9443c5a9e2c551ddbab7c9aa480ce44da47c5ab0<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.android.upon.hash<\/p>\n<p style=\"margin-left:.5in;\">SHA256: 6834bd13f87d6dbb67210838ec7c44e33bb65342091634d614a2868164089125<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.setting.dysdtool<\/p>\n<p style=\"margin-left:.5in;\">SHA256: e5f727bca0b9900bcc3124e9df6d83b32df1306acfaeb40551b2b47746a36959<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.sang.you.mima.yuanhou<\/p>\n<p style=\"margin-left:.5in;\">SHA256: 9f74ab6a92848fcc7861f9fc00b0db3260db0809bc16c519fbcdf644030c72a8<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.music.cloud.app.player<\/p>\n<p style=\"margin-left:.5in;\">SHA256: e48dfb52676a66ee83221fe517408e56dff1fbcf4ee2392d18a8aa31cdcedc9b<\/p>\n<p style=\"margin-left:.5in;\">Package Name: com.android.shopping.eupdate<\/p>\n<p style=\"margin-left:.5in;\">SHA256: 7a27c887c26e068ca28188574b6d731587360f24bcd03033b01e42afb16585e5<\/p>\n<p><strong>C2 Servers<\/strong><\/p>\n<p style=\"margin-left:.5in;\">api[.]gadmobs.com<\/p>\n<p style=\"margin-left:.5in;\">t[.]eqqsl.com<\/p>\n<p style=\"margin-left:.5in;\">t[.]pkqqsl.com<\/p>\n<p style=\"margin-left:.5in;\">t[.]plsskq.com<\/p>\n<p style=\"margin-left:.5in;\">t[.]wqctkq.com<\/p>\n<p style=\"margin-left:.5in;\">gp[.]miaoxia123.com<\/p>\n<p style=\"margin-left:.5in;\">sh[.]pencilli.com<\/p>\n<p style=\"margin-left:.5in;\">down[.]zigyfdeb.com<\/p>\n<p style=\"margin-left:.5in;\">down[.]smykttum.com<\/p>\n<p style=\"margin-left:.5in;\">sys[.]appsolo.net<\/p>\n<p style=\"margin-left:.5in;\">sys[.]gadmobs.com<\/p>\n<p style=\"margin-left:.5in;\">sys[.]iappzone.net<\/p>\n<p style=\"margin-left:.5in;\">sys[.]alowcar.com<\/p>\n<p><strong>The decryption program for the hard-coded method<\/strong><\/p>\n<p>  <script src=\"https:\/\/gist.github.com\/anonymous\/15319837f0ba8f08903a2ac88eff384f.js\"><\/script>    <\/p>\n<p><strong>The decryption program for the http request method<\/strong><\/p>\n<p style=\"margin-left:.5in;\">&nbsp;<\/p>\n<p>  <script src=\"https:\/\/gist.github.com\/anonymous\/759e9c67543f73511214efc56e01c700.js\"><\/script><\/div<br \/><a href=\"https:\/\/blog.fortinet.com\/2017\/07\/09\/unmasking-android-malware-a-deep-dive-into-a-new-rootnik-variant-part-iii\" 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\/rootnikPART3001.png\"\/><\/p>\n<p><strong>Credit to Author: Kai Lu| Date: Sun, 09 Jul 2017 14:00:00 +0000<\/strong><\/p>\n<p>In this final blog in the Rootnik series we will finish our analysis of this new variant.    Let\u2019s start by looking into the script shell rsh.    Analysis of the script shell    Through our investigation we are able to see how the script shell works:      \tFirst, it writes the content of the file .ir into \/system\/etc\/install-recovery.sh. The file install-recovery.sh is a startup script. When the android device is booted, the script can be executed.          The following is the content of the file .ir.          \tNext, it writes some files&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","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-8275","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\/8275","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=8275"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/8275\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=8275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=8275"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=8275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}