1 00:00:00,000 --> 00:00:03,020 All right, good afternoon, and thanks for coming out to see our talk. 2 00:00:03,560 --> 00:00:06,140 There's a great presentation across the way, 3 00:00:06,200 --> 00:00:12,740 so I'm glad you guys were interested in learning about what we have to say. 4 00:00:12,820 --> 00:00:18,260 So basically, we're going to talk about tool smithing using a case study as NIDA bridge, 5 00:00:18,440 --> 00:00:21,220 and we're also going to throw in some other things that we've done previously. 6 00:00:21,880 --> 00:00:24,620 First off, my name is Adam Pridgen, and this is Matthew Wollong-Lebber. 7 00:00:25,960 --> 00:00:29,060 And as a brief introduction to what the presentation is going to cover, 8 00:00:29,060 --> 00:00:31,700 we're going to give an introduction to what we're actually going to talk about, 9 00:00:32,740 --> 00:00:35,060 a little bit of background about tool smithing and such, 10 00:00:35,660 --> 00:00:39,280 then discuss what tool smithing is and the development process that we kind of use, 11 00:00:39,780 --> 00:00:44,680 and then we'll talk about some of the cases and shortcuts that we actually apply our techniques to, 12 00:00:44,780 --> 00:00:48,940 so that way you can see in real life how you could actually learn from this type of stuff. 13 00:00:50,260 --> 00:00:52,340 Then we'll talk a little bit about our eBridge. 14 00:00:52,440 --> 00:00:57,680 It's basically an evolutionary project that just came out of a really random idea 15 00:00:57,680 --> 00:00:58,920 that I was given to by a friend. 16 00:00:59,060 --> 00:01:00,260 And I had experienced previously. 17 00:01:00,720 --> 00:01:04,860 And so it's just kind of evolved from one thing into something grand and spectacular. 18 00:01:05,200 --> 00:01:07,260 But it's tedious to do software and development, 19 00:01:07,540 --> 00:01:12,480 so we use tool smithing and try to do rapid prototyping to help speed up the development process. 20 00:01:12,860 --> 00:01:16,880 And then we'll follow that up with some lessons learned from the various techniques 21 00:01:16,880 --> 00:01:18,680 and various processes that we've used, 22 00:01:18,780 --> 00:01:22,640 and then we'll talk conclusions and give special thanks. 23 00:01:23,140 --> 00:01:25,840 So just a brief background or introduction to me. 24 00:01:26,140 --> 00:01:28,420 I've been in information security for about seven years. 25 00:01:29,140 --> 00:01:30,620 Before that, I was in the military. 26 00:01:31,880 --> 00:01:36,980 So I've always been really entrenched in attacker-defender type of mentality. 27 00:01:37,840 --> 00:01:40,880 So I got involved in security when I was at the University of Texas. 28 00:01:41,120 --> 00:01:42,340 So I've been a student. 29 00:01:42,460 --> 00:01:45,740 I've taught adjunct faculty in an adjunct faculty position before. 30 00:01:45,800 --> 00:01:47,780 I'm a pen tester, reverser, and I love to write code. 31 00:01:48,840 --> 00:01:53,800 Currently, I'm working at Praetorian, and my personal site is thecoverofknight.com, 32 00:01:53,880 --> 00:01:55,780 hence the green and black background. 33 00:01:56,240 --> 00:01:57,260 And this is Matt. 34 00:01:57,480 --> 00:01:58,900 Hi. My name is Matt Wall. 35 00:01:58,900 --> 00:02:01,540 I'm the incident team lead at the George Washington University. 36 00:02:02,480 --> 00:02:04,740 Primarily, we focus on monitoring the network. 37 00:02:05,020 --> 00:02:06,120 It's fairly high throughput. 38 00:02:06,240 --> 00:02:08,500 We have two slash 16s. 39 00:02:08,660 --> 00:02:11,780 Also, handle up all the reversing, the binary analysis type stuff. 40 00:02:12,200 --> 00:02:16,140 I used to be a consultant, worked for the government, was a contractor, a pen tester. 41 00:02:16,800 --> 00:02:19,780 Basically decided that the only place I'd put up with me was a university. 42 00:02:20,240 --> 00:02:23,840 So now I'm staffed there, and hopefully I'll be a PhD student before too long. 43 00:02:26,400 --> 00:02:28,860 So a little bit of introduction to what we're actually doing. 44 00:02:29,380 --> 00:02:32,200 It's a talk about tool smithing, it's a talk about Ida Bridge. 45 00:02:33,100 --> 00:02:34,980 But basically, it all derives from one thing. 46 00:02:35,100 --> 00:02:38,120 We're sort of lazy, but we're OCD about getting things done. 47 00:02:38,920 --> 00:02:41,880 So we want to make sure that we surpass the expectations we have on projects. 48 00:02:42,460 --> 00:02:43,980 But we want to work smarter, not harder. 49 00:02:44,100 --> 00:02:45,980 So if we get a chance to write some code, we want to do that. 50 00:02:46,280 --> 00:02:50,680 So basically, a lot of this talk is tips and techniques to how to get that done 51 00:02:50,680 --> 00:02:53,900 while still doing short-term projects that a lot of people are going to be familiar with. 52 00:02:56,380 --> 00:02:57,800 And a lot of it's experience-based. 53 00:02:58,900 --> 00:03:00,740 So this is called tool smithing. 54 00:03:00,760 --> 00:03:04,220 It's based off of a lot of software development techniques in the past. 55 00:03:04,300 --> 00:03:08,400 It's something that Adam and I both do naturally, and that he really picked up for this talk. 56 00:03:09,120 --> 00:03:12,460 It's intended to make the development process easier, faster, 57 00:03:12,700 --> 00:03:15,680 streamline it from not being a big software development project, 58 00:03:15,840 --> 00:03:18,020 but small tools meant to help get things done. 59 00:03:18,360 --> 00:03:19,940 Generally, these aren't standalone applications. 60 00:03:20,000 --> 00:03:23,920 They're additions or add-ons to other programs 61 00:03:23,920 --> 00:03:26,480 that help you meet particular needs that you have for your project 62 00:03:26,480 --> 00:03:28,060 or whatever software you need to do. 63 00:03:28,060 --> 00:03:30,060 So it's not reinventing the wheel every time. 64 00:03:30,180 --> 00:03:32,620 It's adding on incrementally just to get stuff done. 65 00:03:34,260 --> 00:03:38,100 So really, what we want to talk about are rapid prototyping, 66 00:03:38,220 --> 00:03:39,880 especially in time box windows. 67 00:03:40,180 --> 00:03:43,380 So when we talk about tool smithing, we're talking about prototyping capabilities. 68 00:03:44,160 --> 00:03:47,820 We're talking about saying, I'm on a time box pen test, 69 00:03:48,000 --> 00:03:49,940 and I need a tool that does X and Y, 70 00:03:50,120 --> 00:03:54,580 and I need to model and conceptualize what I'm trying to accomplish. 71 00:03:54,840 --> 00:03:57,620 And then from that model and conceptualization, 72 00:03:57,620 --> 00:04:02,020 I'm trying to implement something so that I can get something useful out of it. 73 00:04:02,160 --> 00:04:06,000 The point being is you don't want to spend 16 hours 74 00:04:06,000 --> 00:04:08,960 when you have only a week to complete an engagement. 75 00:04:09,260 --> 00:04:14,080 The idea is to finish your script or your tool in a matter of, like, 4 to 5 hours 76 00:04:14,080 --> 00:04:16,440 and get it to a point where it's working, 77 00:04:16,580 --> 00:04:18,200 and then you can actually apply it to something. 78 00:04:18,740 --> 00:04:21,940 The whole idea is to build something that's loose and open, 79 00:04:22,040 --> 00:04:25,340 and then you can go back and improve it or release it or do whatever you want. 80 00:04:25,460 --> 00:04:27,600 But, you know, the primary goal is to build something that is loose and open. 81 00:04:27,620 --> 00:04:29,620 goal is always to make everything you do 82 00:04:29,620 --> 00:04:31,520 into a specific functional task. 83 00:04:33,420 --> 00:04:33,700 So 84 00:04:33,700 --> 00:04:35,420 the way we look at this is sort of an evolutionary 85 00:04:35,780 --> 00:04:37,520 type thing. So you have your particular project 86 00:04:37,520 --> 00:04:39,620 requirements that you're doing. You know, if you're a pen tester 87 00:04:39,620 --> 00:04:41,480 you're on the gig for, what, a week, maybe two. 88 00:04:41,800 --> 00:04:43,700 If it's malware reversing, you might have a bit 89 00:04:43,700 --> 00:04:45,560 longer. So from that 90 00:04:45,560 --> 00:04:47,700 you go into quick hacks that just make your life easier. 91 00:04:48,440 --> 00:04:49,620 After a while, though, you might be like, 92 00:04:49,680 --> 00:04:51,540 hey, this was a really good idea. We should make this something 93 00:04:51,540 --> 00:04:53,560 more. You sort of evolve into a proof of concept 94 00:04:53,560 --> 00:04:55,720 code. And this is something that is more 95 00:04:55,720 --> 00:04:57,520 than just a quick hack, but it's just, you know, hey, 96 00:04:57,520 --> 00:04:59,080 this bigger idea might actually work. 97 00:04:59,680 --> 00:05:01,460 From there, you move into a bigger 98 00:05:01,460 --> 00:05:03,480 prototype. This is something that is your 99 00:05:03,480 --> 00:05:05,660 full idea. It's sort of where IdaBridge 100 00:05:05,660 --> 00:05:07,660 slash REBridge is now. It's 101 00:05:07,660 --> 00:05:09,440 there. It's working. It's bigger than something you do 102 00:05:09,440 --> 00:05:11,560 on a project. A lot of time has been put into it, but it's 103 00:05:11,560 --> 00:05:13,440 definitely not something that you'd think of 104 00:05:13,440 --> 00:05:15,280 as, you know, pushed out their software. 105 00:05:15,720 --> 00:05:17,640 And from there, you evolve your tools and techniques. 106 00:05:17,800 --> 00:05:19,420 So you have this big thing that 107 00:05:19,420 --> 00:05:21,280 you have now, and you should 108 00:05:21,280 --> 00:05:23,480 make your process better. You know, take in 109 00:05:23,480 --> 00:05:25,660 your tools to be able to deliver better services 110 00:05:25,660 --> 00:05:27,160 for whatever your next project is. 111 00:05:28,580 --> 00:05:29,260 So rapid 112 00:05:29,260 --> 00:05:31,000 prototyping. We've already 113 00:05:31,720 --> 00:05:33,300 emphasized this before. You need to 114 00:05:33,300 --> 00:05:34,800 meet an objective. You need to do it really quickly. 115 00:05:35,140 --> 00:05:37,220 It's often short-lived, time-boxed development. 116 00:05:37,840 --> 00:05:38,960 So the idea is to 117 00:05:38,960 --> 00:05:41,240 find a task that's going to only take you a couple 118 00:05:41,240 --> 00:05:43,120 hours or, you know, maybe even a day 119 00:05:43,120 --> 00:05:45,280 and use that as one of your primary milestones. 120 00:05:46,100 --> 00:05:47,340 And so what you do from there 121 00:05:47,340 --> 00:05:48,660 is you try to identify 122 00:05:48,660 --> 00:05:51,100 as many shortcuts as you can possibly 123 00:05:52,100 --> 00:05:53,340 take, which means, 124 00:05:53,420 --> 00:05:55,000 you know, taking in open source software, 125 00:05:55,640 --> 00:05:57,220 looking for documentation and 126 00:05:57,220 --> 00:05:57,500 stuff like that. 127 00:05:57,520 --> 00:05:58,140 Stuff along that lines. 128 00:05:59,660 --> 00:06:01,500 So we're going to backpedal a little bit 129 00:06:01,500 --> 00:06:03,240 and talk a little bit about how 130 00:06:03,240 --> 00:06:05,360 we work in this 131 00:06:05,360 --> 00:06:07,400 type of environment. So first 132 00:06:07,400 --> 00:06:09,300 of all, in general, we work in 133 00:06:09,300 --> 00:06:11,420 ad hoc groups. Like, it's not like 134 00:06:11,420 --> 00:06:13,380 someone comes in and says, I need 135 00:06:13,380 --> 00:06:15,220 a tool that is going to, you know, 136 00:06:15,240 --> 00:06:16,920 get me root by, 137 00:06:17,180 --> 00:06:18,700 you know, or get me 138 00:06:19,180 --> 00:06:21,160 passwords out of the registry because somebody 139 00:06:21,160 --> 00:06:23,260 saved their WinSCP key. It doesn't 140 00:06:23,260 --> 00:06:25,440 happen like that. It's very ad hoc. It's very fluid. 141 00:06:25,540 --> 00:06:27,040 So generally what happens is, 142 00:06:27,520 --> 00:06:29,200 you'll find an objective that you need to meet. 143 00:06:29,420 --> 00:06:31,240 You'll be like, hey man, I don't know how to do this. 144 00:06:31,300 --> 00:06:33,200 Do you have any idea? Just start bouncing ideas 145 00:06:33,200 --> 00:06:35,500 off of each other. You'll write code together 146 00:06:35,500 --> 00:06:37,540 and then you'll just glue the code together 147 00:06:37,540 --> 00:06:38,240 and make it work. 148 00:06:39,160 --> 00:06:41,300 Now, another, you know, 149 00:06:41,300 --> 00:06:43,420 drawback to this is putting these 150 00:06:43,420 --> 00:06:45,440 pieces together gets to be a little bit 151 00:06:45,440 --> 00:06:47,420 tedious as you're rewriting code or updating code 152 00:06:47,420 --> 00:06:48,660 or merging code. 153 00:06:49,360 --> 00:06:50,860 It's all super frustrating. 154 00:06:51,860 --> 00:06:53,460 A bigger element 155 00:06:53,460 --> 00:06:55,120 of this is when you start looking at more 156 00:06:55,120 --> 00:06:57,160 complex ideas or more, 157 00:06:57,520 --> 00:06:59,380 complex architectures, say like 158 00:06:59,380 --> 00:07:01,360 a distributed system. Distributed systems 159 00:07:01,360 --> 00:07:03,240 aren't something that people encounter on 160 00:07:03,240 --> 00:07:05,500 a day-to-day basis. So, if you 161 00:07:05,500 --> 00:07:07,140 start looking at, okay, I want to make 162 00:07:07,140 --> 00:07:09,280 tool X and tool Y talk to each other, 163 00:07:09,400 --> 00:07:11,400 how do I do that? You know, I need to 164 00:07:11,400 --> 00:07:13,320 do it so that it's 165 00:07:14,120 --> 00:07:15,380 atomic so that, you know, 166 00:07:15,380 --> 00:07:16,780 any changes made don't 167 00:07:17,300 --> 00:07:19,480 tromp over, you know, changes 168 00:07:19,480 --> 00:07:21,380 made by a previous iteration. You need to 169 00:07:21,380 --> 00:07:22,000 make it so that 170 00:07:23,060 --> 00:07:25,360 the communication makes sense between the two. So you 171 00:07:25,360 --> 00:07:26,800 got to kind of take up, 172 00:07:27,520 --> 00:07:29,480 what you're trying to do and build a prototype so you 173 00:07:29,480 --> 00:07:31,360 can understand, you know, how the two are going to actually 174 00:07:31,360 --> 00:07:33,540 interact. So, this kind of goes back to 175 00:07:33,540 --> 00:07:35,340 Fred Brooks from the Mythical Man Month 176 00:07:35,340 --> 00:07:37,500 where you just prototype so you build 177 00:07:37,500 --> 00:07:39,420 one to throw it away. So, 178 00:07:41,040 --> 00:07:41,660 we tend 179 00:07:41,660 --> 00:07:43,560 to lean towards a more iterative process. 180 00:07:43,780 --> 00:07:45,480 So, you know, we write a basic tool, 181 00:07:45,640 --> 00:07:47,520 we get an idea of, like, what went wrong, 182 00:07:47,560 --> 00:07:49,520 what went right, we take it and we iterate 183 00:07:49,520 --> 00:07:51,660 and we create a new 184 00:07:53,140 --> 00:07:53,540 tool 185 00:07:53,540 --> 00:07:55,460 based off of it, or we create a new iteration, 186 00:07:55,660 --> 00:07:57,500 add more functionality or features based off of it. 187 00:07:57,500 --> 00:07:59,680 The idea is just to model it 188 00:07:59,680 --> 00:08:01,500 once or twice, get a good 189 00:08:01,500 --> 00:08:03,560 understanding or a grasp of what's going to happen 190 00:08:04,040 --> 00:08:05,600 and then start working on 191 00:08:05,600 --> 00:08:07,660 what might be a final product. The idea 192 00:08:07,660 --> 00:08:09,620 is you're never going to come up with the perfect solution 193 00:08:09,620 --> 00:08:11,520 the first time, and the more time you spend 194 00:08:11,520 --> 00:08:13,820 thinking about what you're going to do, you're just going to burn yourself out 195 00:08:13,820 --> 00:08:15,500 wasting time trying to figure out what's 196 00:08:15,500 --> 00:08:17,160 the right way to do things. 197 00:08:18,020 --> 00:08:19,400 So, generally, the third implementation 198 00:08:19,400 --> 00:08:21,780 is considered to be the best. In the case 199 00:08:21,780 --> 00:08:23,700 of IdaBridge, it took me three times to actually 200 00:08:24,060 --> 00:08:25,720 get a working command line interface 201 00:08:25,720 --> 00:08:26,260 to 202 00:08:26,260 --> 00:08:26,580 do it. 203 00:08:27,580 --> 00:08:28,180 That would 204 00:08:28,180 --> 00:08:30,280 interact with not only IdaBridge 205 00:08:30,280 --> 00:08:32,160 but also interact with any other 206 00:08:32,160 --> 00:08:33,640 tools that we would want to connect up to it. 207 00:08:34,140 --> 00:08:36,160 So, all that being 208 00:08:36,160 --> 00:08:38,140 said, most of this development depends 209 00:08:38,140 --> 00:08:38,820 on the project. 210 00:08:40,380 --> 00:08:42,140 That being said, there's 211 00:08:42,140 --> 00:08:43,000 a lot of common challenges. 212 00:08:44,400 --> 00:08:46,300 So, one of the first things you need to do 213 00:08:46,300 --> 00:08:47,800 when you're speccing these projects is identify 214 00:08:47,800 --> 00:08:49,380 exactly what needs to happen. 215 00:08:50,380 --> 00:08:52,000 I don't think people tend to have 216 00:08:52,000 --> 00:08:54,220 these immediate great ideas that just come to them. 217 00:08:54,280 --> 00:08:55,980 I think that more often it's a problem 218 00:08:55,980 --> 00:08:57,220 that you face from a particular 219 00:08:57,500 --> 00:08:58,660 big, from a particular challenge. 220 00:08:59,280 --> 00:09:00,780 So, you need to identify what you need to do. 221 00:09:01,480 --> 00:09:02,940 From there, you need to make your milestones. 222 00:09:03,520 --> 00:09:05,780 This seems a little bit formal for project 223 00:09:05,780 --> 00:09:07,420 development type stuff, but if you're working alone 224 00:09:07,420 --> 00:09:09,480 or you're on a project, maybe you've decided, 225 00:09:09,620 --> 00:09:11,640 hey, I could do this thing manually, or I could 226 00:09:11,640 --> 00:09:12,580 write some code for it. 227 00:09:12,660 --> 00:09:14,020 You've got to sort of set your guidelines of, 228 00:09:14,080 --> 00:09:15,840 if I can't actually get my code to work, 229 00:09:15,980 --> 00:09:18,160 when do I need to call stop and push this off 230 00:09:18,160 --> 00:09:18,720 to something later? 231 00:09:19,180 --> 00:09:21,160 So, milestones are key for that reason. 232 00:09:21,660 --> 00:09:23,760 Additionally, if this is a personal project 233 00:09:23,760 --> 00:09:25,160 that's going to take some more time, you need to 234 00:09:25,160 --> 00:09:27,480 be able to set these milestones so that you know you're getting there. 235 00:09:27,480 --> 00:09:29,920 So, you can work with people, and so it doesn't just 236 00:09:29,920 --> 00:09:31,540 fall away as you have more needs to come up. 237 00:09:32,920 --> 00:09:34,060 Don't try to write more code. 238 00:09:34,200 --> 00:09:35,880 Lots of people are like, oh, I packed out 239 00:09:35,880 --> 00:09:37,460 this many lines of code, this many things. 240 00:09:37,640 --> 00:09:39,580 Just focus on getting things done. 241 00:09:40,760 --> 00:09:42,100 To do this, you're going to use different 242 00:09:42,100 --> 00:09:43,420 libraries, different code bases. 243 00:09:43,860 --> 00:09:44,940 You're going to be reading through documentation. 244 00:09:45,360 --> 00:09:47,160 Basically, don't reinvent the wheel every time. 245 00:09:49,580 --> 00:09:51,980 And so, we also have debugging interactions. 246 00:09:53,340 --> 00:09:55,300 So, when you write code for the very first time, 247 00:09:55,380 --> 00:09:56,620 you don't really know if it's going to work. 248 00:09:56,620 --> 00:09:57,680 You have this general concept. 249 00:09:57,900 --> 00:09:59,340 You compile and run it, and it's like, 250 00:10:00,060 --> 00:10:00,760 there's a bug. 251 00:10:00,940 --> 00:10:03,620 A pointer bug, or maybe you didn't initialize something. 252 00:10:04,120 --> 00:10:07,020 So, having a good environment and interacting with 253 00:10:07,020 --> 00:10:08,840 the data and the functions that you're actually 254 00:10:08,840 --> 00:10:12,140 putting into the development process 255 00:10:12,140 --> 00:10:14,440 is actually one of those key things that 256 00:10:14,440 --> 00:10:16,500 people should really look at and evaluate 257 00:10:16,500 --> 00:10:17,260 as they're doing things. 258 00:10:18,700 --> 00:10:20,820 So, going back to what we've just said, 259 00:10:20,980 --> 00:10:22,760 there are some ways to address some of these challenges. 260 00:10:23,080 --> 00:10:26,080 So, for instance, open source is a great 261 00:10:26,080 --> 00:10:28,540 source for figuring out how to do certain things, 262 00:10:28,700 --> 00:10:37,240 figuring out how to perhaps make a client talk to a server. 263 00:10:37,500 --> 00:10:40,480 So, instead of going back and rewriting the entire 264 00:10:40,480 --> 00:10:42,200 protocol, you just go and repurpose some code 265 00:10:42,200 --> 00:10:43,680 from another person's project. 266 00:10:45,380 --> 00:10:47,520 That being said, you can go through and review the code 267 00:10:47,520 --> 00:10:50,080 and figure out what is usable and what is not. 268 00:10:50,200 --> 00:10:52,460 And then just strip out what you need and get rid of the rest. 269 00:10:53,560 --> 00:10:55,960 So, in that case, you know, the existing 270 00:10:56,080 --> 00:10:57,180 code base is always fantastic. 271 00:10:57,740 --> 00:10:59,700 And this really, really helps out when you're 272 00:10:59,700 --> 00:11:01,320 starting to think about developing complex 273 00:11:01,320 --> 00:11:03,200 components and complex projects. 274 00:11:03,600 --> 00:11:05,620 For instance, if you want to build a DNS 275 00:11:05,620 --> 00:11:07,200 mapping tool, you don't go through and implement 276 00:11:07,200 --> 00:11:10,020 the entire DNS protocol. It's quite tedious. 277 00:11:10,160 --> 00:11:12,560 So, what you do is you go download Bind's 278 00:11:12,560 --> 00:11:14,640 implementation, you strip out their stuff, 279 00:11:14,800 --> 00:11:16,280 and you just take their protocol and you 280 00:11:16,280 --> 00:11:17,680 implement that into your project. 281 00:11:18,300 --> 00:11:20,740 Same thing with building something like a fuzzer. 282 00:11:23,400 --> 00:11:25,300 So, here are some of the tools of the trade. 283 00:11:25,300 --> 00:11:29,860 In general, we try to use Python, but we want to say 284 00:11:29,860 --> 00:11:32,120 that using high-level languages abstracts a lot of 285 00:11:32,120 --> 00:11:33,880 the complexities away from what you're trying to do. 286 00:11:34,040 --> 00:11:35,360 You know, dealing with pointer arithmetic, 287 00:11:35,580 --> 00:11:36,840 dealing with complex structures. 288 00:11:37,060 --> 00:11:39,220 A lot of this stuff can be modeled very quickly 289 00:11:39,220 --> 00:11:42,040 in Python or Ruby if that's your particular flavor. 290 00:11:42,860 --> 00:11:45,580 And that being said, I've talked about using 291 00:11:45,580 --> 00:11:48,600 debugging arguments or debugging environments to help 292 00:11:48,600 --> 00:11:51,140 with, you know, data interaction or rapid prototyping 293 00:11:51,140 --> 00:11:54,040 to enable you to change the functions and, you know, 294 00:11:54,040 --> 00:11:54,540 build quickly. 295 00:11:54,540 --> 00:11:56,380 Or make sure everything works quickly. 296 00:11:57,240 --> 00:12:00,120 IPython or IRB are perfect environments for this. 297 00:12:00,280 --> 00:12:02,080 IPython I use on a regular basis. 298 00:12:03,100 --> 00:12:05,760 IDEs and debuggers are also a good source if you're 299 00:12:05,760 --> 00:12:09,240 working in a structured development project. 300 00:12:10,200 --> 00:12:12,580 Some other stuff, some other things that I've used 301 00:12:12,580 --> 00:12:14,080 in the past and that we've used in the past are 302 00:12:14,080 --> 00:12:15,720 network sniffer such as Wireshark and Mallory. 303 00:12:15,840 --> 00:12:18,280 And this just gives us an opportunity to change 304 00:12:18,280 --> 00:12:21,840 stuff around, flip bits, figure out if we're really 305 00:12:21,840 --> 00:12:24,520 parsing a protocol correctly or, you know, 306 00:12:24,540 --> 00:12:26,780 making sure that the messages that we're forming 307 00:12:26,780 --> 00:12:27,780 actually go out correctly. 308 00:12:30,560 --> 00:12:32,100 So some tools of the trade. 309 00:12:32,740 --> 00:12:34,940 One is make sure you look at the API documentation. 310 00:12:35,480 --> 00:12:36,640 Sometimes it's a bit tedious. 311 00:12:36,760 --> 00:12:38,360 You know, if you're looking to do some assembly or some 312 00:12:38,360 --> 00:12:41,460 stuff there, don't read the whole Intel assembly 313 00:12:41,460 --> 00:12:43,220 architecture, you know, it's like 15 pounds. 314 00:12:43,540 --> 00:12:45,700 But if there's some quick stuff, go to MSDN, 315 00:12:45,760 --> 00:12:47,960 figure out, you know, what to do rather than reversing 316 00:12:47,960 --> 00:12:49,340 a whole Microsoft library. 317 00:12:49,680 --> 00:12:51,600 You know, just go to the documentation, figure it out. 318 00:12:51,620 --> 00:12:52,320 Use what works. 319 00:12:52,780 --> 00:12:53,980 Look for books and papers. 320 00:12:54,140 --> 00:12:54,520 This is something that I've been working on. 321 00:12:54,540 --> 00:12:55,760 This is along the same lines. 322 00:12:55,920 --> 00:12:57,460 You know, make things easy for yourself. 323 00:12:57,520 --> 00:12:58,420 Find out what works. 324 00:12:58,760 --> 00:13:01,180 Don't, you know, push out resources because you only 325 00:13:01,180 --> 00:13:04,080 reverse or you only do things by the API. 326 00:13:05,360 --> 00:13:08,140 And, again, build off of other source code that already 327 00:13:08,140 --> 00:13:08,480 exists. 328 00:13:10,100 --> 00:13:12,920 Real code usages are nice because it shows you, oh, 329 00:13:13,000 --> 00:13:13,820 this actually works. 330 00:13:16,200 --> 00:13:16,640 Experiment. 331 00:13:17,140 --> 00:13:20,840 So the big thing is, the big emphasis is find as many 332 00:13:20,840 --> 00:13:21,860 shortcuts as you can. 333 00:13:21,960 --> 00:13:24,040 And, you know, generally this goes back to using open source 334 00:13:24,040 --> 00:13:24,160 software. 335 00:13:25,100 --> 00:13:28,120 But, you know, ideally what it could come down to is, you 336 00:13:28,120 --> 00:13:30,500 know, maybe you just, instead of opting to do something in 337 00:13:30,500 --> 00:13:34,340 CC++ or Java, you just go straight to Python or Ruby and 338 00:13:34,340 --> 00:13:36,140 then you find out what you really need to implement in 339 00:13:36,140 --> 00:13:37,420 those more complex languages. 340 00:13:38,480 --> 00:13:42,200 So in this first case, what we're going to talk about is 341 00:13:42,200 --> 00:13:46,040 how I went through and identified and decrypted one 342 00:13:46,040 --> 00:13:50,500 of the keys out of a client's Windows registry. 343 00:13:50,620 --> 00:13:53,280 So basically what it came down to is I managed to break into 344 00:13:53,280 --> 00:13:55,420 this host on a paid gig, so it wasn't illegal. 345 00:13:56,840 --> 00:14:00,300 And I noticed that in the registry I found some keys that 346 00:14:00,300 --> 00:14:02,480 had password associated with them. 347 00:14:02,720 --> 00:14:05,020 When I went back and looked, it actually corresponded to the 348 00:14:05,020 --> 00:14:07,120 WinSCP application. 349 00:14:07,640 --> 00:14:10,980 So rather than, you know, trying to reinvent the wheel, 350 00:14:11,500 --> 00:14:15,120 well, first of all, I thought, well, I want to get at that. 351 00:14:15,200 --> 00:14:17,960 I know those passwords have to be reversible because they're 352 00:14:17,960 --> 00:14:19,940 passed on to the client at some point. 353 00:14:21,020 --> 00:14:22,220 So it was like, how do I do this? 354 00:14:22,220 --> 00:14:24,820 I could do something really complex like attach a debugger 355 00:14:24,820 --> 00:14:27,040 or I could do something really quick like download the source 356 00:14:27,040 --> 00:14:27,740 code and review it. 357 00:14:27,940 --> 00:14:33,060 So what I did is I downloaded the WinSCP stuff and found that 358 00:14:33,060 --> 00:14:36,120 there were some pretty nifty APIs that do the encryption and 359 00:14:36,120 --> 00:14:36,480 decryption. 360 00:14:36,720 --> 00:14:40,040 Now, for anyone that's curious, if you've ever installed 361 00:14:40,040 --> 00:14:43,780 WinSCP, your passwords are actually saved in an encoded 362 00:14:43,780 --> 00:14:46,000 format under sessions. 363 00:14:46,540 --> 00:14:49,940 And then, you know, somebody like me can actually come back 364 00:14:49,940 --> 00:14:52,200 and steal them and decrypt them and get access to them. 365 00:14:52,220 --> 00:14:52,960 You can get access to whatever you have. 366 00:14:53,180 --> 00:14:56,520 So the way I found it is I basically grep for encrypt and 367 00:14:56,520 --> 00:14:59,880 then I grep for password and, you know, these few things popped 368 00:14:59,880 --> 00:15:00,180 up. 369 00:15:00,360 --> 00:15:04,680 So, you know, starting off with the process, I found these API 370 00:15:04,680 --> 00:15:07,540 calls and then I went even further and I found the function 371 00:15:07,540 --> 00:15:12,220 definitions and I noticed that this is just encrypting by an 372 00:15:12,220 --> 00:15:13,720 XOR and then hexifying it. 373 00:15:13,840 --> 00:15:17,100 So I wrote a quick Python script to decrypt it. 374 00:15:19,260 --> 00:15:22,200 So, you know, this is just basically showing how I can 375 00:15:22,220 --> 00:15:22,420 decrypt. 376 00:15:22,420 --> 00:15:23,000 So I took it in. 377 00:15:23,120 --> 00:15:26,460 So the first thing I did is I popped up IPython, import Benasky, 378 00:15:26,560 --> 00:15:29,160 unhexify it, and now I have the data to work with. 379 00:15:29,700 --> 00:15:32,820 So the next thing I do is I go through and I write the 380 00:15:32,820 --> 00:15:33,880 decryption implementation. 381 00:15:34,660 --> 00:15:38,000 Unfortunately, in this particular case, I made a mistake because 382 00:15:38,000 --> 00:15:41,720 the output isn't anything legible or anything that I can really use. 383 00:15:41,800 --> 00:15:44,760 So I went back and I reviewed and I noticed, hey, I left a little 384 00:15:44,760 --> 00:15:46,320 tilde off for the unary stuff. 385 00:15:46,640 --> 00:15:51,940 So by implementing this stuff or implementing this in IPython or by 386 00:15:52,220 --> 00:15:55,060 prototyping this in IPython, I was able to quickly get something 387 00:15:55,060 --> 00:15:58,740 back without having to write a script, run a script, and having a 388 00:15:58,740 --> 00:15:59,600 noninteractive environment. 389 00:16:01,800 --> 00:16:06,140 So, you know, the whole premise was being able to write out a 390 00:16:06,140 --> 00:16:11,540 quick script, debug the code very quickly, modify the functions as 391 00:16:11,540 --> 00:16:14,800 needed, and then move on to the next kill. 392 00:16:15,080 --> 00:16:17,640 So IPython was one of those interactive environments that 393 00:16:17,640 --> 00:16:18,380 helped give me this edge. 394 00:16:19,960 --> 00:16:21,960 So moving on to our second case study. 395 00:16:22,420 --> 00:16:24,320 This goes back to when I was a pen tester again. 396 00:16:24,820 --> 00:16:28,160 One of the things I find a lot is that you'll get a tough engagement. 397 00:16:28,380 --> 00:16:29,640 They've already patched everything before. 398 00:16:29,760 --> 00:16:31,460 It's the one time of the year that they manage the patches right 399 00:16:31,460 --> 00:16:32,620 before the pen testers come in. 400 00:16:32,920 --> 00:16:33,800 They set ground rules. 401 00:16:33,920 --> 00:16:34,940 You can't bring in any zero days. 402 00:16:35,120 --> 00:16:36,940 And they make things basically impossible. 403 00:16:37,380 --> 00:16:40,480 So what I like to do is when you get in-house, look for some custom 404 00:16:40,480 --> 00:16:44,040 software, either something they wrote in-house or something that they 405 00:16:44,040 --> 00:16:46,220 brought from a small vendor that caters to their particular industry. 406 00:16:47,540 --> 00:16:51,000 And then I try to reverse that and find an exploit for it in a short 407 00:16:51,000 --> 00:16:51,500 amount of time. 408 00:16:52,220 --> 00:16:54,280 So for small applications, this is pretty easy to do. 409 00:16:54,420 --> 00:16:57,100 I tend to like to focus on things that load in the browser. 410 00:16:57,600 --> 00:17:00,720 But you have some problems that the modules are loaded as they're needed. 411 00:17:00,940 --> 00:17:02,360 You can run through hundreds of iterations. 412 00:17:02,760 --> 00:17:05,600 And if you're trying to do a full trace on this or if you're trying to 413 00:17:06,160 --> 00:17:08,740 manually debug it, you're just going to spend far, far too much time. 414 00:17:08,960 --> 00:17:11,880 So I created some add-ons to community debug. 415 00:17:12,160 --> 00:17:13,140 It's a nice interface. 416 00:17:13,340 --> 00:17:17,340 It's basically Oli debug with Python built in and a nice API. 417 00:17:18,460 --> 00:17:22,200 So basically, again, it's three quick scripts to do some lazy work. 418 00:17:22,200 --> 00:17:22,700 It's called lazy man tracing. 419 00:17:23,220 --> 00:17:26,400 If you were lucky enough and you had Ben Navi, you might not need to do 420 00:17:26,400 --> 00:17:28,160 this, but you don't always have that. 421 00:17:28,880 --> 00:17:31,420 So basically what happened is I identified the vulnerable code. 422 00:17:31,580 --> 00:17:33,880 I knew what was happening because you had the crash there. 423 00:17:34,340 --> 00:17:37,820 And I wanted to develop some scripts that would sort of get me there so I 424 00:17:37,820 --> 00:17:39,940 could figure out exactly where the taint happened and work my way 425 00:17:39,940 --> 00:17:40,320 backwards. 426 00:17:41,500 --> 00:17:44,740 Now, the initial thing was I could use load DLL hook, which is an API 427 00:17:44,740 --> 00:17:46,520 that's made available by Immunity Debugger. 428 00:17:46,800 --> 00:17:48,080 But basically it didn't work. 429 00:17:48,240 --> 00:17:49,520 I had to use BP hook. 430 00:17:49,520 --> 00:17:52,180 I spent hours and hours trying to make this work. 431 00:17:52,580 --> 00:17:54,720 Eventually the easiest way was just to go back and talk to Immunity. 432 00:17:55,100 --> 00:17:57,740 Maybe they fixed it by now, but, you know, as of a year or so ago, 433 00:17:57,800 --> 00:17:58,820 it was still broken. 434 00:17:59,900 --> 00:18:01,540 So here are two examples of the scripts. 435 00:18:01,860 --> 00:18:06,320 On the left-hand side, it's just a script that's loaded in Immunity. 436 00:18:06,380 --> 00:18:08,100 It looks for all the modules loaded. 437 00:18:08,300 --> 00:18:12,520 And once it's there, it sort of stalks and sets a breakpoint for the 438 00:18:12,520 --> 00:18:13,140 particular module. 439 00:18:14,020 --> 00:18:15,540 The way it does it is on the right. 440 00:18:16,260 --> 00:18:17,940 Basically it finds a load library. 441 00:18:17,940 --> 00:18:20,020 Load library A and load library W. 442 00:18:21,260 --> 00:18:22,520 You might have the Y bytes. 443 00:18:23,760 --> 00:18:26,300 And just puts a hook on those functions. 444 00:18:26,540 --> 00:18:29,320 So any time the module is loaded or unloaded in there, it basically 445 00:18:29,320 --> 00:18:31,160 says, okay, I'm going to set a breakpoint. 446 00:18:31,320 --> 00:18:34,360 And then you can use that inside the scripting to do your automated 447 00:18:34,360 --> 00:18:34,820 type stuff. 448 00:18:35,180 --> 00:18:38,280 So in this particular example, it was inside a browser. 449 00:18:38,340 --> 00:18:39,760 It was a custom plug-in that they were using. 450 00:18:39,900 --> 00:18:42,420 And it was loaded hundreds of times for each page that was there. 451 00:18:42,500 --> 00:18:46,780 So if you were doing this manually or if you set Immunity Debugger to 452 00:18:47,640 --> 00:18:50,580 break on each module unloading, you'd just spend hours and hours. 453 00:18:50,800 --> 00:18:52,100 So this way you did it in code. 454 00:18:52,580 --> 00:18:53,500 It was much quicker. 455 00:18:55,020 --> 00:18:58,520 Here's a bit more in-depth of the class that you have to overload to be 456 00:18:58,520 --> 00:18:59,020 able to do that. 457 00:18:59,880 --> 00:19:03,840 Basically it's just using a variable to set a count to how many times you're 458 00:19:03,840 --> 00:19:04,680 going to wait and let this load. 459 00:19:04,780 --> 00:19:07,100 So it's going to have hundreds of objects on a page. 460 00:19:07,160 --> 00:19:08,720 You know that it's not in the first 50. 461 00:19:08,840 --> 00:19:09,500 You iterate through. 462 00:19:09,620 --> 00:19:10,420 It's not in the first 100. 463 00:19:11,100 --> 00:19:12,660 So you keep upping that count. 464 00:19:12,820 --> 00:19:14,320 And eventually you let it load and let it run. 465 00:19:14,580 --> 00:19:16,320 And let's say on the 205th time. 466 00:19:16,320 --> 00:19:17,600 This is the one you care about. 467 00:19:17,860 --> 00:19:19,440 You're there at the break point. 468 00:19:19,560 --> 00:19:21,260 You haven't spent hours and hours doing this stuff. 469 00:19:21,480 --> 00:19:24,540 And you can start debugging backwards by maybe doing a small trace there 470 00:19:24,540 --> 00:19:26,000 forward or manually reversing it. 471 00:19:27,320 --> 00:19:28,720 And here are two more examples. 472 00:19:28,960 --> 00:19:33,200 So if you're still lazy and you want to do this all automated, maybe you 473 00:19:33,200 --> 00:19:36,460 want to let it run, many, many times you want to get a lot of variables 474 00:19:36,460 --> 00:19:37,000 and information. 475 00:19:37,220 --> 00:19:40,520 So on the left it's just dumping the register values. 476 00:19:40,760 --> 00:19:42,780 On the right it's just doing the call stack trace. 477 00:19:43,900 --> 00:19:46,300 So basically it's just doing light tracing. 478 00:19:46,320 --> 00:19:47,480 You know where the problem happens. 479 00:19:47,720 --> 00:19:50,520 You get the debugger to iterate through those hundreds of steps. 480 00:19:50,760 --> 00:19:53,760 And then you get it to dump the information you care about at the last 481 00:19:53,760 --> 00:19:54,040 minute. 482 00:19:54,280 --> 00:19:57,160 That way you don't spend all your time there because, you know, you have 483 00:19:57,160 --> 00:19:58,400 other hosts to deal with. 484 00:19:58,460 --> 00:20:00,100 You have other things to break into. 485 00:20:00,440 --> 00:20:04,300 And basically what this enabled me to do was to fastly, to quickly reverse 486 00:20:04,300 --> 00:20:08,820 and find the taint and some small stack overflow that was used in a browser 487 00:20:08,820 --> 00:20:09,980 that seemed like this really cool thing. 488 00:20:10,180 --> 00:20:13,600 So within a week I was able to find a problem and exploit it and, you know, 489 00:20:13,600 --> 00:20:16,060 gain further access in the systems based on a couple scripts. 490 00:20:17,140 --> 00:20:21,200 So the next case we're going to talk about is IDA Pro scripting. 491 00:20:22,400 --> 00:20:26,800 In this particular case, IDA Pro offers you IDA Python, which is a Python 492 00:20:26,800 --> 00:20:28,520 environment that you get to run Python code in. 493 00:20:28,660 --> 00:20:32,480 You can't prototype outside of it, so you have to do it in a very piecewise fashion. 494 00:20:33,740 --> 00:20:36,280 And that kind of hinders the debugging process. 495 00:20:36,420 --> 00:20:40,340 And it's also not very straightforward about how to get around. 496 00:20:40,540 --> 00:20:44,580 So the trick is, you know, writing small little scriptlets so that you can get 497 00:20:44,580 --> 00:20:46,300 to the point where you're actually doing something interesting. 498 00:20:46,320 --> 00:20:51,820 So this basic example actually comes from an ELF header parser I had to do 499 00:20:51,820 --> 00:20:56,180 in order to update the relocatables and the ELF header that I was looking at 500 00:20:56,180 --> 00:20:56,740 for an ARM binary. 501 00:20:57,260 --> 00:20:59,700 So basically, as I said, I had to do it piece by piece. 502 00:21:00,100 --> 00:21:07,720 One of the big things about IDA Pro is when you're running or one of the crazy 503 00:21:07,720 --> 00:21:14,740 things about IDA Pro or the more unforgiving things is if you run an IDA 504 00:21:14,740 --> 00:21:14,920 Python. 505 00:21:15,500 --> 00:21:20,300 IDA Python script and you start stomping around your IDB, there's no control C. 506 00:21:20,380 --> 00:21:21,660 There's no going backwards. 507 00:21:21,920 --> 00:21:23,020 So there's no real undo. 508 00:21:23,140 --> 00:21:26,280 So you want to make sure what you're doing is effective. 509 00:21:27,080 --> 00:21:32,100 At least in the first or two iterations with, you know, small, small function calls or 510 00:21:32,100 --> 00:21:32,260 whatever. 511 00:21:32,440 --> 00:21:37,640 So in this particular case, I wrote this basic function that would parse out the E header 512 00:21:37,640 --> 00:21:40,160 and give me a nice clean looking ELF header. 513 00:21:41,080 --> 00:21:44,580 Unfortunately, when I did this, I had a bug in it and I wouldn't have caught it. 514 00:21:45,140 --> 00:21:49,980 And it could have resulted in a more potentially disastrous outcome where I would have to 515 00:21:49,980 --> 00:21:51,600 revert back to my original IDB. 516 00:21:51,900 --> 00:21:55,040 And if I hadn't backed it up, that means I have to start all over after I've marked 517 00:21:55,040 --> 00:21:55,440 stuff up. 518 00:21:55,960 --> 00:22:00,300 So in this case, I kind of illustrate that, you know, file start wasn't initialized in 519 00:22:00,300 --> 00:22:01,580 this particular function that I'm calling. 520 00:22:02,140 --> 00:22:03,360 And so it could have been anything. 521 00:22:03,500 --> 00:22:05,000 So it could have been in the middle of the IDB. 522 00:22:05,300 --> 00:22:09,640 And so if that was the case, then I would have just stomped out any code or comments 523 00:22:09,640 --> 00:22:10,380 that I would have put in there. 524 00:22:11,440 --> 00:22:14,300 So as I said, there's no control C. 525 00:22:14,300 --> 00:22:15,180 So there's no going back. 526 00:22:15,360 --> 00:22:19,280 So the whole idea is to implement your code in small segments and then do it iteratively 527 00:22:19,280 --> 00:22:20,840 as you work through the process. 528 00:22:21,580 --> 00:22:25,260 So after I fix a small little bug, I was able to get an ELF header. 529 00:22:25,540 --> 00:22:25,940 Surprise. 530 00:22:26,280 --> 00:22:26,680 Yay. 531 00:22:27,060 --> 00:22:30,720 So the next case that we're going to talk about is code writing code. 532 00:22:30,960 --> 00:22:35,700 This is one of the things I don't see emphasized enough when people are doing software development. 533 00:22:36,020 --> 00:22:42,280 So the idea is to write little scripts that write C code or write Python code for you. 534 00:22:42,280 --> 00:22:47,560 What this generally entails is you write a whole bunch of definitions for commands or messages 535 00:22:47,560 --> 00:22:51,780 or you want to script it in some way so that you don't have to write all of the commands 536 00:22:51,780 --> 00:22:53,020 or messages for like a string. 537 00:22:53,840 --> 00:22:56,940 The best way to do it is write a script that's going to do it for you. 538 00:22:57,000 --> 00:22:59,880 That helps speed up the development process and you don't have to spend all that time, 539 00:23:00,500 --> 00:23:04,060 you know, going through typing it in and possibly making typos. 540 00:23:04,240 --> 00:23:07,580 Additionally, you can actually reuse the script later on if you decide that you want to make some changes. 541 00:23:08,460 --> 00:23:12,260 So in this particular case, I had all these definitions that I wanted to write. 542 00:23:12,280 --> 00:23:17,200 First of all, export to Python and then second of all, make string definitions. 543 00:23:17,460 --> 00:23:21,280 So this is actually kind of a lot of stuff to do for one person. 544 00:23:21,840 --> 00:23:24,420 It kind of drives me nuts when I have to go back and do stuff like this 545 00:23:24,420 --> 00:23:28,100 because I'd rather do stuff like solve a problem, not do data entry. 546 00:23:28,600 --> 00:23:31,220 So in this particular case, I used IPython again. 547 00:23:32,540 --> 00:23:37,740 I basically busted out all the lines and then I went through each definition 548 00:23:37,740 --> 00:23:40,120 and I saw if it had an underscore or not. 549 00:23:40,320 --> 00:23:42,260 And if it had an underscore, I put an S in front of it. 550 00:23:42,280 --> 00:23:46,500 And then from there, I get this nice little output where I get the pound F, 551 00:23:46,680 --> 00:23:52,220 the string underscore BP hit and then I get a string that represents that command 552 00:23:52,220 --> 00:23:53,500 in a lowercase fashion. 553 00:23:54,080 --> 00:23:56,840 Now, doing all the data entry for me is kind of boring. 554 00:23:57,240 --> 00:24:00,020 Some people might like to do it because that's what they do. 555 00:24:00,140 --> 00:24:04,000 But I figured this would be really interesting or not really interesting but really useful 556 00:24:04,000 --> 00:24:07,100 because I don't want to have to do this ever again. 557 00:24:07,380 --> 00:24:11,060 I just want to be able to plug something in, run it, check it over real quick, 558 00:24:11,120 --> 00:24:12,260 and then plop it into my source code. 559 00:24:12,280 --> 00:24:17,660 Additionally, with doing stuff in Python or exploring the Python. 560 00:24:17,800 --> 00:24:21,900 In Python, I realized that I wanted to change the case convention of everything I was 561 00:24:21,900 --> 00:24:26,540 and use a more standard development convention so that if I ever gave this code to anybody, 562 00:24:26,680 --> 00:24:27,820 they would understand what's going on. 563 00:24:28,080 --> 00:24:32,480 So I basically went through and I lowercased everything and put it into 564 00:24:32,480 --> 00:24:36,480 or I just modified it, did a quick update without actually having to go through 565 00:24:36,480 --> 00:24:37,940 and correct the case for everything. 566 00:24:39,220 --> 00:24:42,260 So the final case is more difficult. 567 00:24:42,260 --> 00:24:45,900 It's more to do with adding functionality to an external library. 568 00:24:46,180 --> 00:24:48,740 And this kind of goes back to the whole use open source model. 569 00:24:49,160 --> 00:24:52,620 So what happened was I needed to... 570 00:24:53,060 --> 00:24:55,360 Well, what I was trying to do is I was trying to model the communication... 571 00:24:55,360 --> 00:25:00,140 I was trying to get the communication to work between my debuggers and IDA Pro. 572 00:25:00,540 --> 00:25:02,840 The thing is I was doing all this in C++. 573 00:25:03,160 --> 00:25:06,640 Anyone who's developed in C++ or done C, C++ development 574 00:25:07,200 --> 00:25:10,040 realizes it gets really tedious and gets really difficult to implement stuff. 575 00:25:10,280 --> 00:25:11,480 I wanted to use Python. 576 00:25:12,480 --> 00:25:16,640 But in order to use IDA Python with my plug-in, 577 00:25:16,700 --> 00:25:18,280 I would have to use an external language call. 578 00:25:18,540 --> 00:25:20,260 And then once I do the external language call, 579 00:25:20,360 --> 00:25:23,380 I don't actually get the side effect of when I ran my command. 580 00:25:23,920 --> 00:25:27,260 So what I really wanted was I wanted to be able to load IDA Python 581 00:25:27,260 --> 00:25:32,220 with the IDA Python DLL or the module into my code 582 00:25:32,220 --> 00:25:33,860 so that I could actually make those functions calls. 583 00:25:34,700 --> 00:25:36,920 But IDA Python doesn't really allow this naturally. 584 00:25:37,040 --> 00:25:39,280 So I had to go through and add my own exports. 585 00:25:39,960 --> 00:25:41,660 And so by adding my own exports, 586 00:25:41,660 --> 00:25:43,620 I not only saved time up front 587 00:25:43,620 --> 00:25:46,440 because I was able to now use Python in my application, 588 00:25:46,960 --> 00:25:51,020 but I also saved time because I can use Python. 589 00:25:51,180 --> 00:25:52,100 I can prototype in Python. 590 00:25:52,320 --> 00:25:54,540 I can write 100 plus lines of code 591 00:25:54,540 --> 00:25:58,920 for every three or four lines of C++ code 592 00:25:58,920 --> 00:25:59,820 that I have to write in debug. 593 00:26:00,240 --> 00:26:02,140 Or that's an exaggeration. 594 00:26:02,380 --> 00:26:03,400 But you get the hope. 595 00:26:03,520 --> 00:26:06,140 Hopefully you get the point that using higher level languages 596 00:26:06,140 --> 00:26:08,520 is a lot easier than using lower level languages. 597 00:26:09,940 --> 00:26:11,320 So now all I have to do, 598 00:26:11,660 --> 00:26:13,680 is import the module into my code 599 00:26:13,680 --> 00:26:16,440 and call the function and life is great. 600 00:26:16,820 --> 00:26:17,600 Life is easy. 601 00:26:18,700 --> 00:26:19,080 Okay. 602 00:26:19,140 --> 00:26:22,220 So now we're going to actually talk about our eBridge. 603 00:26:22,320 --> 00:26:23,940 It was originally called IDA Bridge. 604 00:26:24,200 --> 00:26:25,440 The basic idea to start it, 605 00:26:25,480 --> 00:26:26,460 we have all of our debuggers. 606 00:26:26,480 --> 00:26:28,060 Everybody seems to use IDA. 607 00:26:28,160 --> 00:26:29,700 But you might prefer Immunity Debugger. 608 00:26:29,740 --> 00:26:30,940 You might prefer WinDebug. 609 00:26:31,120 --> 00:26:33,180 And you can't get things to talk. 610 00:26:33,300 --> 00:26:35,360 Sure, IDA has its own debuggers in it, 611 00:26:35,400 --> 00:26:37,040 but they're pretty terrible to use. 612 00:26:37,260 --> 00:26:38,880 At least I find them terrible to use. 613 00:26:38,980 --> 00:26:41,080 So you have your own debugger that you have all your scripts for. 614 00:26:42,480 --> 00:26:43,640 You're just used to doing it. 615 00:26:43,780 --> 00:26:46,300 And you just want to convert things back over to IDA sometimes. 616 00:26:47,360 --> 00:26:49,840 So basically you just want the tools to be able to talk to each other. 617 00:26:50,360 --> 00:26:51,620 So originally it was IDA Bridge. 618 00:26:51,760 --> 00:26:52,420 But then we thought, 619 00:26:52,600 --> 00:26:54,420 okay, well all these tools might want to talk to each other. 620 00:26:54,460 --> 00:26:56,480 A lot of the scripts we showed you before 621 00:26:56,840 --> 00:26:59,140 were, you know, sort of reversing type things. 622 00:26:59,820 --> 00:27:01,000 But it mainly stemmed around, 623 00:27:01,080 --> 00:27:02,040 they didn't talk to each other. 624 00:27:02,080 --> 00:27:04,060 You need to get information from one source to the other. 625 00:27:04,400 --> 00:27:06,600 And our eBridge is sort of hoping to do this. 626 00:27:07,140 --> 00:27:09,660 So it's trying to fill a very specific gap. 627 00:27:09,820 --> 00:27:11,000 It's basically middleware. 628 00:27:11,000 --> 00:27:12,600 It's nothing super exciting, 629 00:27:12,720 --> 00:27:14,160 but it lets your tools talk to each other. 630 00:27:14,260 --> 00:27:16,140 So if you have breakpoints set in IDA, 631 00:27:16,160 --> 00:27:17,980 you can push them over to WinDebug 632 00:27:17,980 --> 00:27:21,020 or you can move data back and forth between them. 633 00:27:21,100 --> 00:27:22,420 So it just makes things a little bit easier. 634 00:27:22,960 --> 00:27:24,040 So like Matt was saying, 635 00:27:24,900 --> 00:27:26,260 our eBridge is a middleware. 636 00:27:26,380 --> 00:27:28,580 It's not meant to be an implementation 637 00:27:28,580 --> 00:27:30,060 for another reverse engineering tool. 638 00:27:30,200 --> 00:27:32,520 It's not meant to do, you know, X, Y, and Z. 639 00:27:32,600 --> 00:27:34,440 It's meant to fill a gap, 640 00:27:34,520 --> 00:27:36,480 give you a server that sits between, 641 00:27:36,600 --> 00:27:38,360 or a server and a client that sits between 642 00:27:38,360 --> 00:27:40,660 your IDA Pro and your debugger 643 00:27:40,660 --> 00:27:42,460 or, you know, hopefully in the future, 644 00:27:42,520 --> 00:27:43,580 a debugger or a fuzzer. 645 00:27:43,800 --> 00:27:45,500 And then they can communicate with each other. 646 00:27:45,600 --> 00:27:46,500 They can send each other messages. 647 00:27:46,720 --> 00:27:47,920 And they all understand the messages. 648 00:27:48,240 --> 00:27:50,640 And so basically, no one's reinventing new tools. 649 00:27:50,880 --> 00:27:52,500 They're just reinventing a communication stack. 650 00:27:53,640 --> 00:27:54,680 So like we said, 651 00:27:54,820 --> 00:27:57,460 the whole idea is to make the tools interact with each other, 652 00:27:57,620 --> 00:28:00,060 give users the ability to control their tools 653 00:28:00,060 --> 00:28:01,320 from one tool or another, 654 00:28:01,500 --> 00:28:04,080 and then also build it out as a distributed framework. 655 00:28:04,200 --> 00:28:05,380 So that way you don't have to reverse 656 00:28:05,380 --> 00:28:06,700 from on the same machine. 657 00:28:06,820 --> 00:28:10,640 So if, say, I'm using IDA Pro on my Prime, 658 00:28:10,660 --> 00:28:11,740 on my Windows machine, 659 00:28:11,820 --> 00:28:13,460 and I'm reverse engineering a Linux machine, 660 00:28:13,620 --> 00:28:14,700 I don't have to use, 661 00:28:15,880 --> 00:28:17,460 I don't have to use VMware. 662 00:28:17,580 --> 00:28:19,720 I can just put it on a remote hardware somewhere 663 00:28:19,720 --> 00:28:21,440 and just make them talk across the network. 664 00:28:23,580 --> 00:28:24,720 And of course, 665 00:28:25,480 --> 00:28:27,460 IDA Pro does have the debugger functionality 666 00:28:27,460 --> 00:28:28,440 written into it, 667 00:28:28,520 --> 00:28:30,680 but if anyone's ever tried to use a debugger, 668 00:28:30,760 --> 00:28:32,120 it's very difficult to understand. 669 00:28:32,220 --> 00:28:34,300 It's difficult to use and get set up 670 00:28:34,300 --> 00:28:35,420 in the initial stages. 671 00:28:35,660 --> 00:28:37,360 So having something where you can just use 672 00:28:37,360 --> 00:28:38,940 a native debugger that you're always used to 673 00:28:38,940 --> 00:28:40,320 and not having to use, you know, 674 00:28:40,660 --> 00:28:41,860 somebody else's GUI or somebody else's, 675 00:28:42,660 --> 00:28:44,400 being constrained to somebody else's tool 676 00:28:44,400 --> 00:28:47,300 that you don't appreciate is a huge plus. 677 00:28:47,560 --> 00:28:48,860 And the additional thing that we want to do 678 00:28:48,860 --> 00:28:50,860 is we want to make this middleware extendable. 679 00:28:51,720 --> 00:28:54,040 We want to make the middleware extendable 680 00:28:54,040 --> 00:28:56,200 using stuff like Python or Ruby. 681 00:28:57,160 --> 00:28:58,460 So we have several components 682 00:28:58,460 --> 00:29:00,000 that we've built out so far. 683 00:29:00,140 --> 00:29:01,140 The first one is the IDA bridge. 684 00:29:01,480 --> 00:29:03,120 It's basically a command line interface 685 00:29:03,120 --> 00:29:06,080 that uses asynchronous server or networking client 686 00:29:06,080 --> 00:29:07,420 that we pulled from Collaborate. 687 00:29:07,580 --> 00:29:09,500 Again, we're emphasizing that you should use 688 00:29:09,500 --> 00:29:11,700 open-source tools or open-source software 689 00:29:11,700 --> 00:29:12,740 that's already implemented stuff 690 00:29:12,740 --> 00:29:16,140 to incorporate into your software. 691 00:29:16,860 --> 00:29:19,100 And then what we did is we modified the IDA Python lib 692 00:29:19,100 --> 00:29:20,440 so that way we don't have to go through 693 00:29:20,440 --> 00:29:21,940 and rewrite everything in C or C++ 694 00:29:22,440 --> 00:29:25,380 to do the actual interfacing with IDA Pro. 695 00:29:25,540 --> 00:29:26,960 We can just rely completely on Python. 696 00:29:27,620 --> 00:29:29,380 And that also gave us another one 697 00:29:29,380 --> 00:29:31,100 because we can extend our Python classes 698 00:29:31,100 --> 00:29:33,740 or we can extend our handler classes using Python. 699 00:29:33,900 --> 00:29:35,080 So if we want to add a new command, 700 00:29:35,240 --> 00:29:37,480 we just write a new Python class 701 00:29:37,480 --> 00:29:38,360 with the... 702 00:29:39,040 --> 00:29:40,400 defined command elements 703 00:29:40,400 --> 00:29:42,340 and then we just roll from there. 704 00:29:43,520 --> 00:29:45,120 So we also used... 705 00:29:45,120 --> 00:29:46,180 We also, for this implementation, 706 00:29:46,540 --> 00:29:49,680 incorporated Vtrace or VDB, 707 00:29:49,860 --> 00:29:53,660 which is a product of Conchetto and Avizagoth. 708 00:29:53,780 --> 00:29:55,460 So basically, for VDB, 709 00:29:55,580 --> 00:29:57,380 we added in asynchronous server 710 00:29:57,380 --> 00:29:58,600 into the command line. 711 00:29:58,740 --> 00:29:59,940 And again, we used Python 712 00:29:59,940 --> 00:30:03,700 to be able to extend the handlers as needed. 713 00:30:04,120 --> 00:30:06,400 And so anyone that's familiar with the framework 714 00:30:06,400 --> 00:30:08,100 or understands how to write the plugins 715 00:30:08,360 --> 00:30:09,700 can actually go through and write the plugins. 716 00:30:10,120 --> 00:30:12,240 And again, you can also do it to the point 717 00:30:12,240 --> 00:30:13,820 where you could just load it in 718 00:30:13,820 --> 00:30:15,220 using the Python interface. 719 00:30:16,660 --> 00:30:19,380 So that brings us to the bastard child of them all, 720 00:30:19,640 --> 00:30:19,960 WinDebug. 721 00:30:20,240 --> 00:30:22,320 So WinDebug, when I started working, 722 00:30:22,440 --> 00:30:24,720 didn't really have a Python interface 723 00:30:24,720 --> 00:30:27,100 that I could actually load in as a plugin. 724 00:30:27,540 --> 00:30:31,020 So currently, it's only implemented in C++. 725 00:30:31,320 --> 00:30:33,440 So it's incredibly difficult to add new... 726 00:30:33,440 --> 00:30:35,560 It's more difficult to add new commands 727 00:30:35,560 --> 00:30:38,120 and make everything work and talk... 728 00:30:38,120 --> 00:30:40,040 very quickly without having to go through 729 00:30:40,040 --> 00:30:41,460 recompile and testing all the time. 730 00:30:42,120 --> 00:30:43,920 But it does have the asynchronous server, 731 00:30:44,060 --> 00:30:46,340 which we also pulled from another open-source project 732 00:30:46,340 --> 00:30:49,000 by Edukin, by Lenox and Puscat. 733 00:30:50,560 --> 00:30:50,960 So... 734 00:30:54,080 --> 00:30:55,920 So basically, we got all this stuff going. 735 00:30:56,600 --> 00:30:57,840 It's still an iterative process, 736 00:30:58,100 --> 00:30:59,940 but we have a few lessons that we learned from it. 737 00:31:00,300 --> 00:31:01,520 Basically, as Adam said a lot, 738 00:31:01,720 --> 00:31:02,880 we like high-level languages. 739 00:31:03,060 --> 00:31:04,740 You know, I'm a native C programmer, 740 00:31:04,820 --> 00:31:06,900 but I appreciate that we're trying to get something done. 741 00:31:07,560 --> 00:31:09,480 Python or, you know, Ruby or something 742 00:31:09,480 --> 00:31:10,560 makes things a lot easier. 743 00:31:11,440 --> 00:31:12,940 Documentation is not always useful. 744 00:31:13,080 --> 00:31:14,020 Sometimes it can be, 745 00:31:14,100 --> 00:31:15,940 but make sure you find examples and source code 746 00:31:15,940 --> 00:31:17,780 and just ping people when things aren't working. 747 00:31:17,880 --> 00:31:20,020 Don't waste too much time, you know, 748 00:31:20,020 --> 00:31:21,420 believing that the documentation is right 749 00:31:21,420 --> 00:31:22,340 and that you're doing something wrong, 750 00:31:22,940 --> 00:31:24,280 because sometimes there's a gap. 751 00:31:25,080 --> 00:31:26,620 You know, write scripts to make things 752 00:31:26,620 --> 00:31:27,740 as automated as possible. 753 00:31:28,300 --> 00:31:30,620 Spend time, you know, thinking about what the model is 754 00:31:30,620 --> 00:31:31,720 and what you're really trying to do. 755 00:31:32,100 --> 00:31:34,860 And implement iteratively and understand iteratively. 756 00:31:34,960 --> 00:31:36,880 Don't try to build one big monolithic thing 757 00:31:36,900 --> 00:31:38,240 and solve little problems 758 00:31:38,240 --> 00:31:39,660 and try to piece your code together. 759 00:31:40,000 --> 00:31:42,900 Yeah, the key thing is look for small milestones 760 00:31:42,900 --> 00:31:46,100 that you can accomplish over a long period of time. 761 00:31:46,540 --> 00:31:49,140 Because the more small milestones that you can pile up 762 00:31:49,140 --> 00:31:51,200 or that you can complete, you know, 763 00:31:51,200 --> 00:31:52,560 over a few days or a few weeks, 764 00:31:53,520 --> 00:31:55,880 the more likely you'll move towards something. 765 00:31:56,060 --> 00:31:57,280 As you start building out, 766 00:31:57,420 --> 00:31:59,780 as you start dreaming big and start saying, 767 00:31:59,820 --> 00:32:02,020 I'm going to implement all of this in one sitting, 768 00:32:02,140 --> 00:32:06,300 you start to become a little bit more bogged down 769 00:32:06,300 --> 00:32:08,240 because you're becoming more concerned with, 770 00:32:08,340 --> 00:32:11,460 oh, I'm not getting this done or I'm falling behind. 771 00:32:12,220 --> 00:32:14,240 And then it's just, it rolls, 772 00:32:14,340 --> 00:32:17,000 it starts to propagate or it starts to become 773 00:32:17,000 --> 00:32:20,060 a little bit more cumbersome to deal with. 774 00:32:20,400 --> 00:32:22,660 So, you know, from personal experience, 775 00:32:22,720 --> 00:32:23,560 I've learned that, you know, 776 00:32:23,560 --> 00:32:25,720 the more small things that I say I'm going to accomplish, 777 00:32:25,940 --> 00:32:27,140 the bigger things start to, 778 00:32:27,200 --> 00:32:29,340 or the small things start to add up to those bigger things. 779 00:32:32,620 --> 00:32:34,080 So some of our conclusions. 780 00:32:36,820 --> 00:32:39,000 Basically, you know, try to use rapid prototyping 781 00:32:39,000 --> 00:32:39,840 as much as possible. 782 00:32:40,120 --> 00:32:42,740 We like coming from ideas from real world type thing, 783 00:32:42,800 --> 00:32:45,020 not just thinking of them, being clever yourself, 784 00:32:45,300 --> 00:32:46,980 but here's a problem you have from pen testing, 785 00:32:47,200 --> 00:32:49,500 or here's a problem that you have reversing some malware, 786 00:32:49,680 --> 00:32:50,820 or here's a bug that you found. 787 00:32:51,240 --> 00:32:54,160 You know, go from what you need to get these actual jobs done 788 00:32:54,160 --> 00:32:56,480 as opposed to trying to think things through 789 00:32:56,480 --> 00:32:57,220 all at the beginning. 790 00:32:58,700 --> 00:32:59,620 Always use scripts. 791 00:32:59,880 --> 00:33:02,040 If you're doing something that's very tedious 792 00:33:02,040 --> 00:33:04,060 or painful while you're working, 793 00:33:04,080 --> 00:33:04,960 or you're debugging or reversing, 794 00:33:05,080 --> 00:33:06,100 write a script for it. 795 00:33:06,200 --> 00:33:06,880 You know, make it useful, 796 00:33:07,060 --> 00:33:07,660 and then from there, 797 00:33:07,800 --> 00:33:09,540 it hints that the way that you're doing it 798 00:33:09,540 --> 00:33:10,700 works out better overall. 799 00:33:12,280 --> 00:33:14,240 And so, you know, in addition, 800 00:33:14,380 --> 00:33:16,780 we've introduced our RE Bridge model. 801 00:33:16,960 --> 00:33:18,600 It's basically a distributed network 802 00:33:18,600 --> 00:33:19,740 or a distributed framework 803 00:33:19,740 --> 00:33:22,500 that's going to hopefully be a middleware 804 00:33:22,500 --> 00:33:25,220 that allows independent tools to integrate 805 00:33:25,220 --> 00:33:26,540 and talk to each other. 806 00:33:27,040 --> 00:33:30,240 Currently, what we have is kind of like an alpha piece of software 807 00:33:30,240 --> 00:33:33,620 where it basically allows IDA Pro to talk to 808 00:33:33,620 --> 00:33:35,040 either one debugger or the other. 809 00:33:35,280 --> 00:33:37,220 But hopefully we would like to make this 810 00:33:37,220 --> 00:33:38,100 a little bit more interesting 811 00:33:38,100 --> 00:33:38,800 where we say, okay, 812 00:33:38,920 --> 00:33:44,000 let's connect more elements to the party 813 00:33:44,000 --> 00:33:46,720 and see if we can't get more information being shared, 814 00:33:46,820 --> 00:33:48,580 more data being sifted through, 815 00:33:48,680 --> 00:33:51,360 so that way we get more interesting results. 816 00:33:52,380 --> 00:33:56,320 And the whole idea is also to enable multiple users 817 00:33:56,320 --> 00:33:57,500 to share on the same session. 818 00:33:57,640 --> 00:33:58,840 So something like Collaborate, 819 00:33:58,920 --> 00:34:03,600 but on a more heterogeneous network, 820 00:34:03,600 --> 00:34:04,520 we have this playing field 821 00:34:04,520 --> 00:34:06,940 where basically we're starting to incorporate 822 00:34:07,640 --> 00:34:10,660 frameworks such as Radar or Ben Navi 823 00:34:10,660 --> 00:34:13,260 or, you know, multiple debugger types 824 00:34:13,260 --> 00:34:17,280 into a single distributed session. 825 00:34:18,320 --> 00:34:20,680 So some related work that we've had, 826 00:34:20,820 --> 00:34:23,280 that we've experienced is, of course, Collaborate, 827 00:34:23,380 --> 00:34:25,280 which basically uses a central repo 828 00:34:25,280 --> 00:34:28,260 that maintains IDBs 829 00:34:28,260 --> 00:34:31,140 and allows users to make modifications 830 00:34:31,140 --> 00:34:33,580 and share those modifications out with others. 831 00:34:33,600 --> 00:34:35,720 So multiple users can actually connect 832 00:34:35,720 --> 00:34:37,020 and mark up the IDBs. 833 00:34:37,640 --> 00:34:38,760 Another one is Ben Crowd, 834 00:34:38,900 --> 00:34:43,240 which is a product of... 835 00:34:44,340 --> 00:34:44,800 Zynamics. 836 00:34:44,900 --> 00:34:45,360 Zynamics. 837 00:34:45,480 --> 00:34:46,380 Sorry, there's a bug there. 838 00:34:47,920 --> 00:34:49,460 And this is basically a repo 839 00:34:49,460 --> 00:34:52,840 where users upload comments and functions from IDA Pro, 840 00:34:53,060 --> 00:34:54,920 and then they can share it with others, 841 00:34:55,000 --> 00:34:57,140 and others can actually get the information 842 00:34:57,140 --> 00:34:57,920 that's already been shared 843 00:34:57,920 --> 00:35:00,860 or been revealed or identified 844 00:35:00,860 --> 00:35:02,840 by other people inside the crowd. 845 00:35:02,840 --> 00:35:07,240 So basically people get to reuse the work of others. 846 00:35:07,500 --> 00:35:10,000 There's also another project that we took from, 847 00:35:10,060 --> 00:35:10,580 Biocougan, 848 00:35:10,680 --> 00:35:13,880 which is a little bit different. 849 00:35:13,960 --> 00:35:17,180 It's actually a vulnerability visualization... 850 00:35:17,180 --> 00:35:19,020 or vulnerability research and visualization tool 851 00:35:19,020 --> 00:35:21,780 that allows people to use Metasploit 852 00:35:21,780 --> 00:35:24,000 and WinDebug to create 853 00:35:24,440 --> 00:35:29,600 or speed up the vulnerability research process. 854 00:35:30,800 --> 00:35:32,700 And so, you know, 855 00:35:32,700 --> 00:35:33,420 with that being said, 856 00:35:34,840 --> 00:35:37,060 we'd like to offer a special thanks to SciPy 857 00:35:37,060 --> 00:35:38,940 for creating IPython, 858 00:35:39,160 --> 00:35:41,580 Chris Eagle and Tim Vidas for Collaborate, 859 00:35:42,260 --> 00:35:45,260 E. Erdeli and HexRays for IDA Python, 860 00:35:45,580 --> 00:35:47,420 Postcat and Linux for Biocougan, 861 00:35:47,480 --> 00:35:49,760 and Visigoth and Conchodo for Vtrace. 862 00:35:51,060 --> 00:35:52,600 If you guys are interested in the code 863 00:35:52,600 --> 00:35:53,920 or the presentation slides, 864 00:35:54,060 --> 00:35:55,000 you should be able to find them 865 00:35:55,000 --> 00:35:59,060 from the GitHub link here at Matt's account, 866 00:35:59,220 --> 00:36:00,480 so you won't be hacking mine. 867 00:36:01,340 --> 00:36:01,780 Thanks. 868 00:36:01,780 --> 00:36:03,340 So are there any questions or comments? 869 00:36:03,720 --> 00:36:05,140 We kind of blazed through that pretty quickly. 870 00:36:09,720 --> 00:36:10,240 Yeah, yeah. 871 00:36:18,720 --> 00:36:19,200 Right on. 872 00:36:19,680 --> 00:36:20,140 We're done.