Saturday, September 28, 2019

MMD-0064-2019 - Linux/AirDropBot

Prologue

There are a lot of botnet aiming multiple architecture of Linux basis internet of thing, and this story is just one of them, but I haven't seen the one was coded like this before.

Like the most of other posts on our analysis reports in MalwareMustDie blog, this post was started from a request from a friend to take a look at a certain binary that was having low (or no) detection and at that time hasn't been categorized into a known threat ID.

This time I decided to write the report along with my style on how to reverse engineering its sample, in MIPS architecture.

So I was sent with this MIPS 32bit binary ..


cloudbot-mips: ELF 32-bit MSB executable, MIPS, MIPS-I 
version 1 (SYSV), statically linked, stripped

..and according to its hash it is supposed to be a Mirai-like, (thank's to good people for the uploading the sample to VirusTotal), infact, these are not Mirai, Remaiten, GafGyt (Qbot/Torlus base), Hajime, Luabots, nor China series DDoS binaries or Kaiten (or STD like). It is a newly coded Linux malware using several idea taken from existing ones.

..and this is just one of a series of badness, my honeypots, OSINT and a given tips was leading me into 26 types of samples that is meant to pwned series of internet of things running on Linux OS and the MIPS-32 one I received is just one of them. If you see the filenames you can guess some of those binaries are meant to aim specific IoT/router platforms and not only for several randomly cross-compiled architecture supported result. This type of binaries seem to be started appearing in the early August, 2019.

Below is the additional list of the compiled binaries that are meant to run on several non-Intel CPU running Linux operating systems, they can affect network devices like routers, bridges, switches, and the small internet of things that maybe we use already:

m68k-68xxx.cloudbot:   32-bit MSB Motorola m68k, 68020, version 1 (SYSV), statically linked
hnios2.cloudbot:       32-bit LSB Altera Nios II, version 1 (SYSV), dynamically linked
hriscv64.cloudbot:     64-bit LSB UCB RISC-V, version 1 (SYSV), dynamically linked
microblazebe.cloudbot: 32-bit MSB Xilinx MicroBlaze 32-bit RISC, version 1 (SYSV), statically linked
microblazeel.cloudbot: 32-bit LSB version 1 (SYSV), statically linked,
sh-sh4.cloudbot:       32-bit LSB Renesas SH, version 1 (SYSV), statically linked.
xtensa.cloudbot:       32-bit LSB Tensilica Xtensa, version 1 (SYSV), dynamically linked.
arcle-750d.cloudbot:   32-bit LSB ARC Cores Tangent-A5, version 1 (SYSV), statically linked.
arc.cloudbot:          32-bit LSB ARC Cores Tangent-A5, version 1 (SYSV), dynamically linked.

(The hashes are in the "Hashes" section of this post)

Binary Analysis

Since I was asked to look into the MIPS sample so I started with it. The binary analysis is showing a striping result, but we can still get some executable section's information, compiler setting/trace that's showing how it should be run, and some information regarding of the size for the section/program headers, but it's too few isn't it? Still these are good clues for supporting dynamic analysis afterward. But I don't think I will go that far on the early stage of analysis with this new binaries, I love to solve stuff statically, as much as possible.

For file attributes I extracted using Tsurugi DFIR commands which are also not showing special data too, except of what has been recorded into the infected box. I was taking the checks further I run some several ELF pattern I have with Yara rules and ClamAV signature to match it to see what binary is having, and it is only to make me understand why several false-positive results came up. The malware yet is having several interesting strings but they are too generic to be used to identify the threat without reading its assembly further.

So my practical binary analysis for this MIPS binary is going to be it, nothing much.

Some methods on MIPS-32 static analysis to dissect this sample with radare2:)

So this is the fun part, the binary analysis with radare2 ;). no cutter GUI, no fancy huds, just an old-schooler way with command line, visual mode and graph in a r2shell.

I think there is really no such precise step by step "cookbook" on how to to use radare2 during analyzing something, and basically radare2 is enriched in design for any kind of users to use it freely, once you get into it you'll just get use to it, and before you know it you are using it forever.

But first, let's make sure you are setting"mips" and "32" in radare2 environment of assembly architecture (arc) and bits for this binary, then try to recognize the "main function", which is in "0x4016a0" at the pattern/location that's different than Intel basis assembly like shown in the picture below:

Next, I may just run following commands to be sure that it can be reversed well. It is a simple command for only showing how many Linux syscall is used, and this will work after the radare2 parse and analyze the binary to the analysis database.

PS: If you know what you're doing, a more simple way for the MIPS 32bit to seek where the syscall codes placed is by grepping the assembly code with the hex value of "0x0000000c" like below, the same result should come up:

In my case on dealing with Linux or UNIX binaries, I have to know first what syscalls are used (that kernel uses for making basic operations), "syscall" is used to request a service from kernel. Any good or bad program are using those (if they need to run on that OS), so syscalls have to be there. For me, the syscalls is important and its amount will tell you how big the work load will be, ..then the rest is up to you and radare2 to extract them, the more of those syscalls, the merrier our RE life will be, without knowing these syscalls there's no way we can solve such stripped binary :)

In a Linux MIPS architecture, where assembly and register (reduced registers due to small space) is different than PC's Intel ones (MISP is RISC, Intel is CISC, RISC is for a CPU that is designed based on simple orders to act fast, many networking devices are on RISC for this reason). Linux OS in some MIPS platform can be configured to run either in big or in little endian mode too, you have to be careful about the endianness in reversing MIPS, like this MIPS binary is using big endian, also binaries for SGI machines, but some machines like Loongson 3 are just like Intel or PPC works in little endian, several Linux OS is differing their package for supporting each endianness with "mips" (big) or "mipsel" (little) in their MIPS port. Information on the target machines for each sample can help to recognize the endianness used.

In MIPS the way "syscall" used is also have its own uniqueness. Basically, a designated service code for a syscall must be passed in $v0 register, and arguments are passed in other registers. A simple way in assembly code to recognize a syscall is as per below snipped code:

li $v0, 0x1
add $a0, $t0, $zero
syscall

Explanation: The "0x1" is stored in the "&v0" (it doesn't have to be assembly command "li" but any command in MIPS assembly in example "addliu", etc, can be used for the same effect), which means the service code used to print integer. The next line is to perform a copy value from the register "$t0" to "$a0" (register where argument is saved).
Finally (the third line) the syscall code is there, with these components altogether one "syscall" can be executed.

We can apply the above concept in the previously grep syscall result. The objective is to recognize the address of its syscall wrapper function for this stripped binary analysis purpose. For example, at the second result at "0x004019d0" there's a syscall code, and by radare2 you go to that location with seek (s) command and using visual mode we can figure the function name in no time. I will show you how.

Let's fix the screen for it as per below so we can be at the same page:
I marked the line where it is assigning "0xfa2" value to "$v0", and "0xfa2" is the code for "fork" syscall, the function that's having that syscall code, if you scroll up a bit you can see the function name "fcn.004019a0", which is the "wrapper function" for this "syscall fork".

The manual of syscall [link] is a good reference explaining syscall wrapper in libc. Quoted:

"Usually, system calls are not invoked directly: 
instead, most system calls have corresponding C library wrapper 
functions which perform the steps required (e.g., trapping to kernel 
mode) in order to invoke the system call.  

Thus, making a system call looks the same as invoking a
normal library function.

In many cases, the C library wrapper function does nothing more than:

*  copying arguments and the unique system call number to the
   registers where the kernel expects them;

*  trapping to kernel mode, at which point the kernel does the real
   work of the system call;

*  setting errno if the system call returns an error number when the
   kernel returns the CPU to user mode.

However, in a few cases, a wrapper function may do rather more than
this, for example, performing some preprocessing of the arguments
before trapping to kernel mode, or postprocessing of values returned
by the system call.  Where this is the case, the manual pages in
Section 2 generally try to note the details of both the (usually GNU)
C library API interface and the raw system call.  Most commonly, the
main DESCRIPTION will focus on the C library interface, and
differences for the system call are covered in the NOTES section."

Using this method, in no time you'll get the full list of the syscall function's used by this malware as per following table that I made for myself during this analysis:

The rest is up to you on how to make it easy to name the strings for each "syscall" for your purpose, I go by the above strings naming since it is fit to my RE platform, I suggest you refer to Linux syscall base on naming them [link].

The next step is, you may need to change all function name in radare2 according to this "syscall table". Using the visual mode and analyze function name (afn) command is the faster way to do it manually, or you can script that too, radare2 can be used with varied of methods, anything will do as long as we can get the job's done. In my case I like to use these radare2 shell macro based on table I made for myself:

    :
s 0x0402060; af; afn ____connect; pdf |head 
s 0x0401CF0; af; afn ____write; pdf |head 
s 0x04019B0; af; afn ____fork; pdf |head 
    :

The result is as per seen in the below screenshot:

Up to this way, we'll have all of the syscalls back in place :) Don't worry, you'll do this faster if you get used to it.

The result looks cool enough for me to read the radare2 graph on examining how this MIPS binary further goes..

The next step is a generic way on reversing a stripped binary, by defining the functions that is not part of Libc but likely coded by malware coder. For this task, you have to check the rest of the function and seek whether the XREF doesn't go to any of syscall wrapper functions, nor main(), init_proc() or init_term() functions, and that goes to the below leftover list, just naming it to anything you think it is fit with to what it does.

In my case I named them this way:

Then we can put the correct function name into the binary using the same macro I showed you previously, then we are pretty much completed in making this binary so readable... hold on, but read it from where? Where to start?

To pick a good place to start to start reversing, this command will help you to pick some juicy spots, all the extractable strings will be dumped and we can pick one interesting one to start, and go up to build the big picture.:)

