1 00:00:00,000 --> 00:00:07,620 So my session is called Sneaky PDF. Thanks for your time. So a little bit about myself. 2 00:00:08,910 --> 00:00:14,140 My name is Mahmoud Ibrahim, or Yomu, from Myshirt, part of Cybersecurity Malaysia. 3 00:00:15,140 --> 00:00:18,980 I'm interested in malicious PDF as well as Android malware reversing. 4 00:00:20,640 --> 00:00:27,580 So the agenda for today, I'm going to cover a little bit about intro and then a little 5 00:00:27,580 --> 00:00:32,060 bit about obfuscation technique that we found out in the wild that have been used, and of 6 00:00:32,060 --> 00:00:36,000 course, a little bit about challenge and issues, and the last one is about conclusion. 7 00:00:37,700 --> 00:00:38,740 All right, introduction. 8 00:00:40,080 --> 00:00:45,580 So this is not about PDF reader application zero-day, so don't get confused with that. 9 00:00:45,820 --> 00:00:50,640 And of course, it's also not about Adobe X Reader sandbox bypass, okay? 10 00:00:50,680 --> 00:00:57,420 So this is plainly, we're talking about PDF obfuscation, which is pretty much the same 11 00:00:57,420 --> 00:00:57,560 issue. 12 00:00:57,580 --> 00:01:10,820 So basically, when you talk about obfuscation, so you have a PDF plus obfuscation, what 13 00:01:10,820 --> 00:01:12,280 pretty much you expect to become? 14 00:01:13,240 --> 00:01:14,020 Transformer, maybe? 15 00:01:15,360 --> 00:01:16,440 Not really, right? 16 00:01:16,600 --> 00:01:18,820 Of course, you expect to become a PDF as well, right? 17 00:01:19,240 --> 00:01:26,140 So the topic for today is about you have a normal PDF or you have a PDF that we exploit, 18 00:01:26,600 --> 00:01:27,560 and then you want to use it for a lot of things. 19 00:01:27,560 --> 00:01:28,280 So why do you want to obfuscate it? 20 00:01:28,540 --> 00:01:33,660 The main reason of why you want to obfuscate it, well, obviously, there are many reasons 21 00:01:33,660 --> 00:01:34,180 for that. 22 00:01:35,840 --> 00:01:38,680 Malicious PDF mainly comes with two components. 23 00:01:39,080 --> 00:01:44,360 The first one is probably the exploit, and the second one is the payload itself, or shellcode 24 00:01:44,360 --> 00:01:44,580 rather. 25 00:01:45,240 --> 00:01:49,260 And then, well, the main reason, like I mentioned, is it needs to be off the radar. 26 00:01:49,480 --> 00:01:49,900 How? 27 00:01:50,140 --> 00:01:52,580 Obviously, you need to look like a normal PDF. 28 00:01:52,900 --> 00:01:57,540 You cannot be, you cannot expect to look like a malform, because if you're talking about 29 00:01:57,540 --> 00:02:03,100 a normal PDF, you trigger that then you somehow raise a red flag for any security product 30 00:02:03,100 --> 00:02:04,460 for detection. 31 00:02:06,440 --> 00:02:09,200 Of course, what do you want to obfuscate? 32 00:02:09,360 --> 00:02:12,120 It's dependent on what kind of level that you want to go. 33 00:02:12,400 --> 00:02:17,100 Normally, people just obfuscate on the exploit, or people want to obfuscate on the shellcode. 34 00:02:17,240 --> 00:02:21,940 But the two most, these main components will need to be obfuscated, right? 35 00:02:23,800 --> 00:02:25,880 Well, why are you obfuscating this one? 36 00:02:26,100 --> 00:02:27,120 Obviously, you want to stay. 37 00:02:27,540 --> 00:02:29,880 You want to stop reducing for being detected. 38 00:02:30,280 --> 00:02:34,520 And one of the other things is try to make analysis harder. 39 00:02:34,840 --> 00:02:41,620 Because eventually, if you were here for the previous presentation about APT, there is 40 00:02:41,620 --> 00:02:46,920 always, you know, a wish to believe somehow in the end of the day, your tool is going 41 00:02:46,920 --> 00:02:47,840 to be detected, right? 42 00:02:48,180 --> 00:02:53,300 But you can make analysis become more harder by implementing some obfuscation. 43 00:02:54,660 --> 00:02:57,340 So, statistic of obfuscated malices, PDF. 44 00:02:57,340 --> 00:03:03,680 PDF, I don't think statistically somehow look at this way. It's always going up because 45 00:03:03,680 --> 00:03:15,540 that is pretty much the trend. So yeah. And then the PDF in general. So I hope the PDF 46 00:03:15,540 --> 00:03:24,240 is serious enough nowadays. So this is pretty much the PDF. I tried to cover a little bit 47 00:03:24,240 --> 00:03:32,420 about the structures or the concept of PDF. Okay. The first one is you see on the green color 48 00:03:32,420 --> 00:03:41,360 box, you're going to have PDF version. And on the PDF version, normally you have something like 49 00:03:41,360 --> 00:03:50,120 percent something, percent something. And then you have PDF and then version numbers. One of 50 00:03:50,120 --> 00:03:54,220 the components that can be used to, for example, you know, to create a PDF, you need to have 51 00:03:54,240 --> 00:04:00,640 full couple of PDF analyzer tool is by play around with the version numbers. So not version 52 00:04:00,640 --> 00:04:10,520 numbers by the header or PDF. Like, for example, if you're looking like percent and PDF-1 and 53 00:04:10,520 --> 00:04:16,280 what kind of version is it. It needs to be remembered, though, because for the PDF specification, 54 00:04:16,660 --> 00:04:23,340 it said within one, zero, two, four bytes, for the first one, zero, two, four bytes, it's a 55 00:04:24,240 --> 00:04:33,540 legitimate for you to declare the PDF version. For example, you have, you have some weird numbers, 56 00:04:33,620 --> 00:04:38,120 like you can have percent, percent, percent, or you have ABC, ABC, or whatever you want, and then 57 00:04:38,120 --> 00:04:45,860 you put percent PDF-1.1, it still can be considered as a PDF, still can be considered as a legitimate 58 00:04:45,860 --> 00:04:52,040 PDF version. And then the second body for this one, if you can see over here, is pretty much the 59 00:04:52,040 --> 00:04:53,080 main component of PDF. 60 00:04:54,240 --> 00:05:01,480 Which is normally have object, normally be representing as an OBJ, and it needs to be end with an 61 00:05:01,480 --> 00:05:11,280 OBJ. And later on, I will show some, some rather obfuscation that you can implement when it comes 62 00:05:11,280 --> 00:05:18,620 to the object declaration, like this one. And then, of course, it's also part of the major 63 00:05:18,620 --> 00:05:24,220 component inside here, is the JavaScript. And you have on the yellow box, you have the 64 00:05:25,860 --> 00:05:33,340 cross-reference, which is somehow define the offset of each object. Okay? And then the last one, 65 00:05:33,420 --> 00:05:39,100 you have trailer. Trailer is pretty much the main component that have one major component called 66 00:05:39,100 --> 00:05:47,940 slash root. Slash root especially give you some clue, or some entry point where your PDF will 67 00:05:48,740 --> 00:05:53,780 start, when you open the PDF. Okay? And the last one is also interesting, you have the 68 00:05:54,220 --> 00:06:04,740 NOFI, which is representing of, um, NOFI for the PDF. Uh, it declare a percent percent, uh, uh, um, 69 00:06:05,360 --> 00:06:15,320 NOFI. But, um, it's also can be, uh, you can also have multiple NOFI. Uh, I will show you a demo 70 00:06:15,320 --> 00:06:24,160 later on, on this, uh, specific, uh, uh, topic. So obfuscation. Well, commonly observed in the 71 00:06:24,220 --> 00:06:30,880 obfuscation method, uh, pretty much, uh, like I mentioned earlier, you have, uh, JavaScript. And you 72 00:06:30,880 --> 00:06:37,040 have a PDF syntax. And, of course, you have, uh, PDF, uh, features. And the last one is probably 73 00:06:37,040 --> 00:06:45,020 you have, uh, uh, media reach on PDF. Okay, the first one, uh, abusing of the JavaScript to make 74 00:06:45,020 --> 00:06:52,580 your, uh, PDF, uh, undetectable, or, or make your, uh, uh, make your PDF become more difficult to 75 00:06:52,580 --> 00:06:54,200 analyze, is, uh... 76 00:06:54,220 --> 00:06:59,560 the sky's the limit. Whatever can be executed by JavaScript is pretty much can be rendered as well 77 00:06:59,560 --> 00:07:06,500 within the PDF, uh, engine. And majority of, uh, PDF reader application have, uh, JavaScript engine. 78 00:07:06,680 --> 00:07:13,580 Uh, you name it, like Adobe have it, uh, Nitro have it, um, you also have, um, Fawcett, and even 79 00:07:13,580 --> 00:07:19,980 you have Sumatra PDF as well. Okay, basically it's been, uh, mainly been used for, uh, runtime 80 00:07:19,980 --> 00:07:24,200 export setup. Like, uh, you're not gonna, um, uh, you know, put, like, plain text, you know, 81 00:07:24,200 --> 00:07:29,500 plain text for your exploit. We need a PDF, so you pretty much, uh, construct during runtime for your 82 00:07:29,500 --> 00:07:34,500 exploit to trigger. And then, of course, you're talking about shellcode affisication setup. Uh, 83 00:07:34,580 --> 00:07:42,060 normally you generate shellcode on the fly, uh, to make, uh, it, well, to make your, your, your, your 84 00:07:42,060 --> 00:07:48,780 PDF, uh, uh, obfuscated, I think. And, of course, uh, majority of the PDF that we saw implementation 85 00:07:48,780 --> 00:07:55,560 of the JavaScript is mainly for heap spray. But, uh, recently, if you notice, there is, like, a couple of, uh, 86 00:07:55,800 --> 00:08:01,280 deep spray stuff is also, uh, been implemented as well. And, of course, the main reason is, uh, to make 87 00:08:01,280 --> 00:08:06,780 analysis, well, one of the main reasons is to try to make analysis harder. Well, how does it look like? 88 00:08:06,920 --> 00:08:12,560 Pretty much, if you notice over here, you have Y8, it's a very typical JavaScript operation. You have 89 00:08:12,560 --> 00:08:20,080 Y8, Y, uh, B, and then you have Y, C, blah, blah, blah. And then you have, uh, you combine all this, uh, 90 00:08:20,740 --> 00:08:26,280 this stuff and you execute it. And then, uh, another typical, uh, JavaScript, uh, function that's been 91 00:08:26,280 --> 00:08:33,600 used is argument.cully. And another thing that's normally been used is, uh, ASCII convention. Like, 92 00:08:33,620 --> 00:08:40,180 you have, uh, 0x41 is, uh, basically representing 4, uh, A. And, for example, uh, in within the PDF, 93 00:08:40,180 --> 00:08:46,880 off you have a dictionary called a slash filter and slash filter is going to retrieve some 94 00:08:46,880 --> 00:08:52,680 key value which is a flag decode and instead of representing as a flag decode you can also 95 00:08:53,300 --> 00:08:59,140 spelling or using an ASCII convention. For example, you take a look at this sample over 96 00:08:59,140 --> 00:09:16,840 here. So it pretty much starts with 50 A-R-E and so on and so forth, okay. And, of course, if we see a usual suspect for encoder like 97 00:09:16,840 --> 00:09:26,060 B624 or R-13 and so on and so forth. And normally for JavaScript the certification they tried to make one-liner code 98 00:09:26,380 --> 00:09:28,560 because JavaScript always end up the code 99 00:09:28,560 --> 00:09:28,920 execution 100 00:09:28,920 --> 00:09:34,840 efficient by the semicolon, so the new line really doesn't bother, so normally they try 101 00:09:34,840 --> 00:09:39,100 to screw up the code, the formatting of the code by implementing just one line of code. 102 00:09:41,040 --> 00:09:46,740 And then sometimes you also have some spaghetti code. If you take a look at the sample here, 103 00:09:47,240 --> 00:09:52,320 you pretty much notice this is just a declaration of function, and the last one is probably 104 00:09:52,320 --> 00:10:03,140 tried and catch loop, right? But, um, this is pretty much the try loop, but isn't, oh, okay, 105 00:10:03,260 --> 00:10:21,340 sorry. Over here. So you should notice, so I can make it bigger. Oops. I don't think you guys 106 00:10:21,340 --> 00:10:21,980 can see it, right? 107 00:10:22,320 --> 00:10:27,100 Can you guys see it? But somehow over there, over here is kind of the loop that you can see, 108 00:10:27,140 --> 00:10:34,780 loop for try and catch, but really this is not the, the education part, because it started 109 00:10:35,280 --> 00:10:42,120 earlier, early, early on before that. Like, if you notice here, there is an if-else function, okay? 110 00:10:42,420 --> 00:10:49,480 So this is pretty much a very generic, you know, JavaScript affixation. It's not really 111 00:10:49,480 --> 00:10:51,100 affixation. It's kind of like spaghetti. 112 00:10:51,240 --> 00:10:52,300 You combine multiple things. 113 00:10:52,320 --> 00:10:59,600 You combine multiple code and function within, you know, and then sometimes they also come 114 00:10:59,600 --> 00:11:04,200 with a half-pyramid sometimes. If you notice here, it's kind of like a running bunch of 115 00:11:04,200 --> 00:11:10,640 stuff. So sometimes you can make a pyramid. Probably the guy is boring, so try to make it 116 00:11:10,640 --> 00:11:16,220 look like a pyramid. And then dealing with the JavaScript affixation can be annoying. 117 00:11:17,020 --> 00:11:21,980 Normally you just pretty much always end up. It's always like, because there are many ways 118 00:11:21,980 --> 00:11:27,120 people can fool you with the JavaScript. Like I said previously, JavaScript affixation is 119 00:11:27,120 --> 00:11:34,500 involved with creativity. So if the bad guy is much more creative than the analyst, so you always 120 00:11:34,500 --> 00:11:39,360 end up like this way, you know, fuck or something, okay? But I believe with the help of tools, 121 00:11:39,440 --> 00:11:44,180 you will be probably more relaxed a little bit. So you kind of release, you know, because there 122 00:11:44,180 --> 00:11:50,840 is a tool for you to help you to automate or make your analysis more easier. For example, if you're 123 00:11:50,840 --> 00:11:55,640 talking about, you know, to run the JavaScript, you need to have some sort of emulator for that. 124 00:11:55,740 --> 00:12:02,640 Because you try to trace one, you know, by your bare hand, well, I wish you good luck to manage to 125 00:12:02,640 --> 00:12:08,360 go through all the code. And for emulator, you have a SpiderMonkey, Rhino, or even you can try 126 00:12:08,360 --> 00:12:15,580 Google V8. And of course, like I mentioned earlier about the code spaghetti stuff, you can use a 127 00:12:15,580 --> 00:12:20,820 code beautifier, like a JS beautifier, which is pretty much have been ported to JavaScript. 128 00:12:20,840 --> 00:12:26,780 Or to almost IDE or code editor. And you can also implement some sort of JavaScript dynamic 129 00:12:27,500 --> 00:12:33,500 instrumentation tool as well to see the application, to see the runtime of a JavaScript, okay? 130 00:12:33,920 --> 00:12:41,560 But then, having said so, it's pretty much, if you take a look at the previous sample of the 131 00:12:41,560 --> 00:12:49,740 JavaScript, you pretty much can read all this stuff, right? But maybe in the future, it may come to, 132 00:12:49,740 --> 00:13:00,080 within this function, this is valid JavaScript implementation, okay? And then, it may also come 133 00:13:00,080 --> 00:13:07,140 with the smiley characters for you guys. So this is kind of an application that you can see within 134 00:13:07,140 --> 00:13:14,240 the JavaScript implementation in PDF. And there's a second normal application that we saw is 135 00:13:14,240 --> 00:13:19,720 about abusing the PDF syntax. For example, if you notice the slash root, you can see the 136 00:13:19,740 --> 00:13:24,640 root over here, which as I mentioned earlier on, within the startup of the PDF, normally, 137 00:13:24,740 --> 00:13:29,300 it's going to start with the slash root. At the beginning of it, you need to go to root. 138 00:13:29,500 --> 00:13:34,760 And this one is specified, the object slash, the starting point of this PDF, always going to 139 00:13:34,760 --> 00:13:41,860 refer to the object 21. It will be referred by the object 21. So any education file will start on 140 00:13:41,860 --> 00:13:47,800 the object 21. It's no longer about object 1, 0, OBJ. Because the normal thing that we saw, the 141 00:13:47,800 --> 00:13:52,200 mistake that we've done, is when you start working with analysis on the PDF, you start by 142 00:13:52,200 --> 00:14:00,980 looking at the percent PDF version, and you go with one by one of the PDF component. But really, 143 00:14:01,080 --> 00:14:06,340 you need to start from the slash root. And another thing is about referring to another object. 144 00:14:06,600 --> 00:14:13,420 For example, you notice the var here, okay? The variable var is pointing to the function called, 145 00:14:13,660 --> 00:14:17,780 not a function, it's pointing to object 21. It's pointing to the object 21. It's pointing to the 146 00:14:17,800 --> 00:14:21,220 object 21. I'm going to go ahead and call this dot info dot title, which is the kind of 147 00:14:21,220 --> 00:14:25,200 OO representation, which is this normally referred to the object itself. I'm sorry, 148 00:14:25,300 --> 00:14:32,960 referred to the PDF itself. And dot info is always referred to another component, like for 149 00:14:32,960 --> 00:14:41,020 example, this one, slash info. And slash info is a point, it's referring to the object 5, so 150 00:14:41,020 --> 00:14:47,700 this is the object 5. And then this is your title. So your variable of root will be this 151 00:14:47,700 --> 00:14:47,780 variable. 152 00:14:47,800 --> 00:14:51,560 stream. That's pretty much the obfuscation that we saw 153 00:14:51,560 --> 00:14:55,540 on the PDF. Okay, I'll talk about 154 00:14:56,620 --> 00:14:58,360 the syntax of the percent 155 00:14:59,600 --> 00:15:03,760 PDF and NL5, right? And normally, how you start 156 00:15:03,760 --> 00:15:07,620 parsing your PDF file? If you're building some PDF tools 157 00:15:07,620 --> 00:15:11,720 to analyze a PDF, which one 158 00:15:11,720 --> 00:15:15,940 you start with? You're looking at a percent PDF version, or you're looking for NL5? 159 00:15:15,940 --> 00:15:17,400 According to the 160 00:15:20,260 --> 00:15:23,800 Adobe reference, you somehow should 161 00:15:23,800 --> 00:15:28,020 start from the NL5 of the PDF. 162 00:15:29,360 --> 00:15:30,740 But the problem is, 163 00:15:34,700 --> 00:15:36,020 if you choose 164 00:15:36,020 --> 00:15:39,560 to read from NL5, which one is going to be your 165 00:15:39,560 --> 00:15:43,460 the first NL5? Because like I mentioned earlier, 166 00:15:43,760 --> 00:15:45,920 you can have multiple NL5s 167 00:15:45,940 --> 00:15:49,000 within your single file of PDF. 168 00:15:49,380 --> 00:15:51,000 For example, this one. 169 00:15:53,600 --> 00:15:57,760 If you start from NL5, right? If you're parsing your PDF file 170 00:15:57,760 --> 00:16:01,120 using NL5 as a starting point, which 171 00:16:01,920 --> 00:16:05,740 NL5 that you want to refer? You want to refer to this 172 00:16:05,740 --> 00:16:09,660 one, or you want to refer to this one? 173 00:16:11,520 --> 00:16:13,760 Well, this is pretty much legitimate declaration. 174 00:16:13,760 --> 00:16:17,440 If you open, it's not a malformed PDF. Your reader, 175 00:16:17,560 --> 00:16:21,080 majority of readers, well, I have touched with Nitro, Adobe, 176 00:16:21,420 --> 00:16:25,340 touched with Foxit, and even Evinced. They open nicely. 177 00:16:25,640 --> 00:16:28,920 There's not even a problem with this. So if you build a parser, 178 00:16:29,060 --> 00:16:30,880 which one do you want to choose? 179 00:16:33,180 --> 00:16:35,980 And then, for example, if you choose the last one, 180 00:16:37,780 --> 00:16:41,600 if you choose the last one, and then how about 181 00:16:41,600 --> 00:16:45,060 this? If you choose the last one on the NL5, 182 00:16:46,580 --> 00:16:48,380 and take a look at the object 12, 183 00:16:49,460 --> 00:16:52,300 if you choose the last one, this one, 184 00:16:53,660 --> 00:16:57,620 this one, so in this NL5, 185 00:16:57,900 --> 00:17:01,220 you have multiple object declarations for the object 12. 186 00:17:01,640 --> 00:17:05,120 For example, you have one, you have two, 187 00:17:05,960 --> 00:17:08,360 here. So which one 188 00:17:09,100 --> 00:17:09,660 is 189 00:17:13,320 --> 00:17:15,760 which data now 190 00:17:15,760 --> 00:17:18,820 is representing by the NL5? 191 00:17:19,540 --> 00:17:22,840 Sorry, we've been representing by the object 12. 192 00:17:23,120 --> 00:17:27,320 Because, for example, the first object 12 now here is 193 00:17:27,320 --> 00:17:30,860 half a data that say test first NL5. 194 00:17:31,120 --> 00:17:34,760 The second one is test NL5 second 195 00:17:35,480 --> 00:17:38,740 NL5. I will show you a demo about this later on. 196 00:17:38,740 --> 00:17:40,400 And then another one. 197 00:17:42,660 --> 00:17:43,240 Here. 198 00:17:46,640 --> 00:17:49,140 Okay. But the truth is, 199 00:17:50,760 --> 00:17:52,660 NL5 is not even needed. 200 00:17:52,800 --> 00:17:58,480 If there is no NL5, your PDF application reader can somehow 201 00:17:58,480 --> 00:18:01,020 manage to render it properly. So 202 00:18:01,960 --> 00:18:05,300 the last one of the declaration, for example on this one, 203 00:18:05,300 --> 00:18:09,280 if you notice, from this one, the object 12, the last 204 00:18:09,280 --> 00:18:13,240 object 12 is always going to be the one that 205 00:18:13,240 --> 00:18:15,600 will be picked up by your PDF application. 206 00:18:17,300 --> 00:18:20,720 So like I said, this one declaration for object 12, 207 00:18:21,480 --> 00:18:25,080 so this, the last object 12, will always be 208 00:18:25,080 --> 00:18:27,600 executed. Okay. So 209 00:18:28,960 --> 00:18:32,940 this is the one. So the last one will always be used 210 00:18:32,940 --> 00:18:34,480 by a PDF reader. 211 00:18:35,300 --> 00:18:36,660 So for example, the demo. 212 00:18:52,940 --> 00:18:56,760 So the first one, let me open with this. 213 00:18:57,620 --> 00:18:59,080 If you open this file, 214 00:19:01,860 --> 00:19:02,880 oh crap. 215 00:19:09,000 --> 00:19:09,960 It's freaking slow. 216 00:19:18,520 --> 00:19:21,340 For example, this one, this is your first 217 00:19:23,200 --> 00:19:25,280 NL5. But you can put a bunch of 218 00:19:25,280 --> 00:19:28,860 other things as well below of it. Like this is object 12. 219 00:19:29,400 --> 00:19:32,340 You end with another NL5. 220 00:19:32,340 --> 00:19:35,980 And this is interesting. You have here NL, 221 00:19:35,980 --> 00:19:39,960 you have object 12. 222 00:19:41,000 --> 00:19:44,540 And inside object 12, you have another NL5. 223 00:19:45,120 --> 00:19:48,360 And then this is pretty much another, the data 224 00:19:48,360 --> 00:19:51,880 that belongs to object 12. You notice here the second NL5. 225 00:19:52,100 --> 00:19:56,140 And you have another, the third one, NL5. So if you open this 226 00:19:56,140 --> 00:19:56,640 file, 227 00:20:08,220 --> 00:20:10,360 it's always slow when it comes to demo. 228 00:20:11,040 --> 00:20:11,840 It's always slow when it comes to demo. 229 00:20:11,840 --> 00:20:14,580 So you just open NL5 for the second one. 230 00:20:15,240 --> 00:20:17,540 Right? Because the last one is always 231 00:20:17,540 --> 00:20:22,320 the one that will be choose by the PDF reader. 232 00:20:22,820 --> 00:20:24,040 So this one, 233 00:20:27,820 --> 00:20:29,680 I'll open with this one again. 234 00:20:30,240 --> 00:20:32,660 This one, it don't even have the NL5. 235 00:20:32,940 --> 00:20:37,660 But if you open it with any PDF reader, 236 00:20:39,020 --> 00:20:40,740 everything is just fine. For example, 237 00:20:40,960 --> 00:20:45,520 this one, below this, that is no longer NL5, but you have 238 00:20:45,520 --> 00:20:49,020 object 12 here. And you also have object 12 here. 239 00:20:49,760 --> 00:20:51,520 And then if you just open this, 240 00:20:53,560 --> 00:20:56,680 you can still get NL5. So very tricky one to find 241 00:20:57,240 --> 00:20:58,460 where you can stop. 242 00:20:59,680 --> 00:21:03,120 Building the parser is very tricky where you want to find 243 00:21:03,560 --> 00:21:07,640 a starting point and try to parse for every single object within the PDF. 244 00:21:09,640 --> 00:21:10,640 For example, 245 00:21:16,240 --> 00:21:19,000 in future, I believe for the PDF, 246 00:21:20,400 --> 00:21:22,580 have something like this. For example, 247 00:21:22,720 --> 00:21:27,320 the reference to the object that create loop. For example, you have 248 00:21:27,320 --> 00:21:29,800 the object 1 that have the 249 00:21:31,980 --> 00:21:35,160 dictionary for auto, which is pointing to 250 00:21:35,160 --> 00:21:39,360 object 6 over here. And object 6 auto have also 251 00:21:39,360 --> 00:21:43,140 pointing to the object 1. If you open it with any PDF 252 00:21:43,140 --> 00:21:47,320 application, it may stop. But if you're building your own parser, 253 00:21:47,440 --> 00:21:51,380 when are you going to stop your loop? Right? So that will be interesting to see 254 00:21:51,380 --> 00:21:53,760 when we should stop. 255 00:21:55,120 --> 00:21:57,980 Okay. Then another thing is about 256 00:21:57,980 --> 00:22:01,620 abusing the PDF syntax is relate to the acrobat 257 00:22:01,620 --> 00:22:05,160 are specifically designed for 258 00:22:05,160 --> 00:22:09,920 the PDF engine, especially for Adobe. A couple of 259 00:22:10,980 --> 00:22:13,600 JavaScript functions like get 260 00:22:13,600 --> 00:22:17,820 anode, sing anode scan, get page number. For example, 261 00:22:17,860 --> 00:22:21,500 get a word. Now for example, get page nth word. 262 00:22:21,500 --> 00:22:25,420 This one basically tries to get a word on 263 00:22:25,420 --> 00:22:29,380 page specific and get page nth word to 1. It's 264 00:22:29,380 --> 00:22:33,460 basically get the third word of page 1, for example. And then you can 265 00:22:33,460 --> 00:22:37,080 select based on page as well. So this is pretty much normally 266 00:22:37,080 --> 00:22:40,040 being implemented with the 267 00:22:40,040 --> 00:22:45,120 on the PDF. For example, this is one of the functions you can see. 268 00:22:45,420 --> 00:22:49,280 This one, this get page number and this select page 269 00:22:49,280 --> 00:22:51,220 number something. Okay? So 270 00:22:54,160 --> 00:22:57,260 it's very, very, it's very difficult. It's not, I would say 271 00:22:57,260 --> 00:23:01,140 it's very difficult, but it's very difficult to emulate all of the 272 00:23:01,140 --> 00:23:04,860 acrobat JS engine to your own parser. 273 00:23:05,060 --> 00:23:09,220 Because this kind of, this kind of JavaScript code 274 00:23:09,220 --> 00:23:12,580 is not supported by default for like for public 275 00:23:14,020 --> 00:23:17,340 acrobat PDF engine. Sorry, JavaScript engine 276 00:23:17,340 --> 00:23:20,960 like SpiderMonkey, V8, it's not been designed for this. Okay? 277 00:23:22,040 --> 00:23:24,940 Another thing is, like I mentioned earlier, you can 278 00:23:25,580 --> 00:23:28,820 abuse incomplete syntax. For example, like object stream. 279 00:23:29,580 --> 00:23:32,440 For example, this is object as 1. 280 00:23:33,080 --> 00:23:36,780 We start with a 1, 0, obj. So you're pretty much expecting 281 00:23:36,780 --> 00:23:41,200 it need to be n with obj. But then if 282 00:23:41,200 --> 00:23:44,760 you don't have an obj, that's no problem. 283 00:23:44,760 --> 00:23:48,640 You have a PDF application, we just load it fine. But if you 284 00:23:48,640 --> 00:23:51,680 build your own parser, you need to know where to stop. 285 00:23:52,360 --> 00:23:56,580 For example, this is stream. You're 286 00:23:56,580 --> 00:24:00,400 expecting to have n stream. But if you don't have, it's also fine. 287 00:24:00,920 --> 00:24:04,720 And even funnier, you have stream. You have another 288 00:24:04,720 --> 00:24:08,540 stream. And you have n stream. You have n stream here. 289 00:24:08,940 --> 00:24:12,600 So which stream, which data that belong to this stream 290 00:24:12,600 --> 00:24:16,540 for example? This one? Or this one? Or 291 00:24:16,540 --> 00:24:18,480 this one? Or this one? 292 00:24:20,500 --> 00:24:22,700 Right? It's very tricky to analyze all of it. 293 00:24:24,000 --> 00:24:28,540 Okay, so another thing is, like I mentioned, the problem with this is difficult to 294 00:24:28,540 --> 00:24:32,560 emulate or to automate within a parser. Something like 295 00:24:32,560 --> 00:24:35,840 I mentioned earlier, emulating acroj as code, 296 00:24:36,380 --> 00:24:39,420 finding stopping loop, and finding ending tag for like 297 00:24:40,520 --> 00:24:43,420 obj and stream. And of course, you need to understand 298 00:24:43,420 --> 00:24:47,380 how the PDF3D application parser actually works. But then, are we 299 00:24:47,380 --> 00:24:50,920 building another PDF3D application? I think not, right? We are building 300 00:24:50,920 --> 00:24:52,980 the parser to 301 00:24:55,380 --> 00:24:59,100 analyze the malicious PDF. I put it here, 302 00:24:59,220 --> 00:25:03,360 we're implementing, we organized a challenge for 100Net project last year. 303 00:25:03,520 --> 00:25:07,060 So a couple of tricks have been implemented over there. If you're interested to see the tricks, 304 00:25:07,060 --> 00:25:10,340 just try to, you know, get along with the challenge. 305 00:25:11,540 --> 00:25:15,040 And it seems very difficult 306 00:25:15,040 --> 00:25:18,080 to automate this analysis, so manual tools are recommended. 307 00:25:18,560 --> 00:25:23,000 Manual tools is something like, you don't really, you know, parse the whole thing. 308 00:25:23,100 --> 00:25:26,620 You just somehow grab any object and then you just display the object. 309 00:25:26,840 --> 00:25:30,340 So you can manually trace the component that belongs to the object. 310 00:25:30,640 --> 00:25:34,940 For example, you can follow the PDF flow. You can manually inspect 311 00:25:34,940 --> 00:25:38,740 each object or each stream, so you know where it should end. 312 00:25:38,940 --> 00:25:42,900 And dealing with the AcroJet, there's still pain in the ass, I think. 313 00:25:43,140 --> 00:25:46,100 A couple of tools that you can play around with are PDFStreamDumper, 314 00:25:48,320 --> 00:25:50,240 PDFZerminer, PDFDeceptor, and FileInsect. 315 00:25:52,780 --> 00:25:54,900 Another thing that you can abuse within 316 00:25:54,900 --> 00:25:57,760 the PDF obfuscation is try to abuse the filter. 317 00:25:58,960 --> 00:26:02,500 The main category for here is I put PDF features. 318 00:26:02,500 --> 00:26:06,740 Obviously, one of the normal features in PDF is filter. 319 00:26:07,080 --> 00:26:10,780 Well, the main reason for filter is basically 320 00:26:10,780 --> 00:26:14,280 try to compress the size of PDF, 321 00:26:14,460 --> 00:26:18,360 so you normally use some encoding to compress it. 322 00:26:18,620 --> 00:26:22,700 So if you're using less known filter, for example, 323 00:26:22,820 --> 00:26:26,500 CCR, ITF, FaxDecode, and DCTDDecode, 324 00:26:27,420 --> 00:26:30,340 there's pretty much a high chance for your analysis 325 00:26:30,340 --> 00:26:32,400 PDF not being detected. 326 00:26:33,600 --> 00:26:36,320 But somehow, in general, filter is normally 327 00:26:36,320 --> 00:26:39,160 you have FlaxDecode, ASCIIHaxDecode, and a couple bunch of 328 00:26:40,120 --> 00:26:44,500 ASCII, like ASCII85, JBig2Decode. 329 00:26:44,860 --> 00:26:47,720 And this is also interesting as well, 330 00:26:47,940 --> 00:26:51,520 because if you see at the filter dictionary, 331 00:26:51,920 --> 00:26:55,920 it can accept a couple of parameters. So if you want to make your 332 00:26:57,680 --> 00:27:00,100 filter have some strict 333 00:27:00,900 --> 00:27:03,740 parameters, so that if you're using like 334 00:27:03,740 --> 00:27:07,440 if you're trying to compress without passing this parameter, 335 00:27:07,680 --> 00:27:12,000 your decompression will be filled. You can implement it within 336 00:27:12,000 --> 00:27:13,940 the parameter called decodePAM. 337 00:27:15,200 --> 00:27:19,980 For example, this one, this code implements CCR, ITF, 338 00:27:19,980 --> 00:27:24,100 FaxDecode. It's normally for image, but really it doesn't really matter. 339 00:27:24,280 --> 00:27:27,380 It's not necessarily image. You can put whatever you want, as long as 340 00:27:27,380 --> 00:27:31,180 it's within the format of the CCR, ITF, 341 00:27:31,240 --> 00:27:32,040 FaxDecode. 342 00:27:34,560 --> 00:27:39,220 And then you can also abuse the filter by implementing some multiple 343 00:27:39,220 --> 00:27:43,540 layer of filter. For example, you have combining of ASCII85 344 00:27:43,540 --> 00:27:46,600 decode and with the LZWD decode. 345 00:27:46,720 --> 00:27:51,140 So you just combine between it. Well, there is no limit for you to play around with it. 346 00:27:51,240 --> 00:27:54,380 So you can add a multiple filter. 347 00:27:54,380 --> 00:27:58,460 And this one, for example, this one implements FlaxDecode 348 00:27:58,460 --> 00:28:01,620 and going to do ASCIIHacksDecode later on. 349 00:28:02,060 --> 00:28:06,160 And you can also do some abbreviation, especially on this one, like 350 00:28:06,160 --> 00:28:09,760 85 belongs to ASCII85 decode, 351 00:28:11,620 --> 00:28:14,480 LZW belongs to this one, 352 00:28:14,520 --> 00:28:18,080 LZWD decode. So this kind of abbreviation 353 00:28:18,080 --> 00:28:22,400 somehow, if you don't put it within your parser, it will be difficult for you 354 00:28:23,480 --> 00:28:24,080 to 355 00:28:24,380 --> 00:28:28,160 decompress all these filters. And another 356 00:28:28,160 --> 00:28:32,340 interesting part of this, try to abuse encrypt. Encrypt is something that 357 00:28:32,340 --> 00:28:36,260 when you have PDF, secretive PDF, you 358 00:28:36,260 --> 00:28:40,100 normally try to put a password protected on this PDF, right? 359 00:28:40,260 --> 00:28:42,880 And if you put that on your 360 00:28:44,320 --> 00:28:48,120 PDF, so pretty much your stream and your string are going to be 361 00:28:48,120 --> 00:28:51,760 encrypted. So in Adobe, they're implementing 362 00:28:53,040 --> 00:28:54,800 RC4 and AES algorithm. 363 00:28:55,280 --> 00:28:59,760 So for example, on this one, this is 364 00:28:59,760 --> 00:29:03,500 not, when I mentioned about encrypt, this is not really about protecting 365 00:29:03,500 --> 00:29:07,240 the document itself. It's rather protecting the stream. So 366 00:29:07,760 --> 00:29:11,140 for example, slash root have dictionary 367 00:29:12,940 --> 00:29:15,660 encrypt. So it will 368 00:29:15,660 --> 00:29:19,540 point to the object 76 over here. So if you took the 369 00:29:19,540 --> 00:29:23,460 object 76 here, it has declaration, it's going to be 370 00:29:23,460 --> 00:29:26,620 encrypt with the AES encryption. 371 00:29:27,580 --> 00:29:28,860 And then... 372 00:29:32,760 --> 00:29:35,040 Okay. So with this one, if you 373 00:29:35,040 --> 00:29:39,340 ask like a password or something, like normally when you open PDF, 374 00:29:39,540 --> 00:29:42,920 we trigger like password for that. 375 00:29:44,000 --> 00:29:47,400 Well, we have a sample like, if depending 376 00:29:47,400 --> 00:29:50,520 on the slash root where it starts, you have 377 00:29:50,520 --> 00:29:55,080 while you're busy keeping the password, it already can drop some 378 00:29:55,080 --> 00:29:58,800 exploit that triggered the exploitation already. So... 379 00:30:00,260 --> 00:30:03,220 And then of course it's somehow, it depends on the event, like 380 00:30:03,220 --> 00:30:07,320 auth event. Like for example, you have .open, so it will 381 00:30:07,320 --> 00:30:11,280 trigger when you open the PDF. Okay? So but then if your 382 00:30:11,280 --> 00:30:15,340 slash root have a point in that point to different object that have 383 00:30:15,340 --> 00:30:19,200 exploit on it, so it will trigger that first. And then 384 00:30:19,200 --> 00:30:22,340 we ask the action from these 385 00:30:23,020 --> 00:30:27,160 event. Well, it's pretty much difficult to analyze it, because 386 00:30:27,160 --> 00:30:31,060 simply the fact that you can down the stream, because you need to break the encryption 387 00:30:31,060 --> 00:30:35,480 out of it, right? So there is no plain text. So for example, 388 00:30:35,480 --> 00:30:38,540 a demo. A quick one. 389 00:30:50,240 --> 00:30:53,460 All right, for example, I try to open 390 00:30:53,460 --> 00:30:57,280 this with a file inside first, to show that 391 00:30:57,280 --> 00:31:01,120 this file is, that have encryption. 392 00:31:01,420 --> 00:31:04,220 Like I mentioned, please go to your slash root first. 393 00:31:07,280 --> 00:31:08,980 A flash root normally have 394 00:31:08,980 --> 00:31:13,380 within the trailer. So here you have like definition for encrypt, 395 00:31:13,380 --> 00:31:17,240 which is points to the object 29. But your 396 00:31:17,240 --> 00:31:21,300 slash root here have the object pointed to 397 00:31:21,300 --> 00:31:24,920 object 10 first. Okay? And then this encrypt 398 00:31:24,920 --> 00:31:29,220 have pointing to object 29, I think. 29. 399 00:31:29,860 --> 00:31:33,100 So if you go to the object 29, so this is pretty much 400 00:31:33,100 --> 00:31:36,680 the implementation of RC algorithm 401 00:31:36,680 --> 00:31:40,960 for the encryption. Okay? So we have some 402 00:31:40,960 --> 00:31:44,240 like stream over here. For example, 403 00:31:45,100 --> 00:31:48,000 take a look here. This stream 404 00:31:48,840 --> 00:31:52,060 have implementing some sort of flag decode 405 00:31:52,060 --> 00:31:56,880 filter. So pretty much you try to 406 00:31:56,880 --> 00:32:00,820 decode this one using exactly encoding it should work. 407 00:32:01,060 --> 00:32:02,900 For example, you select this one. 408 00:32:07,580 --> 00:32:08,840 So you just select 409 00:32:08,840 --> 00:32:12,800 and then you right click and then you can, so you can go to 410 00:32:12,800 --> 00:32:16,720 decode and try to inflate. Of course you cannot do inflate, right? Because it's already been 411 00:32:16,720 --> 00:32:20,440 encrypted. And then if you run this 412 00:32:22,320 --> 00:32:24,860 using a PDF 413 00:32:24,860 --> 00:32:28,580 application, the exploit might trigger. 414 00:32:29,200 --> 00:32:32,880 But then, yeah, you couldn't find what kind of exploit I used for this one. 415 00:32:33,500 --> 00:32:36,580 All right? It will take a while for exploit 416 00:32:36,580 --> 00:32:40,560 to work because I'm running some sort of heap spray on top of it. 417 00:32:40,760 --> 00:32:42,440 So it will take a while. 418 00:32:45,880 --> 00:32:48,480 I think we go to this screen 419 00:32:49,340 --> 00:32:51,000 after a couple of slides. 420 00:32:53,560 --> 00:32:54,360 All right? 421 00:32:56,780 --> 00:33:00,120 The fourth one that we normally see within the 422 00:33:00,120 --> 00:33:04,220 PDF application is try to use 423 00:33:04,220 --> 00:33:06,020 media reach on the PDF. 424 00:33:07,800 --> 00:33:10,200 Because the fact that they have many 425 00:33:10,200 --> 00:33:14,600 media types that they support, so pretty much you can embed a couple of 426 00:33:14,600 --> 00:33:17,220 media, for example, AIF, 427 00:33:18,840 --> 00:33:22,500 .mp3, and even now that SWF. 428 00:33:23,480 --> 00:33:26,480 So if you attach any exploit within the PDF file 429 00:33:26,480 --> 00:33:30,320 against this media player, well, you normally win. Because 430 00:33:30,320 --> 00:33:34,240 people are not really suspicious to click on PDF 431 00:33:34,240 --> 00:33:35,840 rather than clicking on their 432 00:33:36,580 --> 00:33:38,100 .mp3 and .mov that 433 00:33:38,100 --> 00:33:39,660 come over your email or something. 434 00:33:40,620 --> 00:33:42,260 Okay? And normally, 435 00:33:42,460 --> 00:33:44,200 for the PDF, 436 00:33:44,520 --> 00:33:46,620 it's used 437 00:33:46,620 --> 00:33:48,580 against the Flash 438 00:33:48,580 --> 00:33:50,300 today. So you have 439 00:33:50,300 --> 00:33:52,660 normal PDF, good-looking 440 00:33:52,660 --> 00:33:53,960 PDF. It's not malformed. 441 00:33:54,180 --> 00:33:55,340 But you have 442 00:33:56,280 --> 00:33:58,080 bugs on Adobe and 443 00:33:58,280 --> 00:33:59,800 on the Flash 444 00:34:00,320 --> 00:34:01,280 get owned as well. 445 00:34:01,780 --> 00:34:04,440 How does it look like within your PDF 446 00:34:04,440 --> 00:34:06,280 structures? For example, 447 00:34:06,580 --> 00:34:08,260 you start with a slash root again. 448 00:34:08,700 --> 00:34:10,440 You check slash root is pointing 449 00:34:10,440 --> 00:34:11,380 to object 31. 450 00:34:12,180 --> 00:34:14,360 And then object 31 have the 451 00:34:14,360 --> 00:34:16,340 page pointed to 452 00:34:16,340 --> 00:34:17,820 page object 1. 453 00:34:18,340 --> 00:34:20,460 So you go to the object 1 here, and then 454 00:34:20,460 --> 00:34:22,280 you have page. And page somehow 455 00:34:22,280 --> 00:34:24,420 have a reference on the object 12. 456 00:34:24,700 --> 00:34:26,480 You go to the object 12, and 457 00:34:26,480 --> 00:34:27,780 object 12 is somehow 458 00:34:28,360 --> 00:34:30,020 have a Flash 459 00:34:30,700 --> 00:34:31,260 flash 460 00:34:33,940 --> 00:34:34,500 file 461 00:34:34,500 --> 00:34:35,920 on top of it. Okay? 462 00:34:36,580 --> 00:34:36,660 So you see, 463 00:34:36,820 --> 00:34:38,240 SWF is basically 464 00:34:40,660 --> 00:34:42,320 CWF is basically compressed file. 465 00:34:42,680 --> 00:34:44,360 And then this is another 466 00:34:44,360 --> 00:34:46,340 one called FWS is uncompressed 467 00:34:46,340 --> 00:34:46,540 file. 468 00:34:48,320 --> 00:34:50,320 PDF is just pretty much 469 00:34:50,320 --> 00:34:51,820 the main transporter for this one. 470 00:34:53,420 --> 00:34:54,340 You need to 471 00:34:54,340 --> 00:34:55,260 extract the 472 00:34:57,600 --> 00:34:58,160 Flash 473 00:34:58,160 --> 00:35:00,340 file to check 474 00:35:00,340 --> 00:35:02,380 what is the exploit, what kind of shell 475 00:35:02,380 --> 00:35:04,240 code inside it. Okay? So 476 00:35:04,240 --> 00:35:06,220 tools normally you can use, like PDF stream 477 00:35:06,580 --> 00:35:07,700 helper, and plus the PDF 478 00:35:08,900 --> 00:35:10,000 examiner for this one. 479 00:35:10,340 --> 00:35:12,200 And then of course you can do a Flash analysis 480 00:35:12,200 --> 00:35:14,220 later on to trace 481 00:35:14,220 --> 00:35:16,420 what's really happened when you 482 00:35:16,420 --> 00:35:18,300 opened the PDF. As we know, 483 00:35:18,320 --> 00:35:20,240 the PDF have engine 484 00:35:20,240 --> 00:35:22,360 for the Flash, right? 485 00:35:22,720 --> 00:35:24,340 So for the Flash analysis, 486 00:35:24,460 --> 00:35:26,380 pretty much very ideal for 487 00:35:26,380 --> 00:35:27,820 us to decompiling Flash 488 00:35:27,820 --> 00:35:30,240 by code, which is normally tried to 489 00:35:30,240 --> 00:35:32,820 from the AS3 or AS2 490 00:35:32,820 --> 00:35:34,680 to AS2 491 00:35:34,680 --> 00:35:35,720 or AS3 code. 492 00:35:36,780 --> 00:35:38,540 Idea, but so far I saw 493 00:35:38,540 --> 00:35:40,320 it's only two software 494 00:35:40,320 --> 00:35:42,440 that do a proper 495 00:35:42,440 --> 00:35:44,400 decompiling on this one, but it's 496 00:35:44,400 --> 00:35:46,100 a commercial, so you can 497 00:35:46,100 --> 00:35:48,500 somehow integrate this kind of tool within 498 00:35:48,500 --> 00:35:49,640 your parser. 499 00:35:50,000 --> 00:35:52,060 So think Flash 500 00:35:52,580 --> 00:35:53,160 decompiler have 501 00:35:55,780 --> 00:35:56,520 decompiler for 502 00:35:56,520 --> 00:35:58,200 this one, and if you look for the 503 00:35:58,200 --> 00:35:59,900 PDF stream damper, they have 504 00:36:00,400 --> 00:36:02,160 another proprietary tool as well called 505 00:36:02,160 --> 00:36:04,360 AS3 software on this one. 506 00:36:04,760 --> 00:36:06,100 So this is pretty much 507 00:36:07,180 --> 00:36:08,820 what the decompiling 508 00:36:08,820 --> 00:36:10,060 code looks like 509 00:36:10,310 --> 00:36:12,180 on the AS3. It's pretty much 510 00:36:12,180 --> 00:36:13,500 AS3 code here. 511 00:36:14,600 --> 00:36:15,960 And if you 512 00:36:16,370 --> 00:36:18,400 cannot do decompiling, you 513 00:36:18,400 --> 00:36:20,220 can always do some bytecode analysis 514 00:36:20,220 --> 00:36:22,420 here. So for example, this 515 00:36:22,420 --> 00:36:24,080 one is pretty much try to construct 516 00:36:24,080 --> 00:36:25,720 the knob slack for the 517 00:36:26,460 --> 00:36:28,520 shellcode. You can see 518 00:36:28,520 --> 00:36:29,360 over here that's 519 00:36:29,360 --> 00:36:32,360 some stuff, push integer, and 520 00:36:32,360 --> 00:36:33,880 this is couple of loop over here 521 00:36:33,880 --> 00:36:36,180 to assign the 522 00:36:36,580 --> 00:36:36,720 array. 523 00:36:38,080 --> 00:36:40,200 And this is another pushing 524 00:36:40,200 --> 00:36:42,300 some ROP 525 00:36:42,300 --> 00:36:44,180 gadget on top of the shellcode. 526 00:36:44,440 --> 00:36:46,440 And then pretty much here, you can 527 00:36:46,440 --> 00:36:48,320 also put some shellcode 528 00:36:48,320 --> 00:36:50,500 and try to translate it 529 00:36:50,500 --> 00:36:52,420 and try to do 530 00:36:52,420 --> 00:36:54,200 encrypt it, so when it comes within the 531 00:36:54,200 --> 00:36:56,320 PDF, you just have a properly 532 00:36:56,320 --> 00:36:58,460 encrypted, not say encrypted, 533 00:36:58,680 --> 00:36:59,100 properly 534 00:37:00,600 --> 00:37:02,300 obfuscated Flash file 535 00:37:02,300 --> 00:37:04,400 within your normal PDF. 536 00:37:05,280 --> 00:37:06,280 Let's see for 537 00:37:06,580 --> 00:37:06,700 this one. 538 00:37:07,820 --> 00:37:09,420 I think this is pretty much 539 00:37:09,420 --> 00:37:12,340 when you open the PDF, the demo 540 00:37:12,340 --> 00:37:14,180 just shows that when you open the PDF, 541 00:37:15,160 --> 00:37:16,480 it just gives 542 00:37:16,480 --> 00:37:17,660 you a calculator. 543 00:37:18,360 --> 00:37:20,000 And then it cracks, 544 00:37:20,260 --> 00:37:22,340 but then again, we don't even know 545 00:37:22,340 --> 00:37:24,340 what is the exploit used for this one. 546 00:37:27,960 --> 00:37:29,900 Alright, so this is pretty much 547 00:37:30,460 --> 00:37:31,700 you know, this is 548 00:37:32,780 --> 00:37:34,280 not the main focus 549 00:37:34,280 --> 00:37:36,400 of this presentation. I just show 550 00:37:36,580 --> 00:37:38,540 here basically how you can do analysis 551 00:37:38,540 --> 00:37:40,260 on the Flash exploit 552 00:37:40,260 --> 00:37:41,880 that embedded within the PDF. 553 00:37:42,220 --> 00:37:44,480 Okay? And then 554 00:37:45,580 --> 00:37:46,480 so this is 555 00:37:46,480 --> 00:37:48,500 a challenge and an issue. I would like 556 00:37:48,500 --> 00:37:50,340 to share with you guys and 557 00:37:50,340 --> 00:37:51,740 hope there is a proper answer 558 00:37:52,380 --> 00:37:54,300 for a couple of these challenges. 559 00:37:54,960 --> 00:37:55,880 I would say 560 00:37:56,400 --> 00:37:58,400 building a complete PDF process 561 00:37:58,400 --> 00:38:00,620 is a task. It's a very tough task. 562 00:38:01,680 --> 00:38:02,240 Having 563 00:38:02,240 --> 00:38:04,460 lexical analysis is one thing, 564 00:38:04,560 --> 00:38:06,440 but not so standard or 565 00:38:06,580 --> 00:38:07,560 processing object is another. 566 00:38:08,260 --> 00:38:10,500 Okay? And embedded components 567 00:38:10,500 --> 00:38:12,500 also need attention, like 568 00:38:12,500 --> 00:38:13,600 font. How many 569 00:38:14,640 --> 00:38:16,340 exploits that are leveraged on 570 00:38:16,340 --> 00:38:18,020 font that have been used? 571 00:38:18,360 --> 00:38:20,080 Recently, you know on iOS, 572 00:38:20,300 --> 00:38:22,500 Jill break me tweet is also 573 00:38:22,500 --> 00:38:24,400 starting from the font as well, 574 00:38:24,480 --> 00:38:25,940 right? And of course, 575 00:38:26,020 --> 00:38:28,200 media, Flash, audio 576 00:38:28,200 --> 00:38:30,140 and stuff is also main problem 577 00:38:30,140 --> 00:38:32,180 as well now to address 578 00:38:32,180 --> 00:38:34,520 within a PDF processor or PDF analyzer. 579 00:38:34,940 --> 00:38:36,380 And of course 580 00:38:36,580 --> 00:38:38,080 try to fully compatible 581 00:38:38,080 --> 00:38:40,240 JavaScript to emulate 582 00:38:40,240 --> 00:38:42,320 this is very painful, especially 583 00:38:42,320 --> 00:38:44,400 that has specific on 584 00:38:44,400 --> 00:38:45,080 Acro.js 585 00:38:46,270 --> 00:38:48,000 function. And 586 00:38:48,580 --> 00:38:50,580 inspection of the whole part of 587 00:38:50,580 --> 00:38:52,360 potential execution within a PDF 588 00:38:52,360 --> 00:38:54,320 reader application contact is 589 00:38:54,320 --> 00:38:56,480 hard. For example, if you try to 590 00:38:56,480 --> 00:38:58,600 analyze outside of contact 591 00:38:58,600 --> 00:39:00,340 of PDF reader 592 00:39:00,340 --> 00:39:02,280 contact, it would be difficult 593 00:39:02,280 --> 00:39:04,440 to find out the floor 594 00:39:04,440 --> 00:39:06,420 of it. For example, you have app version 595 00:39:06,580 --> 00:39:08,560 viewer version 9, it will have 596 00:39:08,560 --> 00:39:10,460 a different execution. So you need 597 00:39:10,460 --> 00:39:11,660 to mimic all this environment 598 00:39:11,660 --> 00:39:13,680 within your analyzer. 599 00:39:15,240 --> 00:39:15,760 And 600 00:39:16,400 --> 00:39:18,060 well, even though they have a challenge 601 00:39:18,060 --> 00:39:20,480 and issue, I think a lot of effort 602 00:39:20,480 --> 00:39:21,480 have been done to 603 00:39:22,120 --> 00:39:24,300 translate within the tools, like you have 604 00:39:24,300 --> 00:39:26,300 PDFMiner, you have 605 00:39:26,300 --> 00:39:27,720 Origami that can be used 606 00:39:27,720 --> 00:39:29,640 within the library on 607 00:39:30,400 --> 00:39:32,180 Ruby. And of course, you have 608 00:39:32,180 --> 00:39:33,720 famous DDS7 stuff 609 00:39:34,460 --> 00:39:36,360 and then PDF stream damper, PDF 610 00:39:36,580 --> 00:39:38,260 sector, which is a commercial, I think, that one. 611 00:39:38,440 --> 00:39:40,220 And PowerVue. Yeah, even 612 00:39:40,220 --> 00:39:42,400 and then there's also a couple of our online 613 00:39:42,400 --> 00:39:44,280 PDF analyzers as well. 614 00:39:45,100 --> 00:39:46,540 The one that we built is 615 00:39:46,540 --> 00:39:48,520 called Gallus. And then 616 00:39:48,520 --> 00:39:49,980 I think the Web Power at Fame, 617 00:39:50,080 --> 00:39:52,420 JS unpack, and PDF examiner. 618 00:39:52,580 --> 00:39:54,360 And the last one is also built by 619 00:39:54,360 --> 00:39:56,380 our friend, our previous presenter 620 00:39:56,380 --> 00:39:57,140 about PDF 621 00:39:58,540 --> 00:39:59,920 analyzer called APTU-Diesel. 622 00:40:00,960 --> 00:40:01,840 So still, 623 00:40:02,060 --> 00:40:04,160 all these applications that have been built, 624 00:40:04,240 --> 00:40:06,240 it's not a fully 100% 625 00:40:07,340 --> 00:40:08,660 compatible with 626 00:40:08,660 --> 00:40:10,420 how the PDF reader 627 00:40:10,420 --> 00:40:11,680 application works. 628 00:40:12,180 --> 00:40:13,520 So it's very tricky. 629 00:40:13,880 --> 00:40:16,160 And then, conclusion that I can 630 00:40:16,160 --> 00:40:17,860 draw from my presentation 631 00:40:17,860 --> 00:40:19,860 for today is many 632 00:40:19,860 --> 00:40:22,220 application method to hide a malice 633 00:40:22,220 --> 00:40:24,520 PDF, like you can do over 634 00:40:24,520 --> 00:40:26,340 JavaScript, you can do a 635 00:40:26,340 --> 00:40:28,240 PDF syntax, you can abuse 636 00:40:28,240 --> 00:40:30,280 some features. And 637 00:40:31,200 --> 00:40:32,360 for the features, 638 00:40:32,540 --> 00:40:34,200 it also leads to many problems 639 00:40:34,200 --> 00:40:36,040 on this one. Like you have slash 640 00:40:36,580 --> 00:40:38,320 encoder, which gives you 641 00:40:38,320 --> 00:40:40,140 some sort of independent to 642 00:40:40,140 --> 00:40:41,720 do some encoding. 643 00:40:42,560 --> 00:40:44,260 And you also have something like 644 00:40:44,260 --> 00:40:46,500 slash launch to launch 645 00:40:46,500 --> 00:40:47,620 whatever command that you want. 646 00:40:47,960 --> 00:40:50,280 Well, it's nice, it's convenient, 647 00:40:50,480 --> 00:40:52,140 but it also can lead to a different 648 00:40:53,360 --> 00:40:54,320 problem as well. 649 00:40:54,540 --> 00:40:55,940 And you also have like slash 650 00:40:55,940 --> 00:40:57,500 encrypt, which I just showed you in the demo. 651 00:40:57,700 --> 00:40:59,420 And again, encryption is a major 652 00:40:59,420 --> 00:41:01,220 stumbling block. Good to protect your 653 00:41:01,220 --> 00:41:03,540 secret data. And then it's also 654 00:41:03,540 --> 00:41:05,520 so dust for the zero-day 655 00:41:06,580 --> 00:41:07,880 encryption as well. You can protect 656 00:41:07,880 --> 00:41:09,860 a zero-day within this encrypt function. 657 00:41:10,520 --> 00:41:12,320 A more complex technique on 658 00:41:12,320 --> 00:41:14,340 exploitation, we make analysis more 659 00:41:14,340 --> 00:41:16,460 difficult, I think. For example, 660 00:41:16,540 --> 00:41:17,860 command PDF from iOS 661 00:41:17,860 --> 00:41:19,680 to lead to the kernel exploitation. 662 00:41:20,400 --> 00:41:22,240 Of course, kernel is a bug 663 00:41:22,240 --> 00:41:24,240 as well on this, right? And 664 00:41:24,240 --> 00:41:26,080 of course, I don't know, big 665 00:41:26,080 --> 00:41:28,100 malice PDF embedded file 666 00:41:28,100 --> 00:41:29,840 scanner or detector 667 00:41:30,840 --> 00:41:31,960 engine within 668 00:41:31,960 --> 00:41:34,380 the reader application itself is 669 00:41:34,380 --> 00:41:35,980 a good idea. Because 670 00:41:36,580 --> 00:41:38,300 I believe it would be good because 671 00:41:38,300 --> 00:41:40,460 you have contacts within 672 00:41:40,460 --> 00:41:42,060 the PDF reader. 673 00:41:42,900 --> 00:41:44,400 But for some reason, 674 00:41:44,420 --> 00:41:46,140 I think it's also a bad idea if you 675 00:41:46,140 --> 00:41:48,340 add another engine on top of it, you 676 00:41:48,340 --> 00:41:50,220 add a complexity of code base, 677 00:41:50,460 --> 00:41:52,560 which is also meant to 678 00:41:52,560 --> 00:41:54,240 do bugs within the engine itself. 679 00:41:54,500 --> 00:41:56,300 It would be embarrassed to have the 680 00:41:56,300 --> 00:41:58,240 code to do a scanner 681 00:41:58,240 --> 00:42:00,380 for malicious stuff. 682 00:42:00,580 --> 00:42:02,540 It's also vulnerable for the bugs. 683 00:42:03,040 --> 00:42:04,260 Alright? So 684 00:42:04,260 --> 00:42:06,360 pretty much that's the conclusion. And if you're 685 00:42:06,580 --> 00:42:08,020 interested in this PDF weirdness, 686 00:42:08,240 --> 00:42:09,980 you can read all these PDF 687 00:42:09,980 --> 00:42:11,500 references from Adobe. 688 00:42:12,480 --> 00:42:14,500 This one. And of course, you can also 689 00:42:14,500 --> 00:42:16,220 read, well, they have a different 690 00:42:16,220 --> 00:42:17,680 reference on both of these. 691 00:42:18,220 --> 00:42:20,280 This one is specifically for 692 00:42:20,280 --> 00:42:21,620 JavaScript scripting engine. 693 00:42:22,040 --> 00:42:24,500 So you can read on this as well. 694 00:42:24,840 --> 00:42:26,480 And of course, a couple of researchers 695 00:42:26,480 --> 00:42:28,640 have been working on this, like Sebastian Foss 696 00:42:29,200 --> 00:42:30,400 has been working on this. 697 00:42:30,560 --> 00:42:32,440 And also Julia 698 00:42:32,440 --> 00:42:34,360 has also been working on this as well. 699 00:42:35,140 --> 00:42:35,840 And then 700 00:42:36,580 --> 00:42:37,960 thanks for all these people that have been 701 00:42:37,960 --> 00:42:39,420 working on this, I feel. 702 00:42:39,760 --> 00:42:42,300 And then I think that is all from my presentation 703 00:42:42,300 --> 00:42:42,860 for today.