1 00:00:00,000 --> 00:00:05,600 So, I'm not sure if this has ever happened at DEF CON before, but our speaker has ‑‑ 2 00:00:06,760 --> 00:00:12,780 hasn't completely lost his voice, but it's a little rough today, so keep that in mind. 3 00:00:13,000 --> 00:00:15,780 But our next speaker here is Raphael Mudd. 4 00:00:25,920 --> 00:00:26,880 Thank you. 5 00:00:26,880 --> 00:00:30,140 I'm not that worried about losing my voice. 6 00:00:30,180 --> 00:00:34,120 I look at this room and I see a lot of my close friends, and I just feel like I'm amongst 7 00:00:34,120 --> 00:00:38,540 family, so I'm really looking forward to sharing something I've been working on for a while 8 00:00:38,540 --> 00:00:40,820 with you, and thank you for being here. 9 00:00:42,300 --> 00:00:47,620 What I'd like to start out with is how many of you have used IRC before? 10 00:00:49,720 --> 00:00:50,120 Excellent. 11 00:00:51,220 --> 00:00:54,540 How many of you have written IRC scripts before? 12 00:00:55,480 --> 00:00:56,580 All my kind of people. 13 00:00:57,260 --> 00:01:03,200 Now, I'd like to ask how many of you have written or used, like, the IRC war scripts 14 00:01:03,200 --> 00:01:04,380 back in the 90s? 15 00:01:05,340 --> 00:01:05,900 Yeah. 16 00:01:06,720 --> 00:01:11,360 I'm 32 years old now, and I feel like I've regressed to 14. 17 00:01:14,100 --> 00:01:20,240 I'm making hacking tools, and I'm making hacking tools that feel like the IRC stuff 18 00:01:20,240 --> 00:01:26,420 I did in the 90s, and I'm trying to make my hacking tools more like the IRC tools I had 19 00:01:26,420 --> 00:01:26,560 in the 90s. 20 00:01:26,580 --> 00:01:31,800 So we're going to talk about that today, and we're going to talk about something called 21 00:01:31,800 --> 00:01:32,400 Cortana. 22 00:01:34,220 --> 00:01:38,780 What Cortana is, well, first off, how many of you know Armitage? 23 00:01:39,660 --> 00:01:40,140 Okay. 24 00:01:40,180 --> 00:01:40,480 Great. 25 00:01:41,360 --> 00:01:45,060 Cortana is a scripting language for Armitage. 26 00:01:45,720 --> 00:01:50,500 I'm actually trying to make Armitage scriptable so you can actually add features to it, write 27 00:01:50,500 --> 00:01:50,780 bots. 28 00:01:52,000 --> 00:01:53,620 Here are the things we're going to talk about. 29 00:01:54,320 --> 00:01:55,280 Really important. 30 00:01:55,280 --> 00:01:57,780 I'm really honored by this. 31 00:01:57,860 --> 00:02:01,720 This work was made possible through DARPA's cyber fast track program. 32 00:02:02,260 --> 00:02:03,260 So thank you, Mudge. 33 00:02:03,360 --> 00:02:06,720 I really greatly believe in your vision and what you're doing with that, and thank you 34 00:02:06,720 --> 00:02:11,060 for letting me be a beneficiary of that, and I hope you guys like what I've put together. 35 00:02:14,020 --> 00:02:15,240 Here's what this talk is not. 36 00:02:15,920 --> 00:02:20,340 Cortana is a programming language, does a lot of stuff, so this is not a tutorial. 37 00:02:23,760 --> 00:02:25,000 And some of the features. 38 00:02:25,000 --> 00:02:25,880 I'm just not going to cover. 39 00:02:27,260 --> 00:02:30,740 But what I want to do today is I want to demonstrate what it can do. 40 00:02:30,840 --> 00:02:31,020 Okay? 41 00:02:31,080 --> 00:02:31,800 We're going to have a lot of fun. 42 00:02:32,340 --> 00:02:36,200 I'm going to cover some of the major high notes and why they're there. 43 00:02:37,160 --> 00:02:41,720 And my goal is I just hope you after this are encouraged to go out and try it. 44 00:02:41,820 --> 00:02:43,220 I look forward to seeing what you do. 45 00:02:45,860 --> 00:02:47,060 A little bit about me. 46 00:02:48,220 --> 00:02:50,580 I started out IRC in the 90s. 47 00:02:51,640 --> 00:02:54,100 I wrote an IRC client called JIRC2. 48 00:02:54,220 --> 00:02:54,500 Okay. 49 00:02:55,000 --> 00:02:56,540 I know Dan is in the audience. 50 00:02:56,620 --> 00:02:57,580 He's a JIRC2 fan. 51 00:02:59,740 --> 00:03:02,480 I'm also the developer of a programming language called Sleep. 52 00:03:02,780 --> 00:03:06,980 I wrote it in 2002 and was very active on it until 2009. 53 00:03:07,840 --> 00:03:09,500 I'm also a developer of Armitage. 54 00:03:09,780 --> 00:03:14,180 And because the work I've done the past year has kind of taken over my professional life, 55 00:03:14,780 --> 00:03:20,960 I started a company, actually my personal and professional life, I won't lie, I started 56 00:03:20,960 --> 00:03:23,020 a company this year, Strategic Cyber. 57 00:03:23,020 --> 00:03:26,080 And I make software for red teams, occasionally do research. 58 00:03:26,660 --> 00:03:29,560 You can learn about that at advancedpentest.com. 59 00:03:31,940 --> 00:03:34,900 This is from my IRC clients, an Easter egg. 60 00:03:35,460 --> 00:03:40,020 But it's from an MIRC add-on that was published in the 90s to make fun of me. 61 00:03:40,800 --> 00:03:44,380 Just to kind of give you an idea of the world I came from, we're sitting at a channel called 62 00:03:44,380 --> 00:03:49,180 Floods and my nickname is Butane and I'm sitting there talking about how to write these 63 00:03:49,180 --> 00:03:51,120 scripts to revolutionize MIRC. 64 00:03:51,340 --> 00:03:53,000 And that's not what I really see. 65 00:03:53,020 --> 00:03:55,340 That's probably what I sounded like, so I deserved it. 66 00:03:56,320 --> 00:04:00,980 But this is kind of the world I came from and what I want to bring back into our community 67 00:04:00,980 --> 00:04:01,480 a little bit. 68 00:04:03,600 --> 00:04:05,860 I mentioned my IRC client, JRC2. 69 00:04:07,100 --> 00:04:09,500 I have experience making something that's scriptable. 70 00:04:11,340 --> 00:04:13,560 JRC2 never became very popular. 71 00:04:13,700 --> 00:04:15,640 There's a lot of really good IRC clients out there. 72 00:04:16,480 --> 00:04:20,320 But it did attract a really healthy little scripting community. 73 00:04:21,040 --> 00:04:22,940 There's ‑‑ I think it's over 70. 74 00:04:23,020 --> 00:04:24,520 Maybe 80 scripts on its website. 75 00:04:25,060 --> 00:04:30,680 And some of them, tens of lines of code, others, thousands, written by people who have actually 76 00:04:30,680 --> 00:04:31,740 never even programmed before. 77 00:04:32,560 --> 00:04:37,260 And I noticed in the security community, there's a lot of people afraid to take the 78 00:04:37,260 --> 00:04:39,040 plunge into writing code. 79 00:04:39,440 --> 00:04:45,440 And so I wanted to create something where people who haven't programmed before have 80 00:04:45,440 --> 00:04:51,300 a friendly path to develop something useful, share it with others, and hopefully get hooked 81 00:04:51,300 --> 00:04:51,880 on the bug. 82 00:04:54,060 --> 00:04:56,140 So that's part of my motivation here. 83 00:04:58,480 --> 00:04:59,860 Let's talk a little bit about sleep. 84 00:05:02,600 --> 00:05:05,940 As I mentioned, I started working on sleep 2002. 85 00:05:06,920 --> 00:05:09,000 I didn't know I was actually going to continue working on it. 86 00:05:09,120 --> 00:05:10,180 It was a weekend‑long hack. 87 00:05:12,000 --> 00:05:13,280 It looks a little bit like Pearl. 88 00:05:13,920 --> 00:05:15,360 It is built on top of Java. 89 00:05:15,840 --> 00:05:17,640 It doesn't have any external dependencies. 90 00:05:18,020 --> 00:05:18,680 I like that. 91 00:05:19,440 --> 00:05:20,400 It's very small. 92 00:05:20,640 --> 00:05:21,440 It's one file. 93 00:05:21,880 --> 00:05:22,520 It's 150 kilobytes. 94 00:05:23,440 --> 00:05:28,600 The nice thing about sleep and my original purpose behind it was to make a base language, 95 00:05:28,820 --> 00:05:34,220 okay, that I could extend with new constructs to make the language really friendly to whatever 96 00:05:34,220 --> 00:05:35,140 purpose I wanted. 97 00:05:35,820 --> 00:05:39,160 Of course, my first round of that was a chat program. 98 00:05:39,620 --> 00:05:41,720 And I thought it worked really well there. 99 00:05:42,720 --> 00:05:45,720 With all things, I document everything. 100 00:05:46,060 --> 00:05:49,140 So sleep has a nice 200‑page manual. 101 00:05:49,320 --> 00:05:51,800 But the same thing is available online. 102 00:05:51,880 --> 00:05:52,420 For free. 103 00:05:52,540 --> 00:05:53,240 It always has been. 104 00:05:53,340 --> 00:05:54,180 Probably always will be. 105 00:05:54,740 --> 00:05:57,680 So this was a labor of love, if anything. 106 00:06:00,820 --> 00:06:02,640 So you're going to see some sleep code today. 107 00:06:02,760 --> 00:06:03,060 Don't worry. 108 00:06:03,200 --> 00:06:04,140 It's not too bad. 109 00:06:05,260 --> 00:06:08,120 You can learn more about sleep at sleep.9.org. 110 00:06:09,920 --> 00:06:11,360 Now let's talk about ARMTAGE. 111 00:06:20,300 --> 00:06:21,860 You know, some really nice things. 112 00:06:21,880 --> 00:06:25,420 folks at Starbucks let us cut in line and when they heard what was happening, they actually 113 00:06:25,420 --> 00:06:32,500 bought the tea and the honey. That was really nice of them. So let me continue on with 114 00:06:32,500 --> 00:06:37,260 Armtage. Armtage, for those of you who don't know it, seems like most of the room does. It's 115 00:06:37,260 --> 00:06:42,700 graphically user interface for Metasploit. And it's gone pretty far in the past year and a 116 00:06:42,700 --> 00:06:48,780 half it's been out. And I've been really pleased with it. Most people know it as a GUI. I 117 00:06:48,780 --> 00:06:55,120 think of it as a red team collaboration tool. And what's possible with Armtage is I can set 118 00:06:55,120 --> 00:07:00,800 up a team server that wraps Metasploit and makes it safe for multiple people to use at the 119 00:07:00,800 --> 00:07:07,180 same time. And using that central team server, a whole team can actually break into a 120 00:07:07,180 --> 00:07:13,560 network, work through one foothold, pivot through it and share the same accesses and the 121 00:07:13,560 --> 00:07:18,680 same data. It's really cool. I've taken it to a lot of exercises and I speak 122 00:07:18,780 --> 00:07:24,640 about it pretty regularly. So there's a lot of material online about that. Now let's talk 123 00:07:24,640 --> 00:07:29,700 about Cortana because we've got this ability for humans to interact with each other, right? 124 00:07:30,860 --> 00:07:41,160 Well, the question with Cortana was what happens when I add bots into the mix? And so created 125 00:07:41,160 --> 00:07:47,220 the scripting language based on sleep to automate the Metasploit framework and to extend 126 00:07:47,220 --> 00:07:48,600 to Armtage with new features. 127 00:07:48,780 --> 00:07:57,840 Just like the IRC clients, the active scripting communities did in the 90s. Why do we want to do 128 00:07:57,840 --> 00:08:04,380 this? Well, one, if you've got bots, you can delegate work to them and you can scale your red 129 00:08:04,380 --> 00:08:10,820 team activities. We'll talk about that. The reason for scripting Armtage, I feel like as a 130 00:08:10,820 --> 00:08:18,760 community, we have a wealth of great stand-alone capabilities. I mean, we are very, very, very 131 00:08:18,780 --> 00:08:24,840 wealthy community in terms of capability. But there's not a lot of glue out there. And I like 132 00:08:24,840 --> 00:08:30,880 the Metasploit framework. It's made a lot of inroads, but there's nothing there for adding a 133 00:08:30,880 --> 00:08:36,260 user interface on top of it and extending that. So that's why I want to make Armtage scriptable. 134 00:08:38,580 --> 00:08:45,100 Here's kind of how it works. It's possible to load Cortana scripts into Armtage. I had to come up 135 00:08:45,100 --> 00:08:48,760 with an extension, something that said cyber, something that said Cortana. So I went ahead and 136 00:08:48,780 --> 00:08:55,880 went with CNA. It's a good acronym. But it's possible to load multiple scripts into Armtage, 137 00:08:56,820 --> 00:09:03,300 stand-alone or with a team server, you can do that. And Cortana itself exists as a stand-alone 138 00:09:03,300 --> 00:09:10,420 interpreter, okay? And I can load as many scripts as I want into this headless, stand-alone 139 00:09:10,420 --> 00:09:16,740 container for bots. And one of the things the language enforces is isolation between each of the 140 00:09:16,740 --> 00:09:18,760 bots. So you don't have to worry about, you know, you don't have to worry about, you know, the 141 00:09:18,780 --> 00:09:24,680 other script that's loaded and de-conflicting with it. This is all built into the language. Lessons 142 00:09:24,680 --> 00:09:43,420 learned from my past experience doing this. Now, I've described Cortana so far in context of, like, 143 00:09:43,440 --> 00:09:48,760 IRC bots and scriptable IRC clients. When I first started working with Cortana, I had a lot of 144 00:09:48,780 --> 00:09:49,560 material that was, like, intelligent. And I was really impressed by Cortana. And I think Cortana is 145 00:09:49,560 --> 00:09:54,980 a great example of that. Really, the academic way of describing it is I see the combination of 146 00:09:55,960 --> 00:10:04,000 Armtage and its team server, the Metasplay framework, and now Cortana as pieces in a multiagent 147 00:10:04,640 --> 00:10:13,440 system for red team operations. So Cortana's the domain specific language to write agents that do 148 00:10:13,440 --> 00:10:18,620 whatever we want them to do, respond to things that happen. The team server provides the 149 00:10:18,620 --> 00:10:26,640 the communication layer and the de-confliction of the agents. Metasploit offers an agreed-upon 150 00:10:26,640 --> 00:10:32,580 vocabulary for our data. And if anybody here has ever built a multi-agent system in a committee, 151 00:10:33,220 --> 00:10:37,020 you'll know that that is something that will never get done and the project will stall for 152 00:10:37,020 --> 00:10:45,580 years. The other nice thing about the Metasploit framework is all of its modules are great 153 00:10:45,580 --> 00:10:58,800 verbs, actions for the simulated humans to do. Quartana gives us the ability to take any of 154 00:10:58,800 --> 00:11:03,480 those verbs, do something with them, Quartana gives us the ability to, when something happens, 155 00:11:03,620 --> 00:11:08,640 react to it just like in writing an IRC bot, when there's a new message in the chat room do 156 00:11:08,640 --> 00:11:15,560 this. In Quartana it's hey, when I see a new host, do this or when a compromised agent goes 157 00:11:15,560 --> 00:11:22,320 host, a session opens up, do this. And one of the challenges though in this kind of system 158 00:11:23,030 --> 00:11:30,360 is positive control. And so it's not so much the topic of this talk, but a lot of the reason 159 00:11:30,910 --> 00:11:37,160 this was a DARPA effort was to actually research those issues and come up with a few simple 160 00:11:37,160 --> 00:11:43,220 ideas and try them out for assuring positive control to debug, understand and rein in these 161 00:11:43,220 --> 00:11:49,200 agents, keep them from taking over the world. If you've ever read the book Damon, my goal is 162 00:11:49,200 --> 00:12:03,500 kind of make a system that would enable somebody crazy to do that. Okay. Well, Cortana is not 163 00:12:03,500 --> 00:12:09,420 the only way to automate the mess framework. First, you do have the option of extending it 164 00:12:09,420 --> 00:12:11,980 and Cortana is not a replacement for that at all. 165 00:12:13,760 --> 00:12:17,820 You should still write your modules if you've got a new exploit. You should still write 166 00:12:17,820 --> 00:12:23,160 auxiliary modules. Plugins are a great way to extend the framework with new commands and 167 00:12:23,160 --> 00:12:29,300 resource files are still a great batch capability. The Medisploit RPC server, probably one of 168 00:12:29,300 --> 00:12:34,920 like two or three people in the world who work with it the most, and it's really low level. So 169 00:12:34,920 --> 00:12:38,340 you can build something on it, but you're going to be reinventing a lot of what I've already done. 170 00:12:43,380 --> 00:12:48,600 But I do like it because it's well thought out and I want just really basic primitives so I can 171 00:12:48,600 --> 00:12:54,540 build what I've done. And, of course, there's MSL CLI which is a command line interface to the 172 00:12:54,540 --> 00:13:00,220 Medisploit framework and that's good for maybe embedding to a script. But this is different in 173 00:13:00,220 --> 00:13:07,940 the sense that we're writing these bots that are long running and we can extend Armitage. Now 174 00:13:07,940 --> 00:13:13,200 let's go into some uses. First I want to give you some background. I'm going to give you some background. 175 00:13:14,840 --> 00:13:22,840 I've mentioned that Cortana can respond to events as they happen. Okay? And here's how that 176 00:13:22,840 --> 00:13:29,640 works and what it looks like. In Cortana, the syntax to say I want to respond to an event is 177 00:13:29,640 --> 00:13:35,880 this. On some event, whatever it is, I get back a bunch of arguments and I can respond. That's 178 00:13:35,880 --> 00:13:43,200 it. I can declare as many of these as I want. And that's how you respond to an event listener. So 179 00:13:43,220 --> 00:13:44,880 you can see that I'm just saying I want to respond to an event listener. By the way, what I'm 180 00:13:44,880 --> 00:13:52,480 going to show throughout this talk, though, is what I call the declarative syntax, meaning I'm 181 00:13:52,480 --> 00:13:57,880 just telling the program what I want. But there's actually a syntax where you can hook an 182 00:13:57,880 --> 00:14:03,500 arbitrary event and give it an arbitrary function. So there's kind of a power user equivalent, 183 00:14:03,600 --> 00:14:12,700 but this is the easier to read one. Here's the way a lot of events are driven. For example, Cortana 184 00:14:13,220 --> 00:14:19,320 is constantly pulling the Metasploit framework, the database it uses. And it's pulling back all 185 00:14:19,320 --> 00:14:25,520 the tables. And there's actually a really efficient protocol where when Cortana says, hey, I want 186 00:14:25,520 --> 00:14:33,400 new data. I want to know what you've got. Here's a hash of what I've got. It'll send that when it 187 00:14:33,400 --> 00:14:39,580 requests an update and if the server says, hey, the data hasn't changed, it'll say, oh, okay. 188 00:14:39,700 --> 00:14:43,200 And nothing's transmitted. So it's very efficient. And the way it works is, it's very efficient. 189 00:14:43,220 --> 00:14:49,980 And the way it works is I have the old data and I have the new data. And I compare the two and I 190 00:14:49,980 --> 00:14:57,240 say, hey, in the case of host, I say, okay, hey, from the old data to the new data, some of this 191 00:14:57,240 --> 00:15:04,760 stuff is missing. Well, I fire a host remove event that scripts can respond to. Or I say, hey, I 192 00:15:04,760 --> 00:15:09,920 see a new host. I'm going to fire a host add event. And what that gives me the ability to do is 193 00:15:10,360 --> 00:15:13,200 take anything that is part of the script and I'm going to say, hey, I see a new host. I'm going to 194 00:15:13,220 --> 00:15:18,040 have this working set of data available in the medisplate framework and it gives me the ability 195 00:15:18,040 --> 00:15:25,360 to respond to it in a very easy, intuitive way. And I'm already doing all this data 196 00:15:25,360 --> 00:15:31,880 synchronization anyway, so this is kind of a free on top of what we already have. Here are the 197 00:15:31,880 --> 00:15:40,440 data events that Cortana fires events for. The medisplate credentials table, host, the routes, 198 00:15:41,740 --> 00:15:48,100 what pivots you set up, which services are seen. You can actually declare an event, for 199 00:15:48,100 --> 00:15:56,160 example, on service add 22 and see when the medisplate framework becomes aware of a new 200 00:15:56,160 --> 00:16:02,080 system with SSH open. And it doesn't matter how it figured that out. Maybe somebody launched a 201 00:16:02,080 --> 00:16:08,120 module and found it. Maybe somebody imported it. And, of course, I can fire events surrounding 202 00:16:08,120 --> 00:16:09,180 sessions as well. 203 00:16:10,980 --> 00:16:27,380 Now a little story. Okay. So I was at the northeast collegiate cyber defense competition this 204 00:16:27,380 --> 00:16:34,140 year. I've done it every year since 2008. I really love the event. And what it is, it's an 205 00:16:35,420 --> 00:16:40,180 exercise where college students come with their team, they're dropped in the middle, they have a 206 00:16:40,180 --> 00:16:46,660 network to manage and run while a red team is stomping on them the whole time. This year we had a 207 00:16:46,660 --> 00:16:54,900 problem. There was a new organizers and they decided to give the students all patched systems. 208 00:16:56,200 --> 00:17:01,340 And I guess they said the XP image that was vulnerable, something went wrong with it so they 209 00:17:01,340 --> 00:17:07,780 swapped it out for a new Ubuntu image. Thanks. You mean expect me to come to these events and 210 00:17:07,780 --> 00:17:07,980 hack? 211 00:17:09,680 --> 00:17:21,340 So anyways, the students have all patched systems, right? And they on top of that, the organizers 212 00:17:21,960 --> 00:17:29,360 decided to firewall the red team off from the competition for the first hour. Okay? So not only did 213 00:17:29,360 --> 00:17:36,280 we not have a possible exploit vector, we couldn't use default creds either. Although funny enough, 214 00:17:36,280 --> 00:17:42,660 even after the hour, two teams, we still got them with PS exec and default credentials. So if you ever 215 00:17:42,660 --> 00:17:48,180 play in these events, change those passwords quickly. But as you can tell, you've got ten 216 00:17:48,180 --> 00:17:56,660 people and you're like, well, what do we do? And a friend of mine, Jolly, he asked, hey, is there a 217 00:17:56,660 --> 00:18:05,140 way to, I don't know, when Chris does an NMAP scan, is there a way we can see what changed and just 218 00:18:05,140 --> 00:18:11,780 get that out to the room? And I said, yeah, I think that's possible. I think I can write a bot for 219 00:18:11,780 --> 00:18:18,040 you. He's like, oh, okay, cool. And Chris, he's a guy who's doing NMAP and changing his IP 220 00:18:18,040 --> 00:18:26,080 constantly and just scanning the student systems, Chris, he's like, Raph, I'm like, yeah, Chris. He's 221 00:18:26,080 --> 00:18:32,220 like, your little bot is kind of cool, but I don't want to import an NMAP scan every minute. And I'm 222 00:18:32,220 --> 00:18:39,940 like, oh, I understand. Can you automate it? Sure. So I wrote a bot for Chris running from his 223 00:18:39,940 --> 00:18:46,200 system to automatically import his NMAP scans every time they finished. Okay? The ones he was 224 00:18:46,200 --> 00:18:54,100 doing on his system. And then my friend Silas says, hey, Raph, I've got a script. I give it a 225 00:18:54,100 --> 00:19:00,300 bunch of IPs and it will start launching just a bunch of normal, you know, run of the mill exploits. 226 00:19:02,220 --> 00:19:09,760 Your bots, can you give me a bot that feeds that? Sure. So we ended up by accident with a system 227 00:19:09,760 --> 00:19:18,620 where I'm running a bot that announces changes to the database, new host, new services. Chris is 228 00:19:18,620 --> 00:19:24,900 running a bot that imports stuff and Silas is running a bot that responds to that data to new 229 00:19:24,900 --> 00:19:30,780 hosts and things become available and launches a bunch of attacks from his system. So I didn't 230 00:19:30,780 --> 00:19:32,200 expect that. I was like, okay, I'm going to do this. I'm going to do this. I'm going to do this. I'm 231 00:19:32,200 --> 00:19:36,020 going to do this. It was kind of cool. It was like this distributed system of hacking going on, 232 00:19:36,100 --> 00:19:42,200 being fed by this central red team collaboration architecture. And what you can see in this 233 00:19:42,200 --> 00:19:48,500 picture, much better than I can see on my laptop, is the Rafi Cortana bot actually announcing 234 00:19:48,500 --> 00:20:02,180 hosts. If there's a camera man, I'm sorry. I like to move around. . 235 00:20:02,200 --> 00:20:07,360 . And I just have to show this. This is, I guess I thought it was a momentous 236 00:20:07,360 --> 00:20:13,600 occasion. This is Chris editing his end map importer bot. And I'm like, oh, Chris, you're the first 237 00:20:13,600 --> 00:20:19,740 Cortana programmer besides me. . By the way, you want to know who the second 238 00:20:19,740 --> 00:20:27,380 one is? There's a student from Land O'Lakes University found the Cortana code and package on my 239 00:20:27,380 --> 00:20:31,800 hidden directory on my web server like a month ago and he's been playing with it since and emailing me. 240 00:20:36,020 --> 00:20:41,200 By the way, I just laughed. I thought it was great. So I forgot his name, but just props to 241 00:20:41,200 --> 00:20:48,480 him. I thought that was pretty cool. So I guess he would be the second one. So let's go 242 00:20:48,480 --> 00:21:02,180 ahead and do a demo. There's a lot of demos in this talk, by the way. Okay. Here I am. I've 243 00:21:02,180 --> 00:21:11,160 got a pivot set up and I've got an exploited host, okay? And earlier, I've got to admit, 244 00:21:11,220 --> 00:21:23,480 that T really helps. My voice is much better than I thought it would be. Okay. Earlier, I 245 00:21:23,480 --> 00:21:31,660 started the red team server. And my Armitage client is connected to it. So let's first 246 00:21:32,460 --> 00:21:48,000 start up Cortana with this differ bot. And I'll show you what it looks like. This is the 247 00:21:48,000 --> 00:21:57,220 entire differ bot. On service add, say, hey, I see this host, this port, and the banner 248 00:21:57,220 --> 00:22:02,160 information for that particular service if we have it. That's not too hard, is it? It's a 249 00:22:03,140 --> 00:22:08,760 nice thing for people who are novice programmers, they like to copy and paste stuff. So there's 250 00:22:08,760 --> 00:22:12,520 no object oriented hierarchy in this. It's pretty much everything you use, you can copy and 251 00:22:12,520 --> 00:22:20,400 paste and it will work elsewhere. So very novice friendly in that sense. So yeah, this is that 252 00:22:20,400 --> 00:22:31,040 whole bot. I'll just change it to convince you I'm not faking my demo. There we go. Now let's 253 00:22:31,040 --> 00:22:45,860 run Cortana headless. Here's how I do that. First, I need a property file. And what I want to 254 00:22:45,860 --> 00:22:53,940 point out is that there is documentation on Cortana, enough to nearly be a book, about 55 pages. 255 00:22:55,200 --> 00:23:04,600 So afterwards, you won't have any problem digging into it. And there's pictures. But what you 256 00:23:04,600 --> 00:23:08,720 have to do is first create a property file and say, hey, here's how I want my bot to connect. 257 00:23:12,060 --> 00:23:22,760 And then to run it, all you do is Java-jar, Cortana.jar, Defcon.prop. And give it the path to 258 00:23:22,760 --> 00:23:35,040 your bots. Okay. So let me go ahead and run that. By the way, I can specify as many bots as I 259 00:23:35,040 --> 00:23:43,640 want and they'll just all load up. And once I do that, you will see it in Armitage as well. But 260 00:23:43,640 --> 00:23:49,400 Cortana has a console for actually interacting with scripts and working with them and playing 261 00:23:49,400 --> 00:23:52,740 with that positive control stuff. Both the Armitage and the Chaindrop runer were factory 262 00:23:52,760 --> 00:23:56,380 and standalone version have the same commands in the console. 263 00:24:04,180 --> 00:24:05,520 Thank you, I just caught that. 264 00:24:06,020 --> 00:24:07,680 I heard you can't see the whole screen. 265 00:24:08,620 --> 00:24:12,020 I did not come here to cheat you guys out of screen space, I promise. 266 00:24:14,060 --> 00:24:16,040 Some people are happy to have me talk less, so. 267 00:24:18,520 --> 00:24:21,300 Let's do something I didn't practice, because I love doing that. 268 00:24:23,260 --> 00:24:26,660 Remember I mentioned that we have all these tools to understand our agents? 269 00:24:27,600 --> 00:24:31,120 Well, kind of, one of the tools is, it's a tracer. 270 00:24:31,460 --> 00:24:34,400 So I'm going to type tron, differ.cna. 271 00:24:34,920 --> 00:24:37,780 Got other great commands like prof and pron. 272 00:24:39,460 --> 00:24:41,500 I love turning something into DARPA and being like, 273 00:24:41,560 --> 00:24:44,800 hey guys, check out the pron command in my hacker tool. 274 00:24:50,260 --> 00:24:51,780 So let's go ahead and import something. 275 00:24:53,480 --> 00:24:57,060 And we can see, by the way, here we are in the event log for our team server. 276 00:24:58,000 --> 00:24:59,300 And we can see our bot joined. 277 00:25:00,200 --> 00:25:01,980 Go to hosts, import hosts. 278 00:25:08,000 --> 00:25:09,840 Hopefully that's the right file I just imported. 279 00:25:13,360 --> 00:25:14,380 And we'll see. 280 00:25:15,720 --> 00:25:17,420 Unless I scan that box already. 281 00:25:26,560 --> 00:25:29,360 All right, I'm going to just make sure there's no services here. 282 00:25:29,400 --> 00:25:30,300 I'll just scan this guy. 283 00:25:30,940 --> 00:25:33,660 Because I imported with this one already. 284 00:25:34,020 --> 00:25:35,560 So there we go. 285 00:25:35,800 --> 00:25:38,800 And come back and start announcing stuff to our chat room. 286 00:25:39,220 --> 00:25:39,800 There we go. 287 00:25:40,960 --> 00:25:42,740 It's saying, hey, I see this, I see that. 288 00:25:43,620 --> 00:25:45,860 And that was the differ script and how it worked. 289 00:25:52,760 --> 00:25:54,240 By the way, there's more to this story. 290 00:25:54,540 --> 00:25:56,080 So let me take you there. 291 00:25:56,800 --> 00:25:59,300 As soon as I fix my, there we go, it's better. 292 00:26:01,760 --> 00:26:05,600 So what was the game? 293 00:26:06,900 --> 00:26:09,460 Remember, I told you at Northeast CCDC, 294 00:26:09,480 --> 00:26:11,240 we ended up in a hard situation, right? 295 00:26:12,840 --> 00:26:16,720 Because we had this, we started seeing stuff. 296 00:26:17,940 --> 00:26:22,380 A couple hours later, we see a system pop up in a banner. 297 00:26:22,380 --> 00:26:23,260 And it said Zimbra. 298 00:26:24,080 --> 00:26:24,960 What's Zimbra? 299 00:26:25,580 --> 00:26:29,100 So Google it, get the default creds and log into it. 300 00:26:29,220 --> 00:26:31,160 And we were able to jump on the system 301 00:26:31,160 --> 00:26:32,720 that students had just put up 302 00:26:32,720 --> 00:26:34,380 before they had a chance to change the passwords. 303 00:26:36,120 --> 00:26:38,380 And that's because we had a bot helping us. 304 00:26:40,780 --> 00:26:44,720 Another example, we saw Apache Tomcat come up. 305 00:26:45,980 --> 00:26:48,480 And my friend Will, who works at Rapid7, 306 00:26:48,640 --> 00:26:49,520 he's a pen tester there. 307 00:26:49,940 --> 00:26:52,020 He was like, ooh, Tomcat. 308 00:26:52,380 --> 00:26:54,960 So he managed to get into that system 309 00:26:54,960 --> 00:26:56,840 before the students had a chance to lock it down. 310 00:26:57,260 --> 00:27:00,760 And so just having this situational awareness 311 00:27:00,760 --> 00:27:03,980 aided by bots was really, really valuable to us. 312 00:27:05,800 --> 00:27:07,540 Another story is, 313 00:27:07,700 --> 00:27:10,140 who here has used Windows Credential Editor before? 314 00:27:11,080 --> 00:27:11,940 A few of you. 315 00:27:12,160 --> 00:27:13,700 It's a really awesome tool. 316 00:27:13,760 --> 00:27:15,000 You should Google it. 317 00:27:15,100 --> 00:27:17,440 Probably while I'm talking right now, it's really that cool. 318 00:27:18,260 --> 00:27:21,980 What it does is it pulls plain text credentials. 319 00:27:22,820 --> 00:27:23,700 Out of memory. 320 00:27:24,520 --> 00:27:25,000 Okay? 321 00:27:25,420 --> 00:27:26,800 For the user, it's logged in. 322 00:27:28,740 --> 00:27:32,580 And I wrote a bot for some other events 323 00:27:32,580 --> 00:27:34,460 that would, every 10 minutes, 324 00:27:34,540 --> 00:27:36,260 sweep through all the hosts we had access to, 325 00:27:36,420 --> 00:27:38,700 run this tool, parse its output, 326 00:27:38,960 --> 00:27:41,380 and make the passwords and usernames 327 00:27:41,380 --> 00:27:42,400 available to our whole team. 328 00:27:43,360 --> 00:27:46,360 So another example of bots just helping with the tedious work. 329 00:27:48,740 --> 00:27:49,220 Oops. 330 00:27:54,640 --> 00:27:55,480 Yeah, good. 331 00:27:56,240 --> 00:27:58,400 So let's talk a little bit about post-exploitation. 332 00:28:00,040 --> 00:28:01,700 Basically, I want to control sessions 333 00:28:01,700 --> 00:28:03,560 with multiple people using them. 334 00:28:03,880 --> 00:28:06,340 And the Armtage team server makes it possible for humans, 335 00:28:06,560 --> 00:28:09,140 so it's pretty trivial to extend to bots as well. 336 00:28:10,280 --> 00:28:11,440 Here's what it looks like. 337 00:28:13,180 --> 00:28:17,020 I queue a command using a function like M underscore command 338 00:28:17,020 --> 00:28:18,720 with the ID of the session. 339 00:28:20,320 --> 00:28:21,280 And, um... 340 00:28:21,920 --> 00:28:23,400 When that command completes, 341 00:28:24,160 --> 00:28:26,960 an event fires in my local instance. 342 00:28:27,180 --> 00:28:28,340 So if somebody else queues a command, 343 00:28:28,480 --> 00:28:29,440 that won't fire an event. 344 00:28:30,360 --> 00:28:33,940 But I get this event on Meterpreter underscore that command. 345 00:28:34,620 --> 00:28:37,160 And I can parse it and do whatever I need to with it. 346 00:28:37,900 --> 00:28:40,600 Also, more generic, on Meterpreter fires, too, 347 00:28:40,720 --> 00:28:44,880 so I can hook kind of anything in my local script that fired. 348 00:28:46,000 --> 00:28:47,900 And one other thing to say to this, 349 00:28:48,540 --> 00:28:49,780 for larger scripts, 350 00:28:50,040 --> 00:28:51,260 there is the ability... 351 00:28:51,260 --> 00:28:54,360 There's the ability to create kind of like isolated agents 352 00:28:54,750 --> 00:28:56,020 from inside of one script 353 00:28:56,020 --> 00:28:58,780 that all just do their own thing. 354 00:28:58,980 --> 00:29:01,300 And that's a really great way to decompose a larger program. 355 00:29:04,100 --> 00:29:06,120 Interacting with a process through Meterpreter. 356 00:29:07,360 --> 00:29:10,320 Again, same thing, M exec, session ID, command. 357 00:29:11,300 --> 00:29:14,380 I get back an event on exec underscore command. 358 00:29:14,540 --> 00:29:17,420 So I can do M exec, session one, 359 00:29:18,240 --> 00:29:19,740 DIR slash S, 360 00:29:19,740 --> 00:29:22,900 star, colon, dot, PDF, or something like that. 361 00:29:23,440 --> 00:29:24,760 And when that finishes, 362 00:29:25,020 --> 00:29:27,560 I'll get all that information back and I can parse through it. 363 00:29:28,680 --> 00:29:30,560 There's also M exec local, 364 00:29:31,520 --> 00:29:33,500 which takes a local executable, 365 00:29:34,120 --> 00:29:37,020 gives it over to Meterpreter to inject directly into memory 366 00:29:37,020 --> 00:29:38,020 without touching disk, 367 00:29:38,280 --> 00:29:40,460 and work in the same way. 368 00:29:40,700 --> 00:29:41,860 So it's pretty cool. 369 00:29:44,640 --> 00:29:45,380 Shell sessions. 370 00:29:46,280 --> 00:29:48,340 When I was first building this technology, 371 00:29:48,560 --> 00:29:49,600 I got this one. 372 00:29:49,600 --> 00:29:50,080 All wrong. 373 00:29:57,660 --> 00:30:00,580 I couldn't interact with a dumb command shell 374 00:30:01,640 --> 00:30:05,500 in the same way I'd interact with Meterpreter, 375 00:30:05,600 --> 00:30:08,620 but then I came up with something that just didn't work, 376 00:30:08,680 --> 00:30:10,000 was really confusing to work with. 377 00:30:10,940 --> 00:30:13,720 So I then said, no matter what I do, 378 00:30:13,780 --> 00:30:15,160 I've got to make this look like Meterpreter. 379 00:30:15,280 --> 00:30:15,980 So now it does. 380 00:30:16,440 --> 00:30:18,060 Shell command, some session ID, 381 00:30:18,060 --> 00:30:19,240 whatever command you want, 382 00:30:19,380 --> 00:30:21,800 and you get back on shell underscore command, 383 00:30:21,980 --> 00:30:22,800 same kind of thing. 384 00:30:23,140 --> 00:30:26,420 So this pattern applies to whatever you're trying to interact with. 385 00:30:28,000 --> 00:30:29,180 Now let's have another demo. 386 00:30:33,780 --> 00:30:35,080 We'll load this into our bot. 387 00:30:36,020 --> 00:30:38,100 Oh, by the way, remember I mentioned the tracing? 388 00:30:38,440 --> 00:30:40,540 This is the output of all the stuff our 389 00:30:40,540 --> 00:30:42,540 one bot was doing behind the scenes. 390 00:30:43,420 --> 00:30:44,420 We'll turn that off. 391 00:30:44,600 --> 00:30:45,400 We don't need that. 392 00:30:46,940 --> 00:30:47,380 Okay. 393 00:30:47,760 --> 00:30:50,880 But you can see all the functions that were called, 394 00:30:51,120 --> 00:30:51,800 what they returned, 395 00:30:52,020 --> 00:30:53,880 and what file and what line number. 396 00:30:54,280 --> 00:30:55,280 Nice debugging tool. 397 00:30:57,100 --> 00:30:58,500 So let's go ahead and load another bot. 398 00:31:00,000 --> 00:31:00,880 It's Defcon. 399 00:31:03,660 --> 00:31:04,940 Autokill, I think it was. 400 00:31:05,300 --> 00:31:06,340 Autokill.CNA. 401 00:31:07,300 --> 00:31:07,900 There we go. 402 00:31:08,000 --> 00:31:08,180 Good. 403 00:31:09,900 --> 00:31:11,980 And I can actually load and unload bots, too, 404 00:31:12,100 --> 00:31:13,400 from Cortana Instance. 405 00:31:14,180 --> 00:31:15,380 So let's have a look at these. 406 00:31:15,380 --> 00:31:16,100 This is the Autokill bot. 407 00:31:19,820 --> 00:31:20,920 Here's what Autokill does. 408 00:31:21,560 --> 00:31:22,640 In this case, 409 00:31:23,200 --> 00:31:24,220 every five seconds, 410 00:31:24,400 --> 00:31:25,960 it looks at all of our sessions 411 00:31:26,740 --> 00:31:28,960 and makes sure that they're Windows Meterpreter 412 00:31:28,960 --> 00:31:30,520 and that they're ready for interaction, 413 00:31:31,200 --> 00:31:32,940 and it sends a command PS. 414 00:31:34,300 --> 00:31:35,500 We get back an event 415 00:31:36,300 --> 00:31:37,540 on Meterpreter PS 416 00:31:38,920 --> 00:31:41,120 and we use a built-in Cortana function 417 00:31:41,120 --> 00:31:41,880 to parse that 418 00:31:41,880 --> 00:31:44,240 into a dictionary it can work with. 419 00:31:45,380 --> 00:31:47,340 And for each process entry, 420 00:31:47,540 --> 00:31:49,500 I extract the name process ID, 421 00:31:50,020 --> 00:31:51,700 I check if Internet Explorer 422 00:31:52,300 --> 00:31:53,160 is that process, 423 00:31:53,380 --> 00:31:53,820 and if it is, 424 00:31:53,840 --> 00:31:54,580 I queue the kill command. 425 00:31:56,520 --> 00:31:57,600 So let's take a look at that. 426 00:32:00,920 --> 00:32:01,780 First thing I'm going to do, 427 00:32:02,820 --> 00:32:03,580 we're going to use another 428 00:32:03,580 --> 00:32:04,940 Cortana debugging function, 429 00:32:06,180 --> 00:32:07,580 which is the logging one. 430 00:32:07,720 --> 00:32:08,100 So we're going to do 431 00:32:08,100 --> 00:32:09,580 logon Autokill.CNA. 432 00:32:10,140 --> 00:32:11,240 And now we can see 433 00:32:11,860 --> 00:32:13,540 everything Cortana is doing on our behalf. 434 00:32:15,380 --> 00:32:15,460 And remember, 435 00:32:15,560 --> 00:32:18,080 a great tool for understanding a script 436 00:32:18,080 --> 00:32:20,240 without tracing every function. 437 00:32:22,020 --> 00:32:23,180 So let's go over here 438 00:32:23,180 --> 00:32:26,120 to my XP victim I've got. 439 00:32:27,660 --> 00:32:28,540 And I don't know, 440 00:32:28,720 --> 00:32:29,920 I'm kind of in the mood 441 00:32:29,920 --> 00:32:30,700 to browse the web, 442 00:32:30,880 --> 00:32:31,600 see what's on the Internet, 443 00:32:31,940 --> 00:32:33,800 see what's on MSN.com today. 444 00:32:35,740 --> 00:32:36,220 Thanks. 445 00:32:49,340 --> 00:32:50,340 Could you imagine, 446 00:32:50,440 --> 00:32:51,940 like, a cyber defense exercise 447 00:32:51,940 --> 00:32:53,420 doing this with, like, 448 00:32:53,440 --> 00:32:54,300 star setup star, 449 00:32:54,520 --> 00:32:55,800 star wireshark star, 450 00:32:56,800 --> 00:32:58,080 star CMD star. 451 00:33:01,160 --> 00:33:02,180 Same thing, though. 452 00:33:02,280 --> 00:33:02,820 Here you go. 453 00:33:03,260 --> 00:33:04,340 There's our kill commands 454 00:33:04,340 --> 00:33:05,760 that are being issued by our bot 455 00:33:05,760 --> 00:33:06,460 on our behalf. 456 00:33:09,060 --> 00:33:10,140 Like, turn that off. 457 00:33:12,480 --> 00:33:13,940 Tell our bot bye-bye now. 458 00:33:15,380 --> 00:33:16,400 Simple kind of post exploitation. 459 00:33:16,860 --> 00:33:17,680 There are bot left. 460 00:33:17,880 --> 00:33:18,320 Bye, bot. 461 00:33:18,400 --> 00:33:19,080 I miss you. 462 00:33:22,160 --> 00:33:23,980 And this is just a screenshot of, 463 00:33:24,180 --> 00:33:25,980 I mentioned the Windows Credential Editor stuff. 464 00:33:26,420 --> 00:33:29,040 This is from the Rochester Institute of Technology 465 00:33:29,040 --> 00:33:30,720 Information Security Talent Search. 466 00:33:31,040 --> 00:33:32,800 An offense and defense competition. 467 00:33:33,520 --> 00:33:34,760 And really great. 468 00:33:34,940 --> 00:33:36,260 If you can go out there, I recommend it. 469 00:33:36,920 --> 00:33:39,320 But here, this is running Windows Credential Editor 470 00:33:39,320 --> 00:33:41,160 and announcing it to the chat room. 471 00:33:41,580 --> 00:33:43,300 So you can see some passwords up there. 472 00:33:44,760 --> 00:33:45,360 Not much. 473 00:33:45,380 --> 00:33:46,200 Not my password, thankfully. 474 00:33:47,900 --> 00:33:48,420 Okay. 475 00:33:48,660 --> 00:33:49,420 Let's see here. 476 00:33:50,840 --> 00:33:53,180 Now, let's talk about scripting 477 00:33:53,180 --> 00:33:54,120 Armitage a little bit. 478 00:33:55,380 --> 00:33:57,180 Through Cortana, it's possible to take 479 00:33:57,180 --> 00:33:58,660 the default behaviors in Armitage 480 00:33:58,660 --> 00:33:59,500 and change them. 481 00:34:00,760 --> 00:34:02,080 So, here's the problem. 482 00:34:03,560 --> 00:34:05,120 Armitage is an opinionated tool. 483 00:34:05,880 --> 00:34:07,480 The developer is an opinionated 484 00:34:07,480 --> 00:34:08,060 tool, too. 485 00:34:16,760 --> 00:34:19,460 And I want to be able to alter how it does things. 486 00:34:19,540 --> 00:34:20,200 I, as a scripter. 487 00:34:20,500 --> 00:34:22,400 For example, Armitage picks my payload. 488 00:34:23,120 --> 00:34:25,300 Wouldn't it be nice if I could change 489 00:34:25,300 --> 00:34:25,980 how that works? 490 00:34:26,520 --> 00:34:28,100 Or here's a really good one. 491 00:34:28,980 --> 00:34:30,160 When I'm doing a pen test, 492 00:34:30,600 --> 00:34:32,660 if I try to PS exec to a system 493 00:34:32,660 --> 00:34:34,280 doing a pass to hash attack, 494 00:34:34,760 --> 00:34:37,200 and I rely on the default binary 495 00:34:37,200 --> 00:34:38,960 generated by the open source 496 00:34:38,960 --> 00:34:40,980 medisplate framework, I'm going to get flagged 497 00:34:40,980 --> 00:34:41,500 by antivirus. 498 00:34:42,140 --> 00:34:43,720 So, what if I want to hook 499 00:34:43,720 --> 00:34:45,440 the workflow in Armitage 500 00:34:45,440 --> 00:34:46,360 for passing the hash 501 00:34:47,200 --> 00:34:48,880 and use a different executable? 502 00:34:49,040 --> 00:34:49,860 How could I do that? 503 00:34:50,440 --> 00:34:52,440 And just, how can I modify Armitage? 504 00:34:53,560 --> 00:34:54,680 So, let's take a look at that. 505 00:34:56,260 --> 00:34:57,520 The mechanism to do 506 00:34:57,520 --> 00:34:58,860 this kind of, these kinds of things 507 00:34:58,860 --> 00:35:00,760 are filters. Filters 508 00:35:01,340 --> 00:35:03,340 hook an action that a script 509 00:35:03,340 --> 00:35:05,540 wants to take and it changes 510 00:35:05,540 --> 00:35:06,780 the parameters on the fly. 511 00:35:06,860 --> 00:35:08,780 You can inspect it and change it 512 00:35:08,780 --> 00:35:10,500 and then it goes through like nothing ever happened. 513 00:35:11,780 --> 00:35:13,100 So, let's have a look at that. 514 00:35:15,660 --> 00:35:16,440 Here I am. 515 00:35:16,560 --> 00:35:18,420 Back in all this nifty stuff. 516 00:35:19,720 --> 00:35:21,160 And let's take a look at 517 00:35:21,160 --> 00:35:23,000 a script called payload.CNA. 518 00:35:26,500 --> 00:35:28,160 I'm kind of messy in my folders, 519 00:35:28,220 --> 00:35:29,000 so don't mind me. 520 00:35:33,340 --> 00:35:34,560 Here's a script to 521 00:35:37,180 --> 00:35:38,440 what it does is 522 00:35:38,440 --> 00:35:40,080 when the on ready events fired me, 523 00:35:40,100 --> 00:35:41,020 hey, I'm synced with the 524 00:35:41,020 --> 00:35:41,480 medisplate framework, 525 00:35:41,500 --> 00:35:42,020 the framework database, 526 00:35:42,600 --> 00:35:44,220 it starts a handler for 527 00:35:44,220 --> 00:35:45,620 reverse HTTP. 528 00:35:47,060 --> 00:35:49,200 And whenever a user launches a 529 00:35:49,200 --> 00:35:50,760 module through like the 530 00:35:50,760 --> 00:35:53,060 Armitage GUI, it looks at the 531 00:35:53,060 --> 00:35:54,920 options, it looks at the payload, 532 00:35:55,180 --> 00:35:56,480 it says, hey, is this Windows 533 00:35:56,480 --> 00:35:57,380 reverse TCP? 534 00:35:58,120 --> 00:36:00,040 If it is, let's modify that, 535 00:36:00,220 --> 00:36:02,340 change it to HTTP, 536 00:36:02,720 --> 00:36:04,400 put in the information it needs 537 00:36:04,400 --> 00:36:06,920 and let it continue going. 538 00:36:07,460 --> 00:36:08,940 So, let's take a quick look at that. 539 00:36:12,140 --> 00:36:13,140 So we're going to go to 540 00:36:13,140 --> 00:36:15,300 there's two ways to load a script in Armitage. 541 00:36:15,500 --> 00:36:17,080 If you wanted to always be there, 542 00:36:17,120 --> 00:36:17,960 go to Armitage scripts 543 00:36:19,080 --> 00:36:20,680 and load and unload stuff 544 00:36:20,680 --> 00:36:21,540 and go to town. 545 00:36:22,100 --> 00:36:23,000 If you're a developer, 546 00:36:23,180 --> 00:36:24,020 go to view, 547 00:36:25,520 --> 00:36:26,320 script console, 548 00:36:29,300 --> 00:36:30,940 and you get that same console 549 00:36:30,940 --> 00:36:32,300 we saw in the command line. 550 00:36:32,480 --> 00:36:33,420 A little nicer, though, 551 00:36:33,440 --> 00:36:34,320 because it has tab completion. 552 00:36:36,660 --> 00:36:38,300 So I'm going to load Armitage, 553 00:36:38,320 --> 00:36:39,400 Defcon, payload, 554 00:36:41,520 --> 00:36:42,500 and there you go. 555 00:36:42,600 --> 00:36:44,320 Started the multi handler for us. 556 00:36:44,880 --> 00:36:45,820 See that? 557 00:36:46,200 --> 00:36:48,960 So let's go ahead and launch 558 00:36:48,960 --> 00:36:50,460 an exploit against the system. 559 00:36:51,120 --> 00:36:52,360 You know, really exciting. 560 00:36:53,420 --> 00:36:55,860 Do the classic MSO867. 561 00:36:56,060 --> 00:36:57,160 I'm feeling lazy. 562 00:36:57,980 --> 00:36:59,500 And we'll tell it to 563 00:36:59,500 --> 00:37:00,280 use a reverse connection. 564 00:37:01,620 --> 00:37:02,480 Press launch. 565 00:37:04,020 --> 00:37:05,740 And what you see 566 00:37:05,740 --> 00:37:07,460 is here's our 567 00:37:07,460 --> 00:37:08,640 payload, Windows interpreter 568 00:37:08,640 --> 00:37:10,540 reverse HTTP, right? 569 00:37:13,260 --> 00:37:15,000 I'll see if my pivot wants to behave 570 00:37:15,000 --> 00:37:16,260 or if the system wants to behave 571 00:37:16,260 --> 00:37:17,040 and it actually triggers. 572 00:37:17,660 --> 00:37:19,000 The main thing I wanted you to see, 573 00:37:19,040 --> 00:37:19,720 though, is the actual 574 00:37:22,220 --> 00:37:22,660 whatchamacallit 575 00:37:24,680 --> 00:37:25,560 the actual 576 00:37:26,360 --> 00:37:27,140 payload change. 577 00:37:28,920 --> 00:37:30,900 Somehow my 2003 box 578 00:37:30,900 --> 00:37:31,760 doesn't want to be exploited 579 00:37:31,760 --> 00:37:32,180 right now. 580 00:37:32,360 --> 00:37:32,940 It's okay. 581 00:37:33,360 --> 00:37:34,540 I know a way around that. 582 00:37:36,520 --> 00:37:36,960 . 583 00:37:41,500 --> 00:37:42,440 If this doesn't work, 584 00:37:42,520 --> 00:37:43,260 then I'm going to just press. 585 00:37:46,220 --> 00:37:47,560 I didn't make it reverse. 586 00:37:47,780 --> 00:37:48,540 But for my next demo, 587 00:37:48,600 --> 00:37:49,840 I actually need to be on that box. 588 00:37:50,020 --> 00:37:51,100 So we'll let that go. 589 00:37:52,580 --> 00:37:54,760 But that's a pretty simple example, right? 590 00:37:54,820 --> 00:37:56,280 Swapping a payload preference. 591 00:37:57,600 --> 00:37:58,360 What about 592 00:38:01,560 --> 00:38:02,700 what about the 593 00:38:02,700 --> 00:38:04,860 PS exec example I mentioned? 594 00:38:06,140 --> 00:38:07,320 Here's a little bit more 595 00:38:07,320 --> 00:38:09,460 complex script that I'm working on. 596 00:38:10,460 --> 00:38:10,940 And 597 00:38:11,840 --> 00:38:13,280 like I said, I'm still working on it. 598 00:38:13,400 --> 00:38:15,140 I'm converting it from something else I used to have. 599 00:38:16,060 --> 00:38:17,000 But what it does, 600 00:38:17,140 --> 00:38:18,140 filter user launch. 601 00:38:18,380 --> 00:38:19,980 If the module's PS exec, 602 00:38:20,620 --> 00:38:22,620 if the payload's a bind payload, 603 00:38:24,240 --> 00:38:25,200 it generates 604 00:38:25,200 --> 00:38:26,180 the raw shellcode 605 00:38:26,700 --> 00:38:28,240 for a payload that 606 00:38:29,220 --> 00:38:29,980 matches that. 607 00:38:30,560 --> 00:38:32,580 And it uses a sleep function I wrote 608 00:38:32,580 --> 00:38:34,880 to embed that shellcode 609 00:38:34,880 --> 00:38:37,260 and obfuscate it inside of an executable 610 00:38:37,260 --> 00:38:39,100 I have that beats 611 00:38:39,100 --> 00:38:39,880 most antivirus. 612 00:38:41,880 --> 00:38:43,380 So this is an example 613 00:38:43,380 --> 00:38:44,040 of how 614 00:38:45,540 --> 00:38:47,100 I can take and use Cortana 615 00:38:47,100 --> 00:38:49,280 to merge my 616 00:38:49,280 --> 00:38:50,900 secret sauce for a pen test 617 00:38:51,500 --> 00:38:52,980 into the workflow in Armitage 618 00:38:53,760 --> 00:38:55,280 without really changing anything 619 00:38:55,280 --> 00:38:56,420 from the user's perspective. 620 00:38:57,380 --> 00:38:59,400 And it's a really, really powerful thing. 621 00:38:59,760 --> 00:39:01,280 Because if you've got other things 622 00:39:01,280 --> 00:39:03,640 you want to integrate, other kinds of callback 623 00:39:03,640 --> 00:39:05,560 agents, other kinds of possibly even sessions 624 00:39:05,560 --> 00:39:06,660 besides Meterpreter, 625 00:39:08,100 --> 00:39:09,660 I'm exploring a lot of this stuff 626 00:39:09,660 --> 00:39:10,940 right now. It's a lot of fun. 627 00:39:11,500 --> 00:39:12,700 So a lot of potential here. 628 00:39:15,100 --> 00:39:16,660 Now let's talk about 629 00:39:17,230 --> 00:39:19,400 user interface here as we start to 630 00:39:19,400 --> 00:39:20,240 wind down the presentation. 631 00:39:22,280 --> 00:39:23,420 This is all about 632 00:39:23,420 --> 00:39:25,360 how do we add features to 633 00:39:25,360 --> 00:39:27,200 Armitage, integrating third party 634 00:39:27,200 --> 00:39:28,640 tools, exposing 635 00:39:29,250 --> 00:39:30,560 capabilities in the framework that 636 00:39:31,330 --> 00:39:32,320 aren't normally used, 637 00:39:32,540 --> 00:39:34,960 or even just controlling something 638 00:39:35,500 --> 00:39:36,400 built in Cortana. 639 00:39:37,880 --> 00:39:39,460 Well here's the things Cortana 640 00:39:39,460 --> 00:39:41,480 scripts can do to extend Armitage. 641 00:39:41,500 --> 00:39:42,660 They 642 00:39:43,280 --> 00:39:45,620 can define keyboard shortcuts. 643 00:39:46,080 --> 00:39:47,480 They can define menus. 644 00:39:48,260 --> 00:39:49,260 They can 645 00:39:49,260 --> 00:39:50,960 create console interfaces, 646 00:39:51,280 --> 00:39:53,320 pop up a tab and you have full control 647 00:39:53,320 --> 00:39:53,740 over it. 648 00:39:54,460 --> 00:39:56,540 They can create tables of information. 649 00:39:57,480 --> 00:39:59,140 And that's kind of what Armitage does 650 00:39:59,140 --> 00:40:00,240 for everything. 651 00:40:01,360 --> 00:40:03,300 Actually, how I evaluated 652 00:40:03,300 --> 00:40:05,240 this technology is 653 00:40:05,240 --> 00:40:07,560 I delivered to DARPA Armitage 654 00:40:07,560 --> 00:40:08,580 written in Cortana. 655 00:40:09,000 --> 00:40:11,480 I ripped everything out and rewrote 656 00:40:11,500 --> 00:40:13,000 all of it with just this stuff 657 00:40:13,000 --> 00:40:14,320 to show it could be done. 658 00:40:15,120 --> 00:40:17,440 And I thought it was going to be easier than it was. 659 00:40:17,540 --> 00:40:19,560 It was doable but it was actually kind of hard 660 00:40:19,560 --> 00:40:21,580 and I was like 661 00:40:21,580 --> 00:40:22,760 it was a 662 00:40:23,420 --> 00:40:24,720 busy time when I did that. 663 00:40:26,060 --> 00:40:26,960 But it was a good test. 664 00:40:27,980 --> 00:40:28,920 So let's have a demo. 665 00:40:30,760 --> 00:40:31,560 How many of you 666 00:40:31,560 --> 00:40:33,340 know that Meterpreter can sniff packets? 667 00:40:34,940 --> 00:40:35,560 Just a few 668 00:40:35,560 --> 00:40:36,240 hands went up. Great. 669 00:40:37,220 --> 00:40:39,240 Meterpreter has a sniffer module built in. 670 00:40:40,260 --> 00:40:40,660 It's 671 00:40:41,500 --> 00:40:43,200 a little cumbersome to use but 672 00:40:43,200 --> 00:40:44,520 it is there. It's a 673 00:40:44,960 --> 00:40:45,860 pretty cool capability. 674 00:40:46,480 --> 00:40:48,260 So let's go ahead and load a Cortana script 675 00:40:48,260 --> 00:40:50,540 that lets us use it. 676 00:40:52,060 --> 00:40:53,340 First, if I right click 677 00:40:53,340 --> 00:40:54,560 on this host, 678 00:40:54,860 --> 00:40:56,340 I've got a Meterpreter menu, right? 679 00:40:57,220 --> 00:40:59,260 And you can see all the things I can do 680 00:40:59,260 --> 00:40:59,620 right now. 681 00:41:00,600 --> 00:41:01,800 Now let's go ahead and load 682 00:41:02,520 --> 00:41:03,320 sniffer.CNA. 683 00:41:08,980 --> 00:41:10,800 Great. I now have a sniffer. 684 00:41:11,720 --> 00:41:13,180 If I right click on this host, 685 00:41:13,280 --> 00:41:15,180 go to Meterpreter, I now have a 686 00:41:15,180 --> 00:41:17,100 sniffer menu. Everybody loves 687 00:41:17,100 --> 00:41:19,100 sniffers. I'm going to press 688 00:41:19,100 --> 00:41:21,460 start and what it's 689 00:41:21,460 --> 00:41:22,760 going to do is go to that host, 690 00:41:22,980 --> 00:41:24,720 query all the different 691 00:41:25,220 --> 00:41:27,240 network interfaces on it and it will 692 00:41:27,240 --> 00:41:29,220 pop up a dialogue asking me 693 00:41:29,220 --> 00:41:30,900 which interface I want to sniff on. 694 00:41:32,460 --> 00:41:33,320 I'm like, oh, okay. 695 00:41:34,000 --> 00:41:35,300 I'll sniff on this one. I guess 696 00:41:35,300 --> 00:41:36,420 I don't really have a choice, do I? 697 00:41:37,040 --> 00:41:38,080 So let me press sniff. 698 00:41:39,760 --> 00:41:40,480 Start sniffer. 699 00:41:42,180 --> 00:41:43,360 And anybody notice 700 00:41:43,360 --> 00:41:44,080 what the script did? 701 00:41:46,320 --> 00:41:47,340 Added a little nose 702 00:41:47,340 --> 00:41:48,380 to indicate that we're sniffing. 703 00:41:50,120 --> 00:41:51,160 Scripts have a lot of power. 704 00:41:53,420 --> 00:41:55,420 Now, let's go do something on my victim 705 00:41:55,420 --> 00:41:55,700 system. 706 00:41:57,580 --> 00:41:58,020 Let's 707 00:42:00,480 --> 00:42:00,920 FTP 708 00:42:01,740 --> 00:42:03,060 162, 1648, 128. 709 00:42:04,100 --> 00:42:04,960 And I'll do, 710 00:42:05,100 --> 00:42:05,900 I don't know. 711 00:42:10,660 --> 00:42:11,440 Login is easier. 712 00:42:11,500 --> 00:42:13,140 Got my password. 713 00:42:13,360 --> 00:42:13,700 Fine. 714 00:42:15,740 --> 00:42:17,400 By the way, I can still do 715 00:42:17,400 --> 00:42:19,340 that logging stuff I told you 716 00:42:19,340 --> 00:42:21,320 about. See what it's doing on my 717 00:42:21,320 --> 00:42:23,280 behalf. Because periodically 718 00:42:23,280 --> 00:42:25,280 the sniffer is pulling back packets for me 719 00:42:25,280 --> 00:42:27,400 and saving them somewhere I can 720 00:42:27,400 --> 00:42:29,200 get to them. So 721 00:42:29,840 --> 00:42:30,780 let's go over here. 722 00:42:31,660 --> 00:42:33,160 Part of the power of the Menace 723 00:42:33,160 --> 00:42:35,160 Play framework is not individual 724 00:42:35,160 --> 00:42:37,420 features but the fact that they work well 725 00:42:37,420 --> 00:42:39,500 together when combined. It's like Magic 726 00:42:39,500 --> 00:42:40,120 the Gathering. 727 00:42:41,500 --> 00:42:41,540 . 728 00:42:43,440 --> 00:42:45,400 So a great module 729 00:42:45,400 --> 00:42:46,780 in MetaSplit is called PSnuffle. 730 00:42:47,300 --> 00:42:49,260 And what PSnuffle does, it can take 731 00:42:49,260 --> 00:42:50,800 an arbitrary PCAP capture, 732 00:42:51,400 --> 00:42:53,400 extract plain text creds out of it 733 00:42:53,400 --> 00:42:54,660 just like DSniff used to do 734 00:42:55,320 --> 00:42:57,140 and put those in the MetaSplit 735 00:42:57,140 --> 00:42:59,380 credentials database. So let me go 736 00:42:59,380 --> 00:43:00,420 sniffer, PSnuffle. 737 00:43:01,280 --> 00:43:03,460 And here, it's 738 00:43:03,460 --> 00:43:04,600 running the module for me. 739 00:43:05,980 --> 00:43:07,320 And you can see 740 00:43:07,320 --> 00:43:09,400 my FTP login I just tried. 741 00:43:10,120 --> 00:43:10,640 . 742 00:43:26,940 --> 00:43:26,980 . 743 00:43:27,040 --> 00:43:27,080 . 744 00:43:27,080 --> 00:43:27,100 . 745 00:43:27,100 --> 00:43:27,120 . 746 00:43:27,120 --> 00:43:27,140 . 747 00:43:27,140 --> 00:43:27,160 . 748 00:43:27,160 --> 00:43:27,180 . 749 00:43:27,180 --> 00:43:27,200 . 750 00:43:27,200 --> 00:43:27,220 . 751 00:43:27,260 --> 00:43:27,300 . 752 00:43:27,300 --> 00:43:27,320 . 753 00:43:27,320 --> 00:43:27,340 . 754 00:43:27,340 --> 00:43:27,360 . 755 00:43:27,360 --> 00:43:27,380 . 756 00:43:55,960 --> 00:43:57,360 . 757 00:44:00,280 --> 00:44:00,400 . 758 00:44:05,960 --> 00:44:06,080 . 759 00:44:07,340 --> 00:44:07,460 . 760 00:44:07,460 --> 00:44:07,480 . 761 00:44:07,480 --> 00:44:07,500 . 762 00:44:07,500 --> 00:44:07,520 . 763 00:44:07,520 --> 00:44:07,540 . 764 00:44:07,800 --> 00:44:07,920 . 765 00:44:07,920 --> 00:44:07,940 . 766 00:44:07,940 --> 00:44:08,020 . 767 00:44:08,020 --> 00:44:08,040 . 768 00:44:09,260 --> 00:44:09,380 . 769 00:44:09,380 --> 00:44:09,440 . 770 00:44:09,440 --> 00:44:13,440 . . 771 00:44:17,420 --> 00:44:18,320 . 772 00:44:18,320 --> 00:44:18,480 . 773 00:44:18,480 --> 00:44:20,380 . 774 00:44:20,380 --> 00:44:20,400 . 775 00:44:20,400 --> 00:44:20,420 . 776 00:44:20,420 --> 00:44:20,440 . 777 00:44:20,440 --> 00:44:20,460 . 778 00:44:20,460 --> 00:44:21,260 . 779 00:44:28,360 --> 00:44:29,760 . 780 00:44:29,760 --> 00:44:29,940 . 781 00:44:29,940 --> 00:44:32,580 . 782 00:44:34,860 --> 00:44:36,260 . 783 00:44:36,260 --> 00:44:37,920 . 784 00:44:37,920 --> 00:44:40,320 . 785 00:44:40,320 --> 00:44:40,420 . 786 00:44:40,420 --> 00:44:40,440 . 787 00:44:40,440 --> 00:44:40,460 . 788 00:44:40,460 --> 00:44:45,520 to display an icon and it's like a pancake or sandwich is a better way to describe it. 789 00:44:45,820 --> 00:44:51,100 And what it does is it's a bunch of images that just gets layered together and resized. 790 00:44:51,540 --> 00:44:58,220 So what this filter does is gives me a chance to interact with that layer or that sandwich 791 00:44:58,220 --> 00:45:04,580 of images and change them. So I loop through all the sessions, relate that host, check 792 00:45:04,580 --> 00:45:11,280 if any of them are sniffing and if they are, I push an image onto that sandwich, on that 793 00:45:11,280 --> 00:45:19,720 array of sniff, dot ping and that's it. The loci add my little nose. So that's the sniffer 794 00:45:19,720 --> 00:45:26,380 script. So to kind of take this and wrap it up a little bit, what is Cortana? It's a 795 00:45:26,380 --> 00:45:34,560 scripting language for writes a bots for Armitage collaboration. It's a scripting language 796 00:45:34,580 --> 00:45:45,140 scripting language to extend armitage. One more thing. This is kind of evil. This function up 797 00:45:45,140 --> 00:45:51,020 here, something sleep can do. It's an inline function meaning when it executes it runs in 798 00:45:51,020 --> 00:45:56,340 the context of its parent. And what it does is it pauses the current function, the parent, 799 00:45:58,460 --> 00:46:03,260 and sends it to another function, the current function, the parent as an object, as a 800 00:46:03,260 --> 00:46:09,400 parameter. And it connects to some server elsewhere, writes this pause function out to the 801 00:46:09,400 --> 00:46:16,760 socket and closes everything down. This is a way that your Cortana agents can migrate to other 802 00:46:16,760 --> 00:46:32,640 attack servers to build a very scary distributed bot net. If you want to check more about this 803 00:46:32,640 --> 00:46:37,700 twist, I've got two articles I've written about this technique, shell scripting with a 804 00:46:37,700 --> 00:46:44,480 distributed twist and agent based traffic generation. So just to wrap this up, I introduced 805 00:46:44,480 --> 00:46:50,140 Cortana to you. We talked about how to build distributed bots, talked about post exploitation, 806 00:46:50,660 --> 00:46:55,480 how to modify how armitage does things and how to extend the user interface with new 807 00:46:55,480 --> 00:47:01,300 features. Again, I would especially just foot stomp like to say thank you to DARPA and the 808 00:47:01,300 --> 00:47:02,620 wonderful things going on with the system. I'm going to stop there. I'm going to stop there. I'm 809 00:47:02,620 --> 00:47:06,640 going to go to the cyber fast track program, just fantastic opportunity. That's what made this 810 00:47:06,640 --> 00:47:12,700 work possible. And here's where to go next. I'm armitage hacker on Twitter. There's my email. 811 00:47:13,300 --> 00:47:18,740 You can learn more about sleep. If you go to fast and easy hacking.com, if you go to that 812 00:47:18,740 --> 00:47:23,480 website and click the download link, Cortana, the documentation, some of these examples are 813 00:47:23,480 --> 00:47:28,520 there. And I'm going to clean all of it up and merge it probably this weekend into what's in 814 00:47:28,520 --> 00:47:31,940 Metasploit. So thank you very much and I'll turn it over to questions. 815 00:47:32,620 --> 00:47:41,520 Thank you very much.