Actually symbols are giving us much better options, but right now we don't have anything else that is readable enough to start..

You can start to trace this binary from these text address reference and then go up to the call in the main function that supports it. For example, by using the visual mode you can seek the XREF of each text to see how it is called from which function and you can trail them further after that. This isn't going to be difficult to read since you have all functions back in place.

The picture below is showing how the "air dropping" is referred to the caller function.

That's it. These methods I shared are useful methodology in analyzing Linux MIPS-32 binary especially stripped ones like the one I have now. I think you're good enough to go to complete your own analysis by yourself too. Please just tried those methods if you don't have any other better ways and don't be afraid if other RE tools can't make you read the MIPS-32 binary well, just fire the radare2 with the tips written above, and everything should be okay :)

We go on with the malware analysis of this binary and its threat then..

What does this MIPS-32 binary do?

Practically. the MIPS binary is bot that is having a mission to infect the host it was dropped into (note: so it needs a dropping scheme to go to the infected host beforehand), making a malicious process called "cloudprocess", send message of "airdopping clouds" through the standard output (that can be piped later on). It is recording its "PID" and fork its process for the further step. The message of "airdropping clouds" is the reason why I called this malware as "AirDropBot" eventhough the coder prefer to use "Cloudbot", which there is also a legitimate good software that uses that name too as their brand.

Upon successful forking it will extract the what the coder so-called "encrypted array", it's ala Mirai table crypted keywords in its concept, but it is different in implementation., I must guess that it could be originally coded to avoid XOR operation which is the worst Mirai bug in the history :) but this "encrypt_array" is just ending up to an encoded obfuscation function :) - Anyhow the value from this "decrypted" coded is used for further malware process.

Then the malware tries to connect to the C2 which its IP address is hard-coded in the binary, on a success connection attempt to C2 server, it will parse the commands sent by the C2 to perform three weaponized functions on the binary to perform TCP, and UDP DDoS attack with either using the specific hex-coded payload, or the latter on is using a custom pattern so-called "hex-attack" that sends DoS packet in a hex escape strings format to the targeted host.

I will break it down to more details in its specific functions in the next sections.

The "encryption" (aka the obfuscation)

The challenge was the "encryption" part, it was I used radare2 with ESIL to see the "encrypted" variables, as per snipped below as PoC:

The decryption is by [shift-1] as per shown in the cascade loop shown in every encoded strings.

If we want to translate this decryoter scheme, it may look something like this (below), I break it up in 3 functions but in assembly it is all in a function and cascaded to each strings to be decoded:

int encrypt_array()
{ 
  array_splitter("xxxx");
  array_splitter("yyyy");
   :
}
int array_splitter(char *src)
{
  strcpy(var_char_buffer, src);
  char_decrypter(var_char_buffer);
    array_counter++
  return;
}
int char_decrypter(char *src2)
{
  int i; strcpy(dstring, src2);
  for ( i = 0; strlen(dstring) > i; ++i )
   // {redacted shift -1 logic to dstring} //
  strcpy(j, dstring);
  return j++
}

The result for the "decryption" can be shown as per below, using ESIL with the fake stack can be used to emulate this with the same result, so you don't need to get into the debug mode:

The last four strings:

/proc/
/maps
/cmdline 
/status 
/exe
...are used for taking information (process name) from the infected Linux box, that will be used for the malware other functions like "killing" processes, etc. The other decrypted strings are used for infecting purpose (known credentials for telnet operation), and also for other botnet operation related.

Understanding the "decrypter" logic used is important because the same decrypter is used again to decode the C2 sent commands to the active bots before parsed and executed.

The C2, its commands and bot offensive activity

What happened after decryption (encrypt_array) of these strings is, the binary gets into the loop to call the "connecting" function per 5 seconds. If I try to write C code based on this stage it's going to be like below snipcode:

Within each loop, when it calls "connecting" function it will try to connect the C2 which is defined a struct sockaddr "addr", pointing to port number (htons) 455 (0x1c7) and IP: "179.43.149[.]189".

When connected to C2, it will listen and receive the data sent by C2, to perform decryption and then to send its decryption result (as per previous logic) to the "command parsing" function, that's having "cmd_parse" sub-function inside. The "command parsing" is delimiting received command with the white space " " for the "cmd_parse" to grep three possible keywords of "udp", "tcp", and "hex", which in next paragraph those keywords will be explained further.

Below is the loop when the command from C2 is received (listened) inside the "connecting" function in radare2:

Now we come into the offensive capability of this bot binary. The "udp" keyword will trigger the execution of "udpattack" function, "tcp" will execute "tcpattack" and so does the "hex" for executing the "hexattack" function. Each of the trigger keywords are followed by arguments that are passed to its related attack function, it emphasizes that a textual basis DoS attack command line starting with udp, tcp or hex, following by the targets or optional attack parameters are pushed from the C2 to the AirDropBots. Based on experience, the C2 CLI interface of recent DDoS botnets is having such interface matched to this criteria.

TCP and UDP is having the same payload packet in binary is as per below:

...that is sent from tcpattack() and udpattack() in TCP and UDP different socket connection from the target sent by C2.

The hexattack is having a different payload that looks like this:

One last command is is "killyourself" (taken from decrypted table that was saved in a var) that will stop the scanning function fork with the flow more or less like this:

result = strstr(var_parsed_cmd, "killyourself");
  if ( result )
   { kill(scanner_fork_PID, 9);
     exit(0);
   }
return result;

..and the kill function above is executing "kill -9" by calling int kill(__pid_t pid, int sig).

As additional, in the older version, there is also another C2 command called: "http" that will execute "httpattack" function that is using HTTP to perform L7 DoS attack using the combination of User-Agents, but in this sample series I don't see such function.

Is there any difference between MIPS and other binaries?

Oh yes it has. The Intel and ARM version (or to binary that is having a scanner function) is interestingly having more functions. If I go to details on each functions for Intel binary maybe I will not stop writing this post, so I will summary them below with a pseudo code snips if necessary.

1. The "array_kill_list" function

This function is used to kill process that matched to these strings:

It seems this is how the bot herder gets rid of the competitor if they're in the same infected Linux box.
This "array_kill_list" is accessed from killer() function that is being executed before going to "connecting" loop in the main for Intel version.

The killer function is having multiple capability to stop unwanted processes too, it will be too long to describe it one by one but in simple C code and comments as per picture below will be enough to get the idea:

2. The scanner, the spreader via exploit

The bot herder is aiming Lynksys tmUnblock.cgi of a known router's brand, the vulnerability that has to be patched since published 5 years ago. For this purpose, in intel and ARM binaries right after killer() function it runs scanner() function, targeting randomized formed IP addresses, using a hard-coded "payload" data, spoofed its origin by faking the HTTP request headers (for "tcp" or "http" flood), which is aiming TCP port 8080 with the code translated from assembly to simplified C code looks like below:

