Welcome to The Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to

existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile

and so much more. This message will be removed once you have signed in.

Active Hackers

The best community of active hackers. This community has been working in hacking for more than 10 years.

 

Hacker Forum

Hacker from all countries join this community to share their knowledge and their hacking tools

    Hacking Tools

    You can find thousands of tools shared by hackers. RAT's, Bot's, Crypters FUD, Stealers, Binders, Ransomware, Mallware, Virus, Cracked Accounts, Configs, Guides, Videos and many other things.

      PRIV8

      Become a Priv8 user and access all parts of the forum without restrictions and without limit of download. It only costs 100 dollars, and it will last you for a lifetime.

      Read Rules

      In this community we follow and respect rules, and they are the same for everyone, regardless of the user's rank. Read the rules well not to be prohibited.

      Sign in to follow this  
      dEEpEst

      "Dream Formula" Second Generation | The First Office 0day Vulnerability (CVE-2018-0802) Analysis Revoked by Microsoft in (data Exploit 2018-01-10)

      Recommended Posts

      Staff

      Introduction

      The Microsoft Security Patch of January 2018 fixes the Office 0day vulnerability (CVE-2018-0802) captured by the 360 Core Security Advanced Threat Response Team. This vulnerability affects almost all versions of Office that Microsoft currently supports.This is the second outbreak of high-level threats using zero-day loopholes since 360's first global interception of the Office 0day vulnerability (CVE-2017-11826).The 360 core security team has been actively communicating with Microsoft and working together to promote the repair of the 0day loophole so that the vulnerability can be properly resolved before disclosure of vulnerability information.The technical principle of the vulnerability is similar to the 17-year-old "Dream Formula" loophole (CVE-2017-11882). It is a re-initiated attack by the hacker using the EQNEDT32.EXE embedded in the office's embedded equation editor. We call it "Nightmare". Formula II (CVE-2018-0802).

      Attack process analysis

      We captured several in-field attacks of "Dream Formula II". The on-the-spot samples were embedded with two formulae objects using Nday and 0day loopholes. At the same time, Nday loopholes can attack unpatched systems, and 0day loopholes attack all patches. The system bypasses the ASLR (Address Randomization) security measures of the CVE-2017-11882 patch, and the attack will eventually implant a malicious remote control program on the user's computer.

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure: "Dream Formula II" in the wild sample attack process

      Vulnerability analysis

      "Dream Formula II" is a patch bypass vulnerability of CVE-2017-11882. The type is stack overflow. The root cause is Microsoft's stack overflow in the "Dream Formula Generation" patch that does not fix the copy of the font FaceName.This vulnerability will only cause a crash on an unpatched version, but it can be perfectly utilized on a patched version.Below we analyze the CVE-2018-0802 vulnerability by poc samples.

      Static analysis

      As with CVE-2017-11882, the trigger data for this vulnerability is within the "Equation Native" stream of the extracted OLE object.The red coiled portion in Figure 1 is core data with a total of 0x99 = 153 bytes.0×08 represents the font tag, followed by 00 01 respectively represents the typeface and style of the font, and the area from 33 to 25 00 is the name of the Font, which is the data copied when the stack overflows.This part of the data contains shellcode, bypass ASLR tricks, process command lines, and related data for padding. We will analyze them later.

       

      Hidden Content

        Give reaction to this post to see the hidden content.

      figure 1

      Equation Native data structure

      According to information published online, the entire "EquationNative" data structure is:

      EquationNative Stream Data = EQNOLEFILEHDR + MTEFData

      MTEFData = MTEF header + MTEF Byte Stream.

      The structure of QNOLEFILEHDR is shown in Figure 2:

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      figure 2

      The structure of the MTEF header is shown in Table 1. Regarding this structure, there are differences between the actual data and the format specifications that we observed. The following table shows the actual observations:

      Offset Instructions value
      0 MTEF version number 0×03
      1 The data generation platform 0x00 is generated on Macintosh platform, 0x01 is generated on Windows platform
      2 Generated product of this data 0×00 is generated by MathType, 0×01 is generated by Equation Editor
      3 Product major version number 0×03
      4 Product minor version number 0x0A

      Table 1 

      In the attack sample, the MTEF ByteStream structure is shown in Table 2:

      Initial SIZE record
      FONT records
      FONT content
      Remaining data

      Table 2

      The FONT record and FONT content structure are shown in Table 3:

      member Instructions Note
      Tag 0×08 1 byte
      Tface Typeface number 1 byte
      Style Font style 1 byte
      Name Font name NULL-terminated ASCII string

      table 3

      Patch bypass analysis

      CVE-2018-0802 vulnerability trigger point is located in sub_21E39 (module address is set to 0 in the IDA), as shown in Figure 3, it can be seen that the function of the function is to initialize a LOGFONT structure according to the font data in the formula :

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      image 3 

      Let's take a look at Microsoft's description of the LOGFONT structure (Figure 4).You can see that the last member of this structure is lfFaceName,

       

      Hidden Content

        Give reaction to this post to see the hidden content.

      Figure 4: LOGFONT Structure

      Let's take another look at Microsoft's description of the lfFaceName member (Figure 5).You can see that lfFaceName represents the typeface name of the font. On the version being analyzed, it is a null-terminated char string with a maximum length of 32, which contains the terminator NULL.

       

      Hidden Content

        Give reaction to this post to see the hidden content.

      Figure 5 

      The problem is obvious: the code in the red box in Figure 3 does not limit the copy length when copying the font FaceName, and the source data for the copy is the user-supplied font name, and the destination address is a LOGFONT structure body address passed in from the parent function.We look back to the parent function of sub_21E39 (Figure 6), you can see this address is located on the stack opened by the parent function, is a local variable of the parent function.The attacker constructs malicious data, overwrites the last two bytes of the return address of the parent function (sub_21774), and then directs the control flow to the shellcode on the stack.

       

      Hidden Content

        Give reaction to this post to see the hidden content.

      Figure 6

      During the analysis, we found a place of suspected recursion. Figure 7 shows the disassembly code of sub_21774. We can see that sub_21774 first calls the vulnerability function sub_21E39 to initialize a LOGFONT structure, and then calls the relevant API to pass in the structure. The system gets a font name saved to Name.Then, it compares the obtained Name with the user-supplied lpLogFont. If it is inconsistent (and the sub_115A7 function needs to return False), it will continue to call or not call itself according to the condition specified by a3, while a3 is the third of sub_21E39 function. Parameters.

       

      Hidden Content

        Give reaction to this post to see the hidden content.

      Figure 7

      Let's take a look at the third parameters of the parameters, otherwise there may be multiple recursive, can not effectively use this overflow.According to the previous CVE-2017-11882 debugging results (Figure 8), we can see that when parsing the user-supplied font data, the function calling sub_21774 is sub_214C6.Let's look back at sub_214C6 (Figure 9). Sub_214C6 calls sub_21774 to pass a value of 1 to the third parameter, so if(a3) in Figure 7 is true.Let's look at Figure 7, when sub_21774 recursively calls itself, the value passed to the 3rd parameter is 0, which means that sub_21774 will not call itself again, and the recursion level will only have 1 level.Analyzed here, recursive doubts have been solved.

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 8: CVE-2017-11882 Triggered Execution Flow

       

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 9 

      One problem that has been analyzed here is that if _strcmpi(lpLogfont, &Name) is not true (if the font data is forged by the user, it certainly does not hold here), sub_115A7 will be called, which means that it will go to CVE-2017. -11882 overflow point.In the version without the November patch, if you want to successfully use CVE-2017-11882, CVE-2018-0802 points will not overflow because the former needs to have a much smaller overflow size than the latter, and the copy last has a NULL truncation (we know that the controllable eip that overflows to CVE-2017-11882 requires only 0x2C bytes, and through the analysis below (Figure 11) we can see that the controllable eip overflowing to CVE-2018-0802 requires 0x 94 bytes).On the other hand, if you want to trigger CVE-2018-0802 on a version that does not have an November patch, CVE-2017-11882 will be triggered first.In short, CVE-2018-0802 is not available on the pre-11 patch.

      However, as can be seen from Figure 10, in the November patch, before the copy of CVE-2017-11882 overflow point, Microsoft performed a length limit of 0x20 on the copy length, and after the copy was completed, it was manually copied at the end of the copy. A NULL was added to invalidate CVE-2017-11882.This directly leads to CVE-2018-0802 being unusable before patching!Now, as long as sub_115A7 returns False, the exploit can be perfectly exploited, and actual debugging finds that sub_115A7 returns False.

       

      Hidden Content

        Give reaction to this post to see the hidden content.

      Figure 10

      Dynamic Analysis

      Spillover data copy

      With the above analysis, dynamic analysis becomes very simple.Since this overflow point will copy the data, let's monitor the source string and the corresponding stack traceback for each copy. We first enter the OLE data-related Load function (sub_6881), and then break the point before copying the data and proceed. Output, the result is shown in the code:

      Hidden Content

        Give reaction to this post to see the hidden content.

      Hidden Content

        Give reaction to this post to see the hidden content.

      Hidden Content

        Give reaction to this post to see the hidden content.

      Hidden Content

        Give reaction to this post to see the hidden content.

      Hidden Content

        Give reaction to this post to see the hidden content.
       

      It can be seen from the log that there are two copies, and we can know from the stack trace back that these two copies are the two calls to sub_21174 in the static analysis.The first time is the sub_214c6 call to sub_21174, and the second is the sub_21174 call to itself.It can be seen that the stack overflow obviously occurs on the first copy.Here to mention a little bit, cb ce cc e5 stands for Songs.

      Let us calculate in detail how much length we need to overflow to control the return address of the parent function (sub_21174). (The conclusion of this question has been mentioned in the “Patch bypass analysis” section). From Figure 11 we can see from lfFaceName(-0× 90) Overflow to ret_addr (+0x4), a total of 0x94 bytes are required. Exceeding the 0x94 portion of the byte will cover the return address one by one from the low address.

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 11

      We look at the data in the POC. As shown in Figure 12, the blue part is the first 0x94 bytes of the overflow, the 2500 is the last two bytes of the overflow, and 00 is the terminator. When the copy encounters 00 Stop.According to the little end address layout, when the poc is running, the EIP will only cover the lower 2 bytes.Why did you do this?The answer is to bypass ASLR.

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 12

      Bypass ASLR

      Let's take a look at why two bytes of a district can bypass ASLR.

      First of all, we must be clear that the patch file is opened ASLR, as shown in Figure 13.As a result, the base address for loading EQNEDT32.EXE is random each time, so the first problem to be considered when overflowing is how to bypass ASLR.(As for DEP, you can see from Figure 14 that DEQ is not enabled in EQNEDT32.EXE in the patch file, so it is not necessary to consider DEP under normal circumstances)

      Unfortunately, attackers clearly understand the Windows system mechanisms and defenses.Because on the Windows platform, the ASLR of a 32-bit process only randomizes the upper 2 bytes of the address each time, while the lower 2 bytes remain unchanged.If a ret instruction can be found in the same low 0xFFFF space of the covered address, and the address is 0xABCD00XY (where ABCD and XY are 6 arbitrary hexadecimal numbers, the second to last byte in the address Must be 0x00, because after the copy needs to be accurately truncated, you can directly use this ret to jump to the stack.Since there is no need to bypass DEP, shellcode can be executed directly on the stack.

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 13: ASLR Status of EQNEDT32.EXE is Enabled and DEP is Non-Permanent DEP

       

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 14: DEP Status of EQNEDT32.EXE is Disabled

      More unfortunately, within the EQNEDT32.EXE module, Microsoft really gave and gave only one such address (Figure 15). There are only one address that satisfies the condition, namely, 20025, two bytes that are covered in the eip. 25 00 is unique, there is no second ret that satisfies the condition.

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 15

      Let's consider what the original return address of sub_21174 is.Of course, sub_214C6 calls the address of the next instruction of sub_21174. It can be seen from Fig. 16 that the offset of this address is 214E2. According to the overlay of Fig. 12, the offset after the overlay becomes 20025, which consists of the above analysis and Fig. 17 As you can see, this address is a ret instruction.This instruction will pop up sub_214C6 to the first parameter of sub_21174 and switch the control flow to this value to execute.To make matters worse, this first parameter happens to be lpLogFont, which is the FontName provided by the user.So after ret is executed, the control flow will be transferred to the stack and it will just start executing the first byte of the user-supplied FontName.

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 16

       

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 17

      Sample A Shellcode Analysis

      In poc for sample A transformation, control flow hijacking and execution of the shellcode section are shown in Figure 18:

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 18: Due to the existence of recursion, we need to return twice from the sub_21774 function, which explains the first two rets

               Immediately after the jmpeax instruction, WinExec is called, and the command line parameter happens to be calc.exe, as shown in Figure 19:

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 19

      Sample B Shellcode Analysis

      Sample B bypasses ASLR in the same way as Sample A, but the shellcode portion is not the same as Sample A.Sample B's shellcode finds the kernel32.dll export table (Figures 20 and 21) through the PEB, and then searches through the export table for a hash of the desired function through a specific hash algorithm (Figure 21). The hash value is given in shellcode.The shellcode then saves the searched function address to where the hash value was previously stored (Figure 22).

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 20: Hash value and copy path name given in sample B's shellcode

       

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 21: Finding the required function in the export table of kernel32.dll with the hash value

      Hidden Content

        Give reaction to this post to see the hidden content.
       

       

      Figure 22: Comparison of data on the stack before and after finding the function address

       After successfully finding the function and saving the address on the stack, first call the ExpandEnvironmentStringsA function to expand the short path (the short path is saved in the shellcode), and then call CopyFileA to copy the payload to the word plugin directory so that the payload will follow the word next time. Start automatically loaded into memory.Finally call ExitProcess to exit the Equation Editor process (Figure 23).The entire process does not affect the normal opening of the document.

      Hidden Content

        Give reaction to this post to see the hidden content.

       

      Figure 23: Expand the short path, copy the file, and exit the process

      to sum up

      The 0day vulnerabilities used by "CVE-2018-0802" are called CVE-2017-11882's twin vulnerabilities. One vulnerability in the attack sample is for unpatched systems, and the other is for vulnerabilities. The system uses two OLEs to attack at the same time. The hackers' well-constructed attacks are perfectly compatible with the different circumstances of the system vulnerability patch environment.The use of this loophole and the Bypass ASLR approach have a certain degree of coincidence, if there is no ret instruction in the EQNEDT32.EXE module can be used to bypass the ASLR, if lpLogFont is not the first parameter of sub_21774, if CVE - 2017-11882 patch repair method forced DEP protection, "Dream Formula II" will not have the opportunity.

      The latest 360 security products have been able to detect and prevent this zero-day vulnerability, and we recommend that users update the Microsoft Security Patch for January 2018.

      reference

      Hidden Content

        Give reaction to this post to see the hidden content.

      Code .py

      Hidden Content

        Give reaction to this post to see the hidden content.
       

      Share this post


      Link to post
      Share on other sites

      hello subject looks great let see if its really works 

      Share this post


      Link to post
      Share on other sites
      Guest
      This topic is now closed to further replies.
      Sign in to follow this  

      • Similar Content

        • By itsMe

          Hidden Content
          Give reaction to this post to see the hidden content. Introduction
          WPScan is a free and automated black box WordPress vulnerability scanner written for security professionals and blog maintainers to test the security of their sites. You can use it to remotely scan WordPress installations, to find vulnerabilities within the core version, plugins, and themes. It’s maintained by the WPScan Team.
          Minor:
              New version for updated dependencies

          Hidden Content
          Give reaction to this post to see the hidden content.
        • By itsMe

          Hidden Content
          Give reaction to this post to see the hidden content. Malicious docx generator to exploit CVE-2021-40444 (Microsoft Office Word Remote Code Execution)
          Creation of this Script is based on some reverse engineering over the sample used in-the-wild: 938545f7bbe40738908a95da8cdeabb2a11ce2ca36b0f6a74deda9378d380a52 (docx file)
          You need to install lcab first (sudo apt-get install lcab)
          Check REPRODUCE.md for manual reproduce steps
          If your generated cab is not working, try pointing out exploit.html URL to calc.cab
          Finally try the docx in a Windows Virtual Machine:

          Hidden Content
          Give reaction to this post to see the hidden content.
          Hidden Content
          Give reaction to this post to see the hidden content.
        • By itsMe

          Hidden Content
          Give reaction to this post to see the hidden content. Learn how to use sqlmap for professional engagements with the most in-depth sqlmap course.
          What you'll learn
              What sqlmap is and how it's used to test web applications for SQL injection vulnerabilities
              How to create a home lab environment to safely and legally attack web applications with SQL injections
              Find and exploit your first SQL injections with sqlmap
              Learn, in-depth, all of the options that sqlmap offers
              How to enumerate vulnerable database information (such as database names, schema, tables, and data within those tables)
              How sqlmap code is structured and how to find what you're looking for (ie: payloads and settings)
              How to manipulate headers, parameters, methods, data, cookies, and more
              How to configure targets via URLs, logfile, bulkfiles, and request files (from Burp/ZAP)
              How to configure proxies and Tor to use sqlmap anonymously
              How to modify requests on the fly with simple Python scripts
              How to identify WAFs and manually as well as automatically bypass them (with tamper scripts)
              How to troubleshoot common sqlmap errors and overcome issues
              Understand how (and when) to use --level and --risk, and how it affects results (this is important!)
              How to use regular and advanced takeover options and techniques to take control of back-end databases and servers
              How to run sqlmap as an API server and client
              How to fingerprint, enumerate, and takeover
          Requirements
              Experience with SQL (you should know what SQL is)
              Experience working with web applications (you should understand how apps use databases)
              Experience working with databases (at least a high-level understanding of how databases work)
              Knowledge of different database engines (ie: you should know what MySQL means)
              Knowledge of the different SQL injection techniques
              Fluent in English
          Description
          About the course:
          Learn how to use sqlmap in-depth for professional engagements, and help support open-source in the process. 40% of every sale will be donated to the sqlmap project to help support its development.
          sqlmap is the most powerful and widely used SQL injection tool, and for good reason. It packs an impressive array of features and options specifically crafted to fingerprint, enumerate, and takeover databases as well as underlying systems. In this course, we take a look at all of that. We start by looking at the sqlmap project, including how the source code repository is structured, where to find important files such as configuration and payload files, and how to set up a home lab environment to safely and legally practice what we're learning. Then, we explore every single option that sqlmap offers with examples and explanations of how and when to use the option(s). We learn tips & tricks to see what sqlmap is doing under the hood and to troubleshoot when we come across issues. Once we've covered sqlmap's options and features, we tie it all together by running through scenarios. This is when we get to see how those options can be used together or on their own to achieve our pentest or bug bounty objectives.
          The course also includes sections dedicated to specific topics such as bypassing WAFs and evading security controls, and how to run sqlmap as an API.
          -----------------------
          Instructor
          My name is Christophe Limpalair, and I have helped thousands of individuals pass IT certifications, learn how to use the cloud, and develop secure applications. I got started in IT at the age of 11 and unintentionally fell into the world of cybersecurity. Fast-forward to today, and I've co-founded a fast-growing cybersecurity community, Cybr, that also provides training resources.
          As I developed a strong interest in programming and cloud computing, my focus for the past few years has been training thousands of individuals in small, medium, and large businesses (including Fortune 500) on how to use cloud providers (such as Amazon Web Services) efficiently, and how to develop more secure applications.
          I've taught certification courses such as the AWS Certified Developer, AWS Certified SysOps Administrator, and AWS Certified DevOps Professional, as well as non-certification courses such as Introduction to Application Security (AppSec), SQL Injection Attacks, Introduction to OS Command Injections, Lambda Deep Dive, Backup Strategies, and others.
          Working with individual contributors as well as managers, I realized that most were also facing serious challenges when it came to cybersecurity.
          Digging deeper, it became clear that there was a lack of training for AppSec specifically. As we explore in the course, SQL injection vulnerabilities can be absolutely devastating when exploited, but preventing SQL injections is actually quite simple. So my goal with this course is to help you get started on your journey of learning the tools, techniques, and concepts to properly find injection vulnerabilities in your own applications (or your client's).
          It's time to take security into our own hands and to learn how to build more secure software in order to help make the world a safer place! Join me in the course, and we'll do just that!
          I welcome you on your journey to learning more about sqlmap, and I look forward to being your instructor!
          Who this course is for:
              Web pentesters
              Application Security Engineers
              Web Developers
              Bug Bounty Hunters
              DevSecOps Engineers
              Security Researchers
              Database administrators
          Hidden Content
          Give reaction to this post to see the hidden content.

          Hidden Content
          Give reaction to this post to see the hidden content.
        • By itsMe

          Hidden Content
          Give reaction to this post to see the hidden content. Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.
          Hidden Content
          Give reaction to this post to see the hidden content.

          Hidden Content
          Give reaction to this post to see the hidden content.