**[Resources](http://www.baesystems.com/en/cybersecurity/resources)** **[Contact us](http://www.baesystems.com/en/cybersecurity/contact-us)** ### BAE SYSTEMS THREAT RESEARCH BLOG **[Home](http://baesystemsai.blogspot.tw/)** **[Products](http://www.baesystems.com/en/cybersecurity/products)** **[Solutions](http://www.baesystems.com/en/cybersecurity/solutions)** **[News & Events](http://www.baesystems.com/en/cybersecurity/news-and-events)** **[Partners](http://www.baesystems.com/en/cybersecurity/partners)** **[About Us](http://www.baesystems.com/en/cybersecurity/about-us)** **[Careers](http://www.baesystems.com/en/cybersecurity/careers)** **SEARCH** # THREAT RESEARCH BLOG **[Home » Unlabelled » Lazarus’ False Flag Malware](http://baesystemsai.blogspot.tw/)** **Posted by Sergei Shevchenko - Monday, 20 February 2017** ## LAZARUS’ FALSE FLAG MALWARE **_Written by Sergei Shevchenko and Adrian Nish_** #### BACKGROUND **We continue to investigate the recent wave of attacks on banks using watering-holes** **on at least two financial regulator websites as well as others. Our initial analysis of** **malware disclosed in the BadCyber blog hinted at the involvement of the 'Lazarus'** **threat actor. Since the release of our report, more samples have come to light, most** **notably those described in the Polish language niebezpiecznik.pl** **[blog on 7 February](https://niebezpiecznik.pl/post/jak-przeprowadzono-atak-na-knf-i-polskie-banki-oraz-kto-jeszcze-byl-na-celowniku-przestepcow/)** **2017.** ----- |MD5 hash|Filename|Compile Time|File Info|Submitte d| |---|---|---|---|---| |9216b29114fb6713ef228370cbfe 4045|srservice.c hm|N/A|N/A|N/A| |8e32fccd70cec634d13795bcb1d a85ff|srservice.h lp|N/A|N/A|N/A| |e29fe3c181ac9ddbb242688b151f 3310|srservice.d ll|2016-10- 22 08:08|Win64 DLL 78 KB|2017-01- 28 11:58| |9914075cc687bdc352ee136ac65 79707|fdsvc.exe|2016-08- 26 04:19|Win64 EXE 60 KB|2017-02- 05 15:14| |9cc6854bc5e217104734043c89d c4ff8|fdsvc.dll|2016-08- 26 04:11|Encrypte d 470 KB|2017-02- 05 15:15| **Of the hashes provided, only three samples could be found in public malware** **repositories. All three had been submitted from Poland in recent weeks.** **In the analysis section below we examine these and the ‘false flag’ approach** **employed by the attackers in order to spoof the origin of the attack. The same ‘false** **[flag’ approach was also found in the SWF-based exploit mentioned in our previous](http://baesystemsai.blogspot.com/2017/02/lazarus-watering-hole-attacks.html)** **blogpost:** **MD5 hash** **Filename** **File Info** **Submitted** **Adobe** **2016-12-07** **6dffcfa68433f886b2e88fd984b4995a [cambio.sw]** **f** **Flash** **23:15** **Here we’ll analyse these files as well as shed further light on the watering-hole exploit** **kit code itself, in the hope this aids further detection and network defence.** #### ANALYSIS Sample #1 – srservice.chm **Most likely, this file is an encrypted backdoor that is decrypted and injected by DLL** **loader. The filename srservice.chm is consistent with the method in which a** **known Lazarus toolkit module constructs CHM and HLP file names:** |MD5 hash|Filename|File Info|Submitted| |---|---|---|---| |6dffcfa68433f886b2e88fd984b4995a|cambio.sw f|Adobe Flash|2016-12-07 23:15| **%SYSTEMROOT%\Help\%MODULE_NAME%.chm** **%SYSTEMROOT%\Help\%MODULE_NAME%.hlp** #### S l #2 i hl ----- **Most likely, this file is an encrypted configuration file, which is decrypted and loaded** **by the sample #1 (srservice.chm).** #### Sample #3 – srservice.dll **This DLL loads, decrypts and injects the 'CHM' file into the system lsass.exe** **process.** #### Sample #4 – fdsvc.exe **This file is a command line tool that accepts several parameters such as encrypted file** **name and process ID. The tool reads and decrypts the specified file, and then injects** **it into the specified process or into the system process explorer.exe.** **The encryption consists of a running XOR, followed with RC4, using the 32-byte RC4** **key below:** **A6 EB 96 00 61 B2 E2 EF 0D CB E8 C4 5A F1 66 9C** **A4 80 CD 9A F1 2F 46 25 2F DB 16 26 4B C4 3F 3C** #### Sample #5 – fdsvc.dll **The file fdsvc.dll is an encrypted file, successfully decrypted into a valid DLL** **(MD5: 889e320cf66520485e1a0475107d7419) by the aforementioned executable** **fdsvc.exe.** **Once decrypted, it represents itself as a bot that accepts the C&C name and port** **number(s) as a string parameter that is used to call the DLL. The parameter is** **encoded with an XOR loop that includes XOR key cEzQfoPw.** **Multiple C&C servers can be delimited with the '|' character and port numbers are** **delimited from the C&C servers with the ':' character.** **Once the bot has established communication with the remote C&C, it uses several** **transliterated Russian words to either indicate the state of its communication or issue** **backdoor commands, such as:** ----- |"Nachalo"|start communication session| |---|---| |"ustanavlivat"|handshake state| |"poluchit"|receive data| |"pereslat"|send data| |"derzhat"|maintain communication session| |"vykhodit"|exit communication session| **The binary protocol is custom. For example, during the "ustanavlivat" (handshake)** **mode, the bot accepts 4 bytes, which are then decrypted. The decryption is a loop that** **involves multiple XOR operations performed over the received data. Once decrypted,** **the 4 bytes indicate the size of the next data chunk to be received.** **The next received data chunk is also decrypted, and its contents checked to see** **whether it's one of the backdoor commands.** **For example, the "poluchit" command instructs the bot to receive the file, and the** **_"pereslat" (send) command instructs the bot to upload the file. The received "poluchit"_** **command may also contain a URL, marked with another transliterated Russian word** **_"ssylka" (link). In this case, the remote file is fetched in a separate thread. If a received_** **data chunk contains the command "vykhodit", the bot quits its backdoor loop.** **The bot implements the SSL/TLS protocol, and is based on a source code of "Curl** **_v7.49.1". Hence, it is able to transfer files via HTTP, HTTPS, FTP, SMTP and many_** **other protocols, with full support of user/password authentication (Basic, Digest,** **NTLM, Negotiate, Kerberos), proxies and SSL certificates.** #### Russian language used in fdsvc.dll **In spite of some 'Russian' words being used, it is evident that the malware author is** **not a native Russian speaker.** **Of our previous examples, five of the commands were likely produced by an online** **translation. Below we provide the examples and the correct analogues for reference:** **Word** **Type of error** **Correct analogue** **omitted sign at the end, verb tense** **_"ustanavlivat"_** **_"ustanovit'" or "ustanoviti"_** **error** **_"poluchit"_** **omitted sign at the end** **_"poluchit'" or "poluchiti"_** **_"pereslat"_** **omitted sign at the end** **_"pereslat'" or "pereslati"_** **_"derzhat"_** **omitted sign at the end** **_"derzhat'" or "derzhati"_** **omitted sign at the end, verb tense** **_"vykhodit"_** **_"vyiti"_** **error** |Word|Type of error|Correct analogue| |---|---|---| |"ustanavlivat"|omitted sign at the end, verb tense error|"ustanovit'" or "ustanoviti"| |"poluchit"|omitted sign at the end|"poluchit'" or "poluchiti"| |"pereslat"|omitted sign at the end|"pereslat'" or "pereslati"| |"derzhat"|omitted sign at the end|"derzhat'" or "derzhati"| ----- **translation of "client2connect" (which means 'client-to-connect'). In this case, the two** **words "client" and "connect" were translated separately, then transliterated from the** **Russian pronunciation form into the Latin alphabet and finally joined to produce** **_"kliyent2podklyuchit"._** **Such a result may look impressive to the bot's author, but would be difficult to** **understand for native Russian speakers.** **Here we provide an example of translating the word "client" in Russian - the word** **_"kliyent" here only demonstrates phonetic pronunciation, not how it's actually written_** **in a transliterated form. When formed using the Latin alphabet, it would actually be** **written "client" or "klient".** **Due to such inconsistencies, we conclude that the Russian language is likely used as** **a decoy tactic, in order to spoof the malware’s country of origin.** #### Sample #6 – cambio.swf **During the investigation of the watering-hole incident, the owner of a compromised** **website shared with us a malicious implant that was added into the site, presumably** **by using an exploit against JBoss 5.0.0.** **The script is called view_jsp.java and is accessed from the watering-hole website** **as view.jsp.** **This script is responsible for serving cambio.swf.** **The infection starts from a primary web site being compromised so that its visitors are** **redirected into a secondary website, calling its view.jsp script from an added** ----- **"GET /[PATH]/view.jsp?pagenum=1 HTTP/1.1"** **This begins the profiling and filtering to identify potential victims. For example, the** **script then checks to see if the client's IP is black-listed. If so, such initial request is** **rejected.** **Next, the script checks if the client’s IP is white-listed (i.e. targeted). If not white-listed,** **it is also rejected. Hence, unless the visitor’s IP is on the attackers’ list, the script will** **not attempt to infect their machine. This helps the infected websites stay undetected** **for relatively long period of time, as they only serve exploits to the selected targets.** **In the next stage of the script, it builds and serves back to the client an HTML page** **with an embedded JavaScript that detects the type of client’s browser (Internet** **Explorer, Google Chrome, Firefox, Safari, or Opera), OS version, and the loaded** **plugins, such as Adobe Flash and Microsoft Silverlight.** **The script executed on a client side then builds a form, and submits it back to the** **gateway script, as shown below:** **The submitted form specifies the pagenum parameter to be set to 2, to advance the** **script to the next step:** ----- **Once the script accepts the incoming request and finds the form's pagenum value is** **2, it reads other fields from the submitted form and decides which exploit to serve** **back to the client.** **At the time of writing, the exploit kit known to serve back two exploits, for Adobe Flash** **and Microsoft Silverlight, though these could be expanded upon as needed.** **The exploits can be individually enabled or disabled by the attackers with the** **standalone file config.dat. For example, to enable both exploits (flag=1), the** **contents of this file can be set to:** **2016-0034:1** **0000-0001:1** **where 2016-0034 identifies the Silverlight exploit, and 0000-0001 is the Flash** **exploit.** **If the script detects that the submitted form contains a non-empty version of Silverlight** **browser plugin, it will generate and serve back a Silverlight exploit. If the submitted** **form has a non-empty version of Adobe Flash browser plugin, the script will generate** **and serve back the Flash exploit. If the client has both plugins loaded within the** **browser, then the script will serve the Flash exploit only.** **NOTE: the script only serves the Flash exploit if the browser is Internet Explorer.** **The exploits are generated by the functions:** **• genExp_20160034() – to generate Silverlight exploit** **• genExp_00000001() – to generate Flash exploit** **The latter is explained in further detail below First the script builds URL string named** ----- **01** **String PARAMNAME_UID = "uid";** **02** **String PARAMNAME_PAGENUM = "pagenum";** **03** **String PARAMNAME_EXPLOITID = "eid";** **04** **String PARAMNAME_STATUS = "s";** **05** **String PARAMNAME_DATA = "data";** **06** **07** **download_url = request.getRequestURL() +** **08** **"?" + PARAMNAME_UID + "=" + uid +** **09** **"&" + PARAMNAME_PAGENUM + "=3" +** **10** **"&" + PARAMNAME_EXPLOITID +** **11** **"=" + exploit.get("eid");** **12** **...** **13** **download_url = download_url +** **14** **"&" + PARAMNAME_STATUS + "=2" +** **15** **"&" + PARAMNAME_DATA + "=";** **For example, the URL string may look like:** **http://[WEB_SITE]/view.jsp?** **uid=30304811&pagenum=3&eid=00000002&s=2&data=** **Note that the pagenum parameter of the URL has now advanced to 3 (third step of** **the view.jsp execution).** **This URL string will be embedded by the genExp_00000001() function into the** **body of the shellcode.** **The output of the genExp_00000001() function is JavaScript that has the following** **format – this script will be executed inside the client's browser:** **01** **var laskfji = 'PGh0bWw+..'; // long string here** **02** **asdlfkj = function(s) {** **03** **// base64-decode string s** **04** **};** **05** **var polkio = asdlfkj(laskfji);** **06** **var poikea = 'document.write(polkio);';** **07** **eval(poikea);** **Once the string s is base64-decoded by client-based JavaScript, it will look like a** **Flash object embedded into HTML:** ----- **02** **
** **03** **** **20** **** **21** **