1 00:00:07,460 --> 00:00:15,000 Hello everyone, I will continue to talk about some of the situations that will occur in other applications. 2 00:00:16,320 --> 00:00:21,860 Another situation is that there will be a loophole in the instant communication software. 3 00:00:21,860 --> 00:00:31,260 Many instant communication software support one user to send a file to another user during the operation. 4 00:00:31,260 --> 00:00:34,800 And this file is not just a picture or audio file. 5 00:00:34,800 --> 00:00:39,440 It can be another kind of document or binary file. 6 00:00:39,440 --> 00:00:45,120 And this kind of file will retain the original file name after it is sent. 7 00:00:45,400 --> 00:00:59,940 If this file name is not fully verified during the download process, it may save this file to any path after the file is downloaded. 8 00:00:59,940 --> 00:01:03,880 This will cause a loophole and cause some subsequent effects. 9 00:01:04,880 --> 00:01:09,460 How to find such files in the instant communication software? 10 00:01:11,000 --> 00:01:18,900 First, we need to send a file with a malicious file name. 11 00:01:18,900 --> 00:01:25,000 Then we need to ask the target user to click and download this file. 12 00:01:25,040 --> 00:01:32,040 One of the most difficult processes is how to send such a file. 13 00:01:32,040 --> 00:01:45,360 Because in the process of implementing the instant communication software, it directly takes the relevant file from the file processor or some other components, and then obtains the file name. 14 00:01:45,360 --> 00:01:49,640 It does not support directly specifying the file name of the target. 15 00:01:49,640 --> 00:01:55,460 So we need to send a file with a malicious file name through some intermediaries or hooks or re-packaging. 16 00:02:03,100 --> 00:02:07,180 It is possible to send such a file through intermediaries. 17 00:02:08,080 --> 00:02:22,980 Because we found that in the process of analyzing a certain instant communication software, it used some requests to pass the file name through Base64 and some code through HTTPS. 18 00:02:23,500 --> 00:02:29,120 However, we did not find such a case in the actual application process. 19 00:02:29,120 --> 00:02:33,500 So it's just that intermediaries have a possibility. 20 00:02:33,500 --> 00:02:36,060 There may be such a situation in other applications. 21 00:02:38,160 --> 00:02:44,580 Through the way of hooking, we have a relatively rich harvest. 22 00:02:44,580 --> 00:03:00,360 In the whole series of Tencent QQ, whether it is QQ Team or QQ International or Weiliao, it can all be done through a way of hooking. 23 00:03:00,360 --> 00:03:08,680 When we send a file, there is a file manager entity in the middle. 24 00:03:08,680 --> 00:03:14,360 In such a file entity, we hook this thing down and send a file name to it. 25 00:03:14,360 --> 00:03:19,140 Replace it with a file name that we need to specify with a dot-dot-dot. 26 00:03:19,420 --> 00:03:21,100 Then send it to the end. 27 00:03:21,180 --> 00:03:23,900 The end will display such a file. 28 00:03:23,900 --> 00:03:29,060 After it is downloaded, it will be stored in one of the paths we specified. 29 00:03:31,260 --> 00:03:38,400 However, there will be some limitations in the process of using this loophole. 30 00:03:39,160 --> 00:03:45,240 This limitation is due to some problems with the Java API itself. 31 00:03:45,240 --> 00:03:52,200 When it downloads, it downloads to a temporary folder on the SD card. 32 00:03:52,380 --> 00:03:54,360 A temporary path below. 33 00:03:54,360 --> 00:03:59,730 After downloading, use the RenameTo API to make a copy. 34 00:03:59,730 --> 00:04:05,490 However, this RenameTo API is a very strange API. 35 00:04:05,490 --> 00:04:10,210 It can be said to be an incomplete API. 36 00:04:10,210 --> 00:04:17,010 When it copies from one file system to another file system, it will cause a return false. 37 00:04:17,710 --> 00:04:19,870 So the copy is unsuccessful. 38 00:04:19,870 --> 00:04:25,290 If the target file exists or the target folder does not exist, it may also return false. 39 00:04:25,290 --> 00:04:31,890 When Tencent QQ is in this code, it does not perform the operation of tolerance. 40 00:04:31,890 --> 00:04:36,350 After it fails to copy, it will throw an abnormality directly. 41 00:04:36,350 --> 00:04:42,870 Then say this abnormality is RenameFileFail, RenameFileError such a situation. 42 00:04:42,870 --> 00:04:51,590 If it has the means of tolerance to ensure that this file can be copied normally, this is actually an opportunity. 43 00:04:52,770 --> 00:04:56,650 But we can't say that this loophole can't be used. 44 00:04:56,650 --> 00:05:11,050 Although it can only be traversed under the SD card, for example, in M.2.0 2017, MWR has already used such a loophole in their use of Samsung phones. 45 00:05:12,350 --> 00:05:29,950 It is to rewrite an INI configuration file on the SD card, and then change the HTTP of the server in this file to point to their own, and then do a middleman attack, which achieves the effect of being able to install a malicious application. 46 00:05:30,750 --> 00:05:41,610 So although this looks very fierce, but it is also possible to produce some beneficial effects. 47 00:05:41,610 --> 00:05:47,190 Then, what do we need to pay attention to in the process of hooking to modify this file name? 48 00:05:48,610 --> 00:05:54,990 In fact, the most important thing is to find a suitable location to place such a hook. 49 00:05:55,890 --> 00:06:01,510 Such a suitable location may usually be a class of a definition. 50 00:06:02,010 --> 00:06:11,430 This class includes some relevant information about the file that needs to be transmitted, such as the file name, file size, etc. 51 00:06:14,330 --> 00:06:30,870 However, such a class requires us to manually, for example, how to get this file when it starts, and then store it and read it to what data structure to do some analysis. 52 00:06:30,870 --> 00:06:45,270 There is another way, it may store these files in a data structure such as a standard map in Java, and then take it out when it is sent and put it in the corresponding request. 53 00:06:47,470 --> 00:06:54,130 We can complete the entire analysis process through a manual trace. 54 00:06:54,930 --> 00:07:04,310 Of course, we have also explored a process related to automating this process, that is, it may be possible to do such a method through 5-point analysis. 55 00:07:05,310 --> 00:07:08,050 There are some problems with static 5-point analysis. 56 00:07:08,610 --> 00:07:15,430 For example, there are some problems with the hidden call, such as the multi-line of this bind. 57 00:07:16,850 --> 00:07:23,510 For dynamics, we have a simpler way, which is to hook up the relevant file name. 58 00:07:23,510 --> 00:07:34,670 For example, we want to send a file name 1, and then we can hook up all the files to read and write, and then print out the return number. 59 00:07:35,850 --> 00:07:45,550 Through this multi-stage binding, we can reproduce the entire process and find some points of such a hook. 60 00:07:47,730 --> 00:07:53,730 In addition to this hook, there may also be a method of re-packaging or re-producing. 61 00:07:53,950 --> 00:08:01,370 If this application is not mixed very seriously, we can use reverse analysis to specify its relevant source code. 62 00:08:01,370 --> 00:08:09,510 In the process of sending files, maybe its file name is already specified in a certain function, in a certain amount of power. 63 00:08:09,650 --> 00:08:13,350 For example, CVE-2017-17715. 64 00:08:13,410 --> 00:08:21,690 This is a loophole found by Project Zero in Telegram Messenger, which is also a pass-through. 65 00:08:21,730 --> 00:08:30,710 When sending files to other users or in the group, a file with a dot-dot-bar can be sent. 66 00:08:30,710 --> 00:08:33,950 When the file is downloaded, it will also be affected. 67 00:08:34,170 --> 00:08:39,990 This loophole is re-packaged or re-produced by Natalia. 68 00:08:40,090 --> 00:08:46,490 It is directly specified in the APK, and then re-packaged and modified. 69 00:08:46,490 --> 00:08:50,970 When running, a malicious file name is sent. 70 00:08:53,030 --> 00:08:59,090 Of course, in addition to the above scenario, there may also be a cloud disk. 71 00:08:59,090 --> 00:09:02,050 When the cloud disk file is downloaded, there will be some problems. 72 00:09:02,050 --> 00:09:08,190 For example, when the cloud disk is stored, the existing file name must not be stored in the server. 73 00:09:08,190 --> 00:09:11,110 It should be in the form of a hash file. 74 00:09:11,630 --> 00:09:17,250 Then, through some searches, the actual file name is unzipped. 75 00:09:17,490 --> 00:09:27,770 Then, this file name may not be very standardized or filtered by some dot-dot-bar. 76 00:09:27,770 --> 00:09:30,330 Then we also have a chance. 77 00:09:30,390 --> 00:09:36,150 There are also some manual backups or restores. 78 00:09:36,250 --> 00:09:38,530 This may also happen. 79 00:09:39,850 --> 00:09:45,390 Then let's talk about the third link, which is some useful skills. 80 00:09:45,410 --> 00:09:48,610 Next, we will talk about some actual loopholes. 81 00:09:52,380 --> 00:09:56,380 Before using, we need to figure out a few problems. 82 00:09:56,380 --> 00:10:01,320 One of them is what kind of loopholes we can classify as. 83 00:10:03,200 --> 00:10:05,320 I have divided it into three categories. 84 00:10:05,320 --> 00:10:13,300 The first category is a single cross-path loophole. 85 00:10:13,300 --> 00:10:19,400 In this kind of loophole, most of it is caused by the output of the component plus some logical loopholes. 86 00:10:19,400 --> 00:10:23,960 For example, this container provider and this file copy. 87 00:10:25,020 --> 00:10:31,480 The second category is a cross-path loophole that can directly cover any file. 88 00:10:32,320 --> 00:10:34,920 This is widely used. 89 00:10:34,920 --> 00:10:41,460 In the last year's Mobile Pong Tournament, there were two cases like this. 90 00:10:41,460 --> 00:10:45,280 This is also the most commonly used one. 91 00:10:45,280 --> 00:10:47,980 There may be a cross-path loophole in Zip. 92 00:10:48,260 --> 00:10:53,800 The third category is some other categories. 93 00:10:53,800 --> 00:10:57,460 We can download something. 94 00:10:57,460 --> 00:11:05,480 But in the process of downloading, due to some business needs, it will check whether this file exists. 95 00:11:05,480 --> 00:11:08,740 If this file exists, it will be renamed. 96 00:11:08,740 --> 00:11:13,560 In this case, it will not cause a copy of any file. 97 00:11:14,340 --> 00:11:20,620 In this case, it is usually difficult to use, but there is no way. 98 00:11:20,620 --> 00:11:22,740 We will have a related introduction later. 99 00:11:23,900 --> 00:11:30,160 This is a classic code that is renamed after the file is downloaded. 100 00:11:31,400 --> 00:11:38,460 It usually adds some extra characters before the original file is traced. 101 00:11:38,600 --> 00:11:50,420 In addition to this loophole classification, we also need to figure out which files are used in the application. 102 00:11:50,420 --> 00:11:53,380 In the process, which files are used? 103 00:11:53,540 --> 00:11:57,080 The first category is a very general file. 104 00:11:57,520 --> 00:11:59,820 Basically, all applications will have it. 105 00:11:59,820 --> 00:12:02,120 It is Share Preference. 106 00:12:03,040 --> 00:12:05,480 There are many configurations in XML files. 107 00:12:05,480 --> 00:12:07,780 These configurations may have some related information. 108 00:12:07,780 --> 00:12:10,480 Then there is Circulate Database. 109 00:12:10,980 --> 00:12:16,580 This type of file contains some related data, such as contacts, etc. 110 00:12:20,280 --> 00:12:27,680 In recent years, Android applications on the market are getting bigger and bigger. 111 00:12:27,680 --> 00:12:30,280 They have more and more functions. 112 00:12:30,280 --> 00:12:44,920 In order to ensure that the size of the initial package is small enough, some complex functions, such as video playback and image analysis, will be loaded as a plug-in. 113 00:12:44,920 --> 00:12:47,860 It will be loaded dynamically. 114 00:12:48,320 --> 00:12:50,940 It will even be dynamically updated. 115 00:12:50,940 --> 00:12:52,680 Then there is the Rippedin mechanism. 116 00:12:52,680 --> 00:12:57,240 There are many Rippedin frameworks developed in China. 117 00:12:57,240 --> 00:13:01,920 Because there is no Google Play, it produces such a relatively... 118 00:13:05,750 --> 00:13:09,770 Then there may be some binary files such as WatchServer. 119 00:13:10,430 --> 00:13:15,890 Such binary files will have some protection process, etc. 120 00:13:15,890 --> 00:13:25,670 In addition, there will also be some configuration files, such as the INI file mentioned earlier, or some files on the SD card outside the sandbox. 121 00:13:26,990 --> 00:13:29,270 We all have the opportunity to use these files. 122 00:13:29,430 --> 00:13:33,770 First, let's look at a case like CVE-2018-8084. 123 00:13:34,010 --> 00:13:36,870 This is a path traversal on a domestic browser. 124 00:13:38,010 --> 00:13:43,750 It is in the process of decompression, which is to download a zip package, and then manually decompress it. 125 00:13:43,750 --> 00:13:47,650 There is no correct verification of the content in this zip package. 126 00:13:47,650 --> 00:13:49,650 Then it will lead to... 127 00:13:49,650 --> 00:13:52,070 It can travel to any path. 128 00:13:52,070 --> 00:13:56,250 At the same time, this app is a browser app. 129 00:13:56,250 --> 00:13:57,510 So it supports... 130 00:13:57,510 --> 00:13:59,870 It supports some video files. 131 00:14:00,110 --> 00:14:03,950 It supports playing some videos online. 132 00:14:04,110 --> 00:14:08,810 So it has a lot of SO files that exist in the form of inserted keys. 133 00:14:10,510 --> 00:14:14,810 For example, this libvplayer.so is a very good coverage target. 134 00:14:14,810 --> 00:14:16,050 We pass... 135 00:14:16,050 --> 00:14:18,510 We pass this... 136 00:14:19,270 --> 00:14:23,210 libvplayer.so gni-onload function rewrite. 137 00:14:23,210 --> 00:14:24,290 Then in this... 138 00:14:24,290 --> 00:14:26,610 Just download one of our... 139 00:14:27,370 --> 00:14:27,850 a shell. 140 00:14:27,850 --> 00:14:29,570 And then execute it. 141 00:14:29,570 --> 00:14:32,030 We can... 142 00:14:32,030 --> 00:14:36,150 When it plays a video, to get a shell. 143 00:14:36,150 --> 00:14:37,970 The interesting thing is that this loophole... 144 00:14:37,970 --> 00:14:43,650 After replacing this libvplayer, This app can still run normally. 145 00:14:43,650 --> 00:14:45,830 That is, the user has no perception. 146 00:14:46,010 --> 00:14:51,350 And in the process of decompression of this app, It also can't see this kind of loophole. 147 00:14:51,350 --> 00:14:53,730 So this loophole is still quite good. 148 00:14:54,110 --> 00:14:56,090 The second case is... 149 00:14:56,090 --> 00:14:57,350 It also uses a plugin. 150 00:14:57,350 --> 00:14:58,670 But it is... 151 00:14:59,670 --> 00:15:00,250 This... 152 00:15:00,250 --> 00:15:01,570 It can't... 153 00:15:01,570 --> 00:15:03,570 Directly cover these files. 154 00:15:03,670 --> 00:15:06,330 This loophole is in the web browser master. 155 00:15:06,330 --> 00:15:07,750 A path... 156 00:15:07,750 --> 00:15:10,970 When it downloads the plugin, There is a loophole. 157 00:15:10,970 --> 00:15:13,750 That is, a user sends to another user... 158 00:15:14,770 --> 00:15:24,830 When sending an app with a malicious file name, A malicious plugin, If it clicks to download, So when it downloads the next time, No... 159 00:15:24,830 --> 00:15:29,330 When it re-opens the app next time, There is a possibility that it will cause... 160 00:15:29,330 --> 00:15:31,270 An attack on RCE. 161 00:15:31,270 --> 00:15:33,550 The specific situation of this loophole is like this. 162 00:15:33,550 --> 00:15:35,710 That is... 163 00:15:35,710 --> 00:15:36,410 Well... 164 00:15:37,950 --> 00:15:43,630 In the process of forcing use, Because when we are in the file hook, We will find... 165 00:15:43,630 --> 00:15:45,630 It has a file called FinalCore.java. 166 00:15:46,130 --> 00:15:50,810 Then before this FinalCore.java, It will first detect this... 167 00:15:50,810 --> 00:15:51,710 NewCore.java... 168 00:15:51,710 --> 00:15:52,950 Such a file. 169 00:15:54,990 --> 00:15:55,550 Well... 170 00:15:55,550 --> 00:15:58,030 Let's confirm this... 171 00:15:58,030 --> 00:15:59,270 Related logic code. 172 00:15:59,270 --> 00:16:01,790 It depends on where these two files are read. 173 00:16:02,190 --> 00:16:03,570 There are two ways. 174 00:16:03,570 --> 00:16:06,190 Because the application of NetEase Mailbox Master, It is... 175 00:16:06,190 --> 00:16:08,250 It has some mixed encryption. 176 00:16:08,250 --> 00:16:10,890 That is, its string of characters is at least mixed. 177 00:16:10,890 --> 00:16:12,970 For example, this A.C. 178 00:16:13,150 --> 00:16:16,030 Through some static methods, You can... 179 00:16:19,230 --> 00:16:20,010 Decrypt this algorithm. 180 00:16:20,010 --> 00:16:22,570 This is not a simple Base64 decode. 181 00:16:22,570 --> 00:16:24,570 It has some other steps. 182 00:16:26,810 --> 00:16:27,430 Then... 183 00:16:27,430 --> 00:16:30,270 You can also directly hook this A.C. 184 00:16:30,270 --> 00:16:32,390 Give its related results to... 185 00:16:32,390 --> 00:16:34,670 The return value. 186 00:16:34,670 --> 00:16:36,430 It can be dynamically decrypted. 187 00:16:36,430 --> 00:16:37,470 Anyway, we end up... 188 00:16:37,470 --> 00:16:39,670 Located here. 189 00:16:39,830 --> 00:16:42,310 The general logic is... 190 00:16:42,310 --> 00:16:46,690 Before loading this FinalCore.java, It will first check... 191 00:16:46,990 --> 00:16:48,710 Does this NewCore.java exist? 192 00:16:48,710 --> 00:16:52,630 If this NewCore.java exists, Rename it. 193 00:16:52,630 --> 00:16:54,890 Rename to this FinalCore.java. 194 00:16:54,910 --> 00:16:56,390 This business... 195 00:16:56,910 --> 00:17:01,350 When NetEase Mailbox Master first opened the screen, It has an ad. 196 00:17:01,350 --> 00:17:03,910 This ad has an update function. 197 00:17:04,070 --> 00:17:05,450 The update of this ad... 198 00:17:05,450 --> 00:17:08,010 Of course, it is not possible to download it every time. 199 00:17:08,130 --> 00:17:10,010 Reinstall such an application. 200 00:17:10,010 --> 00:17:11,650 And then update it. 201 00:17:11,650 --> 00:17:12,670 It can be dynamic. 202 00:17:12,670 --> 00:17:14,250 Push something. 203 00:17:14,610 --> 00:17:16,670 So it led to this loophole. 204 00:17:17,070 --> 00:17:17,610 We... 205 00:17:18,630 --> 00:17:22,870 Therefore, although we are in the process of re-downloading, It will be re-named. 206 00:17:22,870 --> 00:17:24,670 So we don't have this... 207 00:17:24,670 --> 00:17:26,670 The right to cover any file. 208 00:17:26,930 --> 00:17:29,370 But we can put such a NewCore.java. 209 00:17:29,370 --> 00:17:34,930 Then when it is downloaded next time, You may get a share. 210 00:17:35,390 --> 00:17:48,190 In order to ensure the normal operation of this application, That is, to ensure that this exploit is good enough, We need to do some follow-up operations on the downloaded file. 211 00:17:48,190 --> 00:17:55,430 For example, If we want to ensure its function, We can only insert some Smarty codes in it. 212 00:17:56,230 --> 00:17:58,270 Then get a share. 213 00:17:58,270 --> 00:18:00,270 The usual method is... 214 00:18:01,990 --> 00:18:06,050 Generally speaking, We generate such a share through Joseph or Metasploit. 215 00:18:07,470 --> 00:18:10,090 Then extract a share code from it. 216 00:18:10,090 --> 00:18:12,650 Finally, insert it into this related code. 217 00:18:12,650 --> 00:18:21,230 In the process of loading this DexPlusLoader, In the process of this hook, We can tell which types are being loaded. 218 00:18:21,230 --> 00:18:30,550 Then in these types of structure functions, Or some with context functions, We can insert this related payload star code. 219 00:18:30,550 --> 00:18:33,790 To get a remote reverse share. 220 00:18:36,030 --> 00:18:42,810 In addition to the plug-in, Maybe the application itself also has some related codes. 221 00:18:42,810 --> 00:18:43,850 There is a loophole. 222 00:18:43,850 --> 00:18:47,670 For example, Natali found this... 223 00:18:48,230 --> 00:18:51,250 There is such a loophole in the traversal code in Telegram. 224 00:18:51,250 --> 00:18:54,370 It can't cause any file coverage. 225 00:18:54,370 --> 00:18:58,430 However, it is in this KGNet structure. 226 00:18:58,430 --> 00:19:01,830 KGNet is a network related structure that manages Telegram. 227 00:19:03,550 --> 00:19:05,310 It has a configuration file. 228 00:19:05,310 --> 00:19:09,630 In the process of loading the configuration file, It has a back-up mechanism. 229 00:19:09,750 --> 00:19:14,710 That is to say, It will first check if this .bak file exists. 230 00:19:14,710 --> 00:19:17,970 If this .bak file exists, Restore it. 231 00:19:18,070 --> 00:19:20,560 This is usually due to... 232 00:19:20,560 --> 00:19:21,100 This... 233 00:19:21,100 --> 00:19:26,800 In order to co-operate, Some related logic is set. 234 00:19:28,380 --> 00:19:38,520 Therefore, In the process of exploring this loophole, Found that if you write to this .bak file, It may lead to this... 235 00:19:38,520 --> 00:19:40,720 The file is in the process of analysis. 236 00:19:40,720 --> 00:19:42,520 Because of some format problems. 237 00:19:42,520 --> 00:19:44,680 Because there are also some loopholes in it. 238 00:19:44,680 --> 00:19:45,680 Such a loophole. 239 00:19:45,680 --> 00:19:47,560 It will lead to a crash. 240 00:19:47,560 --> 00:19:48,520 So... 241 00:19:49,500 --> 00:19:51,520 So there will be some impact. 242 00:19:51,520 --> 00:19:52,440 Then it also... 243 00:19:53,100 --> 00:19:56,580 In this KGNet.dat file, It also... 244 00:19:57,280 --> 00:19:58,620 Set this... 245 00:19:58,620 --> 00:20:00,540 Related to Telegram... 246 00:20:01,400 --> 00:20:02,780 An IP port of the server. 247 00:20:02,780 --> 00:20:04,680 So there is a potential possibility. 248 00:20:04,680 --> 00:20:06,940 If this Telegram protocol is... 249 00:20:06,940 --> 00:20:11,100 After you figure it out, It may be possible to make a session hijack. 250 00:20:11,220 --> 00:20:15,100 But in this case, Some more in-depth analysis may be needed. 251 00:20:16,040 --> 00:20:20,740 But if such a loophole is used, Specific applications are needed. 252 00:20:20,740 --> 00:20:22,040 To analyze in detail. 253 00:20:22,240 --> 00:20:22,920 And... 254 00:20:22,920 --> 00:20:24,720 It may be difficult to have some... 255 00:20:24,720 --> 00:20:26,920 It is difficult to have some output. 256 00:20:27,020 --> 00:20:28,680 We found... 257 00:20:28,680 --> 00:20:31,200 A more universal way of use. 258 00:20:31,600 --> 00:20:34,420 In AOSP's original... 259 00:20:34,420 --> 00:20:36,040 Share preference. 260 00:20:36,040 --> 00:20:37,100 Such a very universal... 261 00:20:37,760 --> 00:20:39,920 A file type in the middle. 262 00:20:40,060 --> 00:20:41,440 It also has... 263 00:20:41,440 --> 00:20:43,300 Similar to this KGNet module. 264 00:20:43,300 --> 00:20:45,560 A backup mechanism. 265 00:20:45,940 --> 00:20:47,160 That is to say... 266 00:20:47,160 --> 00:20:49,120 Before it loads each... 267 00:20:49,120 --> 00:20:50,040 Share preference... 268 00:20:51,060 --> 00:20:52,540 XML file. 269 00:20:52,540 --> 00:20:55,060 It will first check this related... 270 00:20:55,060 --> 00:20:56,820 Does BAK exist? 271 00:20:56,820 --> 00:20:58,820 If it exists, it is RESTORE. 272 00:20:58,820 --> 00:21:01,100 After RESTORE, it can cause... 273 00:21:01,100 --> 00:21:02,800 An indirect write-in. 274 00:21:02,800 --> 00:21:05,300 That is to say, although we can't cover... 275 00:21:06,140 --> 00:21:07,740 Cover this XML. 276 00:21:07,740 --> 00:21:09,660 But we can write an XML... 277 00:21:09,660 --> 00:21:10,720 To BAK. 278 00:21:10,720 --> 00:21:12,800 In this way, when it loads... 279 00:21:12,800 --> 00:21:15,100 This loadSharePreference... 280 00:21:15,100 --> 00:21:16,860 It will also work. 281 00:21:16,860 --> 00:21:18,640 It is equivalent to... 282 00:21:18,640 --> 00:21:20,320 Covering this XML. 283 00:21:20,320 --> 00:21:23,400 Causing any share preference to be covered. 284 00:21:25,340 --> 00:21:26,720 In the case of Telegram... 285 00:21:27,880 --> 00:21:29,400 We can see... 286 00:21:29,400 --> 00:21:31,400 There is an XML called UserConfig. 287 00:21:32,220 --> 00:21:35,620 There is an XML called UserConfig. 288 00:21:37,320 --> 00:21:39,940 There is an XML called UserConfig. 289 00:21:39,940 --> 00:21:40,360 There is an XML called UserConfig. 290 00:21:40,360 --> 00:21:40,700 There is an XML called UserConfig. 291 00:21:40,700 --> 00:21:42,990 There will be its ID... 292 00:21:43,660 --> 00:21:44,380 FirstName... 293 00:21:45,340 --> 00:21:46,080 PhoneNumber... 294 00:21:46,080 --> 00:21:47,340 These things. 295 00:21:48,570 --> 00:21:50,360 After we cover this file... 296 00:21:50,360 --> 00:21:51,660 What effect can it cause? 297 00:21:51,820 --> 00:21:55,120 After covering TGNet and UserConfig at the same time... 298 00:21:55,120 --> 00:21:58,700 Can make this target user's... 299 00:21:58,700 --> 00:21:59,000 Account... 300 00:21:59,000 --> 00:22:00,600 Replace it with our own account. 301 00:22:00,600 --> 00:22:01,420 That is to say... 302 00:22:01,420 --> 00:22:03,480 It is like a... 303 00:22:03,480 --> 00:22:06,380 When other users send a file... 304 00:22:06,380 --> 00:22:09,180 We can see it here in real time. 305 00:22:09,180 --> 00:22:12,920 It creates a session hijack effect. 306 00:22:12,920 --> 00:22:13,520 Then... 307 00:22:13,520 --> 00:22:16,660 It also has a device binding effect. 308 00:22:16,660 --> 00:22:17,500 That is to say... 309 00:22:17,500 --> 00:22:18,680 It logs in there. 310 00:22:18,680 --> 00:22:20,600 Then I re-log in here. 311 00:22:20,600 --> 00:22:22,280 It can no longer... 312 00:22:22,280 --> 00:22:24,420 It can no longer forcibly... 313 00:22:24,420 --> 00:22:25,720 A offline. 314 00:22:26,060 --> 00:22:29,220 No matter whose account it logs in later... 315 00:22:29,220 --> 00:22:30,960 Because we have implemented... 316 00:22:30,960 --> 00:22:32,560 A device binding operation. 317 00:22:32,560 --> 00:22:34,660 As long as we forcibly log in here... 318 00:22:34,660 --> 00:22:35,760 It will offline there. 319 00:22:35,760 --> 00:22:37,720 No matter whose account it logs in. 320 00:22:39,340 --> 00:22:41,380 We can take a look at this... 321 00:22:41,380 --> 00:22:42,520 It is a common... 322 00:22:42,520 --> 00:22:44,080 Replacement of SharedPreference. 323 00:22:44,080 --> 00:22:45,780 What effect can it cause? 324 00:22:47,400 --> 00:22:48,120 This... 325 00:22:48,120 --> 00:22:50,240 In SharedPreference... 326 00:22:50,240 --> 00:22:52,400 Usually there will be some... 327 00:22:52,400 --> 00:22:53,420 Very important effects. 328 00:22:53,420 --> 00:22:56,520 For example, some links of HTTP. 329 00:22:56,520 --> 00:22:58,260 It may contain some... 330 00:22:58,260 --> 00:22:59,580 Download address of the plug-in. 331 00:22:59,580 --> 00:23:00,620 Update address. 332 00:23:00,620 --> 00:23:01,680 There will be some updates. 333 00:23:01,680 --> 00:23:02,500 There will be some... 334 00:23:02,500 --> 00:23:05,300 Some links of APK. 335 00:23:06,380 --> 00:23:08,500 If we change these places... 336 00:23:08,500 --> 00:23:10,940 It may cause RCE. 337 00:23:10,940 --> 00:23:11,520 Or... 338 00:23:11,520 --> 00:23:13,240 There is a way to fish. 339 00:23:13,300 --> 00:23:16,320 Then it may specify some plug-ins. 340 00:23:16,680 --> 00:23:17,280 Or... 341 00:23:17,280 --> 00:23:19,440 A version code itself. 342 00:23:19,440 --> 00:23:21,760 If we lower it... 343 00:23:21,760 --> 00:23:22,840 That is to say... 344 00:23:22,840 --> 00:23:23,800 It was originally 6.1. 345 00:23:23,800 --> 00:23:24,980 You change it to 6.0. 346 00:23:24,980 --> 00:23:26,960 Then in the next check update... 347 00:23:26,960 --> 00:23:28,540 There will be an update. 348 00:23:28,540 --> 00:23:29,960 Then according to... 349 00:23:29,960 --> 00:23:32,320 Some links of HTTP. 350 00:23:32,680 --> 00:23:34,120 It may... 351 00:23:34,120 --> 00:23:36,140 Implement this attack. 352 00:23:37,080 --> 00:23:37,500 That is to say... 353 00:23:37,500 --> 00:23:40,820 Run the update logic. 354 00:23:42,880 --> 00:23:44,300 There are some related... 355 00:23:44,880 --> 00:23:46,000 Hashi files. 356 00:23:46,800 --> 00:23:48,620 You want to download an... 357 00:23:48,620 --> 00:23:49,800 SO. 358 00:23:49,800 --> 00:23:52,480 But it may be through an HTTPS. 359 00:23:52,480 --> 00:23:54,640 It has already downloaded the SO MD5. 360 00:23:54,860 --> 00:23:56,400 Even if you replace it... 361 00:23:56,400 --> 00:23:57,300 It is also... 362 00:23:57,300 --> 00:24:00,360 In the process of complete verification... 363 00:24:00,360 --> 00:24:02,040 It will fail. 364 00:24:02,660 --> 00:24:03,840 So if we... 365 00:24:03,840 --> 00:24:05,700 After replacing all these things... 366 00:24:05,700 --> 00:24:08,120 You can implement the whole attack. 367 00:24:08,620 --> 00:24:09,580 And then... 368 00:24:09,580 --> 00:24:12,020 There may be some server-related codes. 369 00:24:12,020 --> 00:24:13,460 For example, in some browsers... 370 00:24:13,460 --> 00:24:15,440 It will have some DNS cache. 371 00:24:15,480 --> 00:24:17,440 Some IP port. 372 00:24:17,440 --> 00:24:19,100 Even some proxy. 373 00:24:19,100 --> 00:24:20,600 After modifying these things... 374 00:24:20,600 --> 00:24:21,620 It can also achieve... 375 00:24:22,740 --> 00:24:25,320 Some cool effects. 376 00:24:27,080 --> 00:24:28,420 The third... 377 00:24:28,420 --> 00:24:31,320 One point we can pay attention to is... 378 00:24:31,320 --> 00:24:33,060 Android's Rebooting. 379 00:24:33,060 --> 00:24:34,160 That is... 380 00:24:34,970 --> 00:24:37,080 In the middle of the path traversal loop... 381 00:24:37,080 --> 00:24:38,340 This kind of loop... 382 00:24:38,340 --> 00:24:40,200 This kind of file also has... 383 00:24:40,200 --> 00:24:41,760 A great opportunity. 384 00:24:43,260 --> 00:24:44,900 Rebooting is... 385 00:24:44,900 --> 00:24:46,100 In the application... 386 00:24:46,100 --> 00:24:47,920 When you don't need to reinstall... 387 00:24:47,920 --> 00:24:50,560 It can be very fast and convenient... 388 00:24:50,560 --> 00:24:52,300 Put this resource file... 389 00:24:52,300 --> 00:24:53,460 Even... 390 00:24:53,780 --> 00:24:55,320 Dex files, SO files... 391 00:24:55,320 --> 00:24:56,960 Some updates... 392 00:24:56,960 --> 00:24:59,680 It can be used to quickly repair... 393 00:24:59,680 --> 00:25:01,260 Some emergency booting... 394 00:25:01,260 --> 00:25:02,500 In some cases... 395 00:25:02,500 --> 00:25:05,300 It is widely used in large applications. 396 00:25:07,420 --> 00:25:08,780 In China... 397 00:25:08,780 --> 00:25:12,380 All major manufacturers have some related frameworks. 398 00:25:12,380 --> 00:25:13,660 For example, Tencent... 399 00:25:13,660 --> 00:25:14,380 There are many... 400 00:25:14,380 --> 00:25:15,620 For example, Tink... 401 00:25:18,060 --> 00:25:18,780 SuperHardPrint... 402 00:25:18,780 --> 00:25:19,500 And... 403 00:25:19,500 --> 00:25:21,520 WeChat Reading... 404 00:25:22,360 --> 00:25:23,080 Ali... 405 00:25:24,480 --> 00:25:25,200 Meituan... 406 00:25:26,620 --> 00:25:29,100 Rebooting will introduce some new problems. 407 00:25:29,100 --> 00:25:30,060 That is... 408 00:25:30,060 --> 00:25:31,860 It is difficult for us to guarantee... 409 00:25:31,860 --> 00:25:34,160 The completeness of the downloaded code... 410 00:25:34,160 --> 00:25:36,340 We can control it. 411 00:25:36,400 --> 00:25:37,480 That is... 412 00:25:37,480 --> 00:25:39,220 It may be tampered with... 413 00:25:39,220 --> 00:25:40,660 Or it may load some... 414 00:25:41,210 --> 00:25:42,980 Some codes that we can't control. 415 00:25:43,020 --> 00:25:43,940 In this case... 416 00:25:43,940 --> 00:25:47,140 It may lead to the execution of arbitrary codes. 417 00:25:47,140 --> 00:25:48,940 This is a very dangerous effect. 418 00:25:50,320 --> 00:25:51,480 In our... 419 00:25:52,400 --> 00:25:52,980 For... 420 00:25:52,980 --> 00:25:55,220 In our process of debugging the mailbox application... 421 00:25:56,320 --> 00:25:57,540 We also found that... 422 00:25:57,540 --> 00:25:58,760 In the QQ mailbox... 423 00:25:58,760 --> 00:26:00,080 There are also related... 424 00:26:00,950 --> 00:26:02,520 Related path traversal loopholes. 425 00:26:02,520 --> 00:26:04,960 It can't cause arbitrary files to be covered. 426 00:26:04,960 --> 00:26:07,060 But it has a Rebooting mechanism. 427 00:26:07,060 --> 00:26:09,520 Let's take a look at a related implementation of its Rebooting mechanism. 428 00:26:10,500 --> 00:26:12,320 When it is updated... 429 00:26:12,320 --> 00:26:13,420 It will download this... 430 00:26:13,420 --> 00:26:15,340 Download this link. 431 00:26:15,340 --> 00:26:17,960 Then do some signature verification. 432 00:26:17,960 --> 00:26:19,280 After the signature verification... 433 00:26:19,280 --> 00:26:21,100 There may be some MD5 verification. 434 00:26:21,100 --> 00:26:22,260 In the middle of these processes... 435 00:26:22,260 --> 00:26:23,800 There is no problem. 436 00:26:24,060 --> 00:26:26,360 Then it will put this... 437 00:26:26,360 --> 00:26:27,640 The DEX file inside... 438 00:26:27,640 --> 00:26:29,880 To a specific folder. 439 00:26:30,040 --> 00:26:31,540 This specific folder... 440 00:26:31,540 --> 00:26:33,180 Is specified in an XML. 441 00:26:33,180 --> 00:26:36,060 Up to this point... 442 00:26:36,060 --> 00:26:36,840 There is no problem. 443 00:26:36,840 --> 00:26:39,420 Because we can't control all of these. 444 00:26:39,820 --> 00:26:41,280 But when it is... 445 00:26:43,120 --> 00:26:43,480 Rebooting... 446 00:26:43,840 --> 00:26:45,680 It has some... 447 00:26:45,680 --> 00:26:47,480 Very dangerous operations. 448 00:26:47,480 --> 00:26:49,660 It uses a list file operation. 449 00:26:49,660 --> 00:26:51,180 That is to say, it will put this... 450 00:26:52,660 --> 00:26:54,320 Under the Rebooting path... 451 00:26:54,320 --> 00:26:55,620 All the DEX files... 452 00:26:55,620 --> 00:26:57,600 List them all. 453 00:26:57,600 --> 00:26:59,240 Then download them one by one. 454 00:26:59,360 --> 00:27:01,120 There is no way to do this. 455 00:27:02,180 --> 00:27:03,460 Because a lot of... 456 00:27:03,460 --> 00:27:05,120 Now this kind of... 457 00:27:06,100 --> 00:27:06,760 DEX files... 458 00:27:06,760 --> 00:27:08,520 There are some shortcomings. 459 00:27:09,780 --> 00:27:12,340 The number of methods supported by DEX files... 460 00:27:12,340 --> 00:27:13,800 Is limited. 461 00:27:13,800 --> 00:27:15,380 So it needs... 462 00:27:15,380 --> 00:27:17,200 Multi-DEX support. 463 00:27:17,200 --> 00:27:18,000 Such a mechanism. 464 00:27:18,000 --> 00:27:19,920 So there will be a lot of DEX. 465 00:27:19,920 --> 00:27:22,420 In order to integrate this change... 466 00:27:23,120 --> 00:27:24,320 The way they came up with... 467 00:27:24,320 --> 00:27:26,300 Is to use such a list file... 468 00:27:26,300 --> 00:27:28,900 To make a list. 469 00:27:28,900 --> 00:27:30,840 Then make an attack. 470 00:27:30,840 --> 00:27:32,340 And make a download. 471 00:27:32,340 --> 00:27:35,100 At the same time, at the level of DEX... 472 00:27:35,100 --> 00:27:36,800 There is no way to do... 473 00:27:36,800 --> 00:27:38,460 Signature verification. 474 00:27:38,460 --> 00:27:40,100 Because in this file... 475 00:27:40,100 --> 00:27:42,580 There is no information related to the application signature. 476 00:27:44,040 --> 00:27:46,920 So we can... 477 00:27:46,920 --> 00:27:49,320 Like this... 478 00:27:49,320 --> 00:27:49,720 DEX... 479 00:27:49,720 --> 00:27:50,900 DEX is... 480 00:27:51,740 --> 00:27:53,400 M-O-A-I patch... 481 00:27:53,400 --> 00:27:54,720 Under this path... 482 00:27:54,720 --> 00:27:57,220 Write a DEX of any kind. 483 00:27:57,220 --> 00:27:58,360 That is to use... 484 00:27:58,360 --> 00:28:00,900 The method we introduced in the online email master... 485 00:28:00,900 --> 00:28:03,020 This kind of SMARTY input method. 486 00:28:03,020 --> 00:28:04,020 Input a file. 487 00:28:04,020 --> 00:28:05,640 Then write it in. 488 00:28:05,800 --> 00:28:07,820 When it is executed next time... 489 00:28:07,820 --> 00:28:10,020 You can get a reverse email. 490 00:28:10,280 --> 00:28:11,900 The reverse file of the mailbox... 491 00:28:11,900 --> 00:28:14,020 I think the effect of the application is still great. 492 00:28:14,020 --> 00:28:16,580 Not only can you do this... 493 00:28:17,200 --> 00:28:18,080 Dragon attack. 494 00:28:18,080 --> 00:28:18,960 That is to say... 495 00:28:18,960 --> 00:28:23,100 Copy all his mails at the same time. 496 00:28:23,120 --> 00:28:25,340 So that we can see all his emails. 497 00:28:25,340 --> 00:28:27,820 You can fake his identity and send emails. 498 00:28:27,820 --> 00:28:29,900 It can even cause insect effects. 499 00:28:29,900 --> 00:28:30,920 That is... 500 00:28:30,920 --> 00:28:32,520 For each contact person... 501 00:28:33,120 --> 00:28:35,020 Each such contact person... 502 00:28:35,020 --> 00:28:37,060 Send more such files... 503 00:28:37,060 --> 00:28:39,560 There is still a certain range of influence. 504 00:28:41,080 --> 00:28:42,780 But we just mentioned... 505 00:28:42,780 --> 00:28:44,900 This is a problem with the hot pudding mechanism. 506 00:28:45,860 --> 00:28:46,580 So... 507 00:28:46,580 --> 00:28:49,760 Will only this old version be affected? 508 00:28:49,760 --> 00:28:51,700 Because there is no pudding in the new version. 509 00:28:51,700 --> 00:28:54,020 So there is no pudding path. 510 00:28:54,020 --> 00:28:56,020 We found in the middle of the analysis... 511 00:28:56,020 --> 00:28:57,240 He has such a... 512 00:28:57,240 --> 00:28:59,480 A pudding-specific XML file. 513 00:28:59,920 --> 00:29:00,400 Inside... 514 00:29:01,940 --> 00:29:02,900 This... 515 00:29:03,920 --> 00:29:05,840 When to hit the pudding... 516 00:29:05,840 --> 00:29:07,420 Pudding link... 517 00:29:07,420 --> 00:29:10,000 What path will pudding be placed under? 518 00:29:10,760 --> 00:29:11,800 And this... 519 00:29:11,800 --> 00:29:12,840 Related... 520 00:29:12,840 --> 00:29:14,160 Such a patch key... 521 00:29:14,160 --> 00:29:18,440 If you replace this file... 522 00:29:18,440 --> 00:29:19,060 That is... 523 00:29:19,060 --> 00:29:21,420 Can reach this... 524 00:29:21,420 --> 00:29:22,680 Multi-stage... 525 00:29:24,240 --> 00:29:25,920 Requires more... 526 00:29:25,920 --> 00:29:27,240 An interaction of cycles... 527 00:29:27,240 --> 00:29:29,660 But it can eventually reach such a... 528 00:29:29,660 --> 00:29:30,720 In the middle of the new version... 529 00:29:31,060 --> 00:29:32,520 Can also be used... 530 00:29:35,060 --> 00:29:37,600 Finally, let's talk about... 531 00:29:37,600 --> 00:29:39,840 How to do a fix. 532 00:29:40,200 --> 00:29:41,420 Before that... 533 00:29:41,420 --> 00:29:43,420 We just talked about this... 534 00:29:44,340 --> 00:29:45,580 Some common files... 535 00:29:45,580 --> 00:29:47,100 For example, the SQLite database... 536 00:29:47,100 --> 00:29:49,460 This file can actually... 537 00:29:49,460 --> 00:29:51,380 In a situation where it cannot be covered... 538 00:29:51,380 --> 00:29:52,340 To be covered... 539 00:29:52,340 --> 00:29:53,660 Because we can... 540 00:29:56,580 --> 00:29:58,040 Write a journal file... 541 00:29:58,040 --> 00:29:58,480 Under the db path... 542 00:29:58,480 --> 00:30:01,060 When it rolls back in time... 543 00:30:01,060 --> 00:30:02,660 It will have a... 544 00:30:02,660 --> 00:30:04,200 The effect of rolling back... 545 00:30:04,200 --> 00:30:05,940 Can put this... 546 00:30:06,700 --> 00:30:08,320 A change in the database... 547 00:30:08,320 --> 00:30:10,480 Is to modify it back... 548 00:30:10,480 --> 00:30:12,300 Indirectly create a... 549 00:30:12,300 --> 00:30:14,340 Any coverage of a db file... 550 00:30:14,340 --> 00:30:16,820 And finally, let's talk about how to fix it. 551 00:30:16,820 --> 00:30:19,120 Fix, in fact... 552 00:30:19,120 --> 00:30:20,840 The most critical step is... 553 00:30:20,840 --> 00:30:22,760 To do a... 554 00:30:22,760 --> 00:30:24,660 To do a... 555 00:30:24,660 --> 00:30:25,600 A bit of a test... 556 00:30:25,600 --> 00:30:28,780 First of all, we have to ensure that this file name... 557 00:30:28,780 --> 00:30:29,620 It is... 558 00:30:29,620 --> 00:30:31,220 To standardize it... 559 00:30:31,220 --> 00:30:34,940 Use this... 560 00:30:37,000 --> 00:30:38,480 Use this... 561 00:30:39,520 --> 00:30:40,260 Or... 562 00:30:40,260 --> 00:30:41,820 Such a standardized file... 563 00:30:41,820 --> 00:30:43,040 Read it out... 564 00:30:43,040 --> 00:30:43,680 And then... 565 00:30:43,680 --> 00:30:46,380 See if its db path... 566 00:30:46,380 --> 00:30:47,460 Is it... 567 00:30:47,460 --> 00:30:51,420 Under the path we need to write... 568 00:30:51,420 --> 00:30:52,880 If it exceeds... 569 00:30:52,880 --> 00:30:54,580 It is a path... 570 00:30:54,580 --> 00:30:56,260 A process that may exist... 571 00:30:56,260 --> 00:30:58,580 If we add this line of code... 572 00:30:58,580 --> 00:31:00,680 Is to be able to... 573 00:31:00,680 --> 00:31:01,940 Can cancel this path...