1 00:00:07,600 --> 00:00:09,920 hello everyone good morning good 2 00:00:09,920 --> 00:00:12,719 afternoon good evening good night from 3 00:00:12,719 --> 00:00:15,360 the different parts of the world you are 4 00:00:15,360 --> 00:00:17,520 tuning in to my talk 5 00:00:17,520 --> 00:00:20,720 welcome to my talk on your rules 6 00:00:20,720 --> 00:00:22,960 to rule them all 7 00:00:22,960 --> 00:00:24,640 thank you so much bluetooth village 8 00:00:24,640 --> 00:00:27,039 defcon for giving me an opportunity to 9 00:00:27,039 --> 00:00:28,640 present 10 00:00:28,640 --> 00:00:30,400 so today we're going to be talking about 11 00:00:30,400 --> 00:00:34,559 writing yaras which can rule them all 12 00:00:34,559 --> 00:00:36,960 my name is sarah chaudhary um i'm 13 00:00:36,960 --> 00:00:38,719 currently doing my masters in cyber 14 00:00:38,719 --> 00:00:41,040 security i'm a public cyber threat 15 00:00:41,040 --> 00:00:43,200 researcher with around five years of 16 00:00:43,200 --> 00:00:45,120 experience in 17 00:00:45,120 --> 00:00:47,600 banking and financial domain 18 00:00:47,600 --> 00:00:49,360 i have multiple published research 19 00:00:49,360 --> 00:00:52,719 papers in ieee scopus extras i've been a 20 00:00:52,719 --> 00:00:54,640 speaker and trainer at multiple 21 00:00:54,640 --> 00:00:58,079 conferences like besides san antonio 22 00:00:58,079 --> 00:01:01,199 texas besides budapest 23 00:01:01,199 --> 00:01:06,400 absec indonesia texas cybercon etc etc 24 00:01:06,400 --> 00:01:08,720 i have a background in red teaming 25 00:01:08,720 --> 00:01:12,000 malware analysis and threat intelligence 26 00:01:12,000 --> 00:01:14,159 while i'm trying to pivot my career more 27 00:01:14,159 --> 00:01:16,320 into threat intelligence 28 00:01:16,320 --> 00:01:19,280 i love motorcycles and 29 00:01:19,280 --> 00:01:22,000 all the types of adventure sports which 30 00:01:22,000 --> 00:01:24,960 gives me adrenaline rush 31 00:01:24,960 --> 00:01:27,439 that's my twitter handle 32 00:01:27,439 --> 00:01:30,159 4w4r44 33 00:01:30,159 --> 00:01:34,000 so let's dive into the talk 34 00:01:34,320 --> 00:01:36,159 so today what we're going to be talking 35 00:01:36,159 --> 00:01:38,479 about is 36 00:01:38,479 --> 00:01:41,439 what is your rules 37 00:01:41,439 --> 00:01:44,560 how can we make yara what are 38 00:01:44,560 --> 00:01:47,280 string and code based error rules and 39 00:01:47,280 --> 00:01:49,680 why code based error rule is better and 40 00:01:49,680 --> 00:01:50,640 what 41 00:01:50,640 --> 00:01:53,040 kind of rule we will write which will 42 00:01:53,040 --> 00:01:55,759 rule them all 43 00:01:55,759 --> 00:01:58,079 in case you don't know about yara don't 44 00:01:58,079 --> 00:02:00,640 worry about it i'll try to take it from 45 00:02:00,640 --> 00:02:03,439 the scratch 46 00:02:04,719 --> 00:02:05,520 so 47 00:02:05,520 --> 00:02:07,600 malware comes into different forms it 48 00:02:07,600 --> 00:02:09,758 can come as a macros embedded in your 49 00:02:09,758 --> 00:02:12,720 word document or vb script 50 00:02:12,720 --> 00:02:14,160 pdf 51 00:02:14,160 --> 00:02:16,800 as a file 52 00:02:16,800 --> 00:02:19,520 and the list goes on and on and on and 53 00:02:19,520 --> 00:02:21,680 on 54 00:02:21,680 --> 00:02:24,080 malware's a deceptive and you never know 55 00:02:24,080 --> 00:02:25,280 what's 56 00:02:25,280 --> 00:02:27,760 coming and what file is what 57 00:02:27,760 --> 00:02:30,080 which which is clean which is malware 58 00:02:30,080 --> 00:02:31,519 you know no so 59 00:02:31,519 --> 00:02:34,160 is there a one-stop shop tool to deal 60 00:02:34,160 --> 00:02:35,519 with them all 61 00:02:35,519 --> 00:02:37,120 yes there is 62 00:02:37,120 --> 00:02:40,080 er is your answer 63 00:02:40,080 --> 00:02:42,720 so what is yara 64 00:02:42,720 --> 00:02:46,319 it's an open source tool to identify and 65 00:02:46,319 --> 00:02:48,080 classify 66 00:02:48,080 --> 00:02:50,400 malware samples or 67 00:02:50,400 --> 00:02:52,560 anything it's it's a swiss army knife 68 00:02:52,560 --> 00:02:56,800 for malware analyst threat researcher 69 00:02:56,800 --> 00:02:58,800 it is free and open source it was 70 00:02:58,800 --> 00:03:02,959 created by mr victor m alvarez and it's 71 00:03:02,959 --> 00:03:05,599 maintained by wires total 72 00:03:05,599 --> 00:03:09,920 modern day ips ids frozen preventions 73 00:03:09,920 --> 00:03:13,599 firewalls cms they all support ingestion 74 00:03:13,599 --> 00:03:14,800 of 75 00:03:14,800 --> 00:03:17,040 urls 76 00:03:17,040 --> 00:03:18,640 to find 77 00:03:18,640 --> 00:03:21,519 uh unusual activities and matters 78 00:03:21,519 --> 00:03:22,480 and 79 00:03:22,480 --> 00:03:24,480 you can do almost anything with your 80 00:03:24,480 --> 00:03:25,760 rules 81 00:03:25,760 --> 00:03:28,319 so each year rule 82 00:03:28,319 --> 00:03:30,799 consists of a set of strings and a 83 00:03:30,799 --> 00:03:33,120 boolean expression 84 00:03:33,120 --> 00:03:36,959 which determines its logic 85 00:03:37,920 --> 00:03:41,599 so what can you do with yara 86 00:03:41,599 --> 00:03:43,280 there's a lot of things you can do with 87 00:03:43,280 --> 00:03:44,720 the error 88 00:03:44,720 --> 00:03:47,440 you can identify classify files and 89 00:03:47,440 --> 00:03:49,200 malwares you can find new malware 90 00:03:49,200 --> 00:03:50,879 samples 91 00:03:50,879 --> 00:03:52,560 you can scan 92 00:03:52,560 --> 00:03:55,040 on live data streams and live network 93 00:03:55,040 --> 00:03:57,120 streams 94 00:03:57,120 --> 00:03:59,200 you can help speeding up the incident 95 00:03:59,200 --> 00:04:01,680 response process 96 00:04:01,680 --> 00:04:05,280 you can track future malwares as 97 00:04:05,280 --> 00:04:07,439 well based on the code reuse pattern 98 00:04:07,439 --> 00:04:09,120 which we gonna be talking about later in 99 00:04:09,120 --> 00:04:11,519 the talk 100 00:04:13,200 --> 00:04:14,560 we can use 101 00:04:14,560 --> 00:04:15,439 your 102 00:04:15,439 --> 00:04:18,238 you can use urls to track apd groups you 103 00:04:18,238 --> 00:04:21,040 can build your own anti-malware product 104 00:04:21,040 --> 00:04:22,960 with the help of your rules so it's a 105 00:04:22,960 --> 00:04:24,560 one-stop shop 106 00:04:24,560 --> 00:04:27,040 if you are into malware analysis or 107 00:04:27,040 --> 00:04:29,440 turning 108 00:04:30,240 --> 00:04:32,240 so how does the arrow looks like in case 109 00:04:32,240 --> 00:04:35,840 you have never seen a yara rule 110 00:04:35,919 --> 00:04:37,680 this is how it looks like 111 00:04:37,680 --> 00:04:42,960 this is how it's run so name of the rule 112 00:04:42,960 --> 00:04:45,840 at the first directory 113 00:04:45,840 --> 00:04:48,240 against which it needs to be searched 114 00:04:48,240 --> 00:04:49,199 for 115 00:04:49,199 --> 00:04:52,000 and there are different optional there's 116 00:04:52,000 --> 00:04:54,000 a lot of different optional arguments 117 00:04:54,000 --> 00:04:56,880 which you can use like finding it 118 00:04:56,880 --> 00:05:02,800 recursively multiple threads etc etc 119 00:05:02,800 --> 00:05:04,320 in case you have 120 00:05:04,320 --> 00:05:06,240 never seen a yar rule this is what it 121 00:05:06,240 --> 00:05:09,680 looks like the rule name of the rule the 122 00:05:09,680 --> 00:05:11,440 metadata 123 00:05:11,440 --> 00:05:14,800 which is important so that you can 124 00:05:14,800 --> 00:05:18,720 keep a track of what's what 125 00:05:18,880 --> 00:05:21,840 and the strings 126 00:05:21,840 --> 00:05:23,840 now there are different kinds of string 127 00:05:23,840 --> 00:05:26,400 which we can use we'll talk about that 128 00:05:26,400 --> 00:05:29,120 later and the conditions 129 00:05:29,120 --> 00:05:31,600 so what's happening here in the rule 130 00:05:31,600 --> 00:05:33,440 so in this rule 131 00:05:33,440 --> 00:05:35,919 they are this is this rule is trying to 132 00:05:35,919 --> 00:05:39,759 find the word defcon 133 00:05:39,759 --> 00:05:42,560 in any case jumble case uppercase 134 00:05:42,560 --> 00:05:47,759 lowercase and if anything has this s key 135 00:05:47,759 --> 00:05:50,639 it will flag 136 00:05:51,600 --> 00:05:52,560 so 137 00:05:52,560 --> 00:05:54,560 what yara is consists of 138 00:05:54,560 --> 00:05:58,400 it consists of three things as i told 139 00:05:58,880 --> 00:06:01,840 a metadata to keep things in track 140 00:06:01,840 --> 00:06:05,799 strings and conditions 141 00:06:06,319 --> 00:06:07,280 so 142 00:06:07,280 --> 00:06:10,080 strings here you can use uh 143 00:06:10,080 --> 00:06:12,479 different uh different types of strings 144 00:06:12,479 --> 00:06:14,560 here you can use text strings to 145 00:06:14,560 --> 00:06:17,440 identify you can use hexadecimal strings 146 00:06:17,440 --> 00:06:18,560 hex 147 00:06:18,560 --> 00:06:21,199 that is the fun part and the regex which 148 00:06:21,199 --> 00:06:23,680 is not generally recommended 149 00:06:23,680 --> 00:06:25,280 and at the last of the rule there are 150 00:06:25,280 --> 00:06:27,360 conditions which you define 151 00:06:27,360 --> 00:06:29,520 for the matching based on the strings 152 00:06:29,520 --> 00:06:32,000 you have written 153 00:06:32,000 --> 00:06:34,880 so writing a hair rule based on a unique 154 00:06:34,880 --> 00:06:37,120 string identifier doesn't take more than 155 00:06:37,120 --> 00:06:39,520 10 minutes a good error will consist of 156 00:06:39,520 --> 00:06:42,560 bytes and not just strings 157 00:06:42,560 --> 00:06:44,479 and you will find those juicy bytes 158 00:06:44,479 --> 00:06:46,479 based on the critical thinking thinking 159 00:06:46,479 --> 00:06:47,280 of 160 00:06:47,280 --> 00:06:49,440 the functions and the code reuse and the 161 00:06:49,440 --> 00:06:51,680 program flow 162 00:06:51,680 --> 00:06:53,280 if you want your error rules to last 163 00:06:53,280 --> 00:06:55,759 generation write rules based on code or 164 00:06:55,759 --> 00:06:58,319 use a rule which only matches a single 165 00:06:58,319 --> 00:07:02,240 malware files is no better than a hash 166 00:07:02,240 --> 00:07:04,160 for example gan crab has like five 167 00:07:04,160 --> 00:07:06,479 different versions and with 168 00:07:06,479 --> 00:07:09,120 one rule based on functional reuse you 169 00:07:09,120 --> 00:07:10,880 can find all those different version of 170 00:07:10,880 --> 00:07:13,840 grain craft so when a melbourne mutates 171 00:07:13,840 --> 00:07:15,680 or the third actor writes a new version 172 00:07:15,680 --> 00:07:17,360 of malware 173 00:07:17,360 --> 00:07:19,599 they reuse code and functions and that's 174 00:07:19,599 --> 00:07:21,680 what we're going to leverage to write 175 00:07:21,680 --> 00:07:23,759 arrows strings can change but code 176 00:07:23,759 --> 00:07:25,759 reviews are 177 00:07:25,759 --> 00:07:29,039 more powerful to hit 178 00:07:29,520 --> 00:07:32,319 okay you cannot use these keywords as 179 00:07:32,319 --> 00:07:35,039 they are pre-reserves most of them are 180 00:07:35,039 --> 00:07:36,880 reserved for providing the pool and 181 00:07:36,880 --> 00:07:40,960 logical expressions like ask a uh 182 00:07:40,960 --> 00:07:42,639 n32 183 00:07:42,639 --> 00:07:45,639 us16pe 184 00:07:45,680 --> 00:07:49,520 white xlr etc etc 185 00:07:49,919 --> 00:07:52,080 okay how you use 186 00:07:52,080 --> 00:07:54,240 commands so 187 00:07:54,240 --> 00:07:56,720 comments on your rules is just like how 188 00:07:56,720 --> 00:07:58,879 you comment on c both single and 189 00:07:58,879 --> 00:08:01,599 multi-line commands are supported 190 00:08:01,599 --> 00:08:03,919 c style comma basically it's c styles 191 00:08:03,919 --> 00:08:05,599 commands that are supported you can see 192 00:08:05,599 --> 00:08:07,599 this one like uh 193 00:08:07,599 --> 00:08:09,759 single line command and 194 00:08:09,759 --> 00:08:11,840 dual line 195 00:08:11,840 --> 00:08:14,800 multi-line comments on url 196 00:08:14,800 --> 00:08:16,560 uh 197 00:08:16,560 --> 00:08:19,039 yara is case sensitive you have so you 198 00:08:19,039 --> 00:08:21,759 have to take care of the case 199 00:08:21,759 --> 00:08:26,840 in case you you you want uh 200 00:08:26,879 --> 00:08:30,960 uh you want to write a year rule uh 201 00:08:30,960 --> 00:08:33,279 and you are providing uh 202 00:08:33,279 --> 00:08:35,120 you are providing a word and you want 203 00:08:35,120 --> 00:08:37,839 both the strings about the 204 00:08:37,839 --> 00:08:39,519 both the case to be supported you have 205 00:08:39,519 --> 00:08:41,519 to write no case 206 00:08:41,519 --> 00:08:43,919 uh this is how you 207 00:08:43,919 --> 00:08:47,200 this is how you add text strings 208 00:08:47,200 --> 00:08:49,200 uh horizontal tab 209 00:08:49,200 --> 00:08:51,040 so it can contain these following 210 00:08:51,040 --> 00:08:53,920 subsets of the escape sequence available 211 00:08:53,920 --> 00:08:55,600 in the c language double quotes 212 00:08:55,600 --> 00:08:59,120 backslash horizontal tab 213 00:08:59,120 --> 00:09:00,480 new line 214 00:09:00,480 --> 00:09:02,320 activity for adding 215 00:09:02,320 --> 00:09:05,680 byte and hexadecimal notations 216 00:09:05,680 --> 00:09:07,040 as we talk 217 00:09:07,040 --> 00:09:09,519 the no case modifier 218 00:09:09,519 --> 00:09:11,680 for example here you can see 219 00:09:11,680 --> 00:09:14,800 the rule trying to identify uber 220 00:09:14,800 --> 00:09:18,640 so here adding no case will identify 221 00:09:18,640 --> 00:09:19,680 foober 222 00:09:19,680 --> 00:09:21,360 fubar with uppercase and fubar with 223 00:09:21,360 --> 00:09:23,680 jumble case 224 00:09:23,680 --> 00:09:26,240 coming to the white character strings 225 00:09:26,240 --> 00:09:27,920 a white character is a computer 226 00:09:27,920 --> 00:09:29,839 character data type that generally has a 227 00:09:29,839 --> 00:09:31,680 greater size than the traditional 8-bit 228 00:09:31,680 --> 00:09:33,920 characters so the increased data type 229 00:09:33,920 --> 00:09:36,720 size allows for the use of larger coded 230 00:09:36,720 --> 00:09:38,399 character sets 231 00:09:38,399 --> 00:09:42,480 so using a wide will sorry problem here 232 00:09:42,480 --> 00:09:44,720 xor strings 233 00:09:44,720 --> 00:09:46,640 coming to the exhaust strings there are 234 00:09:46,640 --> 00:09:48,320 two rules 235 00:09:48,320 --> 00:09:50,160 so you can see these are two rules which 236 00:09:50,160 --> 00:09:51,839 are basically the same 237 00:09:51,839 --> 00:09:54,399 so if you write xor 238 00:09:54,399 --> 00:09:55,519 uh 239 00:09:55,519 --> 00:09:57,440 beside the string which you have written 240 00:09:57,440 --> 00:09:59,519 over here 241 00:09:59,519 --> 00:10:02,240 this will be similar to the strings 242 00:10:02,240 --> 00:10:04,800 so remember for an efficient rule write 243 00:10:04,800 --> 00:10:07,279 small and write logically for better and 244 00:10:07,279 --> 00:10:09,279 long-term detections 245 00:10:09,279 --> 00:10:11,120 if with your rule you can only detect 246 00:10:11,120 --> 00:10:13,120 one single file then there's no better 247 00:10:13,120 --> 00:10:15,440 than using a hash write it in such a way 248 00:10:15,440 --> 00:10:18,079 it detects logically 249 00:10:18,079 --> 00:10:21,279 we have base64 strings it is 250 00:10:21,279 --> 00:10:23,200 used in a rule 251 00:10:23,200 --> 00:10:25,200 just like the xor 252 00:10:25,200 --> 00:10:26,399 it will detect 253 00:10:26,399 --> 00:10:28,880 even if it finds 254 00:10:28,880 --> 00:10:31,360 at the byte level of the code as well so 255 00:10:31,360 --> 00:10:33,680 let's see if a cnc address that is space 256 00:10:33,680 --> 00:10:36,240 64 in code encoded and you can use the 257 00:10:36,240 --> 00:10:38,320 expression like this 258 00:10:38,320 --> 00:10:40,320 so this reel will detect all permutation 259 00:10:40,320 --> 00:10:43,920 of base64 encoder string 260 00:10:44,399 --> 00:10:47,120 hexadecimal strings so hexadecimal 261 00:10:47,120 --> 00:10:48,399 strings allows three special 262 00:10:48,399 --> 00:10:49,920 constructions that make them more 263 00:10:49,920 --> 00:10:52,560 flexible this is the fun part 264 00:10:52,560 --> 00:10:54,320 zero to nine a to f as you know 265 00:10:54,320 --> 00:10:56,800 hexadecimal they allow us to use special 266 00:10:56,800 --> 00:10:58,959 constructions in the rule to accommodate 267 00:10:58,959 --> 00:11:01,279 more and more logic 268 00:11:01,279 --> 00:11:04,480 wild cards jumps alternatives so we will 269 00:11:04,480 --> 00:11:06,880 try to focus our rule writing more on 270 00:11:06,880 --> 00:11:09,600 hexadecimal strings than normal ascii 271 00:11:09,600 --> 00:11:11,360 strings 272 00:11:11,360 --> 00:11:13,839 writing an efficient error rule is 273 00:11:13,839 --> 00:11:15,360 regex is not 274 00:11:15,360 --> 00:11:17,200 recommended for writing because it it 275 00:11:17,200 --> 00:11:20,800 comes with a lot of false positive 276 00:11:20,800 --> 00:11:24,479 so we'll try to avoid regex 277 00:11:25,519 --> 00:11:29,839 writing rules on string or bytes 278 00:11:30,320 --> 00:11:32,160 not regex 279 00:11:32,160 --> 00:11:34,480 so i mean write rules 280 00:11:34,480 --> 00:11:36,000 uh 281 00:11:36,000 --> 00:11:37,440 write rules but 282 00:11:37,440 --> 00:11:39,519 do not include much regex because it 283 00:11:39,519 --> 00:11:41,200 will provide you a lot of it will give 284 00:11:41,200 --> 00:11:43,600 you a lot of false positive 285 00:11:43,600 --> 00:11:46,560 so efficient rule doesn't use regex 286 00:11:46,560 --> 00:11:48,959 coming to the conditions 287 00:11:48,959 --> 00:11:50,880 so most of the malware target windows 288 00:11:50,880 --> 00:11:53,279 systems there are pe files and you can 289 00:11:53,279 --> 00:11:55,440 dissect them you'll find they're having 290 00:11:55,440 --> 00:11:57,519 headers sections so you can 291 00:11:57,519 --> 00:11:59,839 uh con you can give arguments and 292 00:11:59,839 --> 00:12:01,600 conditions to your errors based on the 293 00:12:01,600 --> 00:12:04,240 executable entry the string offset or 294 00:12:04,240 --> 00:12:07,440 their virtual offset their file size 295 00:12:07,440 --> 00:12:08,320 uh 296 00:12:08,320 --> 00:12:10,560 their entry points and a lot of other 297 00:12:10,560 --> 00:12:11,519 things 298 00:12:11,519 --> 00:12:14,320 so for example if uh 299 00:12:14,320 --> 00:12:16,639 if if there is a pe file which is less 300 00:12:16,639 --> 00:12:19,920 than xyz kb so you can define 301 00:12:19,920 --> 00:12:21,680 match this 302 00:12:21,680 --> 00:12:23,120 um 303 00:12:23,120 --> 00:12:25,440 this is the end at the entry point 304 00:12:25,440 --> 00:12:27,440 uh match the file which has an entry 305 00:12:27,440 --> 00:12:30,160 point like this and the file size less 306 00:12:30,160 --> 00:12:32,720 than xyz kilobytes 307 00:12:32,720 --> 00:12:34,480 or based on the magic number based on 308 00:12:34,480 --> 00:12:35,839 there's a lot of 309 00:12:35,839 --> 00:12:39,839 conditions which you can implement 310 00:12:40,000 --> 00:12:40,880 so 311 00:12:40,880 --> 00:12:42,800 why code base rules 312 00:12:42,800 --> 00:12:46,240 so as you can see the virus mutates and 313 00:12:46,240 --> 00:12:48,959 with every mutation and it's which has 314 00:12:48,959 --> 00:12:52,320 changes and so are their strings so 315 00:12:52,320 --> 00:12:54,160 these malicious threat actors work just 316 00:12:54,160 --> 00:12:57,120 like software development companies 317 00:12:57,120 --> 00:13:00,959 they reuse codes codes functions logic 318 00:13:00,959 --> 00:13:04,240 program flows so writing one efficient 319 00:13:04,240 --> 00:13:05,680 code-based rule 320 00:13:05,680 --> 00:13:09,519 will also detect future malware 321 00:13:09,519 --> 00:13:12,959 so you can see these two uh 322 00:13:12,959 --> 00:13:15,120 these two programs here they are 323 00:13:15,120 --> 00:13:16,800 printing hello 324 00:13:16,800 --> 00:13:19,120 so here the hello is directly written in 325 00:13:19,120 --> 00:13:21,600 the first program the first 326 00:13:21,600 --> 00:13:23,680 first picture and the second the hello 327 00:13:23,680 --> 00:13:25,360 is broken down into different string and 328 00:13:25,360 --> 00:13:27,200 then it is adding together and printing 329 00:13:27,200 --> 00:13:28,240 it 330 00:13:28,240 --> 00:13:31,440 so if this if i write this rule based on 331 00:13:31,440 --> 00:13:32,639 strings 332 00:13:32,639 --> 00:13:34,880 it will only detect the first one the 333 00:13:34,880 --> 00:13:38,320 first program not the second program 334 00:13:38,320 --> 00:13:41,680 so that is why we need to focus more on 335 00:13:41,680 --> 00:13:42,560 writing 336 00:13:42,560 --> 00:13:45,760 uh your rules based on code reviews 337 00:13:45,760 --> 00:13:48,000 so for example gan cap has like five 338 00:13:48,000 --> 00:13:50,160 version and if you if you made a yard 339 00:13:50,160 --> 00:13:51,600 rule based on 340 00:13:51,600 --> 00:13:52,800 uh 341 00:13:52,800 --> 00:13:55,519 when grand cab one came out 342 00:13:55,519 --> 00:13:57,519 based on the code reuse of the gantt cab 343 00:13:57,519 --> 00:14:00,240 the function you use you can detect even 344 00:14:00,240 --> 00:14:03,120 ganker one two three two three four and 345 00:14:03,120 --> 00:14:05,279 five with one single rule so you can 346 00:14:05,279 --> 00:14:08,079 find future malwares as well with 347 00:14:08,079 --> 00:14:09,760 with your rules if you write it 348 00:14:09,760 --> 00:14:11,040 efficiently 349 00:14:11,040 --> 00:14:12,720 you can write your one rule which will 350 00:14:12,720 --> 00:14:15,040 rule them all on the basis of their code 351 00:14:15,040 --> 00:14:17,040 reuse pattern 352 00:14:17,040 --> 00:14:18,959 code based rule requires a little bit of 353 00:14:18,959 --> 00:14:20,160 understanding 354 00:14:20,160 --> 00:14:21,839 we'll need a little understanding 355 00:14:21,839 --> 00:14:24,320 disassembler and debugger to write code 356 00:14:24,320 --> 00:14:26,320 base real 357 00:14:26,320 --> 00:14:28,839 code based rule lasts for generation 358 00:14:28,839 --> 00:14:31,120 so that's what 359 00:14:31,120 --> 00:14:33,600 it is recommended 360 00:14:33,600 --> 00:14:35,839 so rules that match only to the specific 361 00:14:35,839 --> 00:14:37,600 samples are not much better than the 362 00:14:37,600 --> 00:14:38,959 hash value 363 00:14:38,959 --> 00:14:41,440 making efficient error rules which can 364 00:14:41,440 --> 00:14:42,639 last 365 00:14:42,639 --> 00:14:45,920 and you can track the future malware 366 00:14:45,920 --> 00:14:48,079 from 367 00:14:48,079 --> 00:14:51,199 same malware creators and writing one 368 00:14:51,199 --> 00:14:54,560 rule which will rule them all 369 00:14:54,560 --> 00:14:56,240 so things to take care while creating 370 00:14:56,240 --> 00:14:58,800 code based rule so compilation flags 371 00:14:58,800 --> 00:15:00,720 different compilers work differently so 372 00:15:00,720 --> 00:15:02,560 use wildcards 373 00:15:02,560 --> 00:15:03,920 use 374 00:15:03,920 --> 00:15:04,959 uh 375 00:15:04,959 --> 00:15:07,440 use wildcards or where you 376 00:15:07,440 --> 00:15:10,000 where you can and uh one thing to 377 00:15:10,000 --> 00:15:11,279 remember is 378 00:15:11,279 --> 00:15:13,760 xor and eax can produce different op 379 00:15:13,760 --> 00:15:17,680 codes so write it accordingly 380 00:15:17,680 --> 00:15:19,680 coming to testing error 381 00:15:19,680 --> 00:15:21,199 you should definitely do the following 382 00:15:21,199 --> 00:15:23,360 checks to reduce false positive like 383 00:15:23,360 --> 00:15:25,440 scanning the malware samples 384 00:15:25,440 --> 00:15:27,519 then scanning there 385 00:15:27,519 --> 00:15:29,759 big goodware sample if the rule matched 386 00:15:29,759 --> 00:15:31,759 to the malicious sample and did not 387 00:15:31,759 --> 00:15:34,240 generate a match on the goodwill archive 388 00:15:34,240 --> 00:15:36,240 your rule is not good enough to go into 389 00:15:36,240 --> 00:15:37,680 practice 390 00:15:37,680 --> 00:15:40,560 because it has a false positive 391 00:15:40,560 --> 00:15:42,560 so how do you test this 392 00:15:42,560 --> 00:15:44,959 great kaspersky great team has a project 393 00:15:44,959 --> 00:15:48,399 named clara this is a very nice project 394 00:15:48,399 --> 00:15:50,800 if you want to test your 395 00:15:50,800 --> 00:15:52,399 before 396 00:15:52,399 --> 00:15:55,839 making go to production 397 00:15:55,839 --> 00:15:58,720 this is the life cycle of hero analyze 398 00:15:58,720 --> 00:16:02,399 identify write rules test rules deploy 399 00:16:02,399 --> 00:16:05,920 your error and enjoy 400 00:16:05,920 --> 00:16:08,480 so where you can hunt your error hybrid 401 00:16:08,480 --> 00:16:11,360 analysis mypedia 402 00:16:11,360 --> 00:16:13,360 once total although wise total will need 403 00:16:13,360 --> 00:16:15,120 a premium license for that hybrid 404 00:16:15,120 --> 00:16:16,720 analysis you can do it from free and 405 00:16:16,720 --> 00:16:18,560 there's a new one which came into the 406 00:16:18,560 --> 00:16:21,440 picture recently error 5 from abuse ch 407 00:16:21,440 --> 00:16:24,480 product project so this is really good 408 00:16:24,480 --> 00:16:26,800 this is where you can hunt 409 00:16:26,800 --> 00:16:29,120 so what you can do with era again guys 410 00:16:29,120 --> 00:16:31,759 uh find next-generation malwares hunt 411 00:16:31,759 --> 00:16:34,240 for apd zero days 412 00:16:34,240 --> 00:16:36,480 you can monitor 413 00:16:36,480 --> 00:16:38,880 apd groups you can make your own av you 414 00:16:38,880 --> 00:16:42,160 can combine it with zeek to make an 415 00:16:42,160 --> 00:16:44,880 intros and detection systems so there's 416 00:16:44,880 --> 00:16:46,480 numerous case in the past where people 417 00:16:46,480 --> 00:16:48,160 have identified zero days with the help 418 00:16:48,160 --> 00:16:51,120 of your rules 419 00:16:51,120 --> 00:16:53,360 so conclusion writing 420 00:16:53,360 --> 00:16:55,680 code based rules needs understanding of 421 00:16:55,680 --> 00:16:58,240 debugger 422 00:16:58,240 --> 00:17:01,199 but it's the efficient one string is 423 00:17:01,199 --> 00:17:04,319 not the best thing to write 424 00:17:04,319 --> 00:17:07,199 while writing a rule because uh enough 425 00:17:07,199 --> 00:17:10,000 and and sometime it will become absolute 426 00:17:10,000 --> 00:17:11,520 so always look for code reuse 427 00:17:11,520 --> 00:17:13,679 functionality and build your arrows on 428 00:17:13,679 --> 00:17:15,919 that 429 00:17:16,559 --> 00:17:19,119 thank you so much guys i'll take 430 00:17:19,119 --> 00:17:22,000 questions and feedbacks thank you so 431 00:17:22,000 --> 00:17:23,199 much bluetooth village for this 432 00:17:23,199 --> 00:17:25,119 opportunity please let me know if you 433 00:17:25,119 --> 00:17:26,559 have any questions and feedback thank 434 00:17:26,559 --> 00:17:29,879 you so much