1 00:00:00,000 --> 00:00:00,820 Hello everyone. 2 00:00:02,040 --> 00:00:03,320 Today's topic is 3 00:00:03,800 --> 00:00:07,940 Triton and Symbiotic Execution on GDB. 4 00:00:09,260 --> 00:00:11,760 My name is Weibo Chen. 5 00:00:11,760 --> 00:00:14,020 My common ID on the internet is 6 00:00:15,040 --> 00:00:15,760 BananaAppleTW. 7 00:00:16,000 --> 00:00:17,160 I recently graduated from 8 00:00:17,160 --> 00:00:18,640 the University of California. 9 00:00:19,740 --> 00:00:21,200 Before, at school, 10 00:00:21,680 --> 00:00:24,480 I used to use 11 00:00:24,480 --> 00:00:25,700 the social media of security. 12 00:00:26,740 --> 00:00:27,560 It's called 13 00:00:27,560 --> 00:00:28,580 NCTU-CSC. 14 00:00:29,540 --> 00:00:31,380 It's the Internet Security Association. 15 00:00:31,900 --> 00:00:35,060 I used to use CTF 16 00:00:35,060 --> 00:00:36,040 with the name BambooFast. 17 00:00:37,380 --> 00:00:39,120 I'm good at 18 00:00:39,120 --> 00:00:41,100 Symbiotic Execution 19 00:00:41,100 --> 00:00:42,780 and Binary Exploitation. 20 00:00:43,140 --> 00:00:45,120 I talked about it 21 00:00:45,120 --> 00:00:47,700 in Hikang 2015 and 2017. 22 00:00:48,320 --> 00:00:50,580 This is today's outline. 23 00:00:51,400 --> 00:00:52,940 I will introduce 24 00:00:53,560 --> 00:00:55,080 Symbiotic Execution 25 00:00:55,080 --> 00:00:57,220 and Triton 26 00:00:57,560 --> 00:00:57,860 as a framework. 27 00:00:58,160 --> 00:00:59,720 I will talk about 28 00:00:59,720 --> 00:00:59,740 how I created 29 00:00:59,740 --> 00:01:00,480 the tool SymbGDB 30 00:01:01,900 --> 00:01:03,800 and summarize 31 00:01:03,800 --> 00:01:06,060 Triton's shortcomings 32 00:01:06,060 --> 00:01:08,460 and compare it 33 00:01:08,460 --> 00:01:09,900 with other frameworks. 34 00:01:11,180 --> 00:01:13,560 Why Symbiotic Execution? 35 00:01:13,680 --> 00:01:15,600 In the past, 36 00:01:16,220 --> 00:01:18,040 we used 37 00:01:18,040 --> 00:01:19,760 static analysis 38 00:01:19,760 --> 00:01:20,740 and dynamic analysis 39 00:01:20,740 --> 00:01:23,780 to adjust our program. 40 00:01:24,280 --> 00:01:26,040 Static analysis is like 41 00:01:29,180 --> 00:01:30,120 OVJ dump. 42 00:01:30,280 --> 00:01:30,920 You can look at 43 00:01:30,920 --> 00:01:32,500 the content of the segment 44 00:01:32,500 --> 00:01:34,200 or IDA pool. 45 00:01:34,400 --> 00:01:38,280 It's an anti-independence tool. 46 00:01:39,580 --> 00:01:40,660 Dynamic analysis 47 00:01:40,660 --> 00:01:41,570 is like 48 00:01:44,700 --> 00:01:45,360 GDB, 49 00:01:45,560 --> 00:01:46,480 Ltrace, 50 00:01:46,640 --> 00:01:47,080 Strace. 51 00:01:47,280 --> 00:01:48,080 GDB is 52 00:01:48,080 --> 00:01:49,620 GNU debugger. 53 00:01:51,280 --> 00:01:53,200 Ltrace is a Linux tool 54 00:01:53,200 --> 00:01:54,220 that can help you trace 55 00:01:54,220 --> 00:01:55,500 library code. 56 00:01:57,560 --> 00:01:57,960 It's a new tool 57 00:01:57,960 --> 00:01:59,360 that can help you trace 58 00:01:59,360 --> 00:02:00,640 system code. 59 00:02:01,160 --> 00:02:03,020 You may think 60 00:02:03,020 --> 00:02:04,620 it's quite troublesome. 61 00:02:05,040 --> 00:02:07,780 Every time you use these tools 62 00:02:07,780 --> 00:02:08,760 to look at it, 63 00:02:08,820 --> 00:02:09,780 your head is about to explode. 64 00:02:12,520 --> 00:02:13,420 Symbiotic Execution 65 00:02:13,420 --> 00:02:14,960 is a convenient way 66 00:02:14,960 --> 00:02:16,700 to automatically analyze 67 00:02:17,440 --> 00:02:18,420 the content 68 00:02:18,420 --> 00:02:21,200 and what inputs you need 69 00:02:21,200 --> 00:02:21,940 to get to that point. 70 00:02:22,900 --> 00:02:24,660 What is Symbiotic Execution? 71 00:02:27,720 --> 00:02:29,120 It's a tool 72 00:02:29,120 --> 00:02:30,300 that helps you find 73 00:02:30,300 --> 00:02:31,240 the input 74 00:02:32,840 --> 00:02:34,160 that will go to 75 00:02:34,160 --> 00:02:35,420 a certain part of the program. 76 00:02:38,020 --> 00:02:39,860 The most commonly used 77 00:02:39,860 --> 00:02:40,660 framework is 78 00:02:41,550 --> 00:02:41,900 S2E. 79 00:02:42,120 --> 00:02:44,080 The system level 80 00:02:44,080 --> 00:02:44,900 is S2E. 81 00:02:44,960 --> 00:02:45,380 The system level 82 00:02:45,380 --> 00:02:46,960 includes kernel space 83 00:02:46,960 --> 00:02:48,260 and user space. 84 00:02:49,220 --> 00:02:51,540 For example, 85 00:02:53,000 --> 00:02:54,280 the framework for user level 86 00:02:57,560 --> 00:02:58,520 is S2E. 87 00:02:58,620 --> 00:03:00,160 But it's more special 88 00:03:00,160 --> 00:03:02,540 because it needs 89 00:03:02,540 --> 00:03:03,400 your source code 90 00:03:03,400 --> 00:03:05,260 to make it into IR 91 00:03:05,260 --> 00:03:06,120 to execute. 92 00:03:07,820 --> 00:03:09,200 Let's look at an example. 93 00:03:09,720 --> 00:03:10,440 For example, 94 00:03:10,480 --> 00:03:11,560 this is function F. 95 00:03:11,960 --> 00:03:13,440 Y is our input. 96 00:03:13,620 --> 00:03:13,980 Y reads in from Z. 97 00:03:14,700 --> 00:03:16,380 Z equals Y times 2. 98 00:03:16,700 --> 00:03:18,560 Next, it will make a judgment 99 00:03:18,560 --> 00:03:20,840 to see if Z equals 12. 100 00:03:21,180 --> 00:03:22,020 If it's 4, 101 00:03:27,560 --> 00:03:28,220 the method of Symbiotic Execution 102 00:03:28,220 --> 00:03:29,060 is that when it encounters 103 00:03:29,060 --> 00:03:29,540 this constraint, 104 00:03:29,820 --> 00:03:30,960 it will help us to solve 105 00:03:30,960 --> 00:03:31,820 for example, 106 00:03:31,900 --> 00:03:33,340 if I want to go to fail state, 107 00:03:33,800 --> 00:03:35,060 it will help us to solve 108 00:03:35,060 --> 00:03:36,480 Y equals 6. 109 00:03:36,720 --> 00:03:37,400 For example, 110 00:03:37,500 --> 00:03:39,380 if we want to go to OK state, 111 00:03:39,760 --> 00:03:43,320 it will find a Y 112 00:03:43,320 --> 00:03:44,520 that is not equal to 6 for us. 113 00:03:46,120 --> 00:03:47,360 Next, I will introduce 114 00:03:49,660 --> 00:03:50,100 Triton. 115 00:03:51,260 --> 00:03:52,900 Triton is a framework 116 00:03:57,560 --> 00:03:58,280 that is developed by 117 00:03:58,280 --> 00:03:59,080 Jonathan Sawin. 118 00:04:01,480 --> 00:04:02,880 It's an open source 119 00:04:03,360 --> 00:04:03,800 project. 120 00:04:04,000 --> 00:04:05,120 Although it's mainly 121 00:04:05,120 --> 00:04:05,700 developed, 122 00:04:06,060 --> 00:04:08,820 some users will write code 123 00:04:08,820 --> 00:04:09,920 and pull requests 124 00:04:09,920 --> 00:04:12,920 to help develop it. 125 00:04:13,160 --> 00:04:15,120 It has Python binding. 126 00:04:16,440 --> 00:04:18,020 Its components 127 00:04:18,020 --> 00:04:19,720 include Symbiotic Execution Engine, 128 00:04:20,100 --> 00:04:20,980 Tracer, 129 00:04:21,180 --> 00:04:22,340 AST expression, 130 00:04:22,840 --> 00:04:24,640 and SNT solver interface. 131 00:04:27,560 --> 00:04:28,900 I will introduce its outline. 132 00:04:32,200 --> 00:04:33,820 Its structure is that 133 00:04:33,820 --> 00:04:35,460 you will have some Tracers 134 00:04:35,460 --> 00:04:36,460 such as Pin, 135 00:04:36,640 --> 00:04:37,500 or Valkyrie, 136 00:04:37,600 --> 00:04:38,560 or Cumul, 137 00:04:38,640 --> 00:04:40,760 or you can store your commands 138 00:04:40,760 --> 00:04:41,780 in DB, 139 00:04:42,200 --> 00:04:42,940 like MySQL, 140 00:04:43,200 --> 00:04:44,460 and take it out. 141 00:04:44,700 --> 00:04:46,000 After you throw it to Triton, 142 00:04:46,260 --> 00:04:47,820 it will have some components 143 00:04:47,820 --> 00:04:50,100 to help you specify 144 00:04:50,100 --> 00:04:52,540 which part of the variable 145 00:04:52,540 --> 00:04:53,640 is Symbiotic. 146 00:04:57,560 --> 00:04:58,580 SNT solver 147 00:04:58,580 --> 00:04:59,840 to help you solve it. 148 00:05:01,960 --> 00:05:03,800 Let me introduce 149 00:05:03,800 --> 00:05:05,860 Symbiotic Execution Engine. 150 00:05:06,420 --> 00:05:07,820 Symbiotic Execution Engine 151 00:05:07,820 --> 00:05:09,020 is an engine 152 00:05:09,020 --> 00:05:10,600 to store your Symbiotic State. 153 00:05:12,540 --> 00:05:15,640 It stores three things. 154 00:05:15,920 --> 00:05:16,420 It stores 155 00:05:16,420 --> 00:05:19,780 your Symbiotic Registry State, 156 00:05:20,220 --> 00:05:21,740 Symbiotic Memory State, 157 00:05:22,020 --> 00:05:22,500 and your 158 00:05:23,560 --> 00:05:25,500 reference relationship with them. 159 00:05:25,500 --> 00:05:26,260 For example, 160 00:05:27,660 --> 00:05:28,660 when we run initial, 161 00:05:29,100 --> 00:05:30,540 ES is on set, 162 00:05:30,600 --> 00:05:32,480 which means we haven't executed any commands yet. 163 00:05:32,520 --> 00:05:34,560 When we run to the first one, 164 00:05:34,840 --> 00:05:36,560 move ES is 0. 165 00:05:36,740 --> 00:05:38,260 Now ES is 0. 166 00:05:38,560 --> 00:05:41,360 ES becomes reference 1. 167 00:05:42,440 --> 00:05:43,040 Next, 168 00:05:43,440 --> 00:05:45,420 we execute the second command, 169 00:05:45,720 --> 00:05:47,220 increment ES, 170 00:05:47,660 --> 00:05:49,380 which is to add 1 to ES. 171 00:05:49,380 --> 00:05:50,980 Now ES value becomes 172 00:05:51,280 --> 00:05:51,800 phi 2, 173 00:05:51,980 --> 00:05:53,180 which is reference 2. 174 00:05:53,620 --> 00:05:55,280 It will come from the previous 175 00:05:57,560 --> 00:05:57,840 command. 176 00:05:57,840 --> 00:05:58,640 Next, the third command, 177 00:05:58,860 --> 00:05:59,100 for example, 178 00:05:59,140 --> 00:06:00,320 add ES 5. 179 00:06:00,500 --> 00:06:02,280 Then we add reference 5. 180 00:06:03,360 --> 00:06:06,420 Now ES reference is phi 3. 181 00:06:06,540 --> 00:06:07,600 It will be equal to 182 00:06:07,600 --> 00:06:08,360 phi 2 plus 5. 183 00:06:10,880 --> 00:06:11,840 What conditions should 184 00:06:11,840 --> 00:06:13,240 Tracer meet? 185 00:06:14,160 --> 00:06:15,460 It needs to meet two conditions. 186 00:06:15,460 --> 00:06:15,800 For example, 187 00:06:15,900 --> 00:06:17,320 I need to know what my 188 00:06:17,840 --> 00:06:19,140 OPCode execution is. 189 00:06:19,880 --> 00:06:20,580 For example, 190 00:06:27,560 --> 00:06:29,040 when I'm executing, 191 00:06:29,380 --> 00:06:30,680 I need to know 192 00:06:30,680 --> 00:06:32,540 my register and memory state. 193 00:06:32,860 --> 00:06:34,900 After Tracer knows these two, 194 00:06:35,100 --> 00:06:37,280 it will turn your control flow 195 00:06:37,280 --> 00:06:38,980 into an AST expression. 196 00:06:40,220 --> 00:06:41,080 Most of the time, 197 00:06:41,140 --> 00:06:42,100 you can see in Tracer's 198 00:06:43,420 --> 00:06:44,060 project 199 00:06:44,060 --> 00:06:45,840 that it has a lot of 200 00:06:45,840 --> 00:06:47,700 PIM Tracer examples. 201 00:06:49,380 --> 00:06:50,380 PIM is an 202 00:06:52,860 --> 00:06:53,820 instrumentation tool 203 00:06:54,140 --> 00:06:54,740 developed by 204 00:06:54,740 --> 00:06:55,020 Intel. 205 00:06:57,560 --> 00:06:58,760 What is an AST expression? 206 00:06:59,560 --> 00:07:01,380 Tracer actually supports 207 00:07:01,380 --> 00:07:02,120 two structures, 208 00:07:02,380 --> 00:07:05,020 x86 and x864 commands. 209 00:07:05,260 --> 00:07:07,000 It will turn these semantics 210 00:07:07,000 --> 00:07:08,840 into AST expressions. 211 00:07:10,060 --> 00:07:11,120 Tracer's expressions 212 00:07:11,120 --> 00:07:13,200 are all in SSA form. 213 00:07:13,620 --> 00:07:14,800 Let's look at an example. 214 00:07:15,440 --> 00:07:16,640 For example, our instruction 215 00:07:16,640 --> 00:07:19,000 is add RAS RDS. 216 00:07:19,240 --> 00:07:21,240 This command means 217 00:07:21,240 --> 00:07:23,500 I add RAS and RDS 218 00:07:23,500 --> 00:07:25,120 and then 219 00:07:25,120 --> 00:07:26,480 save it to RAS. 220 00:07:27,560 --> 00:07:28,380 So, 221 00:07:28,500 --> 00:07:31,240 reference 41 is 222 00:07:31,240 --> 00:07:32,380 the last reference of RAS. 223 00:07:33,280 --> 00:07:35,060 Reference 40 is 224 00:07:35,060 --> 00:07:35,900 the reference of RAS 225 00:07:35,900 --> 00:07:38,560 when we are executing this command. 226 00:07:40,620 --> 00:07:42,400 Reference 39 is 227 00:07:42,400 --> 00:07:43,060 the reference of RDS 228 00:07:43,060 --> 00:07:44,300 when we are executing this command. 229 00:07:45,940 --> 00:07:47,580 What I'm talking about 230 00:07:47,580 --> 00:07:49,260 with Tracer 630 231 00:07:49,260 --> 00:07:50,500 is that 232 00:07:50,500 --> 00:07:51,260 I take it out from 233 00:07:51,260 --> 00:07:53,960 bit 0 to bit 63 234 00:07:53,960 --> 00:07:57,020 because RAS is 8 bytes. 235 00:07:57,560 --> 00:07:58,660 So, it's 64 bits. 236 00:07:58,860 --> 00:07:59,600 After I take it out, 237 00:07:59,740 --> 00:08:00,780 I add two bits 238 00:08:00,780 --> 00:08:04,780 and it equals 41 references. 239 00:08:07,240 --> 00:08:08,740 We can see 240 00:08:08,740 --> 00:08:10,740 after we pass through these five commands, 241 00:08:11,060 --> 00:08:12,120 your AST expression 242 00:08:12,120 --> 00:08:13,820 will look like a tree. 243 00:08:14,100 --> 00:08:15,440 The first command is 244 00:08:15,440 --> 00:08:16,760 AS equals 1. 245 00:08:17,020 --> 00:08:19,660 Next, CL. AL equals 1. 246 00:08:19,740 --> 00:08:22,120 CL equals 10. DL equals 20. 247 00:08:22,260 --> 00:08:23,180 These three on the left, 248 00:08:23,520 --> 00:08:24,420 middle, and right. 249 00:08:27,560 --> 00:08:28,160 These three are the values 250 00:08:28,160 --> 00:08:30,060 and the right is the bit number. 251 00:08:31,520 --> 00:08:33,980 Then we have SO, CL, and DL 252 00:08:33,980 --> 00:08:34,660 which are the numbers on the right. 253 00:08:35,780 --> 00:08:36,320 These are 254 00:08:36,320 --> 00:08:38,900 S, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B. 255 00:08:39,000 --> 00:08:41,040 Finally, we add AL and CL 256 00:08:41,040 --> 00:08:41,820 and we get 257 00:08:41,820 --> 00:08:43,800 the bit vector at the top. 258 00:08:45,120 --> 00:08:46,380 What is SAF? 259 00:08:46,600 --> 00:08:47,660 I mentioned that 260 00:08:47,660 --> 00:08:48,940 Triton's ASD expression 261 00:08:48,940 --> 00:08:50,700 is in SSAF. 262 00:08:52,180 --> 00:08:52,880 SAF is 263 00:08:52,880 --> 00:08:55,040 Static Single Assignment Fon. 264 00:08:57,560 --> 00:08:59,260 will only be assigned once. 265 00:08:59,800 --> 00:09:02,180 So for example, we have y equals 1, 266 00:09:02,380 --> 00:09:04,420 and y equals 2, and s equals y. 267 00:09:04,680 --> 00:09:07,960 Then the expression method of SAAFON 268 00:09:07,960 --> 00:09:10,700 will become y1 equals 1, y2 equals 2, 269 00:09:10,860 --> 00:09:12,600 and s1 equals y2. 270 00:09:12,720 --> 00:09:14,320 Because when it passes an assign, 271 00:09:14,540 --> 00:09:15,780 it becomes another state. 272 00:09:16,100 --> 00:09:17,860 It has nothing to do with the previous state. 273 00:09:19,120 --> 00:09:20,680 So after this, 274 00:09:20,840 --> 00:09:23,860 we can set up some unnecessary calculations. 275 00:09:24,040 --> 00:09:25,200 For example, y1 here 276 00:09:25,200 --> 00:09:27,560 has already been deleted by us. 277 00:09:31,320 --> 00:09:34,440 Next, I will introduce the concept of Symbolic Variable. 278 00:09:35,220 --> 00:09:39,320 We can imagine that Symbolic is like an infectious disease. 279 00:09:39,840 --> 00:09:46,780 When a command's calculator is Symbolic, 280 00:09:47,120 --> 00:09:52,220 the memory or register affected by this command 281 00:09:52,220 --> 00:09:53,800 will become Symbolic. 282 00:09:53,800 --> 00:09:54,000 Okay. 283 00:09:55,200 --> 00:09:55,700 In Twitter, 284 00:09:55,940 --> 00:10:01,320 we can use these two messages to control it. 285 00:10:01,440 --> 00:10:04,460 The first message is Convert Register to Symbolic, 286 00:10:04,460 --> 00:10:05,680 which is the Symbolic Variable. 287 00:10:05,940 --> 00:10:09,260 For example, if we want ECS, 288 00:10:09,300 --> 00:10:11,060 and ECS is Symbolic, 289 00:10:11,080 --> 00:10:12,900 we can put ECS in this function, 290 00:10:13,200 --> 00:10:15,520 and it will mark it as Symbolic. 291 00:10:16,220 --> 00:10:19,500 Next, we can use IsRegister Symbolize 292 00:10:19,500 --> 00:10:21,920 to check if this is Symbolic. 293 00:10:22,740 --> 00:10:23,560 Let's look at an example. 294 00:10:23,560 --> 00:10:23,960 For example, 295 00:10:24,620 --> 00:10:28,480 let's take ECS as Symbolic Variable. 296 00:10:28,540 --> 00:10:30,460 The code on the right is a Twitter code, 297 00:10:30,580 --> 00:10:33,600 and the code on the left is a text description. 298 00:10:34,500 --> 00:10:36,740 So we can convert it to Symbolic, 299 00:10:36,780 --> 00:10:38,540 and then we can confirm that it is Symbolic, 300 00:10:38,540 --> 00:10:39,440 and the return will be True. 301 00:10:40,180 --> 00:10:42,740 Next, we can use Test ECS ECS. 302 00:10:42,980 --> 00:10:46,300 Test is a command that you will use before you jump. 303 00:10:48,080 --> 00:10:51,560 It will first confirm the relationship between the two Registers, 304 00:10:51,560 --> 00:10:54,560 and then set the flag. 305 00:10:54,960 --> 00:10:59,480 The flag is actually one of the registers in the CPU. 306 00:10:59,480 --> 00:11:01,160 It will be the flag. 307 00:11:02,800 --> 00:11:06,040 So this means that its real flag will be set up. 308 00:11:06,240 --> 00:11:09,840 If ECS and ECS end equal to 0, 309 00:11:10,180 --> 00:11:11,220 it will be set up. 310 00:11:11,380 --> 00:11:12,620 So if ECS is 0, 311 00:11:13,020 --> 00:11:15,060 the real flag will be set to 1. 312 00:11:15,400 --> 00:11:17,780 Otherwise, the real flag will be set to 0. 313 00:11:18,440 --> 00:11:19,640 But this is not important. 314 00:11:19,640 --> 00:11:20,640 Just remember that 315 00:11:20,640 --> 00:11:23,400 after we pass the test, 316 00:11:24,600 --> 00:11:26,000 ECS was originally Symbolic. 317 00:11:26,020 --> 00:11:28,340 Now, because we passed the test, 318 00:11:28,480 --> 00:11:32,180 the EIP after that will be affected by ECS. 319 00:11:32,680 --> 00:11:35,080 Because it will decide for ECS 320 00:11:35,740 --> 00:11:37,220 where the next register will go. 321 00:11:39,280 --> 00:11:41,780 So EIP will also become Symbolic. 322 00:11:41,820 --> 00:11:43,660 So if real flag equals to 1, 323 00:11:43,840 --> 00:11:44,940 it will jump to the fifth register. 324 00:11:45,340 --> 00:11:47,680 Otherwise, it will go directly to the next register, 325 00:11:47,780 --> 00:11:48,380 which is without jump. 326 00:11:50,120 --> 00:11:50,560 OK. 327 00:11:51,120 --> 00:11:51,560 So, 328 00:11:51,860 --> 00:11:52,900 the way we usually use it is that 329 00:11:52,900 --> 00:11:54,980 we go and choose... 330 00:11:54,980 --> 00:11:56,420 There was that ASTTree just now. 331 00:11:56,460 --> 00:11:58,800 So each node is actually a register. 332 00:11:59,060 --> 00:12:01,560 So we can choose the node we want. 333 00:12:02,040 --> 00:12:03,720 For example, if I am interested in EAS now, 334 00:12:04,140 --> 00:12:05,120 then I will choose EAS. 335 00:12:05,460 --> 00:12:08,440 And then add some of my own settings to the control chain. 336 00:12:08,800 --> 00:12:09,240 Then, 337 00:12:09,280 --> 00:12:11,080 these two control chains and the AND 338 00:12:11,080 --> 00:12:12,640 will be thrown to the SNTSolver. 339 00:12:13,300 --> 00:12:14,420 Then it will help me to explain 340 00:12:14,420 --> 00:12:17,920 whether it is in line with the Symbolic variable. 341 00:12:18,680 --> 00:12:20,240 Finally, I can get the answer. 342 00:12:21,200 --> 00:12:21,680 Now, 343 00:12:21,700 --> 00:12:24,580 let's see how Triton is used on the CTF table. 344 00:12:25,120 --> 00:12:26,860 This example is based on 345 00:12:26,860 --> 00:12:29,200 the 2015 R100 of DevCamp. 346 00:12:29,260 --> 00:12:29,660 That is, 347 00:12:29,760 --> 00:12:32,800 this program will ask you to enter a password. 348 00:12:33,960 --> 00:12:36,560 This password can be up to 255. 349 00:12:37,940 --> 00:12:38,420 Next, 350 00:12:38,780 --> 00:12:40,880 it will do a series of verification 351 00:12:40,880 --> 00:12:43,380 to see if this password is right or wrong. 352 00:12:44,560 --> 00:12:45,360 This is... 353 00:12:45,360 --> 00:12:46,660 Its code is a little bit small. 354 00:12:46,720 --> 00:12:46,840 That is, 355 00:12:46,840 --> 00:12:49,660 we will use fget to read it in first. 356 00:12:49,720 --> 00:12:50,240 Then, 357 00:12:51,700 --> 00:12:55,280 we will throw the function sub4006fd 358 00:12:55,780 --> 00:12:58,880 to determine whether it is right or wrong. 359 00:12:59,280 --> 00:13:01,080 If it returns 0, 360 00:13:01,860 --> 00:13:02,580 it will be correct. 361 00:13:02,760 --> 00:13:03,680 If it returns 0, it will be nice. 362 00:13:03,940 --> 00:13:04,220 So, 363 00:13:04,260 --> 00:13:05,460 we will return 0 in the next function. 364 00:13:07,340 --> 00:13:08,260 In fact, 365 00:13:08,820 --> 00:13:09,660 it will return 1 in the middle. 366 00:13:09,660 --> 00:13:10,820 So, we can't let it happen. 367 00:13:11,180 --> 00:13:12,580 It has to go through 12 rounds. 368 00:13:13,020 --> 00:13:15,660 As long as one of them returns 1, 369 00:13:15,660 --> 00:13:16,520 we will fail. 370 00:13:17,200 --> 00:13:17,600 So, 371 00:13:18,480 --> 00:13:19,880 if it is not equal to 1, 372 00:13:19,980 --> 00:13:20,640 it will return 1. 373 00:13:20,880 --> 00:13:21,040 So, 374 00:13:21,120 --> 00:13:22,600 we have to make it equal to 1. 375 00:13:22,680 --> 00:13:23,140 That is, 376 00:13:23,300 --> 00:13:25,340 if the judgment is equal to 1. 377 00:13:26,580 --> 00:13:26,980 Okay. 378 00:13:27,080 --> 00:13:27,400 Then, 379 00:13:27,460 --> 00:13:28,580 we will use treaten to solve this problem. 380 00:13:29,280 --> 00:13:29,680 Okay. 381 00:13:29,760 --> 00:13:30,860 We will first import treaten. 382 00:13:31,200 --> 00:13:31,920 Treaten context. 383 00:13:32,220 --> 00:13:33,200 We will initialize it first. 384 00:13:33,840 --> 00:13:34,240 Then, 385 00:13:34,360 --> 00:13:36,260 we will set its structure. 386 00:13:36,540 --> 00:13:36,720 That is, 387 00:13:37,320 --> 00:13:38,680 it is x8664. 388 00:13:40,460 --> 00:13:40,860 Next, 389 00:13:41,040 --> 00:13:41,760 we will load the binary. 390 00:13:41,960 --> 00:13:42,080 That is, 391 00:13:42,280 --> 00:13:43,500 we will... 392 00:13:43,500 --> 00:13:45,540 we will use leaf, 393 00:13:45,700 --> 00:13:47,240 this Python module. 394 00:13:47,560 --> 00:13:49,400 We will use its binary header 395 00:13:49,400 --> 00:13:50,080 to... 396 00:13:50,080 --> 00:13:51,120 to... 397 00:13:51,120 --> 00:13:52,540 and its offset 398 00:13:52,540 --> 00:13:53,540 to load it into memory. 399 00:13:53,960 --> 00:13:54,260 Then, 400 00:13:54,340 --> 00:13:55,920 we will use treaten set concrete memory 401 00:13:56,520 --> 00:13:58,420 to set it in treaten's engine. 402 00:13:59,160 --> 00:13:59,760 Then, 403 00:13:59,800 --> 00:14:00,860 we will assume... 404 00:14:01,280 --> 00:14:01,580 that is, 405 00:14:01,720 --> 00:14:03,460 we will set the flag randomly. 406 00:14:03,620 --> 00:14:04,220 No, 407 00:14:04,280 --> 00:14:06,020 we will set the stake randomly. 408 00:14:06,040 --> 00:14:06,640 Then, 409 00:14:06,700 --> 00:14:08,880 we will set two words randomly. 410 00:14:08,880 --> 00:14:09,280 That is, 411 00:14:09,380 --> 00:14:12,040 we will set eBP and eSP. 412 00:14:12,040 --> 00:14:12,540 That is, 413 00:14:12,680 --> 00:14:14,880 64 is RSP and RBP. 414 00:14:15,280 --> 00:14:15,920 That is, 415 00:14:15,940 --> 00:14:16,760 stake base address 416 00:14:16,760 --> 00:14:17,760 and stake address. 417 00:14:18,540 --> 00:14:19,100 Then, 418 00:14:19,120 --> 00:14:20,680 we will define user input. 419 00:14:21,020 --> 00:14:21,300 Then, 420 00:14:21,380 --> 00:14:22,160 in 64, 421 00:14:22,920 --> 00:14:23,480 it... 422 00:14:24,040 --> 00:14:25,500 its parameter is 423 00:14:25,500 --> 00:14:26,380 using RDI, 424 00:14:26,540 --> 00:14:27,160 this register. 425 00:14:27,800 --> 00:14:28,360 Then, 426 00:14:28,400 --> 00:14:29,200 we... 427 00:14:29,200 --> 00:14:30,280 because we don't know 428 00:14:30,280 --> 00:14:31,080 how long it is, 429 00:14:31,300 --> 00:14:32,780 we will set it first. 430 00:14:32,980 --> 00:14:34,600 We will assume that 431 00:14:34,600 --> 00:14:35,420 it has 30 bytes. 432 00:14:35,560 --> 00:14:35,740 That is, 433 00:14:35,800 --> 00:14:36,400 its password length. 434 00:14:36,740 --> 00:14:37,200 So, 435 00:14:37,320 --> 00:14:38,460 we will use this memory 436 00:14:38,460 --> 00:14:39,160 and then, 437 00:14:39,200 --> 00:14:40,140 30 bytes 438 00:14:40,140 --> 00:14:41,340 is its length. 439 00:14:41,540 --> 00:14:42,000 We will set it 440 00:14:42,040 --> 00:14:43,020 as symbolic input. 441 00:14:43,720 --> 00:14:44,120 Then, 442 00:14:44,180 --> 00:14:45,000 we will start executing. 443 00:14:45,180 --> 00:14:45,360 That is, 444 00:14:45,360 --> 00:14:46,320 we will jump directly to 445 00:14:46,320 --> 00:14:47,700 the function to execute. 446 00:14:48,440 --> 00:14:48,840 Then, 447 00:14:49,860 --> 00:14:51,260 when it is executing, 448 00:14:51,480 --> 00:14:51,780 in fact, 449 00:14:51,980 --> 00:14:52,580 because we just 450 00:14:52,580 --> 00:14:53,920 based on binary header, 451 00:14:54,060 --> 00:14:54,520 we have already 452 00:14:54,520 --> 00:14:55,220 read the segment, 453 00:14:55,480 --> 00:14:55,820 that is, 454 00:14:55,920 --> 00:14:57,100 test segment, 455 00:14:57,280 --> 00:14:57,420 that is, 456 00:14:57,440 --> 00:14:58,600 the segment that the program can execute. 457 00:14:59,260 --> 00:15:00,600 The segment has been read in. 458 00:15:01,020 --> 00:15:01,420 So, 459 00:15:01,480 --> 00:15:02,700 we will use gate. 460 00:15:03,060 --> 00:15:04,160 We will directly take the paper from memory. 461 00:15:05,340 --> 00:15:05,740 Then, 462 00:15:05,760 --> 00:15:06,420 after taking the paper, 463 00:15:06,580 --> 00:15:07,600 we will make it into an instruction. 464 00:15:07,940 --> 00:15:08,080 Then, 465 00:15:08,180 --> 00:15:09,220 after the process, 466 00:15:09,900 --> 00:15:10,700 this process, 467 00:15:10,880 --> 00:15:11,320 then it will 468 00:15:12,820 --> 00:15:14,360 update the paper 469 00:15:14,360 --> 00:15:14,940 while running. 470 00:15:14,940 --> 00:15:15,320 Then, 471 00:15:15,440 --> 00:15:16,500 it will update 472 00:15:16,500 --> 00:15:17,700 the counter in it 473 00:15:17,900 --> 00:15:18,420 Then, 474 00:15:18,500 --> 00:15:19,360 PC equals 475 00:15:19,360 --> 00:15:19,940 NET, 476 00:15:20,120 --> 00:15:20,720 which is 477 00:15:20,720 --> 00:15:22,420 the paper of its RIP. 478 00:15:22,980 --> 00:15:23,340 That is, 479 00:15:23,440 --> 00:15:24,120 after it runs, 480 00:15:24,320 --> 00:15:24,900 there will be a paper in your RIP. 481 00:15:25,360 --> 00:15:26,460 It will continue to execute 482 00:15:26,460 --> 00:15:26,680 like this. 483 00:15:26,700 --> 00:15:27,220 Then, 484 00:15:27,380 --> 00:15:28,160 it will not 485 00:15:29,320 --> 00:15:29,840 break. 486 00:15:30,240 --> 00:15:31,020 This is a 487 00:15:31,020 --> 00:15:31,860 loop, 488 00:15:32,060 --> 00:15:32,280 like this. 489 00:15:33,120 --> 00:15:33,640 Then, 490 00:15:33,760 --> 00:15:35,040 we just talked about 491 00:15:35,040 --> 00:15:36,040 we have to equal to 1. 492 00:15:36,220 --> 00:15:36,680 That is, 493 00:15:36,880 --> 00:15:39,360 because it has to equal to 1 494 00:15:39,360 --> 00:15:39,380 in the if. 495 00:15:39,380 --> 00:15:39,720 So, 496 00:15:39,720 --> 00:15:41,620 we stopped at the point just now 497 00:15:41,620 --> 00:15:44,240 to judge whether it is equal to 1. 498 00:15:44,300 --> 00:15:44,900 That is, 499 00:15:45,040 --> 00:15:47,600 the position of 4078B, 500 00:15:49,340 --> 00:15:50,400 it will compare 501 00:15:50,400 --> 00:15:52,100 whether EAS is equal to 1. 502 00:15:52,240 --> 00:15:53,300 So, after we stopped here, 503 00:15:53,840 --> 00:15:55,500 we started to design the counter. 504 00:15:55,740 --> 00:15:56,100 That is to say, 505 00:15:56,220 --> 00:15:57,760 EAS is equal to 1. 506 00:15:57,840 --> 00:15:58,060 And, 507 00:15:58,720 --> 00:16:00,300 from just now to now, 508 00:16:00,440 --> 00:16:01,100 it collects the counter. 509 00:16:01,400 --> 00:16:02,420 After the two are combined, 510 00:16:03,220 --> 00:16:05,600 then we throw it to the SNT solver, 511 00:16:05,680 --> 00:16:06,360 which is the gate model. 512 00:16:06,640 --> 00:16:08,040 This is Chiton's gate model. 513 00:16:08,360 --> 00:16:08,760 Then, 514 00:16:08,760 --> 00:16:09,120 it will explain 515 00:16:09,660 --> 00:16:10,480 what the symbol is. 516 00:16:11,680 --> 00:16:12,120 Then, 517 00:16:12,260 --> 00:16:13,300 the result will be like this. 518 00:16:13,420 --> 00:16:14,020 That is to say, 519 00:16:14,040 --> 00:16:14,660 it will slowly 520 00:16:14,660 --> 00:16:15,400 take turns 521 00:16:15,400 --> 00:16:15,740 to 522 00:16:15,740 --> 00:16:18,040 explain our password. 523 00:16:20,980 --> 00:16:21,420 Okay. 524 00:16:21,660 --> 00:16:22,100 Then, 525 00:16:22,180 --> 00:16:22,760 in fact, 526 00:16:22,840 --> 00:16:24,460 you can feel that 527 00:16:25,760 --> 00:16:26,700 this whole process 528 00:16:26,700 --> 00:16:27,800 is actually quite troublesome. 529 00:16:28,100 --> 00:16:28,320 That is to say, 530 00:16:28,340 --> 00:16:28,780 you need to 531 00:16:28,780 --> 00:16:30,120 know a lot of concepts 532 00:16:30,120 --> 00:16:31,040 before you can use 533 00:16:31,040 --> 00:16:32,040 this tool. 534 00:16:32,700 --> 00:16:33,140 So, 535 00:16:33,740 --> 00:16:34,340 that is to say, 536 00:16:35,420 --> 00:16:36,320 if you have, 537 00:16:36,480 --> 00:16:38,240 if you write something yourself, 538 00:16:38,240 --> 00:16:38,740 you write something 539 00:16:38,760 --> 00:16:39,360 like a debugger, 540 00:16:39,440 --> 00:16:39,580 and then, 541 00:16:39,680 --> 00:16:40,700 and then, 542 00:16:40,700 --> 00:16:41,720 if you have a debugger 543 00:16:41,720 --> 00:16:42,900 to help you provide some paper, 544 00:16:42,980 --> 00:16:43,660 a lot of it 545 00:16:43,660 --> 00:16:44,320 can be omitted. 546 00:16:44,980 --> 00:16:45,500 So, 547 00:16:45,520 --> 00:16:46,200 in fact, 548 00:16:46,300 --> 00:16:47,300 this is today's topic. 549 00:16:47,920 --> 00:16:49,220 What I want to talk about is 550 00:16:49,220 --> 00:16:50,300 this is a tool 551 00:16:50,300 --> 00:16:51,180 I wrote myself 552 00:16:51,180 --> 00:16:51,400 called 553 00:16:51,400 --> 00:16:52,120 SYNGDB. 554 00:16:52,800 --> 00:16:54,000 It is a 555 00:16:54,000 --> 00:16:54,840 symbolic execution 556 00:16:55,580 --> 00:16:56,100 plug-in. 557 00:16:56,200 --> 00:16:56,580 Then, 558 00:16:56,660 --> 00:16:58,600 it is a symbolic execution plug-in 559 00:16:58,600 --> 00:16:58,640 of GDB. 560 00:16:58,640 --> 00:16:59,700 It is mainly 561 00:16:59,700 --> 00:17:00,640 made up of two things. 562 00:17:01,040 --> 00:17:01,580 One is 563 00:17:01,580 --> 00:17:02,520 the Chiton we just talked about. 564 00:17:03,320 --> 00:17:04,360 The other is 565 00:17:04,360 --> 00:17:05,800 the GDB Python API. 566 00:17:06,980 --> 00:17:07,500 Then, 567 00:17:07,640 --> 00:17:08,480 there is also 568 00:17:08,480 --> 00:17:10,160 some symbolic environment. 569 00:17:10,560 --> 00:17:10,980 That is to say, 570 00:17:11,040 --> 00:17:12,000 it can symbolize 571 00:17:12,000 --> 00:17:12,620 ARGB. 572 00:17:14,160 --> 00:17:14,680 Then, 573 00:17:14,780 --> 00:17:15,260 this is probably 574 00:17:15,260 --> 00:17:15,640 the outline. 575 00:17:17,140 --> 00:17:17,660 Then, 576 00:17:17,800 --> 00:17:19,020 let us first introduce 577 00:17:19,020 --> 00:17:19,480 what is 578 00:17:19,480 --> 00:17:21,820 the GDB Python API. 579 00:17:22,180 --> 00:17:22,620 In fact, 580 00:17:22,820 --> 00:17:23,780 the GDB 581 00:17:23,780 --> 00:17:24,840 Python API 582 00:17:24,840 --> 00:17:26,440 has very few files. 583 00:17:26,460 --> 00:17:27,200 This should be 584 00:17:27,200 --> 00:17:27,980 the best one 585 00:17:27,980 --> 00:17:28,180 you can find. 586 00:17:29,360 --> 00:17:29,880 Then, 587 00:17:30,540 --> 00:17:31,720 if you want to use 588 00:17:31,720 --> 00:17:32,540 the GDB Python API, 589 00:17:32,840 --> 00:17:33,260 you need to 590 00:17:33,600 --> 00:17:34,320 create a file 591 00:17:34,320 --> 00:17:34,580 called 592 00:17:35,800 --> 00:17:36,520 gdbinit. 593 00:17:36,580 --> 00:17:37,140 Then, 594 00:17:37,260 --> 00:17:37,660 you can 595 00:17:37,660 --> 00:17:38,240 source 596 00:17:38,240 --> 00:17:39,160 Python commands. 597 00:17:39,440 --> 00:17:40,780 What it can do 598 00:17:40,780 --> 00:17:41,600 is that 599 00:17:41,600 --> 00:17:43,540 you can register 600 00:17:43,540 --> 00:17:44,200 the commands 601 00:17:44,200 --> 00:17:46,180 written by 602 00:17:46,180 --> 00:17:46,800 or 603 00:17:47,620 --> 00:17:48,020 register 604 00:17:48,020 --> 00:17:49,120 event handler. 605 00:17:49,320 --> 00:17:49,900 Then, 606 00:17:50,020 --> 00:17:50,400 you can 607 00:17:50,400 --> 00:17:51,640 execute 608 00:17:51,640 --> 00:17:51,920 some 609 00:17:51,920 --> 00:17:52,780 GDB commands 610 00:17:52,780 --> 00:17:53,520 and get 611 00:17:53,520 --> 00:17:54,020 output. 612 00:17:54,340 --> 00:17:54,700 Then, 613 00:17:54,780 --> 00:17:54,940 you can 614 00:17:54,940 --> 00:17:55,040 come back. 615 00:17:55,120 --> 00:17:56,060 For example, 616 00:17:56,840 --> 00:17:57,160 you want to 617 00:17:57,160 --> 00:17:57,980 register 618 00:17:57,980 --> 00:17:58,400 all the 619 00:17:58,400 --> 00:17:58,820 words 620 00:17:58,820 --> 00:18:00,460 of the register. 621 00:18:01,320 --> 00:18:01,920 Then, 622 00:18:01,960 --> 00:18:03,640 you can execute 623 00:18:03,640 --> 00:18:04,280 info register 624 00:18:04,280 --> 00:18:04,780 all. 625 00:18:04,920 --> 00:18:05,280 Then, 626 00:18:05,340 --> 00:18:06,240 you can cut out 627 00:18:06,240 --> 00:18:06,660 what you want 628 00:18:06,660 --> 00:18:08,680 and throw it 629 00:18:08,680 --> 00:18:09,240 to your program 630 00:18:09,240 --> 00:18:09,940 to execute. 631 00:18:10,280 --> 00:18:11,020 Or, 632 00:18:11,020 --> 00:18:11,840 you can 633 00:18:11,840 --> 00:18:12,260 rewrite 634 00:18:12,260 --> 00:18:12,960 or search 635 00:18:12,960 --> 00:18:13,180 memory. 636 00:18:15,320 --> 00:18:16,800 This is 637 00:18:16,800 --> 00:18:17,060 a code 638 00:18:17,060 --> 00:18:17,580 in my project. 639 00:18:18,480 --> 00:18:19,640 I registered 640 00:18:19,640 --> 00:18:20,480 a command 641 00:18:20,480 --> 00:18:20,680 called 642 00:18:20,680 --> 00:18:21,160 treaten. 643 00:18:21,240 --> 00:18:21,700 So, 644 00:18:21,780 --> 00:18:22,880 you must create 645 00:18:22,880 --> 00:18:23,660 a class 646 00:18:23,660 --> 00:18:23,820 called 647 00:18:23,820 --> 00:18:24,280 treaten. 648 00:18:24,360 --> 00:18:25,640 When you 649 00:18:25,640 --> 00:18:25,780 type 650 00:18:25,780 --> 00:18:26,460 the command 651 00:18:26,460 --> 00:18:26,720 treaten, 652 00:18:26,720 --> 00:18:27,220 it will 653 00:18:27,220 --> 00:18:27,620 call 654 00:18:27,620 --> 00:18:28,120 invoke 655 00:18:28,120 --> 00:18:28,540 this 656 00:18:28,540 --> 00:18:28,940 message. 657 00:18:29,240 --> 00:18:30,040 I wrote 658 00:18:30,040 --> 00:18:31,440 symbolic 659 00:18:31,440 --> 00:18:32,080 class 660 00:18:32,080 --> 00:18:32,880 run 661 00:18:32,880 --> 00:18:33,320 message. 662 00:18:33,460 --> 00:18:34,020 It will execute. 663 00:18:34,540 --> 00:18:35,060 Then, 664 00:18:35,080 --> 00:18:35,400 you 665 00:18:35,400 --> 00:18:35,620 initialize 666 00:18:35,620 --> 00:18:36,000 treaten 667 00:18:36,000 --> 00:18:36,700 class. 668 00:18:37,780 --> 00:18:38,780 It will 669 00:18:38,780 --> 00:18:39,100 add 670 00:18:39,100 --> 00:18:39,780 a command 671 00:18:39,780 --> 00:18:40,280 treaten. 672 00:18:41,680 --> 00:18:42,480 Then, 673 00:18:42,580 --> 00:18:43,860 we can 674 00:18:43,860 --> 00:18:44,260 register 675 00:18:44,260 --> 00:18:44,600 the command 676 00:18:44,860 --> 00:18:45,440 For example, 677 00:18:45,440 --> 00:18:46,400 if the 678 00:18:46,400 --> 00:18:46,440 command 679 00:18:47,760 --> 00:18:48,400 treaten 680 00:18:48,400 --> 00:18:48,440 is 681 00:18:48,440 --> 00:18:48,480 not 682 00:18:48,480 --> 00:18:48,900 in 683 00:18:48,900 --> 00:18:49,040 the 684 00:18:49,040 --> 00:18:49,100 point, 685 00:18:49,300 --> 00:18:49,640 I will 686 00:18:49,640 --> 00:18:50,040 reset 687 00:18:50,040 --> 00:18:50,280 all 688 00:18:50,280 --> 00:18:50,640 the 689 00:18:50,640 --> 00:18:50,960 status. 690 00:18:51,180 --> 00:18:51,740 Like, 691 00:18:51,740 --> 00:18:52,400 gdb 692 00:18:52,400 --> 00:18:52,700 and 693 00:18:53,360 --> 00:18:54,000 arch. 694 00:18:56,740 --> 00:18:57,380 Or, 695 00:18:57,420 --> 00:18:58,440 we can 696 00:18:58,440 --> 00:18:58,780 get 697 00:18:58,780 --> 00:18:59,060 the 698 00:18:59,060 --> 00:18:59,420 stack 699 00:18:59,420 --> 00:18:59,820 star 700 00:18:59,820 --> 00:19:00,260 address. 701 00:19:00,740 --> 00:19:00,960 So, 702 00:19:03,500 --> 00:19:04,140 where 703 00:19:04,140 --> 00:19:04,480 does 704 00:19:04,480 --> 00:19:04,820 the stack 705 00:19:04,820 --> 00:19:05,160 start? 706 00:19:05,840 --> 00:19:06,580 We write 707 00:19:06,580 --> 00:19:07,360 info 708 00:19:07,360 --> 00:19:07,820 process 709 00:19:07,820 --> 00:19:08,280 all 710 00:19:08,280 --> 00:19:08,600 and 711 00:19:08,600 --> 00:19:09,040 use 712 00:19:10,620 --> 00:19:11,340 regular 713 00:19:11,340 --> 00:19:11,740 expression 714 00:19:11,740 --> 00:19:12,180 to 715 00:19:12,180 --> 00:19:12,420 cut 716 00:19:12,420 --> 00:19:12,740 the 717 00:19:12,740 --> 00:19:12,800 part 718 00:19:12,800 --> 00:19:13,520 want. 719 00:19:15,940 --> 00:19:16,660 Or, 720 00:19:16,740 --> 00:19:16,980 read 721 00:19:16,980 --> 00:19:17,320 memory. 722 00:19:18,980 --> 00:19:20,420 I wrote 723 00:19:20,420 --> 00:19:20,800 function 724 00:19:20,800 --> 00:19:21,060 game 725 00:19:21,060 --> 00:19:21,440 memory. 726 00:19:21,660 --> 00:19:22,440 It will 727 00:19:22,440 --> 00:19:22,560 eat 728 00:19:22,560 --> 00:19:22,780 two 729 00:19:22,780 --> 00:19:23,160 parameters. 730 00:19:23,320 --> 00:19:23,560 One is 731 00:19:23,560 --> 00:19:24,260 address, 732 00:19:34,140 --> 00:19:34,260 and 733 00:19:34,260 --> 00:19:35,060 the other is 734 00:19:35,320 --> 00:19:35,500 mainly 735 00:19:35,500 --> 00:19:35,740 used 736 00:19:35,740 --> 00:19:36,340 because 737 00:19:36,340 --> 00:19:37,440 it is 738 00:19:37,440 --> 00:19:37,560 a 739 00:19:37,560 --> 00:19:37,760 simple 740 00:19:37,760 --> 00:19:38,120 execution 741 00:19:38,120 --> 00:19:38,440 of 742 00:19:38,440 --> 00:19:38,760 parking. 743 00:19:38,980 --> 00:19:39,120 So, 744 00:19:39,200 --> 00:19:39,940 when 745 00:19:39,940 --> 00:19:40,140 I 746 00:19:40,140 --> 00:19:40,400 solve 747 00:19:40,400 --> 00:19:40,880 the 748 00:19:42,340 --> 00:19:42,940 memory 749 00:19:42,940 --> 00:19:43,280 value, 750 00:19:44,280 --> 00:19:45,480 I can 751 00:19:45,480 --> 00:19:46,280 write it 752 00:19:46,280 --> 00:19:46,500 back to 753 00:19:46,500 --> 00:19:46,920 gdb. 754 00:19:47,100 --> 00:19:47,700 Then, 755 00:19:47,780 --> 00:19:48,060 it can 756 00:19:48,060 --> 00:19:48,960 continue to execute 757 00:19:48,960 --> 00:19:49,820 and reach 758 00:19:49,820 --> 00:19:50,360 the path we want. 759 00:19:52,260 --> 00:19:53,460 In fact, 760 00:19:53,560 --> 00:19:53,920 at the beginning, 761 00:19:53,920 --> 00:19:55,080 I tried 762 00:19:55,080 --> 00:19:55,800 some methods, 763 00:19:55,920 --> 00:19:56,220 but I wrote 764 00:19:56,220 --> 00:19:56,580 it wrong. 765 00:19:56,640 --> 00:19:57,280 But I think 766 00:19:57,280 --> 00:19:58,220 it's worth 767 00:19:58,220 --> 00:19:58,680 talking about, 768 00:19:58,680 --> 00:19:59,060 so I'll 769 00:19:59,060 --> 00:20:00,400 share it with you. 770 00:20:01,000 --> 00:20:01,860 At the beginning, 771 00:20:02,040 --> 00:20:02,960 when I first 772 00:20:02,960 --> 00:20:03,040 started 773 00:20:03,040 --> 00:20:03,720 this project, 774 00:20:04,000 --> 00:20:05,620 it used 775 00:20:05,620 --> 00:20:06,480 pin 776 00:20:06,480 --> 00:20:07,460 support. 777 00:20:07,800 --> 00:20:08,220 So, 778 00:20:08,300 --> 00:20:08,520 it usually 779 00:20:08,520 --> 00:20:09,200 uses 780 00:20:09,200 --> 00:20:09,240 the 781 00:20:09,240 --> 00:20:09,560 pin 782 00:20:09,560 --> 00:20:10,740 tool. 783 00:20:11,980 --> 00:20:12,960 The way 784 00:20:12,960 --> 00:20:14,060 it uses 785 00:20:14,060 --> 00:20:14,740 it is 786 00:20:14,740 --> 00:20:15,080 that 787 00:20:15,080 --> 00:20:15,720 it will 788 00:20:15,720 --> 00:20:16,100 register 789 00:20:16,100 --> 00:20:16,300 two 790 00:20:16,300 --> 00:20:16,860 callbacks. 791 00:20:16,920 --> 00:20:17,760 The first 792 00:20:17,760 --> 00:20:18,240 callback is 793 00:20:18,240 --> 00:20:18,560 need 794 00:20:18,560 --> 00:20:18,840 concrete 795 00:20:18,840 --> 00:20:19,180 memory 796 00:20:19,180 --> 00:20:19,580 value. 797 00:20:19,820 --> 00:20:20,540 The second 798 00:20:20,540 --> 00:20:20,720 is 799 00:20:20,720 --> 00:20:21,100 need 800 00:20:21,100 --> 00:20:21,460 concrete 801 00:20:21,460 --> 00:20:22,120 register 802 00:20:22,120 --> 00:20:22,660 value. 803 00:20:22,960 --> 00:20:23,540 When it 804 00:20:25,140 --> 00:20:25,880 needs 805 00:20:25,880 --> 00:20:26,580 a 806 00:20:26,580 --> 00:20:27,280 memory 807 00:20:27,280 --> 00:20:27,760 or 808 00:20:27,760 --> 00:20:28,080 a 809 00:20:28,080 --> 00:20:28,560 register 810 00:20:28,560 --> 00:20:29,340 value, 811 00:20:29,960 --> 00:20:30,740 it will 812 00:20:30,740 --> 00:20:31,300 call this 813 00:20:31,300 --> 00:20:31,760 callback. 814 00:20:32,600 --> 00:20:33,180 In this 815 00:20:33,740 --> 00:20:34,260 callback, 816 00:20:34,420 --> 00:20:34,940 you have to 817 00:20:34,940 --> 00:20:35,580 write that 818 00:20:36,240 --> 00:20:37,020 you have to 819 00:20:37,020 --> 00:20:37,440 find a way 820 00:20:37,440 --> 00:20:37,760 to get 821 00:20:37,760 --> 00:20:37,940 your 822 00:20:37,940 --> 00:20:38,520 debugger 823 00:20:38,520 --> 00:20:38,680 or 824 00:20:38,680 --> 00:20:38,980 from 825 00:20:38,980 --> 00:20:39,320 your 826 00:20:39,320 --> 00:20:39,640 tracer 827 00:20:39,640 --> 00:20:39,960 to 828 00:20:39,960 --> 00:20:40,600 set 829 00:20:41,160 --> 00:20:41,680 to 830 00:20:41,680 --> 00:20:41,900 the 831 00:20:41,900 --> 00:20:41,980 context 832 00:20:41,980 --> 00:20:42,120 content 833 00:20:42,740 --> 00:20:43,580 so that 834 00:20:43,580 --> 00:20:43,820 it can 835 00:20:43,820 --> 00:20:44,280 execute 836 00:20:45,120 --> 00:20:45,640 this 837 00:20:45,640 --> 00:20:46,160 command correctly. 838 00:20:46,160 --> 00:20:47,220 For example, 839 00:20:47,280 --> 00:20:48,200 let's look at this. 840 00:20:48,320 --> 00:20:48,900 For example, 841 00:20:48,920 --> 00:20:49,540 move es 842 00:20:49,540 --> 00:20:50,080 is 5. 843 00:20:50,240 --> 00:20:50,620 Then, 844 00:20:50,700 --> 00:20:51,460 move ebs 845 00:20:51,460 --> 00:20:51,880 is 1. 846 00:20:52,160 --> 00:20:52,940 The second 847 00:20:52,940 --> 00:20:53,580 ebs 848 00:20:53,580 --> 00:20:54,080 is 1 849 00:20:54,080 --> 00:20:55,820 will trigger 850 00:20:55,820 --> 00:20:56,700 your callback 851 00:20:56,700 --> 00:20:57,260 because it 852 00:20:57,260 --> 00:20:57,680 needs 853 00:20:57,680 --> 00:20:58,260 the 854 00:20:58,260 --> 00:20:58,500 e s 855 00:20:58,500 --> 00:20:58,820 value. 856 00:20:59,920 --> 00:21:00,460 So, 857 00:21:00,460 --> 00:21:01,340 we need 858 00:21:01,340 --> 00:21:02,140 the e s 859 00:21:02,140 --> 00:21:02,600 value now. 860 00:21:02,860 --> 00:21:03,400 But, 861 00:21:03,540 --> 00:21:04,580 in fact, 862 00:21:04,680 --> 00:21:04,860 this is 863 00:21:04,860 --> 00:21:05,160 not used 864 00:21:05,160 --> 00:21:05,360 in gb. 865 00:21:06,780 --> 00:21:07,320 Because 866 00:21:07,320 --> 00:21:08,420 we can think 867 00:21:08,420 --> 00:21:08,560 that 868 00:21:16,160 --> 00:21:16,320 Triton 869 00:21:16,320 --> 00:21:16,480 has. 870 00:21:16,900 --> 00:21:17,740 So, 871 00:21:17,860 --> 00:21:19,160 we move 872 00:21:19,160 --> 00:21:19,720 ebs 873 00:21:19,720 --> 00:21:20,080 es. 874 00:21:20,600 --> 00:21:21,200 Now, 875 00:21:21,200 --> 00:21:22,140 Triton 876 00:21:22,140 --> 00:21:23,300 will take 877 00:21:23,300 --> 00:21:23,760 gdb. 878 00:21:24,300 --> 00:21:24,940 Because 879 00:21:24,940 --> 00:21:26,060 es 880 00:21:26,060 --> 00:21:26,600 is 5, 881 00:21:26,740 --> 00:21:27,500 gdb 882 00:21:27,500 --> 00:21:27,940 has executed 883 00:21:27,940 --> 00:21:28,120 it. 884 00:21:28,200 --> 00:21:28,300 So, 885 00:21:28,380 --> 00:21:29,120 it is 886 00:21:29,120 --> 00:21:30,120 correct 887 00:21:30,120 --> 00:21:31,100 to 888 00:21:41,740 --> 00:21:42,580 get 889 00:21:44,620 --> 00:21:45,460 the 890 00:21:45,460 --> 00:21:46,160 callback 891 00:21:46,160 --> 00:21:47,460 from gdb. 892 00:21:47,560 --> 00:21:47,920 So, 893 00:21:48,040 --> 00:21:48,140 we get 894 00:21:48,140 --> 00:21:48,540 5 895 00:21:48,540 --> 00:21:49,040 from gdb 896 00:21:49,040 --> 00:21:50,680 it did 897 00:21:50,680 --> 00:21:50,800 not 898 00:21:50,800 --> 00:21:50,960 run 899 00:21:50,960 --> 00:21:51,520 Triton. 900 00:21:52,640 --> 00:21:53,440 In fact, 901 00:21:53,440 --> 00:21:54,480 this is 902 00:21:54,480 --> 00:21:56,120 a way 903 00:21:56,120 --> 00:21:57,200 to 904 00:21:57,200 --> 00:21:58,080 solve 905 00:21:58,080 --> 00:21:58,720 this problem. 906 00:21:58,740 --> 00:21:59,020 For example, 907 00:22:00,340 --> 00:22:01,140 if 908 00:22:01,140 --> 00:22:01,900 I 909 00:22:01,900 --> 00:22:02,000 first 910 00:22:02,000 --> 00:22:02,760 check 911 00:22:02,760 --> 00:22:03,180 if 912 00:22:03,180 --> 00:22:03,640 Triton 913 00:22:03,640 --> 00:22:04,040 has 914 00:22:04,040 --> 00:22:04,380 this 915 00:22:04,380 --> 00:22:04,740 value, 916 00:22:04,820 --> 00:22:05,180 if 917 00:22:05,180 --> 00:22:05,400 there is 918 00:22:05,400 --> 00:22:05,880 this value, 919 00:22:06,000 --> 00:22:06,340 I will 920 00:22:06,340 --> 00:22:06,920 take it from Triton. 921 00:22:07,140 --> 00:22:07,720 If not, 922 00:22:07,920 --> 00:22:08,240 I will take it 923 00:22:08,240 --> 00:22:08,840 from gdb. 924 00:22:09,140 --> 00:22:09,520 Then, 925 00:22:09,540 --> 00:22:10,300 it should be 926 00:22:10,300 --> 00:22:10,460 correct. 927 00:22:11,160 --> 00:22:11,600 But, 928 00:22:11,740 --> 00:22:12,240 in fact, 929 00:22:12,900 --> 00:22:13,420 after test, 930 00:22:13,740 --> 00:22:15,280 it will 931 00:22:15,280 --> 00:22:15,540 enter 932 00:22:15,540 --> 00:22:17,240 an infinite loop. 933 00:22:17,620 --> 00:22:18,060 Because, 934 00:22:18,140 --> 00:22:18,300 for example, 935 00:22:18,420 --> 00:22:18,840 I keep 936 00:22:18,840 --> 00:22:19,500 asking Triton 937 00:22:19,500 --> 00:22:19,700 for the 938 00:22:20,260 --> 00:22:20,700 Triton 939 00:22:20,700 --> 00:22:21,220 will always 940 00:22:21,220 --> 00:22:21,520 trigger 941 00:22:21,520 --> 00:22:21,960 the callback. 942 00:22:22,020 --> 00:22:22,360 Then, 943 00:22:22,400 --> 00:22:23,040 the callback 944 00:22:23,040 --> 00:22:23,160 will 945 00:22:23,160 --> 00:22:23,420 keep 946 00:22:23,420 --> 00:22:24,300 following Triton. 947 00:22:24,520 --> 00:22:24,920 It will 948 00:22:24,920 --> 00:22:25,500 enter 949 00:22:25,500 --> 00:22:26,060 a loop. 950 00:22:26,980 --> 00:22:27,540 So, 951 00:22:27,560 --> 00:22:27,960 it is useless. 952 00:22:28,260 --> 00:22:28,660 Later, 953 00:22:28,860 --> 00:22:29,800 I thought of a way 954 00:22:29,800 --> 00:22:29,900 to 955 00:22:29,900 --> 00:22:31,020 copy all 956 00:22:31,020 --> 00:22:31,940 the gdb 957 00:22:31,940 --> 00:22:32,420 contents 958 00:22:32,420 --> 00:22:33,180 into 959 00:22:33,180 --> 00:22:34,020 Triton. 960 00:22:34,400 --> 00:22:35,240 It is better 961 00:22:37,600 --> 00:22:38,160 because 962 00:22:39,520 --> 00:22:40,080 Triton 963 00:22:40,080 --> 00:22:41,000 won't 964 00:22:41,000 --> 00:22:41,420 affect 965 00:22:42,320 --> 00:22:42,880 gdb 966 00:22:42,880 --> 00:22:43,420 because 967 00:22:43,420 --> 00:22:44,160 it doesn't 968 00:22:44,160 --> 00:22:44,300 need 969 00:22:44,300 --> 00:22:44,480 to run 970 00:22:44,480 --> 00:22:44,600 with it. 971 00:22:45,380 --> 00:22:45,940 Then, 972 00:22:47,120 --> 00:22:47,680 we 973 00:22:47,680 --> 00:22:47,940 can 974 00:22:47,940 --> 00:22:48,060 keep 975 00:22:49,380 --> 00:22:49,960 running 976 00:22:49,960 --> 00:22:50,040 without 977 00:22:50,040 --> 00:22:50,400 a port. 978 00:22:50,700 --> 00:22:51,540 It won't affect 979 00:22:51,540 --> 00:22:52,180 gdb. 980 00:22:52,840 --> 00:22:53,420 So, 981 00:22:53,520 --> 00:22:53,800 our 982 00:22:53,800 --> 00:22:54,020 for 983 00:22:54,020 --> 00:22:54,920 is more like 984 00:22:54,920 --> 00:22:56,560 we get 985 00:22:56,560 --> 00:22:57,940 the state 986 00:22:57,940 --> 00:22:58,320 of gdb 987 00:22:58,420 --> 00:22:59,000 Then, 988 00:22:59,140 --> 00:22:59,480 we 989 00:22:59,480 --> 00:22:59,540 use 990 00:22:59,540 --> 00:23:00,360 gdb 991 00:23:00,360 --> 00:23:00,840 Python API 992 00:23:00,840 --> 00:23:01,240 to get 993 00:23:01,240 --> 00:23:02,280 the state. 994 00:23:02,720 --> 00:23:03,140 Then, 995 00:23:03,180 --> 00:23:03,540 we 996 00:23:03,540 --> 00:23:03,820 give 997 00:23:03,820 --> 00:23:03,980 this 998 00:23:03,980 --> 00:23:05,200 to Triton. 999 00:23:05,360 --> 00:23:05,940 Then, 1000 00:23:06,040 --> 00:23:06,420 we set 1001 00:23:06,420 --> 00:23:06,840 the 1002 00:23:07,680 --> 00:23:08,240 value 1003 00:23:08,240 --> 00:23:09,840 so that 1004 00:23:11,300 --> 00:23:11,600 we can 1005 00:23:11,600 --> 00:23:12,620 target 1006 00:23:12,620 --> 00:23:12,900 edge 1007 00:23:12,900 --> 00:23:13,060 of 1008 00:23:13,060 --> 00:23:13,280 the다고 1009 00:23:13,280 --> 00:23:13,420 level 1010 00:23:13,420 --> 00:23:13,640 to 1011 00:23:13,640 --> 00:23:13,920 ensure 1012 00:23:13,920 --> 00:23:14,660 that 1013 00:23:16,280 --> 00:23:16,840 Triton 1014 00:23:16,840 --> 00:23:18,100 is across the 1015 00:23:34,120 --> 00:23:34,680 gdb 1016 00:23:34,680 --> 00:23:34,700 database 1017 00:23:34,700 --> 00:23:35,180 as 1018 00:23:36,840 --> 00:23:39,200 Because I divided it into three classes when I was working on it. 1019 00:23:39,600 --> 00:23:41,020 The first class is Arch. 1020 00:23:41,940 --> 00:23:46,840 Because Triton supports x86 and x864, 1021 00:23:47,200 --> 00:23:49,880 so when you use two different structures, 1022 00:23:50,200 --> 00:23:52,780 the size of your pointer and the name of your register will be different. 1023 00:23:53,340 --> 00:23:54,440 So that's why we have Arch. 1024 00:23:54,820 --> 00:24:00,500 And GDB Util means that I write some convenient functions 1025 00:24:00,500 --> 00:24:01,700 that allow me to get to the state of GDB. 1026 00:24:01,700 --> 00:24:08,180 With Symbiotic, I will call Triton 1027 00:24:08,180 --> 00:24:10,860 to get my answer, 1028 00:24:11,100 --> 00:24:12,980 to get the answer, 1029 00:24:13,220 --> 00:24:14,440 and give it a set of controls. 1030 00:24:15,880 --> 00:24:17,320 That's about it. 1031 00:24:20,080 --> 00:24:23,820 Some of the instructions I designed are 1032 00:24:23,820 --> 00:24:30,020 Symbolize can mark a certain memory or ARGB 1033 00:24:30,020 --> 00:24:31,680 as a symbol. 1034 00:24:33,640 --> 00:24:37,460 Target is to specify a location I want to go to. 1035 00:24:37,460 --> 00:24:39,720 Then I can set this location. 1036 00:24:40,300 --> 00:24:43,160 Triton is to execute Symbolic Execution directly. 1037 00:24:43,360 --> 00:24:48,280 Answer and Debug are more like the instructions I use when I'm doing my homework. 1038 00:24:52,060 --> 00:24:55,100 So at the beginning, I called info.register 1039 00:24:55,100 --> 00:24:56,620 to get all the registers, 1040 00:24:56,980 --> 00:24:59,300 and readMemory to get its segment. 1041 00:24:59,540 --> 00:25:01,680 Then I set these with set.register. 1042 00:25:01,680 --> 00:25:06,120 Set the position of Triton. 1043 00:25:07,200 --> 00:25:13,000 Then I will call isRegister.Symbolize 1044 00:25:13,000 --> 00:25:16,660 to confirm if I can get the PC address or not. 1045 00:25:16,660 --> 00:25:17,320 If I can get it, 1046 00:25:17,440 --> 00:25:22,920 I'll try to find the input on which address I need. 1047 00:25:23,340 --> 00:25:27,160 Then I set the target address to a contain. 1048 00:25:27,460 --> 00:25:29,960 Finally, I'll call getModel to get the answer. 1049 00:25:29,960 --> 00:25:32,760 and then write it back into the GDB using writeMemory. 1050 00:25:34,460 --> 00:25:37,180 In fact, one of its functions is quite simple. 1051 00:25:37,360 --> 00:25:40,200 For example, if you want to symbolize ARGB parameters, 1052 00:25:41,660 --> 00:25:45,100 you just need to call info.processO 1053 00:25:45,100 --> 00:25:49,060 to get the starting position of the stack. 1054 00:25:49,860 --> 00:25:51,080 From that starting position, 1055 00:25:51,300 --> 00:25:55,980 it will be ARGC, ARGV1, ARGB0, ARGV1, 1056 00:25:56,060 --> 00:25:57,020 and then an array like this. 1057 00:25:57,020 --> 00:25:59,080 Finally, add a null terminator, 1058 00:25:59,240 --> 00:26:01,280 and then your environment variables, 1059 00:26:01,460 --> 00:26:02,600 and then add a null terminator. 1060 00:26:02,720 --> 00:26:05,180 So you can easily get the position of ARGB0. 1061 00:26:06,960 --> 00:26:11,140 When I debug, I will use... 1062 00:26:11,140 --> 00:26:13,260 It actually has a function that is not bad. 1063 00:26:13,280 --> 00:26:17,560 It can simplify your ASC expression. 1064 00:26:17,940 --> 00:26:19,460 Let's look at the first one. 1065 00:26:19,740 --> 00:26:21,900 It says bigVector is all, 1066 00:26:22,140 --> 00:26:25,160 and bigVector value is 1, 1067 00:26:25,300 --> 00:26:26,900 and the value at the back is also 1. 1068 00:26:27,020 --> 00:26:29,160 So both are 1's SO, 1069 00:26:29,460 --> 00:26:30,060 and it will be 0. 1070 00:26:30,320 --> 00:26:32,660 So the next one it simplifies will be bigVector value. 1071 00:26:32,940 --> 00:26:34,260 It will be directly 0. 1072 00:26:34,820 --> 00:26:36,960 That is to say, I often... 1073 00:26:37,540 --> 00:26:39,380 At the beginning, when the program doesn't move, 1074 00:26:39,580 --> 00:26:41,620 I will look at each node, 1075 00:26:41,700 --> 00:26:43,120 to see which line of index is wrong, 1076 00:26:43,240 --> 00:26:43,860 or it didn't run. 1077 00:26:44,160 --> 00:26:45,920 It will be quite useful at this time. 1078 00:26:48,700 --> 00:26:50,320 Next is a demo. 1079 00:26:51,360 --> 00:26:52,640 There will be two demos. 1080 00:26:54,460 --> 00:26:56,800 The first example is QuakeHash. 1081 00:26:57,500 --> 00:27:00,460 This is an example from another project. 1082 00:27:04,740 --> 00:27:11,340 It will pass ARGB1 to the check function. 1083 00:27:12,060 --> 00:27:13,260 In the check function, 1084 00:27:13,460 --> 00:27:16,040 if its SO is serial, 1085 00:27:16,220 --> 00:27:17,700 which is a fixed string, 1086 00:27:18,020 --> 00:27:21,600 and if the added value is 0xABCD, 1087 00:27:21,960 --> 00:27:22,840 it will print win. 1088 00:27:23,060 --> 00:27:24,460 Otherwise, it will print fail. 1089 00:27:24,740 --> 00:27:26,500 This is the whole code. 1090 00:27:28,220 --> 00:27:30,500 Then we need to reach this point, 1091 00:27:30,580 --> 00:27:36,000 which is 0x80484B1. 1092 00:27:36,100 --> 00:27:37,600 This is the point we want to reach. 1093 00:27:39,700 --> 00:27:41,060 Please help me to show it. 1094 00:27:41,320 --> 00:27:41,680 Thank you. 1095 00:27:42,200 --> 00:27:45,380 Now we will use GDB 1096 00:27:45,380 --> 00:27:46,440 to import this program. 1097 00:27:49,200 --> 00:27:51,020 First, we break it in main. 1098 00:27:54,360 --> 00:27:57,000 Then we set ARGB1 directly. 1099 00:27:57,000 --> 00:27:58,180 Then we use GDB to symbolize. 1100 00:27:58,240 --> 00:27:59,200 It is symbolic. 1101 00:27:59,580 --> 00:28:02,240 Then we set the location we want to reach, 1102 00:28:03,340 --> 00:28:04,300 which is the target. 1103 00:28:06,980 --> 00:28:09,280 Then we execute the command gdb. 1104 00:28:10,440 --> 00:28:11,760 Then we call treatment. 1105 00:28:12,140 --> 00:28:13,640 It will help us to solve the answer. 1106 00:28:13,800 --> 00:28:15,980 Finally, it asks if we want to 1107 00:28:16,760 --> 00:28:18,040 inject it back to gdb. 1108 00:28:18,320 --> 00:28:20,300 Then we write yes. 1109 00:28:20,500 --> 00:28:21,920 Then we continue to execute. 1110 00:28:22,120 --> 00:28:23,100 It will print win. 1111 00:28:23,100 --> 00:28:23,180 Then we print win. 1112 00:28:25,040 --> 00:28:28,740 Next, this example is Crayme SO. 1113 00:28:29,020 --> 00:28:29,820 It is also used by others. 1114 00:28:31,200 --> 00:28:32,360 It is the same. 1115 00:28:32,440 --> 00:28:33,320 It will take this from ARGB 1116 00:28:33,320 --> 00:28:37,640 and throw it to the check function. 1117 00:28:38,080 --> 00:28:41,340 It will put every word as SO 0x55. 1118 00:28:42,080 --> 00:28:46,120 If it does not match the SO result 1119 00:28:46,120 --> 00:28:47,640 and the fixed character, 1120 00:28:48,520 --> 00:28:49,400 it will write 1 1121 00:28:49,400 --> 00:28:51,360 and print fail. 1122 00:28:51,360 --> 00:28:53,240 Otherwise, it will go to the next loop. 1123 00:28:53,480 --> 00:28:56,840 So, we have to pass through each loop 1124 00:28:56,840 --> 00:28:59,280 to reach the final return 0. 1125 00:28:59,560 --> 00:29:00,400 Print win. 1126 00:29:01,760 --> 00:29:03,040 This is the code. 1127 00:29:06,200 --> 00:29:09,440 So, we have to find out 1128 00:29:09,440 --> 00:29:10,860 in each loop, 1129 00:29:11,140 --> 00:29:13,700 it will judge where the command is. 1130 00:29:14,280 --> 00:29:17,840 This is the location 08048447. 1131 00:29:18,660 --> 00:29:19,260 Okay. 1132 00:29:19,340 --> 00:29:20,040 Please help me. 1133 00:29:21,680 --> 00:29:23,160 So, the same gdb 1134 00:29:23,160 --> 00:29:23,940 will import it in. 1135 00:29:24,640 --> 00:29:26,180 Then we break it in main. 1136 00:29:27,260 --> 00:29:28,840 Then we also break it in the 1137 00:29:29,140 --> 00:29:30,500 setting of the judgment just now. 1138 00:29:34,460 --> 00:29:36,400 Then we set that 1139 00:29:36,400 --> 00:29:38,560 our ARGB is symbolic. 1140 00:29:39,300 --> 00:29:40,940 Then we specify 1141 00:29:40,940 --> 00:29:42,260 where our target address is. 1142 00:29:44,820 --> 00:29:46,020 Then we start to execute. 1143 00:29:47,000 --> 00:29:47,900 Because when we execute, 1144 00:29:48,180 --> 00:29:49,520 it is actually good to just pass it randomly. 1145 00:29:49,520 --> 00:29:51,700 Anyway, the last symbolic execution 1146 00:29:51,700 --> 00:29:52,860 will help us to finish the calculation. 1147 00:29:52,880 --> 00:29:53,520 Then when you 1148 00:29:55,220 --> 00:29:56,900 inject back to the gdb, 1149 00:29:57,260 --> 00:29:58,780 just kill the original calculation. 1150 00:30:01,280 --> 00:30:02,700 Now it is slowly 1151 00:30:02,700 --> 00:30:03,020 slowly 1152 00:30:03,020 --> 00:30:04,660 solving its loop. 1153 00:30:05,940 --> 00:30:07,420 Because it is a loop, 1154 00:30:07,620 --> 00:30:08,740 you have to solve it one by one. 1155 00:30:15,900 --> 00:30:16,900 Then finally, 1156 00:30:17,060 --> 00:30:18,760 because we all inject back to the original state, 1157 00:30:18,760 --> 00:30:20,400 so when you go to continue, 1158 00:30:20,880 --> 00:30:21,720 when you come back from non-payment, 1159 00:30:22,340 --> 00:30:24,100 then your value will be correct. 1160 00:30:28,200 --> 00:30:28,720 Yes. 1161 00:30:33,660 --> 00:30:35,120 Finally, the word win will be printed. 1162 00:30:37,680 --> 00:30:38,200 Okay. 1163 00:30:38,860 --> 00:30:39,560 In fact, 1164 00:30:39,680 --> 00:30:40,880 most of the time when I write, 1165 00:30:41,140 --> 00:30:42,800 I will write gdb comment. 1166 00:30:43,040 --> 00:30:45,980 I don't know if everyone knows this. 1167 00:30:46,800 --> 00:30:48,040 I will tell you. 1168 00:30:48,560 --> 00:30:50,260 gdb has a function called gdb comment. 1169 00:30:50,440 --> 00:30:50,600 That is, 1170 00:30:50,740 --> 00:30:52,240 you save the comment you want to execute. 1171 00:30:54,200 --> 00:30:55,560 Then it can directly 1172 00:30:55,560 --> 00:30:57,540 be saved in a text file. 1173 00:30:57,740 --> 00:30:58,880 It can read it directly 1174 00:30:58,880 --> 00:30:59,480 and help you run. 1175 00:30:59,560 --> 00:31:00,600 This is very convenient. 1176 00:31:00,720 --> 00:31:01,480 Because I am... 1177 00:31:01,880 --> 00:31:02,660 Can you help me play it? 1178 00:31:03,320 --> 00:31:04,200 Because I am... 1179 00:31:04,800 --> 00:31:05,780 When I am testing, 1180 00:31:06,160 --> 00:31:06,940 it is very troublesome if I keep losing. 1181 00:31:07,540 --> 00:31:09,700 So you can write the comment first. 1182 00:31:10,060 --> 00:31:11,400 When you press it, 1183 00:31:11,500 --> 00:31:12,720 it will help you run it all. 1184 00:31:16,320 --> 00:31:16,720 Yes. 1185 00:31:16,720 --> 00:31:17,560 Probably like this. 1186 00:31:19,680 --> 00:31:20,480 Like this, 1187 00:31:20,620 --> 00:31:21,740 I just have to judge that 1188 00:31:22,500 --> 00:31:23,780 it interacts with me. 1189 00:31:24,020 --> 00:31:24,260 That is, 1190 00:31:24,380 --> 00:31:26,100 it asks me to go back to gdb. 1191 00:31:26,740 --> 00:31:27,700 Other instructions are 1192 00:31:27,700 --> 00:31:29,320 to read from that file. 1193 00:31:29,800 --> 00:31:30,680 I don't have to lose. 1194 00:31:32,360 --> 00:31:32,760 Then, 1195 00:31:33,260 --> 00:31:35,960 the next demo is 1196 00:31:35,960 --> 00:31:39,060 I can combine other gdb plugins. 1197 00:31:39,440 --> 00:31:39,620 Like, 1198 00:31:40,420 --> 00:31:41,740 I don't know if you have heard of 1199 00:31:41,740 --> 00:31:43,560 a gdb plugin. 1200 00:31:43,720 --> 00:31:43,960 It is quite famous. 1201 00:31:44,100 --> 00:31:44,700 It is called payda. 1202 00:31:44,860 --> 00:31:45,060 That is, 1203 00:31:46,720 --> 00:31:48,400 it has some very useful gdb functions 1204 00:31:50,460 --> 00:31:53,400 so that you can use its comment. 1205 00:31:54,740 --> 00:31:55,340 So, 1206 00:31:55,540 --> 00:31:57,160 this is the same demo as just now. 1207 00:31:57,360 --> 00:31:59,320 But what is different is that 1208 00:32:00,380 --> 00:32:01,620 we just used 1209 00:32:01,620 --> 00:32:04,660 the method I wrote 1210 00:32:04,660 --> 00:32:07,520 to find the position of argb directly. 1211 00:32:07,520 --> 00:32:08,260 But in fact, 1212 00:32:08,360 --> 00:32:10,060 we can give a paper first. 1213 00:32:10,060 --> 00:32:10,440 Then, 1214 00:32:10,540 --> 00:32:12,580 after finding this paper in the memory, 1215 00:32:12,580 --> 00:32:13,600 we can mark that memory 1216 00:32:14,220 --> 00:32:15,320 as symbolic. 1217 00:32:15,900 --> 00:32:16,260 Then, 1218 00:32:16,360 --> 00:32:17,180 we can execute it. 1219 00:32:17,460 --> 00:32:18,200 You can play it for me. 1220 00:32:20,700 --> 00:32:21,060 So, 1221 00:32:21,140 --> 00:32:21,800 this time, 1222 00:32:21,900 --> 00:32:23,700 we won't symbolize argb directly. 1223 00:32:26,800 --> 00:32:28,160 The string above is 1224 00:32:28,160 --> 00:32:28,560 the thing of payda. 1225 00:32:31,180 --> 00:32:32,140 It is quite convenient. 1226 00:32:32,380 --> 00:32:33,220 It will help you to 1227 00:32:33,760 --> 00:32:34,480 print the state of your CPU 1228 00:32:34,480 --> 00:32:35,420 when you don't want to break it. 1229 00:32:37,900 --> 00:32:38,260 Then, 1230 00:32:38,320 --> 00:32:39,060 you can execute it to 1231 00:32:39,060 --> 00:32:39,620 which assembly. 1232 00:32:41,540 --> 00:32:42,060 In fact, 1233 00:32:42,160 --> 00:32:43,260 we just give five a. 1234 00:32:43,560 --> 00:32:43,920 Then, 1235 00:32:43,920 --> 00:32:44,820 after that, 1236 00:32:44,900 --> 00:32:45,200 we will 1237 00:32:47,900 --> 00:32:49,340 find the position 1238 00:32:49,340 --> 00:32:49,660 in the memory 1239 00:32:49,660 --> 00:32:50,380 in payda 1240 00:32:50,500 --> 00:32:50,940 Then, 1241 00:32:50,980 --> 00:32:51,640 we know this position. 1242 00:32:51,980 --> 00:32:52,420 Then, 1243 00:32:52,500 --> 00:32:53,500 we set this 5-byte 1244 00:32:53,500 --> 00:32:54,640 to symbolic. 1245 00:32:55,140 --> 00:32:55,580 Then, 1246 00:32:55,620 --> 00:32:56,660 the other demos 1247 00:32:56,660 --> 00:32:57,480 are the same as before. 1248 00:33:01,960 --> 00:33:02,400 So, 1249 00:33:02,600 --> 00:33:04,080 some conclusions are that 1250 00:33:04,080 --> 00:33:04,780 in fact, 1251 00:33:04,920 --> 00:33:07,140 we use gdb debugger 1252 00:33:07,140 --> 00:33:09,160 to provide some basic information. 1253 00:33:09,440 --> 00:33:09,880 So, 1254 00:33:09,920 --> 00:33:11,440 we can save a lot of parts 1255 00:33:11,440 --> 00:33:12,100 to make it easier 1256 00:33:12,640 --> 00:33:13,000 for everyone 1257 00:33:13,000 --> 00:33:13,900 to use it. 1258 00:33:13,920 --> 00:33:14,280 this tool. 1259 00:33:14,580 --> 00:33:15,400 We can use 1260 00:33:15,400 --> 00:33:16,520 this tool. 1261 00:33:17,940 --> 00:33:18,420 Then, 1262 00:33:18,580 --> 00:33:19,960 one of the advantages is that 1263 00:33:19,960 --> 00:33:21,380 it is independent. 1264 00:33:21,800 --> 00:33:22,200 That is to say, 1265 00:33:22,240 --> 00:33:23,620 when you call this tool, 1266 00:33:23,840 --> 00:33:24,600 you won't be affected 1267 00:33:24,600 --> 00:33:25,020 by the state of execution 1268 00:33:25,020 --> 00:33:25,420 of the original gdb. 1269 00:33:27,020 --> 00:33:27,500 Unless, 1270 00:33:27,660 --> 00:33:30,080 you want to return gdb 1271 00:33:30,080 --> 00:33:30,160 indirectly, 1272 00:33:30,160 --> 00:33:31,780 you will change 1273 00:33:31,780 --> 00:33:32,300 the original answer 1274 00:33:32,300 --> 00:33:33,740 to the correct one. 1275 00:33:35,360 --> 00:33:35,840 And, 1276 00:33:35,840 --> 00:33:36,860 it has an advantage. 1277 00:33:37,040 --> 00:33:37,540 It can do 1278 00:33:37,540 --> 00:33:38,280 concali execution. 1279 00:33:38,960 --> 00:33:39,620 What is 1280 00:33:39,620 --> 00:33:40,360 concali execution? 1281 00:33:40,880 --> 00:33:41,660 Concali is 1282 00:33:41,660 --> 00:33:42,860 a combination word. 1283 00:33:42,940 --> 00:33:43,440 It is 1284 00:33:43,440 --> 00:33:43,900 concali 1285 00:33:43,900 --> 00:33:45,760 plus symbolic execution. 1286 00:33:46,920 --> 00:33:47,880 It uses 1287 00:33:49,200 --> 00:33:50,380 symbolic variable 1288 00:33:50,380 --> 00:33:51,720 and concrete value 1289 00:33:51,720 --> 00:33:52,020 at the same time. 1290 00:33:52,100 --> 00:33:52,780 Because, 1291 00:33:52,900 --> 00:33:53,680 in fact, 1292 00:33:53,780 --> 00:33:54,140 this advantage 1293 00:33:54,140 --> 00:33:54,440 is that 1294 00:33:54,440 --> 00:33:55,340 it is very fast. 1295 00:33:55,560 --> 00:33:56,040 Because, 1296 00:33:56,900 --> 00:33:57,980 if it is 1297 00:33:57,980 --> 00:33:58,200 before, 1298 00:33:58,940 --> 00:33:59,740 according to 1299 00:33:59,740 --> 00:34:00,040 the previous 1300 00:34:00,040 --> 00:34:00,380 semantic, 1301 00:34:00,940 --> 00:34:02,160 it will 1302 00:34:02,160 --> 00:34:02,560 predict 1303 00:34:02,560 --> 00:34:03,420 your 1304 00:34:07,420 --> 00:34:08,100 eip 1305 00:34:08,100 --> 00:34:08,380 or 1306 00:34:08,380 --> 00:34:08,900 rip 1307 00:34:08,900 --> 00:34:09,440 according to 1308 00:34:09,440 --> 00:34:09,920 But, 1309 00:34:10,020 --> 00:34:10,580 if it is 1310 00:34:13,900 --> 00:34:14,180 before, 1311 00:34:14,440 --> 00:34:14,940 you won't be wrong. 1312 00:34:15,160 --> 00:34:15,860 You will be able 1313 00:34:15,860 --> 00:34:16,300 to simulate 1314 00:34:16,300 --> 00:34:16,700 the real 1315 00:34:17,180 --> 00:34:17,620 environment 1316 00:34:17,620 --> 00:34:18,340 and 1317 00:34:18,340 --> 00:34:19,500 throw it 1318 00:34:19,500 --> 00:34:19,820 to it. 1319 00:34:21,260 --> 00:34:21,700 So, 1320 00:34:21,700 --> 00:34:22,580 you don't need 1321 00:34:22,580 --> 00:34:23,420 to worry 1322 00:34:23,420 --> 00:34:23,900 that the state 1323 00:34:23,900 --> 00:34:23,980 of the real 1324 00:34:23,980 --> 00:34:24,500 CPU 1325 00:34:24,960 --> 00:34:25,780 will be different. 1326 00:34:26,300 --> 00:34:26,740 Because, 1327 00:34:26,760 --> 00:34:26,980 in fact, 1328 00:34:28,220 --> 00:34:28,720 it is very troublesome 1329 00:34:28,720 --> 00:34:28,840 to write 1330 00:34:28,840 --> 00:34:29,680 the semantic 1331 00:34:29,680 --> 00:34:29,900 interaction. 1332 00:34:33,020 --> 00:34:33,460 Because, 1333 00:34:33,500 --> 00:34:34,140 you have to guarantee 1334 00:34:34,140 --> 00:34:34,620 that 1335 00:34:34,620 --> 00:34:36,040 every semantic 1336 00:34:36,760 --> 00:34:37,200 of your interaction 1337 00:34:37,200 --> 00:34:37,600 is correct. 1338 00:34:43,900 --> 00:34:44,360 Okay, 1339 00:34:44,670 --> 00:34:45,420 some drawbacks. 1340 00:34:47,040 --> 00:34:47,580 Triton's 1341 00:34:47,580 --> 00:34:48,180 drawbacks. 1342 00:34:48,300 --> 00:34:48,900 In fact, 1343 00:34:49,520 --> 00:34:50,700 it doesn't support 1344 00:34:50,700 --> 00:34:51,560 GNU C library. 1345 00:34:51,940 --> 00:34:52,180 It is 1346 00:34:52,180 --> 00:34:52,900 what we usually use, 1347 00:34:53,120 --> 00:34:53,400 for example, 1348 00:34:53,480 --> 00:34:54,100 scanf, 1349 00:34:54,240 --> 00:34:55,100 read, 1350 00:34:55,220 --> 00:34:56,140 some function code. 1351 00:34:56,280 --> 00:34:56,900 It doesn't support it. 1352 00:34:57,000 --> 00:34:57,680 In fact, 1353 00:34:57,800 --> 00:34:58,000 why? 1354 00:34:58,200 --> 00:34:58,480 Because, 1355 00:34:58,520 --> 00:34:59,640 its semantic 1356 00:34:59,640 --> 00:35:00,800 actually only supports 1357 00:35:00,800 --> 00:35:01,180 some 1358 00:35:01,180 --> 00:35:02,580 on this network, 1359 00:35:02,900 --> 00:35:03,780 on this link, 1360 00:35:04,120 --> 00:35:04,320 there are 1361 00:35:04,320 --> 00:35:06,560 its support指令列表. 1362 00:35:06,900 --> 00:35:09,320 If you need to support 1363 00:35:09,320 --> 00:35:09,900 GNU C 1364 00:35:09,900 --> 00:35:10,200 library, 1365 00:35:10,540 --> 00:35:11,260 you must support 1366 00:35:13,900 --> 00:35:14,140 interop. 1367 00:35:14,180 --> 00:35:14,620 It is a 1368 00:35:14,620 --> 00:35:16,840 code system code指令. 1369 00:35:17,100 --> 00:35:17,900 Because, most 1370 00:35:18,640 --> 00:35:18,860 of the 1371 00:35:18,860 --> 00:35:19,760 library code will use 1372 00:35:19,760 --> 00:35:20,860 system code. 1373 00:35:21,000 --> 00:35:21,300 So, you 1374 00:35:21,300 --> 00:35:21,900 must support 1375 00:35:21,900 --> 00:35:22,400 this指令. 1376 00:35:22,540 --> 00:35:22,960 Then, you can 1377 00:35:22,960 --> 00:35:24,880 support GNU 1378 00:35:24,880 --> 00:35:25,280 C library. 1379 00:35:27,000 --> 00:35:28,680 Then, you have to 1380 00:35:28,680 --> 00:35:29,300 make your 1381 00:35:29,300 --> 00:35:32,100 own path choices. 1382 00:35:32,480 --> 00:35:32,920 Because, 1383 00:35:32,980 --> 00:35:33,280 like the 1384 00:35:33,280 --> 00:35:33,720 loop 1385 00:35:33,720 --> 00:35:33,940 just now, 1386 00:35:34,000 --> 00:35:34,560 the loop 1387 00:35:34,560 --> 00:35:35,020 that goes five 1388 00:35:35,020 --> 00:35:36,800 layers you have 1389 00:35:36,800 --> 00:35:37,460 to go 1390 00:35:37,460 --> 00:35:37,980 to that 1391 00:35:37,980 --> 00:35:38,660 loop and 1392 00:35:38,660 --> 00:35:40,480 make path choices. 1393 00:35:44,780 --> 00:35:45,100 Now, 1394 00:35:45,500 --> 00:35:46,120 let's compare 1395 00:35:46,120 --> 00:35:47,360 using 1396 00:35:48,200 --> 00:35:48,840 Triton 1397 00:35:48,840 --> 00:35:49,820 to compare 1398 00:35:49,820 --> 00:35:50,300 other 1399 00:35:50,780 --> 00:35:51,420 Symbiotic Execution 1400 00:35:51,420 --> 00:35:51,860 framework. 1401 00:35:52,500 --> 00:35:53,760 There are two 1402 00:35:53,760 --> 00:35:53,880 to compare. 1403 00:35:53,880 --> 00:35:54,340 The first one is 1404 00:35:54,340 --> 00:35:55,000 Klee. 1405 00:35:55,140 --> 00:35:55,720 The other one is 1406 00:35:55,720 --> 00:35:56,260 Anger. 1407 00:35:57,100 --> 00:35:57,980 Klee is 1408 00:35:57,980 --> 00:35:58,220 a 1409 00:35:58,220 --> 00:35:59,000 Symbiotic 1410 00:35:59,000 --> 00:36:00,620 LLVM Compiler. 1411 00:36:04,380 --> 00:36:05,140 This is 1412 00:36:05,140 --> 00:36:05,940 its website 1413 00:36:05,940 --> 00:36:06,240 and 1414 00:36:06,240 --> 00:36:06,880 its GitHub. 1415 00:36:07,420 --> 00:36:08,460 In fact, 1416 00:36:08,540 --> 00:36:09,080 if you are 1417 00:36:09,080 --> 00:36:09,940 interested 1418 00:36:09,940 --> 00:36:11,100 in Klee's project, 1419 00:36:11,680 --> 00:36:12,300 you can read 1420 00:36:12,300 --> 00:36:12,980 this paper. 1421 00:36:13,560 --> 00:36:14,160 Actually, 1422 00:36:14,160 --> 00:36:14,300 there are 1423 00:36:14,300 --> 00:36:14,660 only a few. 1424 00:36:14,740 --> 00:36:15,000 But, 1425 00:36:15,020 --> 00:36:15,860 most of them 1426 00:36:15,860 --> 00:36:16,840 talk about 1427 00:36:16,840 --> 00:36:17,380 how Klee 1428 00:36:17,380 --> 00:36:18,280 works in 1429 00:36:18,280 --> 00:36:18,620 desktop. 1430 00:36:20,300 --> 00:36:20,900 And, 1431 00:36:21,000 --> 00:36:21,200 what is its 1432 00:36:21,200 --> 00:36:21,420 function. 1433 00:36:22,360 --> 00:36:23,280 The main 1434 00:36:23,280 --> 00:36:24,180 purpose of Klee 1435 00:36:24,180 --> 00:36:25,640 is that 1436 00:36:25,640 --> 00:36:26,400 it wants 1437 00:36:26,400 --> 00:36:26,560 to 1438 00:36:27,440 --> 00:36:28,040 meet 1439 00:36:28,040 --> 00:36:28,280 the 1440 00:36:28,960 --> 00:36:29,840 code coverage 1441 00:36:29,840 --> 00:36:30,220 rate 1442 00:36:30,220 --> 00:36:30,680 as high as 1443 00:36:31,840 --> 00:36:32,440 possible. 1444 00:36:32,480 --> 00:36:32,860 That is, 1445 00:36:32,960 --> 00:36:33,380 it wants 1446 00:36:33,380 --> 00:36:34,560 every place 1447 00:36:34,560 --> 00:36:34,760 in the city 1448 00:36:34,760 --> 00:36:35,400 to be executed. 1449 00:36:35,860 --> 00:36:36,300 And, 1450 00:36:36,420 --> 00:36:37,340 it also wants 1451 00:36:37,340 --> 00:36:38,160 to detect 1452 00:36:38,980 --> 00:36:39,500 which 1453 00:36:41,240 --> 00:36:41,760 calculations 1454 00:36:41,760 --> 00:36:42,340 are dangerous. 1455 00:36:42,620 --> 00:36:42,840 For example, 1456 00:36:42,940 --> 00:36:43,800 the number 1457 00:36:43,800 --> 00:36:43,940 minus zero. 1458 00:36:44,380 --> 00:36:44,980 For example, 1459 00:36:45,220 --> 00:36:45,460 the number 1460 00:36:45,460 --> 00:36:46,220 minus zero 1461 00:36:46,220 --> 00:36:47,800 is dangerous 1462 00:36:47,800 --> 00:36:49,040 because it will 1463 00:36:49,040 --> 00:36:49,240 block 1464 00:36:49,240 --> 00:36:49,480 the whole 1465 00:36:49,480 --> 00:36:50,280 city. 1466 00:36:51,060 --> 00:36:51,580 Or, 1467 00:36:51,720 --> 00:36:52,480 some bugs 1468 00:36:52,480 --> 00:36:53,420 are caused 1469 00:36:53,420 --> 00:36:54,200 by this. 1470 00:36:55,600 --> 00:36:56,120 So, 1471 00:36:56,220 --> 00:36:56,460 it is 1472 00:36:56,460 --> 00:36:57,060 a 1473 00:36:58,840 --> 00:36:59,360 framework. 1474 00:36:59,640 --> 00:36:59,780 And, 1475 00:36:59,780 --> 00:37:00,220 the main 1476 00:37:00,220 --> 00:37:00,520 purpose of 1477 00:37:00,520 --> 00:37:01,360 Klee 1478 00:37:01,360 --> 00:37:01,700 generate 1479 00:37:01,700 --> 00:37:02,080 your 1480 00:37:02,080 --> 00:37:02,680 test case. 1481 00:37:04,060 --> 00:37:04,620 But, 1482 00:37:04,720 --> 00:37:05,860 it must 1483 00:37:05,860 --> 00:37:06,840 compile 1484 00:37:06,840 --> 00:37:07,220 into 1485 00:37:07,220 --> 00:37:07,980 LLVM 1486 00:37:07,980 --> 00:37:08,540 B code. 1487 00:37:08,600 --> 00:37:08,760 So, 1488 00:37:08,780 --> 00:37:09,120 it must 1489 00:37:09,120 --> 00:37:09,440 have 1490 00:37:09,440 --> 00:37:09,780 a source 1491 00:37:09,780 --> 00:37:10,060 code. 1492 00:37:10,460 --> 00:37:11,060 When it 1493 00:37:11,640 --> 00:37:12,200 executes, 1494 00:37:13,160 --> 00:37:13,740 it changes 1495 00:37:13,740 --> 00:37:14,200 the input 1496 00:37:14,200 --> 00:37:14,780 into 1497 00:37:15,420 --> 00:37:15,980 Klee's 1498 00:37:15,980 --> 00:37:16,300 function. 1499 00:37:16,540 --> 00:37:16,900 And, 1500 00:37:16,960 --> 00:37:18,040 it marks 1501 00:37:18,040 --> 00:37:18,400 that part 1502 00:37:18,400 --> 00:37:19,460 as 1503 00:37:19,460 --> 00:37:19,840 symbolic. 1504 00:37:29,780 --> 00:37:29,860 And, 1505 00:37:30,040 --> 00:37:30,880 it also 1506 00:37:30,880 --> 00:37:31,040 input 1507 00:37:32,100 --> 00:37:32,680 information. 1508 00:37:33,000 --> 00:37:33,740 For example, 1509 00:37:33,940 --> 00:37:36,400 we have 1510 00:37:37,080 --> 00:37:37,660 int 1511 00:37:37,660 --> 00:37:38,100 in 1512 00:37:39,400 --> 00:37:39,980 Then, 1513 00:37:40,220 --> 00:37:41,060 we call 1514 00:37:41,060 --> 00:37:41,720 Klee 1515 00:37:41,720 --> 00:37:41,940 make 1516 00:37:41,940 --> 00:37:42,320 symbolic. 1517 00:37:42,660 --> 00:37:42,980 We make 1518 00:37:42,980 --> 00:37:43,160 A 1519 00:37:44,180 --> 00:37:44,760 into 1520 00:37:44,760 --> 00:37:45,640 symbolic. 1521 00:37:45,980 --> 00:37:46,560 Then, 1522 00:37:46,660 --> 00:37:47,860 we call 1523 00:37:47,860 --> 00:37:48,360 it to 1524 00:37:48,360 --> 00:37:48,440 the 1525 00:37:48,440 --> 00:37:48,700 gate 1526 00:37:48,700 --> 00:37:48,900 side 1527 00:37:48,900 --> 00:37:49,600 to 1528 00:37:52,760 --> 00:37:53,340 generate 1529 00:37:53,340 --> 00:37:53,620 all 1530 00:37:53,620 --> 00:37:54,420 routers out 1531 00:37:54,420 --> 00:37:54,760 So, 1532 00:37:54,860 --> 00:37:55,860 it will generate 1533 00:37:55,860 --> 00:37:56,240 all three 1534 00:37:56,240 --> 00:37:56,680 routers. 1535 00:37:57,060 --> 00:37:57,580 return0, 1536 00:37:57,660 --> 00:37:58,360 return-1, 1537 00:37:58,480 --> 00:37:59,000 return-1. 1538 00:38:00,100 --> 00:38:00,620 And, 1539 00:38:00,740 --> 00:38:00,960 this is 1540 00:38:00,960 --> 00:38:02,020 how it compiles 1541 00:38:02,020 --> 00:38:02,880 in LLVM 1542 00:38:02,880 --> 00:38:03,160 IR. 1543 00:38:04,680 --> 00:38:05,200 Yep. 1544 00:38:05,980 --> 00:38:06,500 So, 1545 00:38:06,620 --> 00:38:07,480 this is 1546 00:38:07,480 --> 00:38:07,740 the result 1547 00:38:07,740 --> 00:38:07,820 of it's 1548 00:38:07,820 --> 00:38:08,120 run-through. 1549 00:38:08,440 --> 00:38:08,780 Let's say 1550 00:38:08,780 --> 00:38:09,800 we will have 1551 00:38:09,800 --> 00:38:11,040 three test 1552 00:38:11,040 --> 00:38:11,320 cases. 1553 00:38:11,560 --> 00:38:12,340 The first one 1554 00:38:12,340 --> 00:38:13,020 is 0. 1555 00:38:13,260 --> 00:38:13,940 The next 1556 00:38:14,560 --> 00:38:15,080 one 1557 00:38:15,080 --> 00:38:18,580 is a negative number, because it's the beginning of 0.1, it's a negative number. 1558 00:38:18,860 --> 00:38:21,580 The third one is 0x80, 1559 00:38:21,920 --> 00:38:23,660 which is a positive number. 1560 00:38:23,780 --> 00:38:26,980 It will produce three inputs, 1561 00:38:27,180 --> 00:38:28,340 and it will go to three different cases. 1562 00:38:29,860 --> 00:38:32,620 Let's take a look at how the technology is actually executed. 1563 00:38:35,580 --> 00:38:38,100 It will run down first, 1564 00:38:38,200 --> 00:38:40,560 until it encounters a branch. 1565 00:38:41,060 --> 00:38:42,600 So let's take a look at it first. 1566 00:38:42,600 --> 00:38:44,440 It encounters a branch, for example, 1567 00:38:44,480 --> 00:38:45,780 it encounters x equals 0. 1568 00:38:46,260 --> 00:38:48,100 So it will first judge, 1569 00:38:48,640 --> 00:38:50,980 is this condition, x equals 0, 1570 00:38:51,220 --> 00:38:51,900 all concrete? 1571 00:38:53,380 --> 00:38:54,580 If concrete means, 1572 00:38:55,520 --> 00:38:58,640 for example, if 1 or if 0, 1573 00:38:58,740 --> 00:39:01,000 if constant, it will be concrete, 1574 00:39:01,380 --> 00:39:02,920 then it will be able to solve it directly. 1575 00:39:03,300 --> 00:39:05,360 After solving it, it won't have to 1576 00:39:05,360 --> 00:39:07,340 record the current condition. 1577 00:39:08,080 --> 00:39:10,020 If it realizes it still can't solve it, 1578 00:39:10,080 --> 00:39:11,500 then it will record it first, 1579 00:39:11,600 --> 00:39:12,580 and then it will record the current condition. 1580 00:39:12,600 --> 00:39:13,760 Then it will take the state and copy a part of it. 1581 00:39:13,940 --> 00:39:16,220 Then it will take it as a fork, 1582 00:39:16,580 --> 00:39:20,500 and then it will execute the following path. 1583 00:39:21,540 --> 00:39:25,000 Then it will keep running down, 1584 00:39:25,300 --> 00:39:29,500 until it encounters x equals 0, 1585 00:39:30,280 --> 00:39:31,300 or when it encounters x equals 0, 1586 00:39:31,540 --> 00:39:32,000 it will stop. 1587 00:39:32,520 --> 00:39:34,460 So when it stops, 1588 00:39:34,720 --> 00:39:35,860 it will start to explain, 1589 00:39:36,680 --> 00:39:38,320 after I get to this path, 1590 00:39:39,460 --> 00:39:41,340 what input do I need to get to this path? 1591 00:39:43,520 --> 00:39:43,920 What input do I need to get to this path? 1592 00:39:43,920 --> 00:39:44,860 Then it will solve it. 1593 00:39:46,000 --> 00:39:47,120 Then it will solve it. 1594 00:39:47,120 --> 00:39:47,280 Then it will solve the answer. 1595 00:39:48,600 --> 00:39:49,700 Okay, then this is, 1596 00:39:49,900 --> 00:39:52,520 its entire process will keep running like this. 1597 00:39:52,700 --> 00:39:53,100 Then, 1598 00:39:53,660 --> 00:39:54,060 then, 1599 00:39:54,240 --> 00:39:56,460 in fact, it will run to, 1600 00:39:56,660 --> 00:39:57,700 that is, there is no, 1601 00:39:57,700 --> 00:39:59,440 there is no state that is left. 1602 00:39:59,860 --> 00:40:01,020 That is, because in the end, 1603 00:40:01,060 --> 00:40:02,380 all states will stop. 1604 00:40:03,180 --> 00:40:05,020 If it doesn't leave normally, 1605 00:40:05,020 --> 00:40:05,900 otherwise it will make a mistake. 1606 00:40:06,300 --> 00:40:08,020 Then it will run to all states that are gone. 1607 00:40:08,220 --> 00:40:11,740 Otherwise, you set a timeout yourself. 1608 00:40:11,740 --> 00:40:12,580 If it reaches that timeout, 1609 00:40:12,580 --> 00:40:13,520 then it will stop. 1610 00:40:15,680 --> 00:40:18,440 Okay, then let's take a look at how it's different from Curly. 1611 00:40:23,760 --> 00:40:28,180 So, in fact, Curly has introduced the concept that you have a state. 1612 00:40:28,880 --> 00:40:29,340 That is, 1613 00:40:29,860 --> 00:40:30,260 your, 1614 00:40:30,680 --> 00:40:35,660 your deeper state can go through your clone state and then reach it. 1615 00:40:36,760 --> 00:40:37,160 Then, 1616 00:40:37,900 --> 00:40:38,720 it looks like, 1617 00:40:38,980 --> 00:40:40,140 it's like a compile process, 1618 00:40:40,300 --> 00:40:41,680 from C code to a compile process. 1619 00:40:41,760 --> 00:40:42,120 It looks like, 1620 00:40:42,580 --> 00:40:43,920 it's like a compile process from C code to a compile process. 1621 00:40:43,920 --> 00:40:45,020 Then, we can take a look at it. 1622 00:40:45,340 --> 00:40:45,820 That is, 1623 00:40:46,820 --> 00:40:47,220 now, 1624 00:40:47,900 --> 00:40:48,460 for example, 1625 00:40:48,480 --> 00:40:49,460 our state is now. 1626 00:40:49,720 --> 00:40:50,060 Now, 1627 00:40:51,640 --> 00:40:52,680 this is the paste part. 1628 00:40:52,940 --> 00:40:55,060 Later, I will talk about the C library part. 1629 00:40:55,380 --> 00:40:55,780 Then, 1630 00:40:56,440 --> 00:40:58,300 our state is now. 1631 00:40:58,420 --> 00:40:59,160 Then, in the end, 1632 00:40:59,280 --> 00:41:00,300 we have to reach D, 1633 00:41:00,440 --> 00:41:00,840 this state. 1634 00:41:01,080 --> 00:41:01,720 Then, for example, 1635 00:41:01,740 --> 00:41:02,220 in Twitter, 1636 00:41:02,660 --> 00:41:05,300 we will first go to the output of B, 1637 00:41:05,460 --> 00:41:07,360 this state input. 1638 00:41:07,600 --> 00:41:10,500 Then, we will set the concrete memory, 1639 00:41:10,820 --> 00:41:12,060 the concrete value, 1640 00:41:12,240 --> 00:41:12,560 the concrete value, 1641 00:41:12,580 --> 00:41:14,360 and then we will go to the content of Twitter. 1642 00:41:14,360 --> 00:41:15,220 Then, we will, 1643 00:41:15,240 --> 00:41:16,860 so Twitter has now reached B. 1644 00:41:17,220 --> 00:41:18,840 Then, we will go to solve D. 1645 00:41:19,640 --> 00:41:22,100 We will go to solve this path of D. 1646 00:41:22,780 --> 00:41:24,020 If it is clear, 1647 00:41:24,280 --> 00:41:26,020 it will actually run in parallel. 1648 00:41:26,620 --> 00:41:27,280 That is to say, 1649 00:41:27,380 --> 00:41:28,500 I am now making trouble with this. 1650 00:41:29,080 --> 00:41:30,660 It meets the branch. 1651 00:41:30,900 --> 00:41:32,060 So, it will clone state. 1652 00:41:32,220 --> 00:41:33,340 One runs A, one runs B. 1653 00:41:33,620 --> 00:41:35,640 Then, it meets the branch of B. 1654 00:41:35,640 --> 00:41:37,480 Then, it will run C, one runs D. 1655 00:41:37,600 --> 00:41:40,420 Then, in the end, we hope that we can reach this path of D. 1656 00:41:41,740 --> 00:41:43,880 Then, it will help us to solve the path of D. 1657 00:41:46,080 --> 00:41:49,160 What input can reach this path of D? 1658 00:41:49,900 --> 00:41:52,500 If we need to use the GNU C library, 1659 00:41:53,240 --> 00:41:55,020 we have a parameter that says 1660 00:41:57,460 --> 00:41:59,400 .libc is equal to uclibc. 1661 00:41:59,840 --> 00:42:03,240 uclibc is a smaller libc. 1662 00:42:03,400 --> 00:42:05,460 Then, others write it down. 1663 00:42:05,460 --> 00:42:06,960 Usually, it is used in the embedded system. 1664 00:42:08,380 --> 00:42:10,400 Then, there is postfile. 1665 00:42:10,420 --> 00:42:10,680 Postfile. 1666 00:42:10,980 --> 00:42:12,260 Postfile runtime parameter. 1667 00:42:12,600 --> 00:42:16,260 That is to say, you must provide some postfile runtime environment to it. 1668 00:42:17,520 --> 00:42:20,700 But, in fact, when it detects it, 1669 00:42:21,280 --> 00:42:22,780 for example, you are doing function call, 1670 00:42:22,860 --> 00:42:23,960 for example, you call scanf, 1671 00:42:24,080 --> 00:42:26,260 or call atoi, 1672 00:42:26,520 --> 00:42:27,680 that is to say, turn it into int. 1673 00:42:28,020 --> 00:42:31,380 In fact, it will directly link to, 1674 00:42:32,200 --> 00:42:35,120 it will directly link uclibc to your program. 1675 00:42:35,540 --> 00:42:36,740 It will execute it concretely. 1676 00:42:37,660 --> 00:42:39,900 The meaning of executing concretely is that 1677 00:42:40,420 --> 00:42:41,940 you originally have the part of makeSymbody, 1678 00:42:42,440 --> 00:42:44,360 but in fact, when it is doing function call, 1679 00:42:44,760 --> 00:42:47,280 because it is not programming LLVNIR, 1680 00:42:47,560 --> 00:42:49,460 so it can only execute concretely. 1681 00:42:49,540 --> 00:42:51,100 That is to say, your Symbody information 1682 00:42:51,620 --> 00:42:52,800 will be lost when you call the library call. 1683 00:42:55,160 --> 00:42:59,120 So, in fact, it can't handle the problem of 1684 00:42:59,120 --> 00:43:00,180 GNU C library very well. 1685 00:43:02,140 --> 00:43:03,700 Next, we are going to introduce ANGER. 1686 00:43:05,360 --> 00:43:06,980 ANGER is actually more famous. 1687 00:43:07,320 --> 00:43:07,920 You may have heard of it before. 1688 00:43:10,420 --> 00:43:10,700 This is ANGER. 1689 00:43:10,800 --> 00:43:12,260 It is more special because 1690 00:43:12,260 --> 00:43:16,280 it can support a lot of different directive structures. 1691 00:43:16,980 --> 00:43:20,480 For example, there are ARM, x86, x8664, 1692 00:43:20,600 --> 00:43:21,440 and a lot of MIFs, 1693 00:43:21,660 --> 00:43:24,080 or other different computational structures. 1694 00:43:24,680 --> 00:43:27,000 Usually, we will load the library first, 1695 00:43:27,000 --> 00:43:28,540 then turn it into IR, 1696 00:43:28,780 --> 00:43:30,600 and then execute analysis. 1697 00:43:32,380 --> 00:43:34,560 So, the whole process is like this. 1698 00:43:34,900 --> 00:43:36,920 That is to say, I import ANGER first, 1699 00:43:36,920 --> 00:43:38,940 and then put this binary, 1700 00:43:38,940 --> 00:43:40,680 which is AIS-3-crack-me, 1701 00:43:40,860 --> 00:43:42,100 and then initialize it. 1702 00:43:45,760 --> 00:43:49,920 Because this example is going to eat ARGB, 1703 00:43:50,280 --> 00:43:56,200 so I set ARGB to a 100-byte big beta. 1704 00:43:58,120 --> 00:44:01,060 Next, I initialize its original state. 1705 00:44:01,240 --> 00:44:02,740 Its original state is that 1706 00:44:03,240 --> 00:44:05,660 I will write crack-me 1, 1707 00:44:05,800 --> 00:44:08,120 and then add ARGB to it. 1708 00:44:09,040 --> 00:44:10,520 This is its initial state. 1709 00:44:12,040 --> 00:44:14,700 Finally, it will initialize its... 1710 00:44:15,240 --> 00:44:17,240 This is called Simulation Manager. 1711 00:44:17,560 --> 00:44:17,820 That is to say, 1712 00:44:17,920 --> 00:44:20,320 it will control its state. 1713 00:44:20,760 --> 00:44:21,240 Next, 1714 00:44:21,860 --> 00:44:25,240 actually, like this export function, 1715 00:44:25,580 --> 00:44:27,280 it is actually setting the content. 1716 00:44:27,740 --> 00:44:31,820 That is to say, it translates it as 0x400602. 1717 00:44:31,880 --> 00:44:34,560 It is actually setting symbolic content. 1718 00:44:34,880 --> 00:44:36,860 That is to say, my EIP must be equal to this word. 1719 00:44:37,340 --> 00:44:37,820 Finally, 1720 00:44:37,820 --> 00:44:39,820 after we start running and executing, 1721 00:44:41,660 --> 00:44:43,880 because it might have a lot of results, 1722 00:44:44,220 --> 00:44:46,400 so we will take the 0x of this state, 1723 00:44:47,360 --> 00:44:49,220 and that will be our answer. 1724 00:44:50,780 --> 00:44:51,300 Yes. 1725 00:44:53,220 --> 00:44:55,280 Okay, so this is the example just now, 1726 00:44:55,300 --> 00:44:57,100 but it seems to be over. 1727 00:44:57,540 --> 00:44:58,060 Yes. 1728 00:45:02,060 --> 00:45:05,540 So 0x400602 is the location we are going to arrive at. 1729 00:45:05,900 --> 00:45:06,800 This location, 1730 00:45:06,800 --> 00:45:08,380 it will print out the correct, 1731 00:45:08,640 --> 00:45:09,640 which is this string, 1732 00:45:09,840 --> 00:45:11,020 so we are going to arrive at this location. 1733 00:45:11,740 --> 00:45:13,060 This is its program code, 1734 00:45:13,200 --> 00:45:14,480 which is the string we just added. 1735 00:45:15,840 --> 00:45:16,720 This run, 1736 00:45:17,720 --> 00:45:20,120 it will probably wait for 2-3 seconds. 1737 00:45:20,360 --> 00:45:22,400 Because its state has to keep going down, 1738 00:45:22,800 --> 00:45:23,820 it needs some time. 1739 00:45:24,140 --> 00:45:28,540 Finally, it finds a suitable input, 1740 00:45:28,700 --> 00:45:29,660 then it will print it out. 1741 00:45:31,360 --> 00:45:32,280 What is IR? 1742 00:45:32,600 --> 00:45:32,980 That is to say, 1743 00:45:33,120 --> 00:45:34,060 because actually, 1744 00:45:35,280 --> 00:45:39,060 when you want to write something to support a different computer structure, 1745 00:45:40,500 --> 00:45:41,900 you need to use IR. 1746 00:45:42,260 --> 00:45:43,700 It is the middle expression. 1747 00:45:45,100 --> 00:45:49,800 Because every computer structure is processing its register, 1748 00:45:50,320 --> 00:45:52,140 or the memory method is different, 1749 00:45:52,480 --> 00:45:56,380 so you need to reduce these different effects. 1750 00:45:56,600 --> 00:46:01,120 Then you put your main symbolic on IR. 1751 00:46:01,620 --> 00:46:02,400 In this case, 1752 00:46:02,580 --> 00:46:03,480 you don't need to 1753 00:46:03,480 --> 00:46:04,780 write different things for different structures. 1754 00:46:06,680 --> 00:46:09,120 The IR expression of ANGLE is VASE, 1755 00:46:09,220 --> 00:46:10,500 which is the one Valkyrie uses. 1756 00:46:12,040 --> 00:46:13,800 In fact, if you go to... 1757 00:46:14,320 --> 00:46:16,060 Actually, I am more curious about it. 1758 00:46:16,540 --> 00:46:19,440 I like to see why it uses this. 1759 00:46:19,760 --> 00:46:23,680 It is because you can turn from binary code to VASE, 1760 00:46:23,740 --> 00:46:25,520 which is a very good support. 1761 00:46:25,700 --> 00:46:27,060 That is to say, there are a lot of supports. 1762 00:46:27,300 --> 00:46:30,260 So it uses the IR of VASE. 1763 00:46:32,460 --> 00:46:32,980 Usually, 1764 00:46:32,980 --> 00:46:35,600 IR needs to abstract some things. 1765 00:46:35,880 --> 00:46:36,180 That is to say, 1766 00:46:36,880 --> 00:46:38,760 the first one is the ratio of NAND. 1767 00:46:39,080 --> 00:46:39,620 That is to say, 1768 00:46:39,980 --> 00:46:42,120 for example, if you use ARN or something, 1769 00:46:42,300 --> 00:46:42,780 compared to TABEL, 1770 00:46:43,020 --> 00:46:44,840 it will have a different ratio of NAND, 1771 00:46:44,900 --> 00:46:47,880 like R9, R16, and so on. 1772 00:46:48,180 --> 00:46:49,760 It will have a different ratio of NAND. 1773 00:46:49,880 --> 00:46:51,840 It must be abstracted 1774 00:46:51,840 --> 00:46:54,160 so that it can use the same IR expression. 1775 00:46:54,820 --> 00:46:56,300 Or memory access. 1776 00:46:56,760 --> 00:46:57,900 Because some... 1777 00:46:59,140 --> 00:47:00,700 For example, I will talk about x86. 1778 00:47:01,060 --> 00:47:02,380 I am familiar with this. 1779 00:47:02,380 --> 00:47:06,100 When x86 stores some memories, 1780 00:47:06,420 --> 00:47:07,340 it will store them with register. 1781 00:47:08,640 --> 00:47:10,040 That is to say, it will register 1782 00:47:10,040 --> 00:47:13,060 and add some offset to store its memory. 1783 00:47:13,400 --> 00:47:16,140 So it is very different from other computational structures. 1784 00:47:17,040 --> 00:47:20,680 So it uses the same storage method as much as possible. 1785 00:47:20,680 --> 00:47:22,300 So you won't use EAS. 1786 00:47:23,900 --> 00:47:25,780 Or memory segment. 1787 00:47:26,080 --> 00:47:29,380 For example, have you seen state canary? 1788 00:47:29,580 --> 00:47:30,920 State canary is a 1789 00:47:30,920 --> 00:47:32,720 method to prevent bubble overflow. 1790 00:47:33,940 --> 00:47:35,900 The canary exists in the segment, 1791 00:47:36,180 --> 00:47:37,160 which is in the GS. 1792 00:47:37,400 --> 00:47:38,820 In the GS segment. 1793 00:47:40,380 --> 00:47:43,000 It will have different registers 1794 00:47:43,000 --> 00:47:44,680 to use its segment. 1795 00:47:45,460 --> 00:47:46,940 The last one is the side effect. 1796 00:47:47,240 --> 00:47:48,840 Because, for example, 1797 00:47:49,020 --> 00:47:51,020 if there is a stake architecture, 1798 00:47:51,660 --> 00:47:53,080 it will have these commands, push or pop. 1799 00:47:53,980 --> 00:47:56,180 But actually, the command push or pop 1800 00:47:56,180 --> 00:47:57,120 is destructive. 1801 00:47:57,680 --> 00:47:59,340 Because, for example, 1802 00:47:59,380 --> 00:48:00,180 if you push something 1803 00:48:00,180 --> 00:48:01,080 on the stake, 1804 00:48:01,440 --> 00:48:03,200 the paper on the stake 1805 00:48:03,200 --> 00:48:04,180 will be covered by you. 1806 00:48:04,320 --> 00:48:05,300 This is destructive. 1807 00:48:05,660 --> 00:48:06,500 Because it has side effect. 1808 00:48:06,820 --> 00:48:09,840 So we have to reduce these effects as much as possible. 1809 00:48:09,860 --> 00:48:10,500 For example, 1810 00:48:11,300 --> 00:48:13,500 add L, EAS, EBS. 1811 00:48:14,220 --> 00:48:15,460 It will turn into IR. 1812 00:48:15,580 --> 00:48:16,780 It will be like the situation on the right. 1813 00:48:16,840 --> 00:48:18,160 The left side is x86 code. 1814 00:48:18,240 --> 00:48:18,840 The right side is IR. 1815 00:48:19,800 --> 00:48:22,500 We will take it out from EAS first. 1816 00:48:23,500 --> 00:48:25,160 Then the zero is offset. 1817 00:48:25,460 --> 00:48:25,900 That is to say, 1818 00:48:27,500 --> 00:48:29,280 in fact, in register, 1819 00:48:29,280 --> 00:48:29,860 as mentioned earlier, 1820 00:48:30,980 --> 00:48:31,900 it is offset. 1821 00:48:32,440 --> 00:48:33,500 The zero is offset. 1822 00:48:33,740 --> 00:48:36,060 The 12 in the second line is also offset. 1823 00:48:36,420 --> 00:48:37,220 In the second line, 1824 00:48:37,300 --> 00:48:38,180 we take out the value of EBS. 1825 00:48:40,280 --> 00:48:41,560 Next, T1 is to say 1826 00:48:41,560 --> 00:48:44,080 I put two 32-bit integers together. 1827 00:48:44,800 --> 00:48:47,020 Then PUT is also offset. 1828 00:48:47,280 --> 00:48:47,620 That is to say, 1829 00:48:47,720 --> 00:48:49,700 we will store it back in EAS. 1830 00:48:51,180 --> 00:48:52,220 Because, in fact, 1831 00:48:52,300 --> 00:48:53,320 you can see the value like this. 1832 00:48:53,620 --> 00:48:54,360 This is x86. 1833 00:48:54,560 --> 00:48:56,740 But you may use x64 or something. 1834 00:48:56,860 --> 00:48:57,700 It will also... 1835 00:48:59,280 --> 00:48:59,800 It will be similar. 1836 00:49:00,300 --> 00:49:01,360 After it turns into IR, 1837 00:49:01,660 --> 00:49:02,560 it will be a similar result. 1838 00:49:02,740 --> 00:49:05,280 Let you have two different computer structures. 1839 00:49:06,280 --> 00:49:07,760 It will not go wrong when it turns out. 1840 00:49:09,460 --> 00:49:12,220 This is the state type in ANGLE. 1841 00:49:12,260 --> 00:49:13,380 We just need to look at the result. 1842 00:49:13,700 --> 00:49:14,780 We just need to look at the active. 1843 00:49:16,240 --> 00:49:18,200 Because the active is to say 1844 00:49:18,200 --> 00:49:19,560 it is still executing now. 1845 00:49:20,440 --> 00:49:22,040 Next, there is a found. 1846 00:49:22,200 --> 00:49:23,020 The found is to say 1847 00:49:23,020 --> 00:49:23,900 when I set the counter, 1848 00:49:26,300 --> 00:49:28,620 it finds the counter that fits. 1849 00:49:29,400 --> 00:49:31,620 Then it will put this state into the found. 1850 00:49:32,000 --> 00:49:33,420 Then we can actually go to see 1851 00:49:33,420 --> 00:49:35,340 what its input is in the found. 1852 00:49:38,060 --> 00:49:39,660 What is different about ANGLE? 1853 00:49:39,660 --> 00:49:40,220 That is to say, 1854 00:49:40,620 --> 00:49:43,240 the concept of its state is more complete. 1855 00:49:43,500 --> 00:49:43,980 That is to say, 1856 00:49:44,000 --> 00:49:45,920 it has to classify different states. 1857 00:49:47,000 --> 00:49:48,800 Then we can also go... 1858 00:49:49,400 --> 00:49:50,900 I haven't talked about this example. 1859 00:49:50,900 --> 00:49:51,200 That is to say, 1860 00:49:51,320 --> 00:49:51,760 in fact, 1861 00:49:51,840 --> 00:49:53,940 we can also do some processing for that state. 1862 00:49:55,380 --> 00:49:55,900 That is to say, 1863 00:49:55,920 --> 00:49:56,760 we can go to that state 1864 00:49:56,760 --> 00:49:57,860 and then go to see some things. 1865 00:49:58,620 --> 00:49:59,980 Then there is another most important point, 1866 00:50:00,060 --> 00:50:00,940 which is symbolic function. 1867 00:50:02,220 --> 00:50:02,820 In fact, 1868 00:50:03,000 --> 00:50:05,180 ANGLE can handle symbolic functions. 1869 00:50:05,580 --> 00:50:06,020 That is to say, 1870 00:50:06,140 --> 00:50:08,200 it can handle the Gnostic library. 1871 00:50:11,700 --> 00:50:12,220 Then, 1872 00:50:12,380 --> 00:50:15,960 it will call it 1873 00:50:15,960 --> 00:50:17,180 the SYN procedure. 1874 00:50:18,240 --> 00:50:20,180 This is the term it uses. 1875 00:50:21,060 --> 00:50:21,480 That is to say, 1876 00:50:21,780 --> 00:50:24,680 we put its original... 1877 00:50:24,680 --> 00:50:24,940 For example, 1878 00:50:24,960 --> 00:50:25,940 we call it scanf. 1879 00:50:26,080 --> 00:50:27,860 Then we change it to SYN procedure. 1880 00:50:29,200 --> 00:50:32,680 SYN procedure is a library hook written in Python. 1881 00:50:32,680 --> 00:50:33,240 That is to say, 1882 00:50:33,300 --> 00:50:34,360 you call scanf, 1883 00:50:34,460 --> 00:50:37,140 then it will jump to the Python code I wrote. 1884 00:50:37,320 --> 00:50:38,000 In fact, 1885 00:50:38,220 --> 00:50:42,760 if you really want to simulate the Gnostic library, 1886 00:50:42,880 --> 00:50:43,580 it is very troublesome. 1887 00:50:43,800 --> 00:50:45,480 Because the whole system is very complicated. 1888 00:50:45,700 --> 00:50:48,000 So it actually uses a fake hook. 1889 00:50:48,220 --> 00:50:48,920 That is to say, 1890 00:50:48,960 --> 00:50:50,520 it uses the method written in Python 1891 00:50:50,520 --> 00:50:55,360 to replace your Gnostic library code. 1892 00:50:56,200 --> 00:50:57,460 These are some... 1893 00:50:58,620 --> 00:51:00,280 So you may have a little bit... 1894 00:51:00,280 --> 00:51:02,400 You may have an incorrect result 1895 00:51:02,400 --> 00:51:04,980 or the paste will explode. 1896 00:51:06,560 --> 00:51:08,300 If you encounter this situation, 1897 00:51:08,400 --> 00:51:09,320 you can disable it. 1898 00:51:09,500 --> 00:51:11,700 Or you can use what you wrote 1899 00:51:12,500 --> 00:51:13,900 or fix it. 1900 00:51:15,920 --> 00:51:18,280 Let's look at a simple example. 1901 00:51:18,460 --> 00:51:18,780 That is to say, 1902 00:51:18,860 --> 00:51:19,400 how to handle scanf. 1903 00:51:20,860 --> 00:51:21,940 This source code, 1904 00:51:22,100 --> 00:51:23,580 you can see it on the top. 1905 00:51:24,140 --> 00:51:24,480 That is to say, 1906 00:51:24,620 --> 00:51:25,300 if you are interested, 1907 00:51:25,420 --> 00:51:27,100 you can go and see how it is done in the library. 1908 00:51:27,680 --> 00:51:31,520 The first thing we need to do is to get the first argument. 1909 00:51:32,080 --> 00:51:35,220 Because the first argument of scanf is formatString. 1910 00:51:35,700 --> 00:51:39,760 Next, we define the returnType of your function. 1911 00:51:39,780 --> 00:51:43,400 Because it supports a lot of different architectures, 1912 00:51:43,460 --> 00:51:46,140 it must first determine its returnType. 1913 00:51:46,340 --> 00:51:48,360 Next, it parses the formatString. 1914 00:51:48,560 --> 00:51:50,840 Then, according to the formatString content, 1915 00:51:51,220 --> 00:51:53,360 it reads the input from the input. 1916 00:51:54,080 --> 00:51:55,800 Because scanf reads from the input. 1917 00:51:56,240 --> 00:51:56,820 Next, 1918 00:51:57,100 --> 00:51:58,400 it reads the input from the input. 1919 00:51:59,160 --> 00:51:59,640 Next, 1920 00:52:00,040 --> 00:52:01,160 these three classes, 1921 00:52:01,280 --> 00:52:04,660 I hope you can memorize them. 1922 00:52:04,740 --> 00:52:07,800 Because there won't be these things in the next page. 1923 00:52:07,820 --> 00:52:08,860 Then, when you memorize them, 1924 00:52:08,920 --> 00:52:10,060 you will understand them better in the next page. 1925 00:52:10,100 --> 00:52:11,580 The first one is Procedure. 1926 00:52:12,240 --> 00:52:13,200 Scene Procedure. 1927 00:52:13,400 --> 00:52:17,380 It has a message called typePTR. 1928 00:52:17,640 --> 00:52:18,140 That is to say, 1929 00:52:18,680 --> 00:52:21,160 you see it eats the ARCH parameters. 1930 00:52:21,560 --> 00:52:23,120 So, it decides according to your architecture 1931 00:52:23,120 --> 00:52:25,960 what your returnType should be. 1932 00:52:25,960 --> 00:52:27,960 The second one is FormatParser. 1933 00:52:30,120 --> 00:52:31,660 It is derived from Scene Procedure. 1934 00:52:32,380 --> 00:52:37,800 It has a message called underscoreParser. 1935 00:52:38,060 --> 00:52:40,840 The first one it eats is the index of formatString. 1936 00:52:41,880 --> 00:52:47,600 So, for example, scanf will eat the first one. 1937 00:52:47,780 --> 00:52:49,640 Then, after parsing, 1938 00:52:49,980 --> 00:52:52,060 the interpreter will say that 1939 00:52:52,060 --> 00:52:53,160 according to the content of the parser, 1940 00:52:53,160 --> 00:52:55,560 I will put it in the back. 1941 00:52:55,580 --> 00:52:55,940 Then, the interpreter will say that 1942 00:52:55,940 --> 00:52:57,400 I will put it in the back variable of scanf. 1943 00:52:58,660 --> 00:53:03,580 So, I will read the data from the address parameter 1944 00:53:04,340 --> 00:53:06,660 and then put it in the ARGS. 1945 00:53:07,080 --> 00:53:09,380 This is usually a array. 1946 00:53:09,580 --> 00:53:11,280 The array is in the back of the ARGS. 1947 00:53:11,460 --> 00:53:13,320 Then, it starts from the number of arguments. 1948 00:53:14,220 --> 00:53:15,980 That is the argument starting from the number of arguments. 1949 00:53:17,900 --> 00:53:19,460 This is the whole code. 1950 00:53:19,680 --> 00:53:20,200 That is to say, 1951 00:53:20,940 --> 00:53:22,840 I first decide its argumentType, 1952 00:53:22,840 --> 00:53:24,300 and its returnType. 1953 00:53:24,440 --> 00:53:25,660 Then, I pass it. 1954 00:53:25,900 --> 00:53:26,760 After I pass it, 1955 00:53:27,160 --> 00:53:29,040 I get the file from FD0. 1956 00:53:29,340 --> 00:53:31,500 That is, I take it from FD0, 1957 00:53:31,500 --> 00:53:32,700 which is the standard input. 1958 00:53:34,120 --> 00:53:36,500 Then, I decide its region. 1959 00:53:36,640 --> 00:53:38,020 In fact, this region can be given or not. 1960 00:53:38,260 --> 00:53:40,140 Then, start means 1961 00:53:41,440 --> 00:53:42,940 its file descriptor 1962 00:53:43,480 --> 00:53:45,060 reads from the position of the memory. 1963 00:53:45,320 --> 00:53:46,460 Because in Angular, 1964 00:53:46,780 --> 00:53:48,440 whether it is FD or something else, 1965 00:53:48,440 --> 00:53:49,100 other ratios, 1966 00:53:50,460 --> 00:53:51,340 it uses 1967 00:53:52,840 --> 00:53:55,400 it as a flat memory to read. 1968 00:53:55,480 --> 00:53:57,460 So, each one has its memory address. 1969 00:53:58,100 --> 00:53:59,200 Then, after reading, 1970 00:53:59,460 --> 00:54:00,740 we interpret it. 1971 00:54:01,600 --> 00:54:04,560 Then, we throw the formatString 1972 00:54:04,560 --> 00:54:05,060 from the input 1973 00:54:05,060 --> 00:54:07,280 to the variable at the back. 1974 00:54:07,740 --> 00:54:09,840 Finally, we do the read action. 1975 00:54:11,260 --> 00:54:11,980 This way, 1976 00:54:12,020 --> 00:54:13,280 you may not be clear. 1977 00:54:13,500 --> 00:54:15,860 So, I use another function 1978 00:54:15,860 --> 00:54:16,320 to compare. 1979 00:54:17,140 --> 00:54:18,720 I just talked about scanF. 1980 00:54:18,920 --> 00:54:20,740 Now, I use scanSscanF 1981 00:54:22,640 --> 00:54:22,820 to compare. 1982 00:54:23,840 --> 00:54:25,020 scanSscanF is a function. 1983 00:54:27,400 --> 00:54:29,560 Its input is not read from the standard input. 1984 00:54:30,020 --> 00:54:31,880 It is read directly from the variable. 1985 00:54:33,520 --> 00:54:34,460 So, for example, 1986 00:54:34,600 --> 00:54:36,440 when I scanF pass on the left, 1987 00:54:36,540 --> 00:54:37,760 formatString is the first one. 1988 00:54:37,840 --> 00:54:38,440 So, it is 0. 1989 00:54:39,260 --> 00:54:40,280 When I scanF pass on the right, 1990 00:54:41,180 --> 00:54:42,100 formatString is the second one. 1991 00:54:42,140 --> 00:54:42,620 So, it is 1. 1992 00:54:46,500 --> 00:54:48,480 Then, scanF is read from FD0. 1993 00:54:48,860 --> 00:54:49,720 It is read from the standard input. 1994 00:54:50,020 --> 00:54:51,460 So, its get file is 0. 1995 00:54:51,720 --> 00:54:52,320 On the right, 1996 00:54:52,620 --> 00:54:52,820 it is read from the standard input. 1997 00:54:52,840 --> 00:54:54,560 In fact, what it gives is 1998 00:54:54,560 --> 00:54:56,400 saved ARG0. 1999 00:54:56,700 --> 00:54:58,360 That is, I read directly from the sentence. 2000 00:54:59,820 --> 00:55:00,540 So, on the left, 2001 00:55:02,120 --> 00:55:04,220 I read from the start memory 2002 00:55:04,220 --> 00:55:06,920 to the first one. 2003 00:55:06,980 --> 00:55:07,400 That is, 2004 00:55:07,500 --> 00:55:09,140 I start from the first one. 2005 00:55:09,460 --> 00:55:10,020 That is, 2006 00:55:10,120 --> 00:55:11,940 I insert it from I. 2007 00:55:13,340 --> 00:55:14,420 That is, the first one of ARG. 2008 00:55:15,200 --> 00:55:16,760 I insert it from I. 2009 00:55:16,760 --> 00:55:17,540 On the back, 2010 00:55:17,640 --> 00:55:19,660 it starts from 2011 00:55:19,660 --> 00:55:22,820 the start memory 2012 00:55:22,840 --> 00:55:23,260 to the second one. 2013 00:55:23,840 --> 00:55:25,520 The first one is sentence. 2014 00:55:25,780 --> 00:55:26,880 The second one is formatString. 2015 00:55:27,240 --> 00:55:29,500 It starts from the second one, str and I. 2016 00:55:29,660 --> 00:55:30,980 Then, I insert it from the second one. 2017 00:55:33,180 --> 00:55:34,060 In fact, 2018 00:55:34,180 --> 00:55:35,240 this is some reference. 2019 00:55:35,500 --> 00:55:38,200 This talk is over.