This scanner is having four pattern of payloads which I quickly paste it below for your reference if you are either receiving or researching this attack:

Maybe one of the thing that I may suggest for this bot's scanner functionality is what it seems like a spoof capability. I examined into low level for code generation of about this part and found what the send syscall performed when AirDrop bot make scanning with exploit is interesting :) please take a look yourself of what has been recorded as per below snipcodes:

On those "scanner" function supported binary, the spreading scheme is executed with targeting random generated IP addresses by calling sub-function "get_random_ip" right after the the C2 has been attempted to call, and is using the same socket for multiple effort to infect Linksys CGI vulnerability. Below is the record in re-production this activity:

3. The "singleInstance" function

This is a code to make sure that there is no duplication of "cloudprocess" process that runs after a device getting infected. It's a simple code to kill -KILL the PID of detected double instance. You can easily reverse and examine it by yourself.

Below is the example ARM-32 assembly code for this function with my comments in it just in case:

for the right side of code, if I write that in C it's going to be something like this, more or less:

BONUS: AirDropBot and the custom ELF packer case

As per other ELF badness produced by botnet adversaries in the internet, the AirDropBot is having binary that is packed with custom packer too.

The below file [link] is one good real example of AirDropBot ELF in packed mode, the VirusTotal detection is like below:

This sample is spotted in the wild a while ago on trying to infect one of my honeytraps. The "file" result looks like this:

x86.cloudbot: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, stripped

The binary is packed and by reading the assembly flow in the packer codes we can tell it is a UPX-like packer. It looks like this:

If you follow my presentation in R2CON2018 in the last part (the main course) about unpacking with radare2 for an unknown packer, the same method can be applied for you to get the OEP by implementing several "bp" on the unpacker processes. There are slides and video for that, use this link for some more information: [link]
That is exactly the method I applied to unpack this ELF.

Then next, after you bp to part where packed code copied to the base memory defined in the LOAD0 section, I will share "my way to" easily extract the unpacked ELF afterward:

ELF file headers is having enough information to be rebuilt, let's use it, assuming the header table is the last part of the ELF the below formula is more or less describing the size of the unpacked object:

// formula:

e_shoff + ( e_shentsize * e_shnum ) = +/- file_size

// math way:

0x00013af8 + ( 0x0028 * 0x0013 ) = file_size

// radare2 way:

? (0x0028 * 0x0013) + 0x00013af8|grep hex

And.. there you go, this is my unpacked file: [link]

Next, let's see the detection ratio of this packed binary in Virus Total after successfully unpacked (..well, at least it is two points higher than the packed one) :

And the binary after unpacked is very much readable now..and BOOM! the C2 of this packed ELF is in 185.244.25[.]200, 185.244.25[.]201, and 185.244.25[.]202 are revealed! :)) Now we know why the adversary wanted to pack their binary that bad.

For the addition, nowadays IoT botnet adversaries are not only packing the Intel binaries, but the embedded platform's (some are RISC cpu too) Linux binary are often seen packed also with the custom packers. Like in this similar threat report I made [link], with the ELF binary for MIPS cpu (noted: big endian one), sample that was actually spotted inside of the house of a victim (in his MIPS IoT daily used device, I won't disclose it further). I analyzed and unpacked it, to find that is not only "UPX!" bytes tampering that has been replaced.

Let me quote it in here too about my suggested unpacking methods for embedded Linux binaries I wrote in the linked post, as follows:

"There are other radare2 ways also for unpacking and extracting 
unpacked sample manually too.

The "dmda" is also useful to dump but it's maybe a bit hard effort to 
run it on embedded system, or, you can fix the load0 and load1 that can 
also be done after you grab "OEP", or, you can also break it in the exact
rewriting process to the base address, but either ways, should be able 
to unpack it. 

First ones will consume workspace in the memory for performing it.. I 
don't think RISC systems has much luxury in space for that purpose, 
but the latter one in some circumstance can be performed in ESIL mode."

The thing is you should master all of those methods, and only by that most of binary packing possibility in Linux can be solved manually without depending on UPX or any automation tools.

"So don't worry, just fire your radare2, and everything will be just Okay!" :D (my favorite motto)

In a short summary as the conclusion

This binaries are a DoS bot clients, a part of a DDoS botnet. It spread as a worm with currently aiming Lynksys tmUnblock.cgi routers derived by non MIPS built binaries that infects machines to act as payload spreader too. I must warn you that I did not check the details in every 26 binaries came up during this investigation, but I think the general aspect is covered.

These are malware for Linux platform, it has backdoor, bot functions and are having infection capability with aiming vulnerability in routers CGI or telnet. The malware is coded with many originality intact, again, it is a newly coded, it is not using codes from Mirai-like, GafGyt (Qbot/Torlus base), or Kaiten (or STD like), but I can tell that the development is not mature yet. I was about to name it as "Cloudbot" but it looks like there is a legitimate software already using it so I switched to the "Airdropbot" instead due to the hardcoded message printed on a success infection. This is a new strain of various library of IoT botnet, I hope that other security entities and law enforcer aware of what has just been occurred here, before it is making bigger damage like Mirai botnet did before.

Detection methods

Binary detection

For the binary signature method of detection. The unpacked version will hit just fine. But since the AirDropBot was developed to support many embed platform from various CPU and "endianness" type, to detect it precisely you may need to code several signatures. However, if you see the typical functions of their binary carefully, so it is yes, one generic rule can be generated and applied. For that I PoC'ed it myself to develop a bit complex Yara rules to detect them all and to recognize which binary that is having the scanner and not.

The snippet code and scan example is as per screenshot below.

Traffic detection

For the traffic detection, there are two methods that you can apply as detection: (1) The Initial Connection and activities of AirDropBot does right after the success infection, or (2) the DoS traffic, I am explaining both as follows.

The Initial connection detection is related to the nature of this malware, which is connecting to C2 and performing scanning for vulnerabilities aiming random IP in 8080. I can suggest a nice Suricata or Snort rule can be coded for connection that's aiming TCP/455 (C2 connection port), but the C2 port can be changed by the adversaries too on their next campaign, but that's not going to be easy for them to prepare all of those varied binaries and C2 port changes immediately (smile). The other way is to focus on the scanner payloads as per described in some of pictures above, the Surucata rules to detect them will last longer IF the same vulnerability is still being aimed.

The other detection is by using the AirDropBot's hardcoded flood packets, which I was in purpose whoring them in the attached pictures above too. This way you may be able to recognize the DoS traffic activity performed by this threat in the future DDoS incidents. Sucicata and Snort rules are supported for this purpose.

The bad actors and his gang are still at large and reading this blog post too :) , I am sorry I can not share the generic scanning code I made in here, but the screenshots I provided are enough for fellow reversers to recognize and implement these detection methods to filter these series of AirdropBot activities. The rest is OpSec.

Hashes and IOC information

The hashes are listed as per below and IOC has been posted to MISP and OTX for all blue-teamer community to be noticed.

../bins/aarch64be.cloudbot    | 417151777eaaccfc62f778d33fd183ff
../bins/arc.cloudbot          | d31f047c125deb4c2f879d88b083b9d5
../bins/arcle-750d.cloudbot   | ff1eb225f31e5c29dde47c147f40627e
../bins/arcle-hs38.cloudbot   | f3aed39202b51afdd1354adc8362d6bf
../bins/arm.cloudbot          | 083a5f463cb84f7ae8868cb2eb6a22eb
../bins/arm5.cloudbot         | 9ce4decd27c303a44ab2e187625934f3
../bins/arm6.cloudbot         | b6c6c1b2e89de81db8633144f4cb4b7d
../bins/arm7.cloudbot         | abd5008522f69cca92f8eefeb5f160e2
../bins/fritzbox.cloudbot     | a84bbf660ace4f0159f3d13e058235e9
../bins/haarch64.cloudbot     | 5fec65455bd8c842d672171d475460b6
../bins/hnios2.cloudbot       | 4d3cab2d0c51081e509ad25fbd7ff596
../bins/hopenrisc.cloudbot    | 252e2dfdf04290e7e9fc3c4d61bb3529
../bins/hriscv64.cloudbot     | 5dcdace449052a596bce05328bd23a3b
../bins/linksys.cloudbot      | 9c66fbe776a97a8613bfa983c7dca149
../bins/m68k-68xxx.cloudbot   | 59af44a74873ac034bd24ca1c3275af5
../bins/microblazebe.cloudbot | 9642b8aff1fda24baa6abe0aa8c8b173
../bins/microblazeel.cloudbot | e56cec6001f2f6efc0ad7c2fb840aceb
../bins/mips.cloudbot         | 54d93673f9539f1914008cfe8fd2bbdd
../bins/mips2.cloudbot        | a84bbf660ace4f0159f3d13e058235e9
../bins/mpsl.cloudbot         | 9c66fbe776a97a8613bfa983c7dca149
../bins/ppc.cloudbot          | 6d202084d4f25a0aa2225589dab536e7
../bins/sh-sh4.cloudbot       | cfbf1bd882ae7b87d4b04122d2ab42cb
../bins/sh4.cloudbot          | b02af5bd329e19d7e4e2006c9c172713
../bins/x86.cloudbot          | 85a8aad8d938c44c3f3f51089a60ec16
../bins/x86_64.cloudbot       | 2c0afe7b13cdd642336ccc7b3e952d8d
../bins/xtensa.cloudbot       | 94b8337a2d217286775bcc36d9c862d2

