1 00:00:00,000 --> 00:00:01,320 Good morning. 2 00:00:03,380 --> 00:00:05,280 Everyone showed up bright and early. 3 00:00:06,200 --> 00:00:10,720 It's a little early for a conference, but thank you guys for coming this early and joining us. 4 00:00:11,020 --> 00:00:13,860 My name is Ben Sadegopour, and I have Adam here. 5 00:00:14,380 --> 00:00:21,980 We every year come to DEF CON and we try to do a workshop that's different, and we'll talk about the workshop today. 6 00:00:21,980 --> 00:00:27,620 But this is, I think, a fundamentally interesting and useful skill that I want you to take away. 7 00:00:27,620 --> 00:00:31,480 There is a lot of slides to go through today, so we're going to go through them as fast as we can. 8 00:00:31,480 --> 00:00:34,080 I think he has 190 slides or something like that. 9 00:00:34,540 --> 00:00:35,780 198 slides. 10 00:00:36,600 --> 00:00:40,260 So it's going to be very fast. 11 00:00:40,260 --> 00:00:43,760 It's going to be a lot of regex stuff, and then we're going to apply it to bug bounties. 12 00:00:43,760 --> 00:00:46,920 So tons of stuff for our schedule today. 13 00:00:46,920 --> 00:00:50,580 I will talk about some of the OSINT and how I apply this to bug bounties. 14 00:00:50,740 --> 00:00:54,480 Adam's going to cover, pretty much teaching you how to do regex. 15 00:00:54,480 --> 00:00:56,480 Again, if anyone here is really good at regex... 16 00:00:57,840 --> 00:00:59,260 Okay, I'm not either. 17 00:01:00,520 --> 00:01:01,320 I'm with you. 18 00:01:01,320 --> 00:01:02,120 Yeah, chat GPT. 19 00:01:02,120 --> 00:01:04,420 So yeah, we want to make sure you learn something and you can apply it. 20 00:01:04,420 --> 00:01:12,060 I think regex is a root cause of a lot of client-side vulnerabilities, some server-side vulnerabilities, and you can do a lot of good stuff with it on GitHub. 21 00:01:12,060 --> 00:01:16,480 So I'll let Adam... Actually, I'm going to introduce myself and then hand it over to Adam and I'm going to sit down. 22 00:01:16,600 --> 00:01:17,140 So I'm Ben. 23 00:01:17,140 --> 00:01:21,520 I've been doing bug bounties since 2013 or 14. 24 00:01:21,960 --> 00:01:24,680 I've done over 1.8 million in bounties. 25 00:01:24,680 --> 00:01:28,600 Majority of it since I've gone full-time since 2022 or 2023. 26 00:01:29,400 --> 00:01:41,600 Previously, I was the head of hacker education at HackerOne and currently Adam and I have co-founded a company called Hacking Hub, where we want to do more of these things and these workshops and courses and talks where we train the next generation of hackers. 27 00:01:42,100 --> 00:01:49,200 Most people have probably seen me on social media for my bug bounty stuff or content, but I also do some pen tests and content creation on the side. 28 00:01:49,200 --> 00:01:52,880 And you can just follow me at NahumSick on most social media platforms. 29 00:01:54,360 --> 00:01:55,920 Hey, I'm Adam Langley. 30 00:01:56,220 --> 00:02:03,600 Apologize if I have my head in the laptop, because like you heard earlier, I've got 198 slides, so there's a lot to look at and a lot to explain. 31 00:02:03,980 --> 00:02:06,820 So I started hacking in the late 90s. 32 00:02:06,820 --> 00:02:11,940 Got some interesting stories that I won't share quite on stage, but may exchange them for some drinks. 33 00:02:12,180 --> 00:02:19,960 Worked in web development for 20 years, then finally put both of those things together by creating CTFs and learning labs for people. 34 00:02:20,160 --> 00:02:27,460 You'll find some of my CTFs and educational content on Hacking Hub, HackerOne, TryHackMe, and other CTF events as well. 35 00:02:27,720 --> 00:02:35,200 As Ben mentioned, we run a company called Hacking Hub, where I'm the CTO there, and I build core applications, courses, labs, and learn CTFs. 36 00:02:35,200 --> 00:02:37,600 You can find me online at buildhacksecure. 37 00:02:39,380 --> 00:02:42,020 Okay, so just a brief purpose of this. 38 00:02:42,080 --> 00:02:46,100 Regits can always look very overwhelming, but we're here to help. 39 00:02:46,100 --> 00:02:47,620 We want to teach you the basics. 40 00:02:47,620 --> 00:02:51,740 It's not going to go through completely everything that's involved in Regits. 41 00:02:51,740 --> 00:03:00,800 There's different Regits packages as well, which some have some features and the other ones don't, but we're hoping to kind of give you enough information to make you dangerous. 42 00:03:02,280 --> 00:03:07,080 Using this will help you discover vulnerabilities and understand why they might occur. 43 00:03:07,400 --> 00:03:09,580 It'll help you search for things better. 44 00:03:09,800 --> 00:03:16,700 It'll help you discover secrets, and also I'll mention at the end some cool tools as well that you can build with it as well. 45 00:03:16,700 --> 00:03:24,060 So in summary, we're going to take you from this, hopefully, to Anoregits. 46 00:03:24,700 --> 00:03:28,180 Okay, so the first part is basic string matching. 47 00:03:28,420 --> 00:03:38,720 So in most programming languages, you have some functions in there which will help you work out if a string starts with, ends with, or maybe contains. 48 00:03:39,680 --> 00:03:43,100 So we've got Python, which it starts with, ends with, substring. 49 00:03:43,180 --> 00:03:45,860 JavaScript starts with, ends with, includes. 50 00:03:46,040 --> 00:03:49,620 You'll see a very common pattern throughout all the different languages. 51 00:03:49,640 --> 00:03:54,000 They all contain these things, apart from Go, which gets a bit crazy. 52 00:03:54,000 --> 00:03:58,320 It's got its own things with half-prefix and half-suffix, which is just a bit posh. 53 00:03:58,840 --> 00:04:07,460 Okay, so the first part of... so the problem with this is that it actually has limitations, so you can't always match the exact data that you want to. 54 00:04:07,460 --> 00:04:09,920 So let's just discuss the starts with limitations. 55 00:04:10,460 --> 00:04:16,520 So say if you've got a range of IP addresses and you want to see whether your client is visiting from one of those. 56 00:04:16,720 --> 00:04:21,800 In code, you might just have to have some horrendous if block or a switch statement to do that. 57 00:04:22,340 --> 00:04:28,720 With Regex, you can have this very easy to read thing to match all those patterns. 58 00:04:28,720 --> 00:04:31,100 Don't worry if you don't understand it, we'll break it down. 59 00:04:31,100 --> 00:04:36,440 There's just a few little things you need until you can have that moment where you go, I know what that means. 60 00:04:37,540 --> 00:04:39,040 Ends with limitations. 61 00:04:39,180 --> 00:04:47,200 Say if you want to check an email address to make sure it ends with a specific domain on there, or like a top-level domain, so you might have three different ones. 62 00:04:47,400 --> 00:04:54,020 Again, you can have an if statement or a switch statement to check for those things, or you can have a nice Regex which covers it in one go. 63 00:04:55,140 --> 00:04:57,080 And then it contains limitations. 64 00:04:57,240 --> 00:05:06,240 So imagine if you're running some kind of chat service and you want to check for any kind of dodgy input, making sure nobody's getting scammed and putting like credit card numbers in there. 65 00:05:06,240 --> 00:05:13,500 So obviously you can't search for every credit card in existence, you need to search for a particular pattern in there. 66 00:05:14,000 --> 00:05:24,620 And also that pattern can change as well, it might just not be like a straightforward bunch of numbers, there might be hyphens in there, or there might be spaces in there, which makes it very difficult to find that information. 67 00:05:27,340 --> 00:05:36,940 But then again, this simple Regex can actually match all those patterns, it can match for those digits, it can match for spaces, it can match for hyphens in between, just with that simple statement. 68 00:05:38,680 --> 00:05:40,500 So what is Regex? 69 00:05:40,500 --> 00:05:48,460 So Regex is a search pattern language, and it will help you find, match and extract specific parts of text from strings. 70 00:05:48,960 --> 00:06:02,840 Think of it like a state machine, so each of your Regex instructions, so you start at one place, if that rule matches, it moves to the next, and then it moves to the next, and then if that rule fails, it goes back to the beginning again, and it tries to match it somewhere else, 71 00:06:02,840 --> 00:06:05,660 until you've got all the way through, and you've finally got a match. 72 00:06:05,660 --> 00:06:12,740 So think of it like a flow diagram, where it asks questions, yes, no, and then kind of goes all the way down until you've found a complete match. 73 00:06:14,600 --> 00:06:21,920 So at first, you've got like literal matches, which is basically the same as like finding something on a page, and like hitting control F. 74 00:06:21,980 --> 00:06:26,180 So if you're certain, if you do a Regex, which is just hello, it'll find the string hello in there. 75 00:06:26,800 --> 00:06:28,140 So nice and easy. 76 00:06:28,540 --> 00:06:41,220 Then you've got, again, with like words, if you're searching for the word computer, we've just found, you'll notice that you'll find the word computer, but you'll also find the word supercomputer as well, which, so you've got kind of some false positives in here. 77 00:06:41,880 --> 00:06:44,460 This is where you can start using word boundaries as well. 78 00:06:44,460 --> 00:06:51,980 So you can wrap your words with this slash B, and then you can make sure that there's no characters either side of that. 79 00:06:52,180 --> 00:06:55,880 It does have exceptions for like punctuation marks as well. 80 00:06:56,780 --> 00:07:00,240 So like question marks, full stops, that works absolutely fine. 81 00:07:00,240 --> 00:07:03,820 But as soon as you introduce another letter in there, then that Regex will fail. 82 00:07:03,820 --> 00:07:05,160 It won't catch that word. 83 00:07:06,900 --> 00:07:09,440 Okay, and then we have anchors for starts with. 84 00:07:09,440 --> 00:07:23,980 So if you're receiving some strings, so say if you want to like get a website address, from an input field, but somebody randomly types in a whole string where there is a website address in there, but it's not where you think it's going to be. 85 00:07:23,980 --> 00:07:26,780 So in this case, you can see it's in the middle of the string. 86 00:07:26,780 --> 00:07:28,120 So that's no good to us. 87 00:07:28,560 --> 00:07:35,920 What we want is this symbol here, which is just a caret at the start, which says the string must start with HTTPS. 88 00:07:36,160 --> 00:07:42,280 You'll also notice as well that there's some special characters in there, like the forward slashes, which you have to put back first. 89 00:07:44,160 --> 00:07:46,860 So now you can see that this matches perfectly. 90 00:07:48,120 --> 00:07:51,940 And then on the opposite side of that, you've got anchors with the end width. 91 00:07:52,140 --> 00:07:54,140 And that's just a dollar sign on here. 92 00:07:54,140 --> 00:08:02,840 So if again, you have some simple Regex, which is example.co, you'll see again, the middle of it matches, which will pass the Regex rule. 93 00:08:02,840 --> 00:08:06,240 But of course, that's not correct, because you've got UK at the end. 94 00:08:07,260 --> 00:08:16,180 But if you pop the dollar sign at the end, you're basically saying you want example.co, and nothing else after that, not anything whatsoever. 95 00:08:16,180 --> 00:08:19,300 So now it's gone to blank, so it's not matching that rule. 96 00:08:20,600 --> 00:08:24,600 Again, you change the code back, and it's correct. 97 00:08:25,760 --> 00:08:31,600 One thing to note as well is the period symbol in here, which you'll see come up in the vulnerabilities. 98 00:08:31,600 --> 00:08:36,220 This catches so many developers out, and it leads to very interesting results. 99 00:08:36,220 --> 00:08:38,660 So this is actually treated like a wildcard. 100 00:08:38,660 --> 00:08:42,980 You'd think they'd use something like a star or something, or a percent symbol to cover this. 101 00:08:43,100 --> 00:08:49,740 But it's the full stop, which can basically mean any character you want, apart from a carriage return. 102 00:08:50,620 --> 00:09:00,000 So if you put the backslash in there to signify it must only be a period sign, you'll see the example.xco doesn't match anymore. 103 00:09:04,250 --> 00:09:06,350 Next is character sets. 104 00:09:06,390 --> 00:09:09,750 This is where you can start making some really interesting rules. 105 00:09:09,750 --> 00:09:13,630 So character sets, you have it per character. 106 00:09:13,630 --> 00:09:17,310 It checks the string, and it's each character. 107 00:09:17,310 --> 00:09:23,190 So the first one on this character set says it can only be the characters A, B, or C. 108 00:09:24,470 --> 00:09:29,210 So just in some example, if there's any bricks in here, you'll notice that these are postcodes. 109 00:09:29,210 --> 00:09:37,490 So what this is saying is we've got the character sign, which is saying the string must start with, and then anything that starts with M, L, or B. 110 00:09:37,490 --> 00:09:42,890 So you can see it's matched the two first ones, and the fourth one as well, absolutely fine. 111 00:09:42,890 --> 00:09:48,130 Obviously, OX and EX doesn't start with MLB, so that one doesn't get matched. 112 00:09:49,210 --> 00:09:53,570 You can also add a character symbol within character sets. 113 00:09:53,570 --> 00:09:59,130 So instead of this meaning that the string must start with, it actually inverts the rule instead. 114 00:09:59,130 --> 00:10:02,950 So it'll find anything that doesn't match the characters that you've put in there. 115 00:10:02,950 --> 00:10:06,350 So now you can see the OX and EX match absolutely fine. 116 00:10:08,690 --> 00:10:10,410 And then it gets even more interesting. 117 00:10:10,410 --> 00:10:12,310 You can have character ranges in here. 118 00:10:12,310 --> 00:10:17,670 So in this example, we've got any characters between A to L that will match. 119 00:10:17,670 --> 00:10:23,390 So of course, we've got those three postcodes that do match there within that range, but the M and the OX don't. 120 00:10:24,430 --> 00:10:33,250 So with ranges, you can have uppercase letters, lowercase letters, numbers, but then you can also add them together as well. 121 00:10:33,250 --> 00:10:39,050 So this is saying the character can match A to L, or 0 to 5. 122 00:10:39,270 --> 00:10:47,130 So then we can start using the information that we've learned so far to build like a basic regex, which would match postcodes. 123 00:10:47,130 --> 00:11:08,750 So we're saying that these postcodes, postcodes must start with a letter between A to Z, which is the capital, two digits, a space, another digit, and then two letters at the end, A to Z, and then nothing else after that. 124 00:11:08,750 --> 00:11:12,390 And you can see that those rules match exactly on there. 125 00:11:14,170 --> 00:11:16,190 Next we have quantifiers. 126 00:11:16,550 --> 00:11:23,530 So with this, you can have like your character sets and your rules, and then you can have kind of a rule after that. 127 00:11:23,530 --> 00:11:26,210 So we'll go through each one kind of so it makes sense. 128 00:11:26,510 --> 00:11:34,830 So the first one, again, we've got the character set of A to Z with the plus after this, and that says it must match one or more instances of characters. 129 00:11:34,990 --> 00:11:42,170 So we can see that the I is highlighted because we found one of those, then the comma, that's not in that character set, so that doesn't get matched. 130 00:11:42,270 --> 00:11:51,090 And then the rest of it, my name is, of course, those are all characters, and there's one or more instances of them in the string, so that's like matching the whole my name is. 131 00:11:51,330 --> 00:11:59,830 The capital A isn't matched on there because we've only done lowercase letters, and then the D-A-M, that matches absolutely fine and not the exclamation mark. 132 00:12:01,590 --> 00:12:07,770 Of course, then, like I mentioned before, with the character sets, you can add your capital letters in there as well, so now it's matching the A. 133 00:12:09,590 --> 00:12:23,370 With the starts with as well, so again, we want to match the... so now we're trying to match like URLs on there, so this first regex example is only going to match HTTP and then slash slash. 134 00:12:23,370 --> 00:12:28,710 You can see HTTPS or HTTPSS isn't matched in there. 135 00:12:29,830 --> 00:12:35,610 So if we move into HTTPS, now HTTP isn't recognized, but we want to cover both of those. 136 00:12:35,730 --> 00:12:44,870 So what we can have is a question mark after it, so that matches the S, and you can have either zero instances of that or just one instance of that. 137 00:12:44,870 --> 00:12:55,050 So of course that's matched HTTP, and HTTPS has been correct, but of course HTTPS, which I don't know, maybe super secure HTTP, doesn't match because it doesn't exist. 138 00:12:57,330 --> 00:13:01,870 And then the next thing we can have is the number of instances. 139 00:13:01,970 --> 00:13:13,030 So in this simple match, we've gone back to our credit card example, which is going to be a recurring theme throughout this, and we've got like the digits zero to nine, and we've got exactly 16 of those. 140 00:13:13,030 --> 00:13:18,270 So as long as there's just 16 within those, we've reintroduced the word boundaries as well. 141 00:13:18,270 --> 00:13:21,550 So 16 digits, it'll be fine, it'll match. 142 00:13:22,110 --> 00:13:27,730 But of course not all credit cards are exactly 16 numbers, you can have some which are a little bit more. 143 00:13:27,790 --> 00:13:36,130 So then we've got this quantifier, which is a number and then a comma, so that means at least 16, and then you can have anything over that. 144 00:13:37,310 --> 00:13:49,350 But then you've got a problem, because now you've got a false positive, where somebody's just sent somebody a message saying, hey, check out this binary string, and of course it's flagged it up thinking, hey, that's a credit card, because it's, you know, 145 00:13:49,350 --> 00:13:52,910 it's numbers, and it's at least 16 characters long. 146 00:13:53,710 --> 00:14:04,530 So then it introduces another quantifier for the range, so now you can say, okay, I want numbers, but only 16 to 19 digits in length, and that's it. 147 00:14:06,010 --> 00:14:09,470 So you can see that's matched it absolutely fine in this instance. 148 00:14:10,890 --> 00:14:17,090 Okay, so it gets a little bit more complicated now, because we've got to cover patterns which contain spaces as well. 149 00:14:17,130 --> 00:14:31,810 So we can see we've got the word boundary again, and then we've got, like, it's going to match four characters on there, and then it's going to match where we've got, like, the space after those four character sets of zero to nine, we've got a space and a star. 150 00:14:32,010 --> 00:14:35,870 Now, the star means zero instances or more. 151 00:14:35,870 --> 00:14:47,410 So just in case somebody types something in, like the first four digits, and they might hit, like, space, space, space, or they might put tabs, some kind of, like, extra spacing, extra padding in there, that'll actually cover it. 152 00:14:47,410 --> 00:14:56,090 As you can see, it's covered the first credit card number, which is just, you know, 16 digits, and then it's covered the next one as well, which has got the spaces in there. 153 00:14:58,310 --> 00:14:59,670 Okay, shortcuts. 154 00:14:59,670 --> 00:15:04,250 So this is where we can actually start compressing the regex to make it a little bit easier to read. 155 00:15:04,310 --> 00:15:11,170 So instead of doing the character sets of zero to nine, we can use the slash d instead, which just basically says any digits. 156 00:15:11,170 --> 00:15:21,450 So instead of us doing those four separate character sets for the first part of the credit card number, instead of doing the zero to nine, zero to nine, zero to nine, zero to nine, we could simply do that as a slash d. 157 00:15:21,510 --> 00:15:27,510 And as we saw in the quantifiers as well, if we put four in there, that's duplicating that pattern four times. 158 00:15:27,710 --> 00:15:30,370 And then again, we've got this space, which is optional. 159 00:15:33,560 --> 00:15:48,260 As well, like I mentioned before, in case somebody puts more than one space in there, we've got the slash s, which basically says any kind of space in there, any tabs, and we have the star after it as well, so we can have multiple ones of that. 160 00:15:49,700 --> 00:15:51,960 And then we've got the word character as well. 161 00:15:51,960 --> 00:15:59,340 So when that's matching, it matches characters a to z in upper and lower case, zero to nine, and then the underscore as well. 162 00:15:59,340 --> 00:16:04,520 I really wish they'd introduced the hyphen as well, just so it makes it easier matching things like domain names, things like that. 163 00:16:04,780 --> 00:16:06,200 But not so. 164 00:16:06,200 --> 00:16:09,240 So you can see it's matched like a username up there, absolutely fine. 165 00:16:09,240 --> 00:16:18,480 So if you wanted to, if somebody's signing up to a website, and you want to make sure that there's no strange characters in there, because you only want to have those ones, then that'll work fine. 166 00:16:18,480 --> 00:16:25,060 If somebody maybe put an email address in by accident instead of a username, you'll see that the at symbol hasn't been matched. 167 00:16:26,420 --> 00:16:30,820 And again, you can go the opposite way by doing a capital letter as well. 168 00:16:30,840 --> 00:16:33,820 So this searches for any non-digits in a string. 169 00:16:33,820 --> 00:16:40,720 So this might be some kind of validation on like a telephone number to make sure there's no like any other like strange characters in there, that shouldn't be. 170 00:16:42,000 --> 00:16:48,700 And again, the capital S as well, that signifies anything that isn't a white space. 171 00:16:48,700 --> 00:17:00,280 So in case for some stranger, I don't know if anyone's done it, but if you sign up for something and it says your password must be eight characters long, and you do eight spaces, which I don't know, maybe is a good password idea. 172 00:17:00,280 --> 00:17:03,020 I don't think I've seen a bunch of spaces in a word list before. 173 00:17:03,440 --> 00:17:05,320 And so that would match as false. 174 00:17:05,320 --> 00:17:08,940 So just to signify that there's no like normal characters in there. 175 00:17:11,000 --> 00:17:15,060 And again, the uppercase W is any non-word characters. 176 00:17:15,080 --> 00:17:21,500 So again , you can check on the string to see if your string contains any non-word characters, you might want to check that out. 177 00:17:22,700 --> 00:17:23,340 Okay. 178 00:17:23,340 --> 00:17:24,760 And then you've got wildcards. 179 00:17:24,760 --> 00:17:27,620 So these are where Regex can get dangerous. 180 00:17:27,940 --> 00:17:39,020 So on here, it's just basically matching any characters whatsoever between the href in the link and then anything between the two double quotes. 181 00:17:39,320 --> 00:17:43,100 So we'll go in a bit deeper why this is so dangerous. 182 00:17:44,680 --> 00:17:50,540 So what if we just want to extract the link from that, because that's matching the whole href pattern. 183 00:17:50,980 --> 00:17:53,080 So this introduced groups. 184 00:17:53,100 --> 00:18:02,160 And with groups, you can use that to repeat patterns that you've done multiple times, or you can actually use it to extract the text that you want that you're searching for. 185 00:18:02,300 --> 00:18:07,780 So in this example, again, it's just matching the whole href equals. 186 00:18:07,780 --> 00:18:16,040 So when you do this in a programming language, whichever you're using, you'll probably like be returned an array or some kind of object which matches all your results. 187 00:18:16,040 --> 00:18:18,480 So we can see you get this kind of result in here. 188 00:18:18,900 --> 00:18:21,600 It contains a href, but we don't want that information. 189 00:18:22,500 --> 00:18:29,720 Instead, if we wrap it in a group, for the wildcard and the star, you'll see that we've got an extra result in the array. 190 00:18:29,760 --> 00:18:39,260 So the first one is what actually matched it, and the second one is the groups that are in your Regex for the information that you want to actually extract out of it. 191 00:18:41,780 --> 00:18:47,000 So you can see with groups as well, you can make your Regexes even prettier. 192 00:18:47,000 --> 00:19:00,520 So again, back down to the credit card example, instead of specifying like four groups of digits over and over again, you can wrap that matching the four digits or in a space inside a group. 193 00:19:00,520 --> 00:19:05,500 And then you can put a quantifier after it, say you want to repeat that pattern three times. 194 00:19:05,500 --> 00:19:19,440 So it's like four digits and any optional space with the slash S and the star, you repeat that three times, and then any like four digits on its own, and you can see that matches it, and it's a nice, much easier to read Regex. 195 00:19:23,450 --> 00:19:25,550 So yeah, sorry, that's just the breakdown of it. 196 00:19:25,550 --> 00:19:29,570 And like I explained, so you've got the group at the start and then the iterator of the three. 197 00:19:32,030 --> 00:19:35,890 You can also inside groups introduce an or operator as well. 198 00:19:35,890 --> 00:19:43,850 So you can say, so if the credit card has spaces, and then all the pipe symbol, you can have a hyphen as well. 199 00:19:43,850 --> 00:19:48,190 So again, that will match the credit card numbers that are being entered with a hyphen in there. 200 00:19:49,730 --> 00:19:56,970 So this is where it starts getting interesting, where Regex goes wrong, and where developers start implementing it. 201 00:19:56,970 --> 00:19:59,650 So we're going to go through some vulnerabilities. 202 00:19:59,770 --> 00:20:10,930 So the kind of real world examples, this could be like a black box exercise in kind of two ways, one where you're not given any source code, or this is Regex that's going on in the background. 203 00:20:10,990 --> 00:20:18,250 Or white box might be where you do have source code, so you can go through and you can see the exact Regexes that are being used. 204 00:20:18,310 --> 00:20:23,650 Or it might be a Regex that's being used on the front end of like a website, say in JavaScript. 205 00:20:25,130 --> 00:20:28,790 So the first vulnerability we're going to go through is post message. 206 00:20:30,210 --> 00:20:40,190 So if some people aren't familiar with post message, it's a way of two browser windows or tabs communicating with each other. 207 00:20:40,350 --> 00:20:49,010 So say for things like, sometimes you'll open like a login prompt, so you do like log in with Google, it'll jump up with a little separate page. 208 00:20:49,010 --> 00:20:55,910 Once you log into there, it can actually send a message back to your original page to say, this user's logged in, here's their information. 209 00:20:56,670 --> 00:20:59,210 So we can see that with passing the data back. 210 00:20:59,290 --> 00:21:10,050 So to make that secure, when you listen, so this is a little JavaScript example, so you use event listeners to listen for any messages coming back to your browser window. 211 00:21:10,670 --> 00:21:27,050 And ideally, I mean, two things can happen, they don't check whatsoever where that information has been coming from, which is really dangerous, or they can implement a Regex on there to test for the browser for where that information's come from, and that comes in the origin, 212 00:21:27,050 --> 00:21:29,290 in the event of the message. 213 00:21:29,330 --> 00:21:42,910 So just in this simple example, we're checking to make sure that the window that was opened and passing the message back to the original website is supposed to be HTTPS www.trusted.com. 214 00:21:42,910 --> 00:21:50,810 And then just for our example, so you kind of understand it as a vulnerability, it looks for inside the JSON object that's being passed. 215 00:21:50,810 --> 00:21:58,830 If the event.datatype equals error, all it's going to do is fill in a div with the error message that's on there. 216 00:21:59,850 --> 00:22:04,670 So this is kind of an example payload, which might be passed back to the original site. 217 00:22:04,670 --> 00:22:21,070 So if you're familiar with cross-site scripting, all that's going to do is put an image tag on the website, it's going to try and load the source of X, which is going to fail, and then it's just going to pop an alert on there, because we've got the JavaScript in the onError event handler. 218 00:22:21,070 --> 00:22:28,890 I mean, don't worry about that too much, but just take it as if somebody's got postMessage, and they're putting that information on the page, it can get dangerous. 219 00:22:35,800 --> 00:22:42,020 So as we saw, this is the regex that's been used on here, which is just www.trusted.com. 220 00:22:42,620 --> 00:22:46,440 So the first thing that we're missing is an anchor at the end. 221 00:22:47,000 --> 00:22:58,480 So the problem with this is, if you've got the domain name attacker.com, you can just create these chains of subdomains, so you could have a website of www.trusted.com.attacker.com. 222 00:22:58,480 --> 00:23:07,780 If you force your victim to go there, that'll pop open the original window of the main website you're trying to hack, and then you can actually communicate between those two. 223 00:23:07,780 --> 00:23:23,140 So all you need to do is send a link to a user that opened up this attacker.com subdomain, and then instantly you'd be able to launch JavaScript on that original site, which of course you can then start stealing cookies, taking over accounts, things like that. 224 00:23:23,580 --> 00:23:27,200 So that's the first thing that we need, a dollar sign on the end. 225 00:23:27,200 --> 00:23:33,060 And again, going back to what we learned, that dollar sign says nothing can be after this. 226 00:23:33,060 --> 00:23:35,420 It's just got to be that domain name, and that's it. 227 00:23:35,480 --> 00:23:36,980 No other characters. 228 00:23:37,920 --> 00:23:40,220 And then the next one is the wildcard. 229 00:23:40,220 --> 00:23:42,980 This is probably the most common one that we see out there. 230 00:23:43,060 --> 00:23:47,340 Developers always forget to put that backslash on there to mark it as being a period. 231 00:23:47,340 --> 00:23:58,260 You could register the domain name www.xtrusted.com, and then that will pass the regex rules, and then you can move on from there. 232 00:24:00,660 --> 00:24:10,080 This is the fix for it, so we can see that we've got the dollar sign at the end, and we've also done the backslashes on the periods as well to make this one now secure. 233 00:24:11,000 --> 00:24:13,620 So open redirects is the next one. 234 00:24:14,080 --> 00:24:18,680 So again, we've just got some simple code which is basically testing the URL. 235 00:24:18,680 --> 00:24:31,800 So you might have a website, and there's a variable on there which you can pass in a URL, but you want to make sure that it's only domains that belong to trusted... sorry, you want to make sure it's only subdomains that belong to the trusted.com. 236 00:24:32,260 --> 00:24:35,640 If it does, and that passes, it will redirect to that website. 237 00:24:35,640 --> 00:24:37,180 Otherwise, it will fail. 238 00:24:38,140 --> 00:24:56,320 So again, we've got the wildcard, which is going to be quite familiar on there, and because that requires a backslash on there, then again, we can have the www.xtrusted.com, and then you can redirect people to that website. 239 00:24:56,320 --> 00:25:04,880 Again, that could potentially be used in like phishing engagements, so people look at the link on their email and think, oh yeah, that's a valid URL at the start. 240 00:25:04,880 --> 00:25:08,100 I'll click on that, but then you could get redirected somewhere else. 241 00:25:08,100 --> 00:25:13,420 It might trick you into putting account credentials in or downloading something like malware. 242 00:25:15,800 --> 00:25:19,600 Also, the subdomain part of this as well. 243 00:25:19,660 --> 00:25:26,200 So this wildcard on here is because they want to accept any subdomain of trusted.com. 244 00:25:26,200 --> 00:25:36,780 Usually, you want to restrict this a little bit, because especially with very big scopes, and you've got like kind of like engineering side where they'll do a lot of testing. 245 00:25:36,980 --> 00:25:41,740 There could be something like QAProd.1 or something, and you definitely don't want that being matched. 246 00:25:42,040 --> 00:25:47,340 It might be just some really vulnerable old code that somebody's managed to find while they've been doing some reconnaissance. 247 00:25:49,060 --> 00:25:54,380 Again, we've got the dollar sign at the end, so then you can add to it. 248 00:25:54,380 --> 00:25:57,940 So you can have the www.trusted.com.evil.com. 249 00:25:57,940 --> 00:26:00,860 So then you can use that to take over. 250 00:26:02,120 --> 00:26:15,500 And of course, at the start symbol as well, the caret at the beginning, what you could do is actually pass in a domain name and then pass in the original one as a query string instead. 251 00:26:15,500 --> 00:26:22,720 So again, without that caret symbol at the start, say this must start with a subdomain of trusted.com. 252 00:26:22,720 --> 00:26:26,340 It'll still match that part at the end, and it'll get passed through. 253 00:26:28,700 --> 00:26:30,720 So here's our fixed one. 254 00:26:30,940 --> 00:26:35,960 So it's only accepting certain subdomains between A to Z, 0 to 9. 255 00:26:35,960 --> 00:26:37,840 So this is just going to be like top level domains. 256 00:26:37,840 --> 00:26:41,800 So you can have like www.oradmin, things like that. 257 00:26:42,220 --> 00:26:45,460 Even better, let's actually put the domains that you're allowed on there. 258 00:26:45,460 --> 00:26:47,980 So again, we've got the group with the or on there. 259 00:26:47,980 --> 00:26:52,780 So it'll just accept admin, www, and download, and nothing else. 260 00:26:54,060 --> 00:26:58,680 So this is one of Ben's examples where that actually happened. 261 00:26:58,680 --> 00:27:05,360 So on the URL, you could put in the site name, the application name, and the path. 262 00:27:05,360 --> 00:27:15,760 But because the path on there wasn't checking whether it began with a slash at the beginning, you could instead just change the path to .evil.com. 263 00:27:15,760 --> 00:27:22,760 So it'd actually redirect to some application .redacted.com.evil.com, which would be your domain name. 264 00:27:22,760 --> 00:27:27,940 And in this instance, Ben used this as an open redirect, which would actually grab somebody's auth token. 265 00:27:27,940 --> 00:27:30,720 So it just wasn't a kind of a simple open redirect. 266 00:27:30,720 --> 00:27:35,480 It was actually an account takeover where you could steal somebody's cookie after logging in. 267 00:27:36,700 --> 00:27:39,380 And that got $14,000, I believe, Ben. 268 00:27:42,530 --> 00:27:44,270 Okay, calls. 269 00:27:44,270 --> 00:28:05,110 So when you're on a website and you're making an AJAX request to a different domain name or a different subdomain to what you're on, or even a different scheme, you have what's called a pre-flight check, where it sends an options header to the server that you're going to communicate with and say, 270 00:28:05,110 --> 00:28:06,750 hey, I'm coming from this website. 271 00:28:06,750 --> 00:28:09,050 Am I actually okay to send this information? 272 00:28:09,470 --> 00:28:11,850 Especially with things like credentials as well. 273 00:28:11,850 --> 00:28:17,710 So you might have like a second website where, say, if it's like an API. 274 00:28:17,710 --> 00:28:23,130 So you have like, well, in this example, we have like a slash API slash me. 275 00:28:23,130 --> 00:28:30,950 So if you visited that normally, it would use your cookies, and then it would show you the information in API slash me. 276 00:28:30,950 --> 00:28:36,890 So that would be really dangerous if any website could make a call to that and then grab that information. 277 00:28:36,930 --> 00:28:40,070 So this is why we have calls and those pre-flight checks. 278 00:28:40,150 --> 00:28:44,970 It will pass the origin, which is the website that you're currently on. 279 00:28:44,970 --> 00:28:59,110 And if that matches the rule on there to whether it is an allowed website, you'll get a response in there saying the action control allow origin header will be returned, and that has to match your address. 280 00:28:59,110 --> 00:29:02,270 So the scheme and the domain in your address bar. 281 00:29:02,410 --> 00:29:08,370 Also, if you can send cookies along with that request, you'll get the access control allow credentials. 282 00:29:08,590 --> 00:29:21,670 Interestingly, most browsers have actually removed this, because a lot of the time, passing cookies back and forth towards third party domains, it's mainly used for analytics so that people can track you all over the web. 283 00:29:21,670 --> 00:29:26,570 Every browser has removed this, apart from Google, surprise, surprise, with Chrome. 284 00:29:26,650 --> 00:29:28,370 They keep on promising to do it. 285 00:29:28,370 --> 00:29:30,810 They also keep on extending that data as well. 286 00:29:32,010 --> 00:29:36,950 So where the issue is, so we've got the calls code on the server side. 287 00:29:36,950 --> 00:29:43,670 Again, it's using a regex to check whether this domain is actually allowed to communicate with it. 288 00:29:43,670 --> 00:29:47,610 If it passes that check, it will then set those headers. 289 00:29:48,890 --> 00:29:59,790 So again, we've got the wildcard character, which we explained, so we can just, you know, purchase a completely different domain with an X in there, and we can bypass that regex check, and then we can start stealing information. 290 00:30:00,350 --> 00:30:09,490 Again, the subdomain, so we can add in a completely random domain that possibly we've taken over, something which is a little bit easier to hack into. 291 00:30:10,690 --> 00:30:13,350 Again, no dollar sign on the end as well. 292 00:30:13,490 --> 00:30:17,510 So we can add our evil.com domain on there, and we can steal the information. 293 00:30:18,310 --> 00:30:33,550 So this is the fixed one on there, so we only cover subdomains, like top level ones, A to Z, zero to nine, and an underscore, and then we've got the backslashes in there for the wildcards with the trusted.com, so this has made this now secure. 294 00:30:35,590 --> 00:30:40,070 SSRF, so I'm not going to go through every vulnerability, don't worry, because they're all pretty similar. 295 00:30:40,830 --> 00:30:57,210 Say if you had a website and it was going to make a PDF of your LinkedIn user page, so it's expecting for you to give a LinkedIn domain, it'll grab that, it'll convert it to a PDF, and it'll send it to you. 296 00:30:57,210 --> 00:31:06,810 You don't want this accepting any domain name, because you could potentially access things that are on local host or metadata if you're hosting on the cloud. 297 00:31:08,550 --> 00:31:27,030 So again, we've got the full stop on there, which is the wildcard, and we could create a domain, the www.xlinkedin.com, we could register that or any character, set the ADNS record to local host, and instead it'll communicate with the local host instead. 298 00:31:28,730 --> 00:31:43,530 And there's no slash at the end of the domain that's been put on there as well, so we could make that a subdomain of a domain that we already have control over, and again, we can control the DNS and where that goes to. 299 00:31:44,490 --> 00:31:50,190 And the no caret symbol at the start say the string must start with this. 300 00:31:50,190 --> 00:32:03,730 So if we pass in a whole URL, again, we could be hosting something which either redirects to somewhere completely different, or again, we can set that DNS record, and we can get it to create a PDF of any page we want. 301 00:32:05,490 --> 00:32:16,230 Also as well, don't just trust the start of it, maybe after the slash at the end, let's get the exact path in there, because what happens if we find an open redirect on LinkedIn? 302 00:32:16,470 --> 00:32:29,930 So it's passing all the regex, it hits the slash redirect, which is hosted on LinkedIn, goes back to your evil.com domain, which has a DNS record of 127.0.1, which will then start querying local services. 303 00:32:29,930 --> 00:32:32,910 Obviously, we could change that address to different things as well. 304 00:32:35,670 --> 00:32:37,690 So this is the fixed version. 305 00:32:38,010 --> 00:32:51,350 So with what we've learned is we've got the... it has to start with HTTPS, LinkedIn.com, and then slash in, slash then the word symbol, which will only accept characters A to Z, zero to nine, and underscores. 306 00:32:51,350 --> 00:32:54,590 So that should be safe after that with my example at the bottom. 307 00:32:58,660 --> 00:32:59,260 Okay. 308 00:32:59,260 --> 00:33:00,800 So I think now Ben's up. 309 00:33:00,800 --> 00:33:05,420 So he's going to go through some vulnerabilities that he's found where regex has been involved. 310 00:33:05,420 --> 00:33:07,800 He's going to chat about that and some refund stuff. 311 00:33:08,760 --> 00:33:09,820 All right. 312 00:33:13,780 --> 00:33:20,160 So I did a similar talk to this one somewhere else, and I talked about some vulnerabilities I got in trouble for. 313 00:33:20,340 --> 00:33:24,720 So I couldn't put the screenshots of the vulnerabilities on this slides. 314 00:33:24,780 --> 00:33:30,740 So instead, I'm going to just show you similar findings on GitHub that scored me the same bounties. 315 00:33:30,740 --> 00:33:33,640 I just couldn't put the specific bugs up here. 316 00:33:33,640 --> 00:33:39,340 But when it comes down to SSRF, the majority of the goal is internals, right? 317 00:33:39,340 --> 00:33:44,760 Get into the internal network or get some AWS keys or something fun, right? 318 00:33:44,760 --> 00:33:51,860 So we'll come back to this, but there is something beautiful about using regex on GitHub. 319 00:33:52,140 --> 00:33:53,500 And I use this a lot. 320 00:33:53,500 --> 00:34:01,800 I've gone away from using the traditional sub finder, amass, domain finder, whatever you want to name it. 321 00:34:01,800 --> 00:34:11,720 I've kind of stepped away from those because one, everybody else is using them on public programs and B, I wanted something new and I really wanted to drive this home for this DEF CON talk. 322 00:34:11,720 --> 00:34:16,460 So you can do a couple of things with regex on GitHub. 323 00:34:16,460 --> 00:34:19,080 You can actually use regex to look for subdomains. 324 00:34:19,120 --> 00:34:27,680 So let's say you have a environment on cert.sh that comes back and it says, yeah, I have a wildcard certificate here. 325 00:34:27,680 --> 00:34:30,640 It's something.corp.site.com. 326 00:34:30,700 --> 00:34:33,760 And you can't see what's behind corp because it's a wildcard. 327 00:34:33,760 --> 00:34:35,280 You have to brute force for it. 328 00:34:35,380 --> 00:34:37,280 This is a really good way to find it. 329 00:34:37,280 --> 00:34:41,840 Again, the regex that you see on this screen is one of many things you can try. 330 00:34:42,020 --> 00:34:45,400 It's something that we've came up with, so it simplifies what we're doing. 331 00:34:45,900 --> 00:34:52,340 And you can take that even a step further and just look for subdomains that contain specific keywords. 332 00:34:52,560 --> 00:34:55,600 So if you want to find APIs, you can put an API in there. 333 00:34:55,660 --> 00:34:58,380 If you want to look for dev sites, you can put dev in there. 334 00:34:58,380 --> 00:35:02,140 And the cool thing about doing that is it also gives you context. 335 00:35:02,140 --> 00:35:05,040 It gives you context of what people are doing on these APIs. 336 00:35:05,280 --> 00:35:08,080 Are these internal APIs that they have leaked data on? 337 00:35:08,080 --> 00:35:10,960 Have they given you their paths and things like that? 338 00:35:10,960 --> 00:35:22,080 So one of the really cool bugs that I found using this method was on one of the bug bounty platforms, we were hacking on a redacted program and this guy came to me on Discord. 339 00:35:22,080 --> 00:35:28,020 He's like, hey, I have a SSRF, but I know it's hitting something internal, but I just can't prove it. 340 00:35:28,020 --> 00:35:34,940 And it's not on AWS, it's not on GCP, so we don't have any access to anything that we can prove. 341 00:35:34,940 --> 00:35:37,760 And I just think there's something on the internal that we can find. 342 00:35:37,880 --> 00:35:45,120 So we went through this example and instead of putting API, we were looking for a specific keyword.site.com. 343 00:35:45,440 --> 00:35:49,420 And we ended up making a quick list of everything that was on GitHub. 344 00:35:49,420 --> 00:35:52,780 And one of those was their source code. 345 00:35:53,180 --> 00:35:58,820 There's a frog or whatever it's called, JFrog, that was on auth and you can just pull source code from it. 346 00:35:59,000 --> 00:36:09,080 And none of the databases that we went through for asset discovery, your sub finder, your cert.sh, your c99.nl, all of those didn't have data on this specific thing. 347 00:36:09,080 --> 00:36:16,920 But some developer unfortunately had leaked their automation on GitHub and had the instance for us that we could pull for. 348 00:36:16,920 --> 00:36:18,720 So we had access to all their source code. 349 00:36:18,720 --> 00:36:19,380 We reported it. 350 00:36:19,380 --> 00:36:25,060 And I think that one was a $5,000 or $6,000 bounty on a public bug bounty program. 351 00:36:25,180 --> 00:36:33,800 So this is a really, really good way to find assets that you can narrow your focus on what you want to hack on. 352 00:36:33,800 --> 00:36:35,000 I'm just going to make sure I have my notes. 353 00:36:35,000 --> 00:36:37,980 I don't miss anything since I don't have... I couldn't put slides. 354 00:36:37,980 --> 00:36:38,760 There we go. 355 00:36:39,720 --> 00:36:41,500 So that's one of the things that I want to do. 356 00:36:41,500 --> 00:36:48,180 This is the starting point for me when it comes down to looking for assets that I want to hack on. 357 00:36:48,180 --> 00:36:54,600 So with bug bounties, one of the number one questions I get is like, where do I pick the targets out of these thousand subdomains that I found? 358 00:36:54,820 --> 00:36:56,640 This could be a really good way. 359 00:36:57,080 --> 00:37:01,140 So you also have the content discovery part of this. 360 00:37:01,280 --> 00:37:13,200 You can find a lot of cool content that you probably can't brute force for if you were to find a random API that doesn't have any swagger or open API JSON on there. 361 00:37:13,200 --> 00:37:19,360 So again, very random, but also high level regex for it. 362 00:37:19,360 --> 00:37:20,740 We're using Netflix for this. 363 00:37:20,740 --> 00:37:29,300 We're saying anything that has Netflix, it could be netflix.com, netflix.io, netflix.net, because those are also tier two assets on Netflix's bug bounty program. 364 00:37:29,300 --> 00:37:33,300 And then we're hitting it with, I want it to have slash API in there. 365 00:37:33,300 --> 00:37:48,960 This alone on a, this is not on Netflix's bug bounty program on a private , no public program on HackerOne that's been around maybe for, I want to say over six years , have a massive scope to have massive presence online. 366 00:37:49,340 --> 00:37:52,540 And two cool things came out of this two types of vulnerabilities. 367 00:37:52,540 --> 00:38:03,420 The first one was, I just wanted to find APIs to hack on because everything for these websites that I would go to, you needed an account. 368 00:38:03,560 --> 00:38:08,660 So they have a domain in, let's say Netherlands. 369 00:38:08,920 --> 00:38:10,660 It's a .nl domain. 370 00:38:10,740 --> 00:38:14,020 You need to be a Dutch citizen to be able to get an account. 371 00:38:14,020 --> 00:38:16,660 You need to have an ID to get logged in. 372 00:38:16,660 --> 00:38:19,160 And then you can see their API routes to interact with it. 373 00:38:19,380 --> 00:38:21,580 Obviously not Dutch, don't have an ID. 374 00:38:21,620 --> 00:38:22,940 This was a great way to do it. 375 00:38:22,940 --> 00:38:29,860 So actually I found an asset on there that not only did it give me the API routes, it also gave me how the usernames were being created. 376 00:38:29,860 --> 00:38:35,440 So it was like a first name, initial, last name, and the year of their birth. 377 00:38:35,960 --> 00:38:45,560 And it's, you know, it's in, if it's a Dutch that you go to chat GPT and say, Hey, give me a top 10, most common Dutch last names, add an A through Z in the beginning. 378 00:38:45,940 --> 00:38:50,060 And then numbers that you think are birth years where, you know, people that I can use. 379 00:38:50,060 --> 00:38:52,280 So that's one, it was a $5,000 bounty. 380 00:38:52,940 --> 00:38:57,800 And then you can also do things like, Hey, maybe it doesn't have API in it. 381 00:38:57,800 --> 00:39:04,760 It could be something like app dash API, but then, you know, app name, the app name could be anything arbitrary, right? 382 00:39:04,760 --> 00:39:09,220 It could be a printer API dash whatever. 383 00:39:09,220 --> 00:39:12,740 And then there's a V1 in there and you do that and it gives you a lot of good results. 384 00:39:12,740 --> 00:39:21,260 And all this, honestly, all these APIs are also cool to look at, but for that one specifically, it wasn't anything with the API itself that was vulnerable. 385 00:39:21,280 --> 00:39:26,340 It turns out that had some very obscure path for all of their applications. 386 00:39:26,760 --> 00:39:28,460 It was about five dashes. 387 00:39:28,460 --> 00:39:36,140 And so five different words, it was like a region, app name, environment, and then a country at the end. 388 00:39:36,140 --> 00:39:37,880 So it was really hard to brute force. 389 00:39:37,880 --> 00:39:43,720 But once I found every single one of those on GitHub, every single one of those endpoints had an actuator with a heap dump. 390 00:39:43,960 --> 00:39:49,580 So if you're not familiar with actuator heap dumps, it's just for Java backend, you can use something like a spring boot. 391 00:39:49,580 --> 00:39:51,660 It gives you access to the environment variables. 392 00:39:51,660 --> 00:39:52,980 You can pull credentials. 393 00:39:53,060 --> 00:39:57,560 The heap dump is just a snapshot of the memory that has all the HTTP requests. 394 00:39:57,560 --> 00:40:00,260 And I will show some of those in here. 395 00:40:00,360 --> 00:40:14,340 And I want to say I found four of those at $3,000 a pop within just a couple of hours of just realizing like, hey, I can just go on GitHub and somebody else had leaked these paths for me to be able to look for it. 396 00:40:14,340 --> 00:40:23,820 So keep this in mind when you're looking at a random asset you found, you're banging your head against the wall going, what is on this API? 397 00:40:23,820 --> 00:40:25,600 What are the routes on this API? 398 00:40:25,640 --> 00:40:30,900 Somebody, I promise you has leaked it on GitHub, but you just got to be able to find it with a good regex. 399 00:40:30,900 --> 00:40:35,420 So those are a couple of bugs that I can talk about throughout all this. 400 00:40:35,720 --> 00:40:37,560 You can also use it for things like GraphQL. 401 00:40:37,560 --> 00:40:39,400 I just want to give you examples of things that you can look. 402 00:40:39,400 --> 00:40:40,560 It's not just always API. 403 00:40:40,560 --> 00:40:41,720 It's not always GraphQL. 404 00:40:41,720 --> 00:40:53,680 You could also just literally be knowing that this company has this stack that they use, technology stack or this component that they use across their environments and you want to find it. 405 00:40:53,680 --> 00:41:06,160 So you can just purely do for this one, we're doing every domain obviously that's on GitHub, but you can just narrow it down to something like a netflix.com or fort.com and then looking for every GraphQL instance in there. 406 00:41:07,700 --> 00:41:10,900 We can also use this for parsing data dumps. 407 00:41:10,900 --> 00:41:12,580 Do you want to take this one or maybe you could keep going? 408 00:41:13,240 --> 00:41:17,460 I'll take this one just because of the fact that it's, I talked about actuators and I kind of want to show what it looks like. 409 00:41:17,600 --> 00:41:26,520 So this is obviously a fake version of actuator that we have as a lab, but most of the time if you do, if you find actuator, this will be something that it would look like. 410 00:41:26,520 --> 00:41:27,960 If you're lucky, this is what it looks like. 411 00:41:27,960 --> 00:41:32,400 If you're unlucky, then it just shows you health, info and metrics. 412 00:41:32,420 --> 00:41:35,380 If you don't see those three, I'll give you a hug. 413 00:41:35,380 --> 00:41:36,180 It sucks. 414 00:41:36,180 --> 00:41:41,540 It's not fun to see those, but when you do come across an actuator, you can download the actuator heap dump. 415 00:41:41,960 --> 00:41:45,860 It looks a little ugly like this if you open it because it's not human readable. 416 00:41:45,900 --> 00:41:57,700 You can pass it to strings, for example, and you can grip for some data, but keep in mind when you're gripping for, I don't know, password, you're going to get a ton of other variables that have the word password in it or username in it or whatever it is. 417 00:41:58,080 --> 00:42:09,860 But we can use something like this to just pull everything that has, that ends with an equal sign, which is a parameter or even better, it could be a base 64 of a password that ends into two equal signs. 418 00:42:10,040 --> 00:42:16,160 And it could be a password for something or it could be something that we can use and leverage it. 419 00:42:16,160 --> 00:42:21,140 You can look for things like, I think Adam's going to cover these, but you can look for JWT tokens. 420 00:42:21,140 --> 00:42:22,720 They start in a very specific way. 421 00:42:22,720 --> 00:42:24,260 You can look for AWS keys. 422 00:42:24,260 --> 00:42:26,440 They look a very specific way that we'll cover. 423 00:42:26,740 --> 00:42:48,600 But this has been something that I have had to shift to because I realized after creating this course with Adam, I went through all the heap dumps that I've had on my laptop and I realized how much data I had missed by just doing a strings file and then piping into GRIP without regex because there's so much data that I couldn't go through. 424 00:42:48,700 --> 00:42:56,180 So I'll let Adam cover some of the other safe secrets and then we'll wrap it up with some code review and maybe take some questions at the end. 425 00:43:04,710 --> 00:43:08,810 Okay, so very quickly, again, using GitHub, we can look for things. 426 00:43:08,810 --> 00:43:26,050 So all JWT tokens quite nicely start with EYJ, which is the opening bracket on there, followed by characters A to Z, zero to nine, underscores and hyphens, and then with a dot in the middle. 427 00:43:26,050 --> 00:43:34,070 So if you search for this on GitHub, don't know who these poor people are, sorry, you'll find a bunch of JWT tokens which have been put on there. 428 00:43:34,630 --> 00:43:38,650 Again, things like AWS keys as well, that can be put on there as well. 429 00:43:38,650 --> 00:43:42,290 You can also combine that with like Netflix domains as well. 430 00:43:42,510 --> 00:43:50,250 I've found this random thing, I don't know what it is, there's some research.netflix and there's a JWT token in there as well. 431 00:43:53,910 --> 00:44:00,190 All right, sorry, yeah, if you put when you're searching on GitHub, where the and is, you have to put that as capital, sorry. 432 00:44:01,870 --> 00:44:04,650 Regex as well can be really useful for code review. 433 00:44:04,690 --> 00:44:09,730 So whatever your stack is that you're used to, I'm used to PHP, so I'm just going to use this as an example. 434 00:44:09,790 --> 00:44:20,950 So if you're searching for anything that might reflect XSS in your code, so it'll be echo and then you're just echoing out straight away any get or post requests with no validation on there whatsoever. 435 00:44:20,950 --> 00:44:25,310 That's a good indication that you're going to get an XSS on your website. 436 00:44:25,310 --> 00:44:37,190 So it's just looking for any instances where it's echoing out and then using Regex, we've managed to put the group and the author operator on there and to look for anything that's get post and then starts with the open bracket. 437 00:44:39,130 --> 00:44:42,370 So here's some code example that might come up on there. 438 00:44:43,450 --> 00:44:49,530 Anything that's potentially using the system command as well, that could be receiving some information. 439 00:44:49,530 --> 00:45:02,550 So any websites that are using system to actually process some code on there, you're going to want to make sure that you have a look at that, make sure it's not taking any variables that you could potentially then get RCA on the website. 440 00:45:03,410 --> 00:45:07,590 And you can also use a Regex to look for Regexes as well. 441 00:45:07,590 --> 00:45:11,950 So this checks for Regex code for PHP, JavaScript and Python. 442 00:45:11,950 --> 00:45:16,310 You have different packages on there which you put regular expressions into. 443 00:45:16,350 --> 00:45:20,410 Again, this will flag them all up in your code and then you can review them manually. 444 00:45:22,190 --> 00:45:26,030 Again, you can search for things like basic auth, that's in your code as well. 445 00:45:26,030 --> 00:45:29,830 So that's going to match any of the base 64 strings and then ends in an equals. 446 00:45:30,130 --> 00:45:32,510 Again, finding JWT tokens. 447 00:45:32,510 --> 00:45:34,530 Sorry if this is really fast, but we're running out of time. 448 00:45:35,230 --> 00:45:40,350 You can also do these things on not your own code, but you could also do it on GitHub as well. 449 00:45:40,350 --> 00:45:43,950 Again, looking for any XSS which might be in PHP. 450 00:45:46,110 --> 00:45:48,950 And then you can use the and command as well with WordPress. 451 00:45:48,950 --> 00:45:55,870 So if you're targeting particularly like WordPress plugins through like a bounty program like WordFence, you can do that. 452 00:45:56,370 --> 00:46:02,810 And also look for things that system commands that like either get or post has been passed into as well. 453 00:46:02,810 --> 00:46:05,850 So there's like user input, which is going into a system call. 454 00:46:06,850 --> 00:46:10,870 So like on this one that I searched for, which you can get some interesting results. 455 00:46:10,870 --> 00:46:13,910 This was just basically somebody's web shell that they've hosted on there. 456 00:46:13,910 --> 00:46:17,150 So we've got some hackers posting some stuff on there as well. 457 00:46:18,950 --> 00:46:25,450 One of the cool things I've really found about it is now and again, I find like building tools for the community really interesting. 458 00:46:25,570 --> 00:46:31,790 So one of the first ones that created was creatures of habit, which wouldn't be possible without regexes on there. 459 00:46:31,790 --> 00:46:36,670 So all this does is it goes, I increment through every package on GitHub. 460 00:46:36,670 --> 00:46:40,690 It grabs certain web extensions on there. 461 00:46:40,690 --> 00:46:44,970 And then it goes through every different framework that's out there. 462 00:46:44,970 --> 00:46:48,430 Like we've got like Python, like Flask on there. 463 00:46:48,430 --> 00:46:49,890 So it looks for any routes. 464 00:46:49,890 --> 00:46:55,730 So we can start making loads of routes and then we can use those for word lists for finding other things on other domains. 465 00:46:56,250 --> 00:46:58,450 And PHP with Laravel has gone there. 466 00:46:58,450 --> 00:47:06,350 JavaScript, Python, ASP.NET, Ruby on Rails, and Go as well on there. 467 00:47:06,350 --> 00:47:15,510 Another one I wanted to create word lists as well for when I'm hacking into websites, where I want to create a unique list of parameters as well. 468 00:47:15,510 --> 00:47:26,170 So it's great to go to GitHub, find all the parameters that developers are actually using, either in query strings or the post body or HTTP headers and methods. 469 00:47:26,230 --> 00:47:44,930 And again, I could cycle through pretty much most of GitHub, look for PHP pages and look for any get or post things in the code and then I'd extract the actual string in the middle and then I'd put those into a word file and then I can use that later on for reconnaissance. 470 00:47:44,930 --> 00:47:54,450 With parameters I've done that, with HTTP headers and with get methods as well, because they tend to get reused in web paths. 471 00:47:55,430 --> 00:47:56,690 So that's been pretty interesting. 472 00:47:56,690 --> 00:48:01,590 I've managed to make some really interesting word lists and found some very interesting things from that. 473 00:48:02,770 --> 00:48:04,530 I think we are finally done. 474 00:48:04,570 --> 00:48:06,110 Sorry if we've melted your brain. 475 00:48:06,110 --> 00:48:07,410 It's been a lot of information. 476 00:48:07,410 --> 00:48:13,250 Don't worry if you didn't grab it all, but hopefully it's kind of prompted you enough to go, yes, I will learn Regex. 477 00:48:13,350 --> 00:48:21,490 One more note, because for the GitHub stuff, for the code review, the reason why we have it in there, a lot of companies open source a lot of their frameworks. 478 00:48:21,490 --> 00:48:22,630 So keep that in mind. 479 00:48:22,630 --> 00:48:24,510 You can go and find vulnerabilities in those. 480 00:48:24,510 --> 00:48:25,470 That's why we have them on there. 481 00:48:25,470 --> 00:48:27,610 We just can't show you exact examples of it. 482 00:48:27,610 --> 00:48:35,770 But a lot of the large organization, especially if they've been around for years, all of their frameworks that they use internally for their basic applications, that code is online. 483 00:48:35,770 --> 00:48:36,790 You can look at it. 484 00:48:36,830 --> 00:48:38,950 Enterprise tools, you can launch them on your own. 485 00:48:39,190 --> 00:48:42,750 Go through the EC2 instance, get the code and dump it and look for vulnerabilities. 486 00:48:42,810 --> 00:48:43,930 Keep that in mind. 487 00:48:43,930 --> 00:48:44,930 That's why we have it in there. 488 00:48:44,930 --> 00:48:45,570 It's not a teaser. 489 00:48:45,570 --> 00:48:47,310 It's just get creative. 490 00:48:47,310 --> 00:48:49,430 Look at these things and go, what else can I do with it? 491 00:48:49,430 --> 00:48:51,830 How can I chain all these and apply them in a real world? 492 00:48:52,450 --> 00:48:55,430 With that said, I think we have only two minutes before we get kicked out of the room. 493 00:48:55,430 --> 00:48:57,230 If there are any questions, we would love to answer them. 494 00:48:57,250 --> 00:48:59,170 If not, hang out here and answer any questions. 495 00:48:59,170 --> 00:48:59,570 Okay? 496 00:49:17,520 --> 00:49:21,300 You can use tools to unpack that actuator dump. 497 00:49:21,300 --> 00:49:22,180 Is that what you're talking about? 498 00:49:22,180 --> 00:49:23,280 You can use tools. 499 00:49:23,280 --> 00:49:26,520 I personally don't use them with bug bounty programs because they usually don't care. 500 00:49:26,940 --> 00:49:30,020 I literally just run them through GRIP with regex. 501 00:49:30,020 --> 00:49:31,800 Look for things that I think is valuable. 502 00:49:31,800 --> 00:49:33,380 Look for cookie values, for example. 503 00:49:33,380 --> 00:49:36,360 Look for JWT tokens. 504 00:49:36,360 --> 00:49:38,460 Look for bearer tokens and things like that. 505 00:49:38,460 --> 00:49:47,500 When you see that access, you'll see the whole HTTP request on there so you can see where they're actually using that token and where sending it to or receiving it from as well. 506 00:49:50,020 --> 00:49:53,940 They'll be on the website with the actual workshop soon. 507 00:49:54,280 --> 00:49:55,660 This is a part of a bigger workshop. 508 00:49:55,660 --> 00:49:56,780 It's just what we could... 509 00:49:59,240 --> 00:50:00,300 It will be an additional one. 510 00:50:00,300 --> 00:50:01,220 I'll send it to you.