{
	"id": "341585e5-00dc-41e2-aba1-bf683a1c59b2",
	"created_at": "2023-01-12T15:10:30.609702Z",
	"updated_at": "2026-11-18T02:10:57.108908Z",
	"deleted_at": null,
	"sha1_hash": "0a9930afd2f80ce9f1b09e34f4005d025fac3df0",
	"title": "2017-03-15 - Teardown of Android-Ztorg (Part 2)",
	"llm_title": "2017-03-15 - Teardown of Android-Ztorg (Part 2)",
	"authors": "",
	"file_creation_date": "2022-05-27T19:11:00Z",
	"file_modification_date": "2022-05-27T19:11:00Z",
	"file_size": 439050,
	"plain_text": "1/9\r\nMarch 15, 2017\r\nTeardown of Android/Ztorg (Part 2)\r\nblog.fortinet.com/2017/03/08/teardown-of-android-ztorg-part-2\r\nThreat Research\r\nBy Axelle Apvrille | March 15, 2017\r\nUPDATE March 20, 2017 : the sample does not seem to embed root exploits themselves,\r\nbut more precisely executables that run rooting tools. Also Agcr64 is curiously a 32-bit\r\nexecutable, not 64-bit.\r\nIn the part 1 of this blog, we saw that Android/Ztorg.AM!tr silently downloads a remote\r\nencrypted APK, then installs it and launches a method named c() in the n.a.c.q class. In this\r\nblog post, we’ll investigate what this does.\r\nThis is the method c() of n.a.c.q:\r\nThis prints \"world,\" then waits for 200 seconds before starting a thread named n.a.c.a. I'll\r\nspare you a few hops, but among the first things we notice is that the sample uses the same\r\nstring obfuscation routine, except this time it is not named a.b.c.a() but a.a.p.a(). We patch\r\nthe JEB2 script to deobfuscate those strings:\n\n2/9\r\nEmbedded Packages\r\nThe sample checks for various packages (om.android.provider.ring.a, com.ndroid.livct.d). If\r\nthey are present, it starts them. If not, it retrieves them and starts them.\r\nThe way it retrieves the application is quite peculiar. By default, it does not download it from\r\nthe web, but gets it from a hexadecimal string stored in the code itself. It only downloads\r\nfrom the web if the hexstring is not present.\r\nIt retrieves many files that way: Android applications, ELF executables and scripts. All of\r\nthese are embedded in the sample itself. Sometimes, the sample is embedded in an\r\nencrypted form (making it even more difficult to detect for an anti-virus engine.) This is the\r\ncase of the mainmtk.apk application, which is retrieved from a DES encrypted hex string.\r\nThe DES key is built using a homemade algorithm, which consists of numerous Base64\r\nencodings and decodings.\r\nResorting to Encrypted File Download\r\nWhen the files are downloaded from the web, they are not sent in clear text, but are XOR\r\nencrypted (see class b.b.b.a.b). The XOR key is contained within the encrypted stream.\r\nBased on the reverse engineering of the decryption class, we can implement a decryptor.\r\nMine is available here.\r\nFor example, once decrypted, the bx file downloaded from hxxp://ks.freeplayweb.com/lulu/bx\r\nturns into an ELF executable (a root exploit):\n\n3/9\r\nCreating Scripts\r\nThe sample also uses some shell scripts. They are not included in the assets or\r\nresources, but embedded in the code. This is probably done so that anti-virus engines\r\ncannot directly match or search for those scripts.\r\nFor instance, the code below writes a shell script named boy.\r\nThe script will look as follows, and is used to run shell commands.\n\n4/9\r\nFiles Summary\r\nNow let's summarize the various files the sample uses. We have applications and ELF\r\nexecutables. If you want to follow along in the source code, those are retrieved in\r\nthe b.b.d.a namespace.\r\nThe files are stored locally in the application's directory, in subdirectories named .zog or .zok.\r\nNote, the name starting with a point will conceal the file to basic file listings.\r\nFile name File type Description\n\n5/9\r\nFile name File type Description\r\nAgcr32 ELF\r\nexecutable\r\nRuns root exploit tools, 32 bit version\r\nAgcr64 ELF\r\nexecutable\r\nRuns root exploit tools, expected a 64 bit version, but actually\r\nit seems it's a 32 bit version too...\r\nbbox.apk Application Installs busybox\r\nbx ELF\r\nexecutable\r\nRuns root exploit tools\r\ncx ELF\r\nexecutable\r\nRuns root exploit tools\r\nexp ELF\r\nexecutable\r\nRuns root exploit tools\r\nmaink.apk Zip Contains boy and bx files\r\nmainmtk.apk ELF\r\nexecutable\r\nRusn root exploit tools\r\nmainm.apk Replacement for com.android.musitk.b\r\nmainp.apk Could not be retrieved (server down)\r\nmains.apk Application Replacement for com.ndroid.livct.d\r\nmains2.apk Application Replacement for com.android.provider.ring.a\r\nnn.zip ELF\r\nexecutable\r\nRuns root exploit tools\r\nnp ELF\r\nexecutable\r\nRuns root exploit tools\n\n6/9\r\nFile name File type Description\r\nsupolicy ELF\r\nexecutable\r\ntool\r\nym32 ELF\r\nexecutable\r\nRuns root exploit, 32 bit version\r\nym64 ELF\r\nexecutable\r\nRuns root exploit, 64 bit version\r\nWe see we have:\r\nTools such as busybox and supolicy. These are not malicious. Busybox is used to\r\nsupport various Unix commands on Android. Supolicy is used to modify the current SE\r\nLinux policies on Android, and for instance, switch the phone to permissive policies.\r\nRoot exploit tools. For example, the executable Agcr32 tries to root the phone by\r\nrunning rooting tools. It considers it has succeeded if the output contains the\r\nkeyword TOY. See below. This is the 32-bit variant.\r\nScripts to run commands.\r\nRunning the exploits\n\n7/9\r\nOnce the root exploits are on the file system, they need to be run. This is done in the code by\r\ncreating a new process that runs sh, writing the shell commands to the process's output\r\nstream, and reading the responses on the input stream.\r\nPayload\r\nLet's put pieces together.\r\nThe sample:\r\nGets numerous exploits, tools and scripts to root the device. The files are embedded in\r\nthe code itself, or retrieved from external websites.\r\nLowers the SE Linux policy and attempts to root the device.\r\nOnce the device is rooted, the sample gets to its real payload:\n\n8/9\r\nReplaces some system files with its own versions. For example, it creates a\r\nbackup of the original /system/bin/debuggerd, replaces it with its own .zog/.k file,\r\nassigns it to root, and changes its SE Linux security context.\r\nInstalls various applications and runs them. In the case of this sample, those\r\napplications are com.android.provider.ring.a, com.ndroid.livct.d, and\r\ncom.android.musitk.b. The .zog/.k ELF executable also downloads other applications\r\nfrom a remote server and installs them. The screenshot below shows\r\nthe .zog/.k starting a key assistance application (am start -n) and downloading from\r\nhttp://api.agoall.com/ (no longer responds.)\r\nSo, we have a malware that roots victims' devices without their knowledge, and uses this\r\nprivilege to install other malicious applications.\n\n9/9\r\nConclusion\r\nThis concludes the analysis of the sample silently downloaded by the Android/Ztorg.AM!tr\r\nsample that we studied in Part 1 of this blog.\r\nMy guess is that you will agree with me that this malware is very advanced. There is string\r\nobfuscation, multiple levels of encryption (nested), root exploits, tools, and scripts hidden\r\ninside the code. The malware will be difficult to remove from the device, because it spans\r\nacross many locations and replaces system binaries.\r\nThis malware is detected as Android/Ztorg.K!tr. Its sha256 sum\r\nis 5324460dfe1d4f774a024ecc375e3a858c96355f71afccf0cb67438037697b06.\r\nThe downloader (see Part 1) is detected as Android/Ztorg.AM!tr.\r\nIts sha256 sum is\r\n2c546ad7f102f2f345f30f556b8d8162bd365a7f1a52967fce906d46a2b0dac4.\r\n-- the Crypto Girl\r\nRelated Posts\r\nCopyright © 2022 Fortinet, Inc. All Rights Reserved\r\nTerms of ServicesPrivacy Policy\r\n| Cookie Settings",
	"extraction_quality": 1,
	"language": "EN",
	"sources": [
		"VXUG"
	],
	"origins": [
		"pdf"
	],
	"references": [
		"https://papers.vx-underground.org/papers/Malware Defense/Malware Analysis 2017/2017-03-15 - Teardown of Android-Ztorg (Part 2).pdf"
	],
	"report_names": [
		"2017-03-15 - Teardown of Android-Ztorg (Part 2).pdf"
	],
	"threat_actors": [],
	"ts_created_at": 1673536230,
	"ts_updated_at": 1794967857,
	"ts_creation_date": 1653678660,
	"ts_modification_date": 1653678660,
	"files": {
		"pdf": "https://archive.orkl.eu/0a9930afd2f80ce9f1b09e34f4005d025fac3df0.pdf",
		"text": "https://archive.orkl.eu/0a9930afd2f80ce9f1b09e34f4005d025fac3df0.txt",
		"img": "https://archive.orkl.eu/0a9930afd2f80ce9f1b09e34f4005d025fac3df0.jpg"
	}
}