Salutation & Epilogue

I would like to thank to @0xrb for his persistence trying to convince me that this binary is interesting. It is interesting indeed, and as promised, this is the analysis I did after work, writing this in 8hours more non-stop. Thank's also for other readers who keep on supporting MMD, and as team, we appreciate your patience in waiting for our new post.

Thank you pancake and Radare2 teams who keep on making radare2 the best RE tools for UNIX (All of the radare2 reversing was done in FreeBSD OS, thank you for your great support to FreeBSD!), and also I thank Tsurugi DFIR team for your great forensics tools. For these open source security frameworks I still keep on helping with tests and bug reports.

Okay, I will rest and will wordsmith some miserable jargon parts of the post later, maybe I will add detail that I didn't have much time to write it now, or, to correct some minor stuff. In the mean time, enjoy the writing, please share with mention or using #MalwareMustDie hashtag. This post is a start for more posts to come.

A tribute to the newborn radare2 community in Japan "r2jp", that we established in 2013 together with "pancake" on AVTokyo workshop in Tokyo, Japan.

This technical analysis and its contents is an original work and firstly published in the current MalwareMustDie Blog post (this site), the analysis and writing is made by @unixfreaxjp.

The research contents is bound to our legal disclaimer guide line in sharing of MalwareMustDie NPO research material.

Malware Must Die!

Saturday, September 21, 2019

MMD-0063-2019 - Summarized report of all three years MalwareMustDie research (Sept 2016-Sept 2019)

Hello, it's unixfreaxjp here. It has been a while since I wrote our own blog, and it is good to be back. Thank you for your patience for all of this time.

The background

It was after September 2016 when we decided to move our blog and since then I had a lot of fun in learning and experimenting much with "Jekyll" (based on "Poole") and "BlackDoc", and I just convert all posts statically into "Markdown" and all syntax highlighter into "Rouge" highlighter with templates coded in "Liquid", and I was seriously dealing with coding in Ruby on FreeBSD for it. Wasn't easy, but with help from the team, we did that, and I learned a lot.

Then on posting my research I moved along to try out several platforms, it's good to actually know that we don't have to depend only into a platform, and 3 (three) years out there was making us learning a lot about other reliable services in here and there. What me and the mates have learned is, in using any media services, either it's your own or other's party ones, they all are having their pro's and con's points. And frankly speaking, you won't know for sure about each one of those con's unless you go out there and try them yourself.

So, here we are, back to service where we first started to do MalwareMustDie blog. And I found that the environment is way nicer than before, thank you Google for doing the hard work in satisfying and securing bloggers. So I just set it up and switched all access to HTTPS and hopefully the broken-links effect are minimum. For the unnoticed broken links occurs during this transition please adjust the URL's subdomain from blog.malwemustdie.org to blog2.malwaremustdie.org, this should fix that up. For those who previously had problem with broken RSS this HTTPS effort may be a good news for you. And, you can still access the MMD (MalwareMustDie) blog under sub-domain of "blog2" with HTTP, yet I won't add more posts in there though, and I will minimize its service.

The flip side of all of these adventure is, now I have my research materials scattering around all over the internet during these past three years (smile). Oh yes, the research and its activity has been actively going on as usual, yet now we're happy that we don't need to make much voice anymore (and also we're practicing a better OpSec), the security awareness is also blooming..not like we had before in 2012, I am still hanging out with our friends and we're still on to dissecting malware.. Linux or not.. Intel CPU ones or not, and to be noted: I am still a great fan of radare2 and FreeBSD!

I think some followers may not know what we've been doing all of these three years, or maybe they can't track well our activities on our security research, so I decided to list some links for you to catch up with for the public related threat only. Some of those reports are just screenshots with comments (security related pictures really paint thousand words), some are just text posts or analysis comments, but all contains important information.
Does this means I am posting analysis blog again? Well, you're going to find that out too :)

Here's the list of what's been done during these three years, enjoy:
(For the previous Linux Malware Research list can be seen in here [link])

1. Windows related malware posts

Raccoon stealer infection in the wild

Dissecting on memory post exploitation powershell beacon w/ radare2

Intel POPSS Vulnerability PoC Reversed

Win32/TelegramSpyBot

Win32/WaRAT

Win32/Bayrob

"FHAPPI attack" : FreeHosting APT PowerSploit Poison Ivy

2. Linux related malware posts

Honda Car's Panel's Rootkit from China

Linux/SystemTen

Linux/Httpsd

Linux/SS(Shark)

Linux/DDoSTF today

GoARM.Bot + static strip ARM ELF by ChinaZ

Linux/ChinaZ Edition 2

Linux/CarpeDiem

Linux/Haiduc (bruter/memo)

Linux/Vulcan

Linux/HelloBot

Linux/Cayosin

Linux/DDoSMan

Linux/Mirai-Miori

Linux/Mandibule (Process Injector)

So Many Mirai..Mirai on the wall)

Today's Kaiten and PerlDDoS

Linux/STD bot

Linux/Kaiten (modded ver) in Google clouds

Linux/Qbot or GafGyt ..in Kansas city?

ChinaZ gang is back to shellshock drops Elknot abuses USA networks

3. Mac OSX related malware posts

OSX/MugTheSec

OSX/MachO-PUP (a quickie)

4. Other malware reports

Webshell/r57shell, and..

I also posted either in VirusTotal comments, or previously posted some on kernelmode(not anymore), or sometimes making several posts or notes in reddit. We also has opened the public twitter with handle of @MalwareMustD1e, a lot of analysis screenshots as awareness are posted in there too along with several news of forensics tools development matters, feel free to follow or check the time line. Again, the previous Linux Malware Research list is also available.

5. My talks on security conference

About my presentation of: "Unpacking the non-unpackable" (ELF packers talk) in R2CON2018

Epilogue

I may edit/change my posts to adjust or brush up their contents along with this post on transitioning the services, so there will be addition or changes.

Please stay safe, don't code/use bad stuff, and enjoy the summary!

#MalwareMustDie!

Wednesday, March 8, 2017

MMD-0062-2017 - Credential harvesting by SSH Direct TCP Forward attack via IoT botnet

Sticky note: We call this threat as "Strudels Attack"

1. Background

In this post there is no malicious software/malware analyzed, but this is one of the impact of the malware infecting IoT devices caused by weak credentials that are utilized by the bad actors for bigger crime process. The only malicious aspect written in the post is/are individual(s) involved and participated to these attacks, and, well, I personally do not think the tool or method used (in SSH TCP Forwarding itself) is as “malicious”, since. in a way, it is very useful concept for UNIX networking and development.

Please bear with this long and thesis-like technical write-up, and it is indeed necessary, since this post is the first proof of concept of a new vector of crime (an automation of mass credential harvesting via SSH TCP forwarding through cascaded proxy cushions), and this is also an on-going threat, so it will be academically useful (hopefully) for the future research. But, if you need more simple, shorter and lesser technical explanation you can first read my interview in form of Q & A about this matter in Infosec Insitute web site (thank’s to Mr. Paganini & Infosec Institute folks), but yet, if you need only a very short summary you can find it in this reddit threat.

