Conference DEFCON 17. Laugh at your viruses! Part 2

 3r33412. 3r3-31. Conference DEFCON 17. Laugh at your viruses! Part 1
 3r33412.
 3r33412. Then you can load it into IDA and see that everything in the table of imported addresses looks fine, and we can follow the cross-references to set a pointer to the desired file. So we get exactly to the point of location of the dependent encryption code.
 3r33412.
 3r33412. Conference DEFCON 17. Laugh at your viruses! Part 2  3r33412.
 3r33412. Thus, with just a few memory dump commands, we found a place where Coreflood hid. We disassembled, extracted and pasted the PE header, even without it, and got a fully restored address table in less than 20 seconds.
 3r33412.
 3r33412. The next story is called “Honey, sorry for bothering you again - I have stung the Internet!” This story tells that a defective IP generator Conficker.B scans only part of the Internet. Here we go back to the rand function. An important part of this function is the most recent instruction, which I marked with a green arrow — it performs any final value in EAX with a value of 7FFF. If you are not familiar with the principles of assembly and do not know what this instruction can do, here is a small demo about this.
 3r33412.
 3r33412. 3r3013.
 3r33412.
 3r33412. We move the maximum value that EAX can contain into this registry and execute the final instruction. You can see that it “chops off” the upper half of the value and then subtracts 7FFF, which in the decimal system is converted to the number 32767. Apparently, the authors did not realize that this restriction that Windows runs does not return the whole number to the integer number . It "cuts off" it so that the value does not exceed 7FFF, so that one byte of 7F will never be greater than this value of 7F, that is, it will never be equal to 80 or something like that.
 3r33412.
 3r33412. Further in the left part of the slide, which I called the “Vicious Method”, you see the Conficker.B code. Shown here is one rand call that initiates the first octet of an IP address, which is meant to be scanned after it returns from rand. The next rand system call initiates the third and fourth octets of the IP address, but because of the above, two of these octets will never be greater than 7F. Thus, most of the Internet will not be able to be scanned due to the fact that Conficker.B uses this algorithm.
 3r33412.
 3r33412. In the right part of the slide is a part of the source code, which shows the work of the assembler. It is difficult to read on the screen, but this example is publicly available, and you can read it online if you are interested.
 3r33412.
 3r33412.  3r33412.
 3r33412. At the bottom of the next slide, entitled “Simulating the Perverse Method”, is a link to this tool. You also see that the IP address is generated from PRNG, but not scanned.
 3r33412.
 3r33412.  3r33412.
 3r33412. I want to say a big thank you to Brandon Enright, who made the graph on the next slide. This graph is called the “Hilbert curve,” and I’ll now enlarge the image so that you can see better on the screen. The blue color on the graph indicates the range of IP addresses that are not available for scanning by Conficker.B using this vicious algorithm. Dark red color indicates what can be scanned. You see that most parts of the graph are not dark red, but purple, and you will not see why this happens until you increase the corresponding rectangle.
 3r33412.
 3r33412. 3r362.
 3r33412.
 3r33412. Even in this enlarged rectangle, in each block /1? you see a lot of blue fragments that turn a dark red color into purple. These are the parts of addresses that Conficker.B is unable to scan.
 3r33412.
 3r33412.  3r33412.
 3r33412. This is quite interesting because many people believe that Conficker.B created “great minds”. Perhaps it is, but these minds were not aware of the limitations that rand () exists in Windows.
 3r33412.
 3r33412. Matthew Richard: Let us return to those guys who, as I have already said, do not manage their viruses too well, so in cybercrime it is akin to the proverb “man is wolf,” so these guys are not respected in their circles.
 3r33412.
 3r33412. Let's talk about the hacker toolkit Neosploit, which “got” everyone. We can say that the motto of its developers was “Thank you for the cash, now it's time to run.” Neosploit is a set of tools for organizing web attacks, so the guys from cybercrime will buy it and tune it against the guys on the server, hack the server, download codes, and so on.
 3r33412.
 3r33412.  3r33412.
 3r33412. The creators of Neosploit made a good investment by selling their instrument, but not allowing it to change, modify, or use its individual parts. The third version of this toolkit was released in April 200? and most unique exploits are written in C, so this is not PHP or some kind of lame web application. Clients received a binary distribution with a set of CGI exploits.
 3r33412.
 3r33412. Neosploit has features that prevent clients from sharing or cutting exploits. To do this, all exploits were presented in binary format, encrypted using XOR. The creators made it so that no one could cut, glue and create their own set of exploits based on Neosploit. There are 40-50-60 different types of web attacks, based on stolen and copied codes inserted into their own exploits, so the Neosploit guys turned out to be a bit smarter by encrypting their exploits from the inside. In the screenshot you can see that they have a file with the key neosploit.key, so this is fully licensed software.
 3r33412.
 3r33412.  3r33412.
 3r33412. I have no doubt that they had a bunch of really good customers, on whom they made a lot of money. Their most famous customers were Torpig. I think you heard about the Mebroot rootkit, with which they compromised the system to create a botnet network. But the creators of Neosploit had many other customers. In May 200? they released a fresh enhancement - the 3rd version of their toolkit. Clients were asked to prepay for a package of exploits with all subsequent updates for $ 1000. Later, I will tell you more about this, for now I’ll notice that they really worried about the pirates and tried to protect their product from them as much as possible, so it was definitely a lot of fun.
 3r33412.
 3r33412. 3r33112.
 3r33412.
 3r33412. Even the media wrote that these exploits are everywhere. So by itself, we will try to disassemble the code and show how Neosploit works.
 3r33412.
 3r33412. The first fun thing they did after they vigorously unwound this set of exploits from April to July — they stopped their support from July 2? 2008. In the explanation that they just posted on their website, it was said: “Unfortunately , further product support is not feasible. We apologize for the inconvenience, but the business is a business, and the time spent on the project is not justified. We have tried to meet the requirements of our clients until the last months, but sometime the support had to stop. We have been with you for a year and a half and we hope that this was not the worst time for your business. Now we will not be near you, but, nevertheless, we wish your business to flourish for a very long time. ” In general, we received your money, you paid a subscription, so be healthy!
 3r33412.
 3r33412. However, they just joked and in August 2008 they returned again and released a completely new version 3.? which they provided to their key customers, indicating that all other customers will receive an update after they pay for it. This update contains several new exploits for Adobe PDF, Shockwave Flash and Quicktime for Firefox.
 3r33412.
 3r33412. Then they decided to be serious again and announced that they were actually stopping the release of updates, so everyone who made the prepayment of a subscription was screwed up.
 3r33412.
 3r33412. So, let's move on to considering Neosploit, this pretty cool web-based attack kit. Since its developers fought against pirates and theft of exploits that could be copied and pasted into someone else's kits, they took each exploit and placed it in a CGI file, coding it in such a way that it was very difficult to get it out. Binary exploit files written in C were slightly different from PHP scripts.
 3r33412.
 3r33412.  3r33412.
 3r33412. In the Neosploit blog, the phrase Dancho Danchev was posted that “anyone can create a new exploit,” but this is rather difficult. I decided to find out how difficult it is and started disassembling one of the exploits.
 3r33412.
 3r33412. Each exploit was stored in encrypted form using a 3-byte XOR key. For each incoming request, the exploit was decrypted and made available to the user for work, and this cycle was constantly repeated.
 3r33412.
 3r33412. 3r33150.
 3r33412.
 3r33412. So even if you could get through the memory, and removing the memory dump is still quite difficult, and getting all the exploits, still these buffers are cleared every time.
 3r33412.
 3r33412. Fortunately, if you can copy and paste these exploits into the program you need, you can find the answer. It uses a very powerful decryption tool - IDA scripting. With it, you can comment or remove a dump of a certain area of ​​memory, update exploits, it can be useful for working with malicious software that uses strings complicated by xor, base6? etc. I wrote an IDE script with which I tried to disassemble the captured memory dump of an encrypted exploit.
 3r33412.
 3r33412. 3r3163.
 3r33412.
 3r33412. It goes through all the encrypted objects, searches for all calls to the decryption functions, captures the encrypted objects, decrypts them using XOR and then takes a dump. This is one way, but I think you could write your own script, an application that does the same. If you know how to add new exploits to Neosploit, then you can do something in this direction and of course, once you remove the dump, you will know the whole plaintext, you can “rip out” the instrumentation and resell it. New guys developing exploits just gave up because someone earned good money without worrying about their customers.
 3r33412.
 3r33412. If anyone has heard of the great hip-hop philosopher Biggy Smalls from Notorius B.I.G, he knows his song called Ten crack commandments, “The Ten Commandments of Crack,” which contains great wisdom. If you are a drug dealer, follow the 4 commandments: "Never sit on your own foolishness, which you are pushing." Probably the guy I called Peeper who distributed my own malicious code never heard this song because I tested my product on myself.
 3r33412.
 3r33412. His attack was as follows. He sent emails disguised as various government agencies and appealing to people by name: “Dear such-and-such, someone has filed a complaint with the Federal Trade Commission about your company, so click here to download the document, which describes the essence in detail” .
 3r33412.
 3r33412. 3r33180.
 3r33412.
 3r33412. Then the user followed the link and tried to download this document, and it really was a Word document in the .doc format. However, there was one very tricky feature. You had the opportunity to simply drag the executable files from the Word document and then rename them, but when you try to download the file, a message appears: “Microsoft Word detected a problem and the document could not be loaded. Please double click on the document icon to continue. ” Awesome idea!
 3r33412.
 3r33412. 3r3189.
 3r33412.
 3r33412. Naturally, people clicked, they clicked 6 times to get this infected message, so this guy had a lot of victims. I liked this post: “They tried to fool me, blah blah blah.”
 3r33412.
 3r33412. The next thing we found, tracking this guy, are the open directories of the Drop Directory, where he dumped the received information.
 3r33412.
 3r33412. 3r3202.
 3r33412.
 3r33412. He may not have had his own tools for managing them or he thought that open directories is a good thing, but open directories are bad if you store a lot of information received from different people. Any server that he would have set up for his “landing” site had an open directory, and you could just go there and view the lists of all its victims and each one individually.
 3r33412.
 3r33412. In a sense, he was a good developer because he wrote quality code. But his disadvantage was that by addressing his code to the current server, he used his real IP address, and you would not last long using such things.
 3r33412.
 3r33412.  3r33412.
 3r33412. So in fact, he had a standard DSL modem that communicated from Ukraine, he tested all his code and malware, which has a good function called “watch me”, or “watch it”. This guy was involved in stealing banking information, but sometimes he just wanted to watch his victims to see what they were doing, so we called him Peeper, or “Observer.” He was not satisfied with the simple functionality of his software, he began to monitor himself. It looks rather strange, as if you opened VNC remote access windows on your own computer and looped them in to get smaller and smaller images. In fact, he did this many times, on many landing servers, in fact, it was very, very strange. So looking through these “landing” servers, one could say: “oh, look, this is a picture, where he watches himself, watching himself, who watches himself.”
 3r33412.
 3r33412.  3r33412.
 3r33412. “My light, mirror, tell me, who is the kindest in the world”?
 3r33412.
 3r33412. Most of all I liked what he did for himself. He used this “watch me” feature in the code development process. In fact, he wrote the code, watching himself, sending it all back to the command and control server. Thus, he gave the opportunity for the official to break through the back door, lay his face on the floor and confiscate his computer. In short, nothing helps to get rid of you as an image of the source tree associated with your IP address.
 3r33412.
 3r33412.  3r33412.
 3r33412. The last piece of malware that we are going to look for will certainly interest people who are well acquainted with Internet Explorer 7. But don’t worry, Microsoft says that everything is under control, trust them!
 3r33412.
 3r33412.  3r33412.
 3r33412. So Microsoft was in painThis is a problem with Internet Explorer ? due to the fact that it was very easy to steal saved passwords from this browser. Usually you enter the site, you are asked if you want to save the password, a special form is called, you answer “yes”, and it is saved in the registry. The problem with IE 6 was that if you log in as a user, you only need to make one CryptUnprotectData () system call to decrypt these passwords, which really do not have protection.
 3r33412.
 3r33412. Therefore, malware running with the user's authority freely read these passwords and sent them to the attacker. Therefore, in IE ? they installed a great “patch” - passwords were encrypted with a 128-bit key. Really no hackable solution!
 3r33412. If you look deeper, you can see the hash that is available on the site, I will explain this a little later, in which there is a binary file containing the username and password. I want to quote another great philosopher, John Travolta, from the Swordfish movie. My favorite passage is when he sits there and explains: "This cipher is so good that even I can't hack it." I think he was referring to 512-bit encryption, and he, the world's best cryptographer, why he was hired, says that even he cannot do it.
 3r33412.
 3r33412. So, that's what Microsoft did. They encrypt the password, for which they will generate a 128-bit key based on the MD5 hash of the site for which they store this password. That seems pretty reasonable, so if you went to www.bank.com/login.sp then they will take this string, make all the letters lowercase, then convert them to large characters and use the MD5 algorithm, turning this string into a key that will be used to encrypt the password in the registry for the user name.
 3r33412.
 3r33412. Then, when you visit this site for which there is a saved password, they do the opposite: IE normalizes the URL, recodes the string and looks in the registry to see if there are any values ​​stored for you. Details it happens like this:
 3r33412.
 3r33412.
 3r33412.
