Wednesday, 25 December 2019

BlackNet RAT - When you leave the Panel unprotected

BlackNET is a PHP based Web Panel which has a builder written in VB.NET. It is being actively used in-the-wild for malicious activities.

Recently, while analysing a malicious .NET Binary, I came across something interesting which caught my attention. Before I share those details, I will discuss a little bit about the capabilities of the payload, the project itself and then will present the discovery :)

MD5 hash of the sample discussed: 7e88ccc91e0f9a242c4723e43afa93ab

The .NET binaries used in-the-wild which leverage BlackNET panel are not obfuscated. At least the binaries I analysed so far are not protected or obfuscated. This makes the process of analysis straightforward.

How to identify whether this is related to BlackNET?

When you decompile the binary, the list of .NET methods are sufficient to correlate and understand that they have used the BlackNET project. In our case, after decompiling the .NET binary, we can see the list of methods as shown below:


The names of the methods are self explanatory however for the purpose of brevity, I will mention below some of the capabilities:

AntiVM: It has the ability to detect a Virtual Machine by checking for the presence of the DLL files, vmGuestLib.dll and vboxmrxnp.dll on the file system. If it finds these files, then it will delete them.

It also tries to load the DLL, SbieDll.dll to check for the presence of Sandboxie (a very common method).

DDoS: Various methods of DDoS are supported by this binary which include: ARME, Slowloris, UDP, TCP, HTTP GET and HTTP POST request based. The attacker can specify the host address they want to perform the DDoS attack against using the BlackNET Panel. They can also select the DDoS method as can be seen here

LimeLogger: This is the key logging module which leverages LowLevelKeyboardProc() function along with SetWindowsHookEx() to do keylogging.

Screening_Programs: This method checks for the presence of analysis tools used by Malware Researchers. It performs checks using both the process names as well as the Window Titles as shown below:


I have included the list in Appendix which can be used as a reference by you to harden your Virtual Machine while analyzing malwares in future.

Unprotected Web Panels

These web panels are easy to deploy. Just get a web hosting, upload the PHP scripts, run the Installation script which sets up the database and the Panel is ready to use.

I noticed that most users of BlackNET Web Panel are leveraging the hosting provided by 000webhostapp.com

One such example is the binary we are discussing in this article.

Once the sample is executed on the machine, it will gather basic details from the machine, send them in an HTTP GET request to the BlackNET panel and register the machine. For each victim's machine, an ID is generated in the format: Hacked_<ID>

Below is an example of the HTTP GET requests initiated by the binary:


Web Panel is located at: kiraamora.000webhostapp.com/blacknet

If we visit the hosting, we notice that there is no index.php script present. As a result of it, directory listing is enabled as shown below:


There is an upload directory in which the information captured from the machines is stored. Inside the upload directory, there is a directory for each victim's machine with the name in the format: Hacked_<ID>

There is one directory of specific interest as shown below:


The JPG file there is the screenshot taken from the machine. If we check the screenshot, we notice that it is the screenshot taken from the BlackNET panel's admin machine itself as shown below:


If we check the URL in the address bar in screenshot above, we can see that the command: tkschot was used to capture the screenshot from the machine.

The command itself is defined in the code here

This could be the result of the admin verifying whether the panel is working properly by taking a screenshot of their machine. However, they forgot to delete the screenshot from the panel to clear any traces.

Below are some more MD5 hashes of .NET binaries using the BlackNET Panel:

d25ee82934bec167345502a1e7e3c931
3d28dc46e048daee4974dc5e2fe08bfd
1fd19fcca59ed976ee57640dafba5518
601b4e3b04069beed78e8ce1d2859d4a
c736fcdba9c96eb9b7d8f65e6ab8a4c9
52cd657b18efdbd92f7347d439016c6b
6e36e783324800952f4c0ebea2262fb9
e829cf7a744547e5f1aca6f53061a7b7
2033caac6e8064bd845004d4d628ebe3
8ea79fb698558a8fbed892a8297f3f4b
8d72b32f0d9796443218f1363324f731
281a4bbd61d5e5e310c407b10dafb78c
cd1084d9755db2a38402df2171f25948
83614ce163a71a04fb450f5cd55bfb9f
4a9102b122d9a8dcfe693693f4d91910
8c7e485a40ba5f1881801e56ca298eb0
6fa52977cb3aef5606900cd7a11df4da
6947014e2a2b60445860bfaf5ba35dc6
bdfa464369c660fabff9ec700c49bab9
9b4402ac464744fd4ed118c956752bbc
dc4cf73a81f74f4aa3ec5224ba2cee91
31dc0a5c441b531e029a4158354a1529
6d34058315b46deb297c3d7f712f7451
53c1d9cbf7ca1147880de072d64980dd
d45bac3b009058b11cabc7a9b4048c8d

More Web Panels:

hxxp://davidescu.000webhostapp.com/BlackNET Panel/
hxxps://imdavidfree.000webhostapp.com//BlackNET%20Panel
hxxps://impieselfree.000webhostapp.com/blacknet
hxxp://homedeco.id/
hxxps://davidbotnet.000webhostapp.com/blacknet
hxxp://piratashost.top:82/panel/

Appendix:

List of Process Names Checked:

procexp
SbieCtrl
SpyTheSpy
SpeedGear
wireshark
mbam
apateDNS
IPBlocker
cports
ProcessHacker
KeyScrambler
TiGeR-Firewall
Tcpview
xn5x
smsniff
exeinfoPE
regshot
RogueKiller
NetSnifferCs
taskmgr
Reflector
capsa
NetworkMiner
AdvancedProcessController
ProcessLassoLauncher
ProcessLasso
SystemExplorer