Here we go:

The definition of SSH port forwarding:

" (1) SSH port forwarding is a general proxy-ing mechanism for TCP only. Forwarding can't work with protocols not built on TCP, such as the UDP-based DNS, DHCP, NFS, and NetBIOS,[121] or with non-IP-based protocols, such as AppleTalk or Novell's SPX/IPX. (2) Port forwarding can be specified only when you create an SSH connection. You can't add a forwarding to an existing SSH connection with any SSH implementation we know of, though there's nothing intrinsic to the SSH protocol that would prevent it, and it would sometimes be a useful feature. "

above quoted statements are from “O’Reilly’s SSH: The Secure Shell - The Definitive Guide, 9.2. Port Forwarding”

This threat has been observed by our monitoring since October 24, 2016. I firstly discussed this type of attack during the AVTokyo event in 2016 with our team mate in Tokyo, Japan. We follow its progress afterward then firstly reported to authority in December 2016 (the attack on PlayStation Store account authentication), and at the same time tried to email Pokemon Go since I realized they were hit by this attack too back in November, 2016, but the email seemed wasn’t sent/received well.

From that point, we continue our analysis and on entering the 2017 these type of attack is getting “better” (automated & loaded with more exploits), so we tried to publicly warn via our community, that was also the same time when PlayStation Network (PSN) account authentication was targeted by attackers. Following. in February, 2017, the official report sent to law enforcement channel we have, along with asking permission for disclosure this on-going threat for the public awareness, at the same time frame we also reported another attack that was conducted against a undisclosed Canadian online wholesale store via our CERT channels to be escalated to the Canada law enforcement and related authorities.

Either of the announcement and communication stated above was received satisfactory result of ending the abuse. And the abuse is still on going as per I wrote this report. For supporting the facts, screenshots were taken during the series of events described above. As per below details:

Additional: I received many calls after this post has published, about other good analysis on SSH TCP Forwarding abuses aspect (one of them is mentioned in the Prologue section in this post). I, on behalf of my team, want to make sure that, we, in MalwareMustDie, are having a strict policy to conduct analysis by avoiding outside influence as much as possible to keep our analysis original, thus, this analysis is different, although it is describing a TCP Port Forwarding, it is not about a case of hack to HTTP service or No-Auth SSH forwarding. This report is a disclosure of an organized mass credential automated stealing process utilizing attacks using several TCP hacking patterns (HTTP/HTTPS/POP3/SMTP/IMAP) via the hacked SSH cascade infrastructure.

Message to the law enforcement:

2. Threat definition

As per quoted from above stated O’Reilly’s SSH guidance book. A legitimate user who is having authentication privilege of an existing SSH connection can forward TCP protocol in proxy-ing mechanism. It’s an almost common practice nowadays in the nutshell, specially to the services that is meant to be view from a local networking area.

This threat’s definition is The abuse of SSH TCP forward legitimate usage, by performing automatic or manual attack to weak SSH accounts of remote devices (either servers and IoT), with brute-forcing account’s credential or passwords, to perform malicious set of TCP attacks via TCP Direct Forward technique on SSH Forwarding functionality utilizing this “force-accessed” SSH connection to targeted remote services.

By that definition, this threat is creating a double verdicts, one for the hacking of SSH services, and, second, attempt to attack targeted service(s). Thus, if this can be considered as the third verdict, the actor makes hacked SSH services looks “hostile” just as if they were in performing the attacks to the targets.

3. Threat detail

Below is the diagram to explain the overall process of this threat.

(please click the image to enlarge the size)

The attacker is grabbing credentials from the hack-able targets from their infrastructure. They manually perform the attack or daemonized the SSH connectivity to be TCP forwarded through some layers of hack-able SSH accounts to perform the attack. The infrastructure of compromised SSH services and IoT devices are used as front-end cushion for the attack. They aimed for credential launched through several TCP attacks (HTTP/HTTPS or SMTP).

The grabbed credentials are used by attackers to login to several sites for further hack on registered accounts to gain more data. Other access (non hacking in verdict) are also spotted to actually supporting this attack activity (attack research/test via browsers, WHOIS checking, GeoIP checking, successful SSH forwarding checks, etc.), and all are pushed through the same infrastructure.

The attack process described in the above diagram is elaborated in the below points:

3.1. Gaining SSH privilege method

Attacker(s) is gaining privilege by brute forcing access to SSH users by login with the known weak credentials, the method used are either the attacker does manually enter the values to break the credential using the keyboard, or brute forcing it by the scripts, the below illustration is showing few of many events we monitored:

  • 3.1.1. Manually brute-force:

  • 3.1.2. Automated (scripted) brute-force:

3.2. SSH TCP Direct Forward method

There are some ways being used by attacker(s) to perform SSH TCP direct forward method. In general, we can devide its common malicious usage as follows:

  • 3.2.1. Using (or fabricate a request from) a browser to access a specified site like these requests:

  • 3.2.2. Using malicious script (for automation), written for this purpose to send multiple TCP direct forward contains data of malicious HTTP in one session of SSH, like this: The detail will be elaborated in the PoC section.

  • 3.2.3 Using the specific TCP request queried to port SMTP (TCP/25) to map the network’s email servers.

3.3. Event occurrence in SSH TCP Direct Forward attack, in steps

  • Checking the success attempt of TCP Direct Forward
    • An attacker upon a success attempt to compromised an SSH account will obviously test their connection, this is likely to use their own sites, or in some earlier stages, iplogger sites or any sites that can give a good HTTP log feedback for the forwarded HTTP request. Usually sent by GET / HTTP/1/1.
  • Get the Proxy device’s IP addresses
    • Secondly, the atacker is naturally seek the location of the infected device, this is necessary since the attacker are mostly brute-forcing wide range of SSH service and they need to know which country that gives a promising infection sign. So far I recorded the callback to the services I listed below:
      • checkip.dyndns.com
      • api.ipify.org
      • ipinfo.io
      • ip2location.com
      • ipinfoplz.com (NOTE: mostly used in malicious compromising scheme with w/o malware)

    The above services are mostly good services and they are being abused for the attack purpose.

  • Browsing or other TCP harmless activity via hacked SSH as proxy without SSH owner’s consent.
    • Several attempts spotted as preliminary check the attacker are browsing with the bogus browser, just to make sure that the attacker can really browse through the hacked service, this type of attacker is the cautious one and performing some tests, assuming the packet capture process was being conducted. I usually implement a special menu for this type of attacker(s).
  • Keeping several SSH connection sessions to be in established state
    • Attacker will keep the some SSH connections alive to be connected to attacker environment’s upstream, and within it, each of the established sub-session will be requested connections for TCP Forwarding connection request (a child process connection session on a established one) to perform a specific “task” (read: attack). Obviously this will bring bad effect to the hacked SSH service to be flooded by attackers, like this scenario:

    One SSH connection session with multiple connection channels used for TCP Forward attack snippet is as per shown in the below real log when the hackers was trying to make a hit on lowlaw.ca web service :

  • Utilizing hacked SSH as attacker’s front-end medium or cushion to hack targets.
    • This part will be explained in the following section (4. Attack details).

4. Attack details

We were saying “attacks” so many times, it won’t be fair if we don’t elaborate, hence, you deserve to know on what was hitting you, and maybe what made your IP blocked from several services caused by these attacks that you’re not knowing utilized your routers, gateways, DVR, WebCam or etc IoT.

4.1. The type of attack by its forms

The performed TCP attacks forms which is varied, mostly are aiming HTTP (protocol) with and without SSL, and so far what we detected are as per following types:

  • Sending malform HTTP requests to a targeted web server to exploit the service:

  • Sending invalid HTTP method requests for mod-ssl vulnerabilities with the same purpose as above

  • Sending HTTP requests to force (brute) authencation in a legitimate sites for user(s) and password(s)

  • Sending HTTP requests to a comproomised sites to allegedly confirm suspicious activities: These wordpress sites are hacked sites that has been accessed under the same time when the Wordpress patched their version and hack events were happening a lot “recently”. It seems the malicious filename were requested via the botnet to the hacked wordpress sites for confirming some “ungood” activities via this botnet..

  • Utilizing a known URI’s API used by a known HTTP affiliation site:

  • Sending SMTP requests to several email servers (hereforth is called as MTA), with having below purpose:

    • Mass-sacnning the availability MTA service on a subnet via SSH Forward’s SMTP scripted textual requests to known SMTP port and pushing the QUIT command (this can be seen in the screenshot in the Victims section) upon the connection establishment.
    • Manually or automatically hack to a targeted MTA to brute account by sending malicious unauthenciticated USER and PASS commands, we don’t elaborate this with further evidence, since it is well-known and self-explanatory that PLAIN TEXT in SMTP or POP3 protocol is supporting the automation for the usage of the email client software (hereforth is called as MUA) in general, and will not give further idea to the blackhats who we know is reading this blog too.

