Malicious PDF exploiting CVE-2010-0188
I recently analysed a malicious PDF named Request.pdf which arrived by email. The original PDF has the following MD5 fingerprint: 8b7f28c8de922fcaac96846d24e30780. Since it seemed to be compressed, the first step was to use pdftk to uncompress the PDF:
pdftk Request.pdf output Request.unc.pdf uncompress
This resulted in the following MD5 fingerprint: f516be63a69d23a36ca948b039be9a05 and it also revealed some interesting Metadata embedded into the PDF document:
<uri>D:\project\2010\CVE-2010-0188\Final\poc-ever.pdf</uri>.
It looks like someone was working on a proof-of-concept exploit for the CVE-2010-0188. The next thing that caught my attention was a small piece of JavaScript:
<script contentType="application/x-javascript">
var a=app.viewerVersion;
if (a<9)
{ sBase64="SUkqADggAAB...";
} else {
sBase64="SUkqADggAAB...";
}
1.rawValue = sBase64;
It basically just checks the Adobe Reader version and outputs a base64 encoded TIFF image accordingly. This TIFF contains the actual exploit, which leads to a small XOR loop, that deobfuscates further parts of the shellcode:
000001B2 5B pop ebx
000001B3 4B dec ebx
000001B4 33C9 xor ecx,ecx
000001B6 66B9A604 mov cx,0x4a6
000001BA 80340BA0 xor byte [ebx+ecx],0xa0
000001BE E2FA loop 0x1ba
If we use XOR with 0xa0 on the remainder of the TIFF image, a second XOR loop is revealed:
0000036E 33C9 xor ecx,ecx
00000370 B900040000 mov ecx,0x400
00000375 807C0EFF00 cmp byte [esi+ecx-0x1],0x0
0000037A 740C jz 0x388
0000037C 807C0EFF85 cmp byte [esi+ecx-0x1],0x85
00000381 7405 jz 0x388
00000383 80740EFF85 xor byte [esi+ecx-0x1],0x85
00000388 E2EB loop 0x375
This code checks whether the current byte is 0x0 or 0x85, if this is the case do nothing, else XOR the byte with 0x85. This operation is performed on the embedded JPEG image and results in two executables and one PDF. Thus, no malicious file is downloaded of the Internet as a first step, but the executables to run are directly embedded in the malicious PDF within an embedded JPEG image.