read the register hash for each URL in index.dat;
 3r33412.
URL is converted to lower case;
 3r33412.
GET parameters are reduced;
 3r33412.
URL is converted to large characters;
 3r33412.
if the hash of the URL value is equal to any value in the register, the data is decrypted using this URL.
 3r33412.
 3r33412. This seems pretty reasonable, but if you think about it, there is a slight problem here. In fact, there is too little entropy, and a hacker can easily cope with this. This is not much more complicated than encrypting passwords in IE 6.
 3r33412.
 3r33412. Hacking it is pretty simple. To save the password, the user must visit the site, which can then be easily found in index.dat or in the “TypedURLS” registry key section. If we consider only the US, then there are about 1?000 sites of banks and credit unions, and you can easily find them. You know the sites for which you want to find passwords, and each such site has login pages, so it is easy enough to collect a whole collection of keys. As you can see, the protection here is clearly insufficient.
 3r33412.
 3r33412. Of course, if you're a bad guy, you probably know a lot of sites that need passwords: Facebook, Myspace or Twitter, or others with a login page, so you can just figure out such sites. You can use the Alexa service, which keeps a list of the most popular sites, collecting statistics on their attendance. The keys are really easy to decipher, you can make something like a Rainbow Table “rainbow table” based on these common sources, and then you will have all the keys for decrypting passwords.
 3r33412.
 3r33412. For the bad guys, this is pretty simple, so the moral of the IE 7 story is: it’s not as good as the developers try to convince.
 3r33412.
 3r33412. Can you help in this situation? Honestly, no. Nobody dealt with this question properly. Michael and I looked at a whole bunch of applications, including Mozilla Firefox, and saw that almost everyone was trying to write a password retrieval tool for them. Indeed, there is little that can protect you, if you store passwords for websites, you probably know such a thing as the “Remember my password” tool. Almost all passwords can be extracted one way or another. Compared to other browsers, Firefox and IE 7 provide stronger protection, since you actually have to enter the password first, but even if you just entered the password without saving it, the guy may already be able to steal it.
 3r33412.
 3r33412. Avoid hacking, do not save valuable passwords, if you run the site with a login form, do not allow users to save their data.
 3r33412.
 3r33412. Finally, we will look at a Trojan called Laqma. This is a typical Trojan that steals confidential data and other pieces of information that it takes from cookies. It loads its cookies in some strange way, thanks to which it does not undergo data sanitization, the user becomes infected, the trojan steals the values ​​of its cookies and sends it to command and control.
 3r33412.
 3r33412. 3r33333.
 3r33412.
 3r33412. This trojan is loaded with a file that can have any name. If you emulate a trojan using your own code, you can specify any name, such as another PHP file, so you can simply upload your own PHP script to the bad guy's website, exploiting this vulnerability - the ability to download arbitrary files.
 3r33412.
 3r33412. And now I give the floor to Michael for the last demo.
 3r33412.
 3r33412. Michael Lai: I'm sorry it's not funny, but it's worth seeing because it's cool. Now I will try to present this demo in a convenient presentation format for you to see. The presentation is based on the Laqma rootkit that we installed. Imagine that you are engaged in the analysis of incidents or reverse engineering of malware and encounter a computer infected with Laqma or any rootkit that throws hooks into the system service manager table. First of all, you will try to figure out which functions are hooked on the SSDT, and then you can try to restore a working kernel module if you test it with IDA or something like that.
 3r33412. So it's great that I wrote a plugin for the Volatility command line tool that automates all these tasks. I have already dumped the memory of a computer infected with Laqma, so I just use the SSDT plugin that Brendon Dolan Gavit developed, this is a terrific plugin. By default, it simply prints all the records from the SSDT, the module and the address pointed to by the SSDT function, and does this for all four SSDTs.
 3r33412.
 3r33412. 3r33333.
 3r33412.
 3r33412. All these entries must be legally specified inside the TOS kernel, for the second table they must be specified inside win32k, and for the third and fourth tables this location is random, because it is not set by default. Therefore, I am going to use the Brandon Dolan Gavit SSDT script and just install a filter on the command line, so I will ignore everything that is specified inside the TOS kernel and inside win32k.
 3r33412.
 3r33412. The result is four functions shown at the bottom of the screen that indicate the module name, the domain name, drv, .sys, lists the key values ​​of hidden registry entries for hidden processes and information on system queries. As I said, this is the first stage. Next, you need to find out which SSDT functions are hooked. The next stage consists in removing the module dump and searching for registry keys and files hidden there.
 3r33412.
 3r33412. 3r33333.
 3r33412.
 3r33412. This process is a bit automated using the SSDT plugin. You can see how BSOD flashed on the screen, it worked IDA command line program. As a result of the automatic processing, an IDB is created, this is some more automation, as a result of which IDB functions are marked that correspond to the hooked functions of the SSDT.
 3r33412.
 3r33412. Thus, using one small step, we learned what SSDT functions were associated with the dump that owns the created IDB module, and were able to call them in order to know exactly where to look in the IDB when I start doing reverse engineering.
 3r33412. Hope you had fun!
 3r33412.
 3r33412.