4.2. The type of SSH TCP Direct Forward attack by its targets

In this section we are going to elaborate the type of this threat’s attacks by its target. Which target are mostly spotted and performed. What is the aim for the attacks? What requests are formed and the technical details, and so on.

I am not into practice of any kind of “Red Team” act, so does our team mates (we’re Blue teamer), so I don’t know how attacker will act in their attacker shoes in this particular incident, in this step pentesters know more I guess.

What I do in analyzing this threat is based on reverse engineering of facts on what we see and collect. And I have to warn that reversing is not as same as reading source code .In this case we are collecting traffic here, not samples, and we are doing the best to understand its scheme by this minimum resource, so bear with the inaccuracy that might occur, and I will upgrade this post along with the new progress in analysis come up.

Let’s go into each sub-sections to elaborate the details:

4.2.1. Remote Authentication Web Server as targets

HTTP attacks formed by SSH forwarding are all aiming server that is having authentication scheme. The attacker is meant to break the authentication and try to find their way in by sending several “known” malformed HTTP headers (with crafted “refeRer” and some customization to fabricate several browser, either PC or Mac or Mobile device’s browser to send the package. The most favorite techniques are the malform traffic sent to either HTTP or HTTPS (mod-ssl or similar) that was expected to crash the service, encryption authentication. the session (cookies etc) and the database, to then opening chance for the further hack attempt.

What the attackers are aiming is credential. Like login user, login’s password, email address and more of data linked to those credentials like maybe credit cards, and so on. They will then use the taken credentials to form more malicious act that will be explained in the next section. In this section I will show some samples on how the attackers are making attempts to force their way in.

The aimed targets are services that’s having web login or web auth form, either PC or mobile. The fabricated requests shown that the attackers was recording traffic to the auth service beforehand, and studying for flaw that can be reproduce into a scripting method. Aimed portals for those services are varied too, from the category of banks, online payment system, online shopping, entertainment or game networks, social or business network services, and many of the adult sites with some of them are using live camera. What attackers get from these sites are crucial data, although there are some throwaway accounts spotted too, that can be used to further hacking attempt of specific users, or worse, the identity personification. To be noted: I will refrain to elaborate more than this explanation since some of the attacks seems making impact or effect, I also will not post attacks that is not mitigated by the service vendors, furthermore, this post is meant for the awareness for people whom their SSH service were hacked and used, for the services to be aware more of what are these attacks actually, and for users of the aimed portal to be very careful to use strong credential and privacy.

OK, here is some of the screenshots of most seen abuses, there are much more than these:

  • SunTrust Bank:

  • RoyalBank:

  • PayPal:

  • AT&T:

  • LinkedIn:

  • Playstation Store:

  • eBay:

  • Loblaw:

  • Mojang.com :

  • Ubisoft:

  • Playstation Network:

  • Sony Entertainment Network:

  • Facebook:

  • Nianticlabs / PokemonGo:

  • Gmail (and also Yahoo too) by aiming IMAP service, ping me for more on email servers, have tons of these..

4.2.2. Emails and a lot of more emails

Well, it seems that some of the emails were harvested, there are many from known email online portal like GMail, Yahoo, AOL, Microsoft (Live Mail & Hotmail), Mail.ru, Yandex, etc..

What the attackers do with these emails is, they confirm it again to the web email where these email belong, to check whether the account is accessible or not. And how do I know this? Guess what, yes, they use AGAIN the SSH HTTP forwarding for that purpose, I will snip you some pictures below, for GMail, Yahoo, and Hotmail (there are others, but the systems “maybe” are still affected so I don’t post those):

The credentials they stole from one site is being used to brute force to other services, we have a recycle-like process for ultimate credential harvesting directed by hackers. The picture below is clearly describing how one leaked credentials is used for checking an account of another site.

These email addresses they stole, how many are they so far? I am not sure about the quantity that they succeeded to achieved by the malformed HTTP sent to auth services. And we can’t state any of these unless having their environment in our hands legally, but the fact right now is, according the data that I saw in the used traffic, it’s about less that 600 emails (unique) in my entry counted from early December 2016 when I first counted them. I am sure there are more of them, considering that the first hack was done in October 2016.

Let me show you a responsible disclosure for the fact that I am saying in here as per below video (credentials & password are all blurred and we hope this is more than enough to show as PoC of this threat’s cyber crime attempt, and only law enforcement & affected services can query these data directly)

4.3. Manual attack type

As per mentioned before, the manual attacks are spotted too, it is showing a different characteristic in its way on making connection and performing attack sessions. Some typical characteristic in its logged activities have suggested a human’s direct interactive during a session of attacks, supporting facts of the establishment for connection used to conduct TCP forwarding that was manually set.

The attacker seems hard to be able to spawn one SSH connection session to launch multiple TCP Forward session, which is a bit tricky to perform it manually.

They tend to brute SSH credential with the certain/similar phrases with more limited range. This is enough to realize there are more than one actor who jumped to SSH Forwarding attack. The interesting part is the characteristic of manual attacker using TCP Forwarding is a bit unpredictable, there are some tests were performed. And mostly the attacker(s) is switching into browsers (either PC or Android mobile), or others to perform some action.

For this type of attack, we can not share the screenshot due to OPSEC.

5. Supported analysis

5.1. Analysis of web service exploitation

5.1.1. Exploitation information in sent attack

The HTTP malformed requests sent are not 0day, generally it contains a formed exploit strings to attack protocol sanitation handling of web service application with several types, like:

  • Forming Format String Vulnerabilities (a well known attack started from year 2000), so that the attacker can pop the stack and viewing memory at any location or in the worse scenario will crash the web service app process. In web services where the httpd are mostly run on specific users, the credential will be saved in area to be accessed by the same privilege as the web server’s, is making the attacker have possibility to see credential in a flawed software.
  • Forming a overflow state in stack of child process on web service app to crash (DoS) it, this part is mostly related to the older vulnerabilities, for example in exploitation of the Apache httpd protocol.c, The follow up for this attack is to gain more privilege to access information or databases that is not supposed to be accessed, or -
  • Forming abuse with exploit to be sent to trigger vulnerability in mod_ssl for the SSL handling flaws, which hoping the the child process of web service to crash (DoS) and can be exploited to further leaking information that is not supposed to be seen, to be used for the further hack.

Some sent strings during the attack are also matched with several information shared in other’s web servers vulnerability notes, from the protocol (input sanitation or filtration handling) or SSL (input sanitation or handling) part. There is a possibility for the script interface attack formed, but for that area is not being disclosed in here at this moment.

Several references that can bring you better explanation for the exploitation forms of these HTTP malformed requests can be read further read in the below good articles linked below:

Quoted from OWASP Attack Category:

The Format String Exploit occurs when the submitted data of an input string is evaluated as a command by the application. In this way, the attacker could execute code, read the stack, or cause a segmentation fault in the running application, causing new behaviors that could compromise the security or the stability of the system.

5.1.2. Corelation of known web service vulnerabilities CVE to the malformed HTTP attack

We may point to some older vulnerabilities that are “commonly aimed” in the attack squence from the Format String attack, like: CVE-2015-0253, CVE-2012-0053, CVE-2009-3555, CVE-2005-3357, CVE-2005-2700, CVE-2005-1268, CVE-2004-0751 for Apache project, and other type of vulnerability from other web service products. Practically, the hacker was frabricating its malform request depending on the targeted server’s characteristic. Below is the links that can elaborate more information accordingly:

5.1.2.1. Examples in Apache project’s httpd:

5.1.2.2. Examples in Apache project’s mod_ssl:

5.1.2.3. Examples in Apache project’s mod_status

Other web services with other interfaces has similar exploitation possibility.

5.1.3. Input sanitation to prevent exploitation in real attack

As per references above we can understand that the software with remotely accessible can be affected to Format String Exploit. A way to prevent this is by the input sanitation or filtration handling method.

For a very simple example, I run the format strings attack that the attacker sent in the debugging environment on several web application that can be affected to the real attacks sent to the service.

A good sanitated software will reject the code, which the result I can be previewed in my radare2 shell interface during ptrace on my FreeBSD as per below:

  :
[0x28065e80]>   RET   stat 0
[0x28065e80]>   CALL  read(0xa,0x8066f80,0x3ff)
[0x28065e80]>   GIO   fd 10 read 276 bytes
       "16030100a8010000a40301Xa9`e599dfa6=J15|d012d16c496la9c5rZf9b8Vf6de79a1a9; db0c%af~a5O9b8
        f8ee686\\\\aca9 b91deedqccZ0gJa9dbd1?cc7f001800/005000500\\\nc013c014c0\\tc0\\n002008001
        30004010000Cff01000100000000*00(0000%auth.api.sonyentertainmentnetwork.com00\00060004001
        70018000b00020100"
[0x28065e80]>   RET   read 276/0x114
[0x28065e80]>   CALL  read(0xa,0x8066f80,0x3ff)
[0x28065e80]>   GIO   fd 10 read 0 bytes
       ""
[0x28065e80]>   RET   read 0
[0x28065e80]>   CALL  madvise(0x2840f000,0x1000,MADV_FREE)
[0x28065e80]>   RET   madvise 0
[0x28065e80]>   CALL  madvise(0x2840f000,0x1000,MADV_FREE)
[0x28065e80]>   RET   madvise 0
[0x28065e80]>   CALL  write(0x2,0x2841f100,0x3c)
[0x28065e80]>   GIO   fd 2 wrote 60 bytes
       "EOF in backquote substitution
       "
[0x28065e80]>   RET   write 60/0x3c
[0x28065e80]>   CALL  madvise(0x2840f000,0x1000,MADV_FREE)
[0x28065e80]>   RET   madvise 0
[0x28065e80]>   CALL  madvise(0x2840f000,0x1000,MADV_FREE)
[0x28065e80]>   RET   madvise 0
[0x28065e80]>   CALL  write(0x2,0x2841f100,0x3c)
[0x28065e80]>   GIO   fd 2 wrote 60 bytes
       "Error in command substitution
       "
[0x28065e80]>   RET   write 60/0x3c
[0x28065e80]>   CALL  exit(0x2)
  :

This is a self explanatory, there are two places that hits error during input sanitation process, which will block the command to the executable level to avoid it performing further exploitation.

5.2. PoC & regeneration of automation usage in SSH forwarding to send Format Strings Exploitation

A simple python script was found in the internet, was explaining in the big deal the method that can be used by attacker(s) to perform multiple connection’s forwarding sessions under one SSH connection that runs as a daemon (service or process that always up and alive) to forward the request defined via client’s command line, or via other script interface, is a perfect explanation scenario explaining the rapidity time span logged in these attacks.

The logic of this script is short and flexible enough without using much imports, and only 70 lines in length, the snippet of the code can be viewed in the below screenshot:

Above is the PoC of the SSH TCP direct forwarding used for performing attacks mentioned in the automated type. The source code of this attack itself could be written in diferent language, and that is not being disclosed for the on-going investigation on a known suspects.

6. Statistic

I will split the statistic into two sections:

  • Victims , and
  • Attackers

We will go from the victimization of the threat and fo to the allegedly source of the therat.

6.1. Victims

Previously we mentioned about the target victims in the classification of attacks. Not only the web sites with the credential that are abused by this attack, but there are others.

6.1.2. GeoIP Map for victim’s network

Before we jump to that data, let’s summarize the victimization data in general as per below geographical map.

Just in case you can not see the map below is the top 20 countries victim list:


-----------------------
Country          Count
-----------------------
United States    2180
Netherlands       400
Germany           166
United Kingdom    133
Ireland           109
France             99
Russian Fed        98
Canada             89
China              86
Europe             74
Japan              74
Italy              70
Australia          66
Vietnam            55
Brazil             43
S. Korea           40
Poland             39
Spain              34
Sweden             32
Switzerland        32
-----------------------

6.1.3. Who are the victims

  • Sites that are having credentials stored in their servers and accessible via web. (this part was explained above)
  • Sites that are having open service that can be utilized by attacker to their purpose, such as confirming the Geo location, or using a WHOIS database (i.e. I noticed there are many request sent to JPRS via script).
  • Sites that is having an affiliation URL API scheme that can be utilized by attackers.
  • Email servers (MTA) For the email servers we spotted the mass effort to map the MX servers in the world wide web via TCP Forwarding to SMTP protocol, that can be seen in the below picture. Many main or big servers are included in the list, and also services belong to specific business and organization. Screenshot of the total SMTP scanning and the “method” used: For the data of the SMTP abuse, you can grep whether your email server is slurped by this attack or not by accessing this list There are more email protocols which are under attacks too, i.e. POP3 and IMAP.

6.1.4. The targeted IP lists

Our community has voted to share the list of the targeted IP of the victims. We upload the data in the repository. There are two lists, one is the list of the targeted IP in “overall”, meanings, these IP are aimed and suffered to some access via TCP activities from cushion SSH but not all of them are having hack verdict. For example: checking WHOIS data, or checking GeoIP is not a hack, as far as we concern. Scanning for MX records or SMTP servers is a grey matter but many people are doing similar activiry via Nmap, Shodan or MASSCAN too.

The other one is the list of IP that is having positive verdict of hacking, either HTTP, HTTPS or SMTP. “Hacking” by the meaning of violating the authentication scmeme of a service by accessing information that is not supposed to be seen.

There is another list contains the victims IP that were utilized and participating as cushion for SSH TCP forwarding attack, along with the infrastructure use dby the attackers. There are IoT IP addresses and hacked services in the list, specially the Vietnam origin IP addresses and dial up IP addresses. I am putting the access for this list too.

Below is the access to those lists:

6.2. The attacker

There are the sources of attacks:

  • Attacks that come directly from services used or utilized by attackers. This type of attacks are mostly coming from IDC and not dial up public pool IP network.
  • Relayed attack: This type of attacks are coming from other IoT devices and mostly the IoT devices SSH service that was hacked or infected device by known ELF/Linux malware we posted in previous posts in this same blog. You can prevent the further attack by blocking IP listed in the attacker section defined as Red Network.
  • Relayed and relayed again attack: There are some IP addresses that linked to the atack utilizing IoT SSH weak credential that was originated from the hacked servers and the servers then connecting to another service. These connectivity are formed via SSH and mostly are manually performed. We put some of these IP in the Red Network, like we have one Google address listed in there, which is actually being used (this can not be spoofed) for attacking other IoT after confirming its GeoLocation. That one address was located in the Google cloud service.
  • Sentinel panels, upon a success exploiting an SSH connection, one of first series of request sent by attacker is to confirm the exploitation. Most of the time the attacker can confirm the exploited device’s global IP, network and location via GeoIP services they use, but we also saw several bogus HTTP callback to poke the attacker web service. We call these as “sentinels”.

6.2.1. Most abused data center as origin of the attack:

------------------------------------
No IDC/Hoster   Cn.  Amount of C2
------------------------------------
a. SERVERIUS    NL (5.45.*) = 43++
b. HETZNER      DE = 27
c. VOLUMEDRIVE  US = 12
d. OVH          FR = 10
e. IOFLOOD      US = 4
f. WORLDSTREAM  NL = 3
g. DATASHACK    US = 3
h. ONEANDONE    DE = 2
i. AS-CHOOPA    US = 2
j. SUPERSERVERS
   DATACENTER   RU = 2
------------------------------------

6.2.1. Most abused dialup/ pool IP (IoT/routers hacked SSH)

------------------------------------
No Country         Amount (updates)
------------------------------------
a. Vietnam         213 (now 222)
b. Russia+Ukraine   10
d. China             6 (now 9)
e. Canada            6
f. S. Korea          3 (now 11)
g. Spain             3 (now 4)
------------------------------------

The Vietnam IP addresses are ruling the most relayed TCP forwarding attacks, all of the relayed attacks are automated ones. After checking some IP addresses origin we can tell that the list are mostly hacked SSH service and most of them are referring to compromised and/or infected IoT devices. Pmenty of these IP addresses are actually a part of the known IoT Linux DDoS botnet that we disclosed in the older analysis in this blog. For the hint: Mirai, Luabot and Qbot/GyFt/Torlus/Bashdoor ELF botnet. But we are not talking about this botnets now.

6.2.2. Geo IP Map statistic of the attacker source IP address in overall

We collected all of the source IP that we can confirmed from the several sensors and traps we spread, and we collect the confirm IP that was ctually proven conducted the tcp direct forward requests and following by the tcp direct connections to the up and alive targets and also receiving response from its targets. We map the IP in the Geo location using the MaxMind dataset to confirm the data below:

The overall list of the recorded attacker’s IP address can be seen from this link, noted: please mind the date in the BGP part is when the BGP info was extracted from a detected connection.

The potential infrastructure data centers utilized by the attacker (behind the hacked SSH or where the attack script is/was served) can be seen in this list. These nodes can be rented or hacked, which is worth for further investigation. The IP addresses listed is good for the blocking purpose to prevent further damage.

6.2.3.The volume of the attacks recorded since October 24, 2016

If we parse the traffic used from attacker to attack, to a honeypot, we can count the amount of attacks performed. These are the records of tons of attacks performed since the day one we spotted this malicious activity:

The targeted uniq IP itself is about 8,000+ of them:

6.2.4. “Who” are these attackers and “Why”

A possible keyword to describe the attackers is: Script kiddies.

But if we learn of what had happened with Mirai botnet, and considering the IoT aimed. Seeing the harvest of credential are on going too as per you read this post, do not underestimate of what damage that can occur by these hack efforts. Next, the motivation is credentials collective to be used for further malicious cyber crime related activity.

There are many things that they can do by utilizing the email address and the passwords leaked from one site, since people tend to use same passwords anywhere.

The scanning for email server services may have different motivation.

7. How to spot, block and mitigate

UNIX sysadmin networking 101 commands are the best way for spotting the attacks. For the compromised SSH service, all of attack efforts are view-able via netstat and you can seek for the longest ESTABLISHED session in the from the network that is unrelated to your activities as suspicious. Pick one process that linked to a connection and you can elaborate the data based on the connection aimed (as root of course), a set commands like ps, ptrace+ *debuggers and list of files is useful to be used for detection.

For the targeted HTTP or SMTP service, the log is your friend. Please see the data we pasted in the attached picture in this post and see some updates we posted in the github repository too. If you see the similar pattern of attacks are affecting your service, you’d better start to investigate same pattern that may come to your neighbor IP addresses too, since the attacker is not aiming by IP but mostly by services and those services are the ones that stored credentials.

Blocking for the threat is simple. For the SSH victims the Linux sysadmin iptables is good, for BSD users you can use ipfw, pf, or ipf, or as an option you can use the TCP wrapper compiled web application or services to be blocked by hosts.allow which will work just fine. For the SMTP or HTTP service, you may need to filter any malform requests coming into your service by firewalling your service to drop the attacks. Or, a simple and good configured fail-to-ban scheme can be used too (please be careful in configurating this scheme). You can help further by studying the pattern of attacks and contributing the information into a snort IDS signature to be pushed in very good services providing them, like Suricata, Emerging Threat or Snort.org.

The best way to mitigate is to cleanup the compromised IoT as soon as possible from the internet. I am positively thinking we are having a road map to conclude the IoT issue in the near future too, yes? (blink).

Several sample to block with iptables and ipfw:


// iptables (linux)
sudo iptables -A INPUT -s 5.45.72.0/22 -j DROP
sudo iptables -A INPUT -s 5.45.84.0/22 -j DROP
sudo iptables -A INPUT -s 5.45.76.0/22 -j DROP
sudo iptables -A INPUT -s 5.45.64.0/21 -j DROP

// ipfw (freebsd)
ipfw add deny from 5.45.72.0/22 to any 
ipfw add deny from 5.45.84.0/22 to any 
ipfw add deny from 5.45.76.0/22 to any 
ipfw add deny from 5.45.64.0/21 to any 

8. Epilogue

Four straight months was taken to monitor this threat to understand what exactly happened. We wait that long to confirm and collect plenty of facts and modus operandi performed by the bad actors. We have almost 5 TerraBytes data for the traffic performed for this particular case only. By this post, we hope this threat information can raise more awareness on the subject. We don’t think the attack will be stopped that easy, since nasty hacks will always happen.

For the related script kiddies who we know reading this blog: Please stop this, do those hacks with your own IP and present it as Penetration Tester Papers or something positive and productive that can improve our Internet’s Security,instead of cowardly pinning down routers for stealing credentials and credit cards. There are real people who got blocked by the ISP or services without knowing what was happened, and think about what if your mother’s credit card is stolen by someone. There is no easy way to get rich by hacking. We in MMD are not rich people either (we’re mostly poor actually), we have our hard times in work and life too, but we won’t use our skill for any badness. Stuff like this will bounce its bad “karma” back at you. We’ll make sure your vandalism will get a “proper” handling with the tons of data we “harvest” back from you. (/for the skids)

I am sorry for there are some demonstration that I can not perform openly in this blog, like stack crashing PoC in several web services viewed by radare2 and debugger for processing the sent malformed requestst. Also there are some of the attack details that can not be mentioned here too, for the on-going OPSEC. We can not disclose much information on how to monitor, howto pin some transferred data during the attack directly, and so on, to avoid mitigation that will surely be performed from the “dark force”. But please read between the lines for I try to do best to reveal all things we witness on this case. I planned to visit several events, maybe when we meet I can show you several interesting demonstration.

We are open to communicate with fellow good guys to elaborate more of this threat, and to share to law enforcement & authority with all of the data we collected. Instead of sharing “samples” or hashes of malware, in this post we are sharing the access to our repository stored with the share-able data supporting to evidence collected for this investigation. We have a big collected data since October, 2016, so I can not upload them all. But you can query some IP address in github and we can reply which IP are affected or not.

I just talked with my (kudos) long time friend during FD time, Mr. Larry W Cashdollar and he was informing that Akamai was writing SSH Forward hacking via IoT in fall 2016, and that did not get much attention that time. I didn’t know much details of the post, and I explained that with our disclosure we focus on cyber crime process that is utilizing the hacks with more further aspects and backgrounds, including verdict and evidence, and pointing to the sources of the badness, so the authority will hopefully move and people to block, specially after the tons of credentials spotted and saved as cyber crime evidence. Their post is good one. So please review their report too.

I would like also to thank Mr. Michel Oosterhof for the request to perform a deep analysis for this threat, we kept our promise to post as analysis in our blog. Thank’s for always maintaining the nice pot.

9. Reference

Supporting to this analysis there are more reference contains follow up from this initial report. The bullet listing of the reference is as per following:

  • Infosec alerts for the issue in several countries in various languages were raised, i.e. in Japanese, Italian and German, which contains specific damage details in each affected regions. For Italy and Germany we received confirmation from CERT-BUND, while in Japan this matter was presented directly to the MPD Force Cyber Crime unit’s channel. Noted: The United States law enforcement channel were notified about this malicious activity by preliminary report we sent since early February, 2017, following by the disclosure report of allgedly actor behind this crime scene.

  • Thank you for Security Affair team to be the first media publication for this threat, to Mr. Paganini and Odisseus.

Thank you all, and stay safe.

#MalwareMustDie!

  • This post is dedicated to our friends for so long waiting for next blog, and radare.org is proven useful to analyze vulnerability too (you must note this), to loyal solid of small people in malwaremustdie.org and the open source community in UNIX platform. Big thank’s to the best friends in our AVTokyo community that full of cool whitehat hackers who promptly just jumped in (literally speaking) to support this investigation.

  • Reversed, written and analyzed by @unixfreaxjp on behalf of MalwareMustDie team, on February 27 2017 to February 28, 2017.

  • Tags used for the post: SSH TCP-Forward Format String Exploit Malform HTTP Request Credential stealing Hacking IoT Weak passwords Mod SSL botnet hacktool hacking