List of Window Titles Checked:

ApateDNS
Malwarebytes Anti-Malware
TCPEye
SmartSniff
Active Ports
ProcessEye
MKN TaskExplorer
CurrPorts
System Explorer
DiamondCS Port Explorer
VirusTotal
Metascan Online
Speed Gear
The Wireshark Network Analyzer
Sandboxie Control
.NET Reflector

c0d3inj3cT

Tuesday, 24 December 2019

Unpacking Payload used in Bottle EK

On December 13th 2019, @nao_sec discovered a new Exploit kit targeting users in Japan and it was given the name, Bottle Exploit Kit.

@nao_sec described in their blog the details of the Exploit Kit including the two vulnerabilities (CVE-2018-8174 and CVE-2018-15982) which were exploited in this attack.


In this article, I will go into the details of the multiple stages of unpacking the payload used in Bottle Exploit Kit.


tl;dr: Multiple stages of packing are used in the payload. The XOR decryption routine used is common for all the payloads related to Bottle Exploit Kit and can be used to discover more instances.


MD5 hash of the sample discussed: ee98ef74c496447847f1876741596271

The WinMain() subroutine creates a new Thread as shown below:



The newly created Thread creates another Thread in turn as shown below:


The first stage of unpacking is performed by Thread 2 (function start address: 0x40105b). The figure highlights the important stages of unpacking:


The main stages of unpacking of the first stage are:

1. VirtualAlloc() to allocate memory to decrypt stage 1.
2. RtlMoveMemory() to copy 0x1ed8 bytes of encrypted data from 0x412db8 to memory allocated in step 1.
3. XOR decryption routine at address: 0x401000 is invoked. The XOR decryption key is 0x3c bytes in length and is passed as an argument to the XOR decryption routine.
4. VirtualAlloc() is called again to decompress the XOR decrypted output of step 3.
5. Decompression is performed using RtlDecompressBuffer()
6. A new Thread with function start address set to decompressed code in step 5 is started.

The XOR decryption routine mentioned in step 3 above is as shown below:


The next decrypted stage looks as shown below:


Another layer of XOR decryption is done by stage 2 which gives us the following decrypted data:


In the next stage of execution, it performs the System Language Check using the API, GetUserDefaultUILanguage() as shown below:


The system language code is compared with 0x411 which corresponds to Japanese System Language. The payload will execute completely only if the system language code is: 0x411.

Here is the list of decrypted strings:

0000000028DF   0000000028DF      0   shlwapi.dll
0000000028EB   0000000028EB      0   User32.dll
0000000028F6   0000000028F6      0   Advapi32.dll
000000002903   000000002903      0   ntdll.dll
00000000290D   00000000290D      0   Ws2_32.dll
000000002918   000000002918      0   Wininet.dll
000000002924   000000002924      0   Urlmon.dll
00000000292F   00000000292F      0   bcdfghklmnpqrstvwxzaeiouyT
000000002A56   000000002A56      0   DataDirectory %s
000000002A77   000000002A77      0   POST %s HTTP/1.1
000000002A89   000000002A89      0   Host: %s
000000002A93   000000002A93      0   Connection: close
000000002AA6   000000002AA6      0   Accept: */*
000000002AB3   000000002AB3      0   User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
000000002AE4   000000002AE4      0   Accept-Encoding: identity
000000002AFF   000000002AFF      0   Content-Type: application/x-www-form-urlencoded
000000002B30   000000002B30      0   Content-Length: %d
000000002B4C   000000002B4C      0   WSAStartup
000000002B57   000000002B57      0   socket
000000002B5E   000000002B5E      0   setsockopt
000000002B69   000000002B69      0   connect
000000002B7B   000000002B7B      0   closesocket
000000002952   000000002952      0   AppData\LocalLow
000000002974   000000002974      0   \Data\Tor
000000002988   000000002988      0   \Data\Tor\geoip
0000000029A8   0000000029A8      0   \Data\Tor\geoip6
0000000029CA   0000000029CA      0   \Tor\taskhost.exe
0000000029EE   0000000029EE      0   \Tor\tor.exe
000000002A08   000000002A08      0   \torrc
000000002A16   000000002A16      0   1.zip
000000002A22   000000002A22      0   1.exe
000000002A2E   000000002A2E      0   -o -qq "%s" -d "%s"
000000002A66   000000002A66      0   s-f "%s"
000000002B86   000000002B86      0   t.jpg
000000002B9B   000000002B9B      0   ALLUSERSPROFILE
000000002BBB   000000002BBB      0   rundll32.exe

From the Decrypted Strings above, we can see that it will make a Network Request to download TOR browser.

The XOR decryption routine used in the payload is the same among all the samples (DLL and EXE files) related to Bottle Exploit Kit instances.

Here are more MD5 hashes of payloads used in Bottle Exploit Kit:

5c9522927945f7fde17724360e9fec64
d408c3f58c3407e5d37ec524db03deb9
d6ae17d1d8ba79de1f936092297e44f9
d1bdc7c37f66702bf72d41a9276777dc
894794945683db1e708d2e9304821b19
6c71ca4978095b24a10487a84215d5bd
ee98ef74c496447847f1876741596271
e65322b4add2e5183616ce283e99614f
c67c6f2f212ffe7d99c7238c959c95e6
972d77bd40b0acfa9c0ffaf12b7cbba4
8fdd5e90c33b4feb83b74b3922c09c6d
e753d7a35a9144dd820d4d6e9be970ee

The only change is the XOR decryption key.

c0d3inj3cT