3r33333.
3r33333. 3r3408. 3r3408. 3r3408.
 3r33412. Thank you for staying with us. Do you like our articles? Want to see more interesting materials? Support us by placing an order or recommending a friend, 30% discount for users of Habr for a unique analogue of entry-level servers, which was invented by us for you: 3r33380. The whole truth about VPS (KVM) E5-2650 v4 (6 Cores) 10GB DDR???GB SSD 1Gbps from $ 20 or how to share the server? 3r3013. (Available options with RAID1 and RAID1? up to 24 cores and up to 40GB DDR4).
 3r33412.
 3r33412. VPS (KVM) E5-2650 v4 (6 Cores) 10GB DDR???GB SSD 1Gbps until December for free When paying for a period of six months, you can order 3r3333388. here 3r3013. .
 3r33412.
 3r33412. [b] Dell R730xd 2 times cheaper? 3r33399. Only we have [b] 2 x Intel Dodeca-Core Xeon E5-2650v???GB DDR4 6x480GB SSD 1Gbps 100 TV from $ 249 in the Netherlands and the USA! 3r33399. Read about
How to build the infrastructure of the building. class c using servers Dell R730xd E5-2650 v4 worth 9000 euros for a penny? 3r3013. 3r3408. 3r33412. 3r33412. 3r3405. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d,! 1): e.attachEvent ("onload", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r3406. 3r33412. 3r3408. 3r33412. 3r33412. 3r33412. 3r33412.
+ 0 -

Add comment