1 00:00:00,458 --> 00:00:07,042 >> This is acquired current user hashes without admin privileges. So please join me in giving 2 00:00:07,042 --> 00:00:18,160 Anton Sapozhinikov a very warm welcome. (Applause.) 3 00:00:18,160 --> 00:00:27,740 >> Hi guys. So what this talk about I will 4 00:00:27,750 --> 00:00:37,350 discuss common penetration testing case I expect to see during any engagement during my 5 00:00:37,350 --> 00:00:47,625 work. We will discuss traditional techniques to gather credentials for the user and 6 00:00:47,625 --> 00:00:58,285 dive into SSPI. So, who is me? A little bit of penetration tester for some years. CTF 7 00:00:58,417 --> 00:01:04,417 player; maybe you know my team is MoreSmokedLeetChicken (indiscernible 1:04 – 1:10) 8 00:01:11,460 --> 00:01:27,458 But anyway. Working for KPMG Russia and project volema. So let's start. Let's imagine a situation 9 00:01:27,458 --> 00:01:36,292 where we don't have ‑‑ we exploited some vulnerability in the (indiscernible) sites of 10 00:01:36,292 --> 00:01:41,792 (indiscernible) for example browser or I don't know, Flash Player . Or maybe user just 11 00:01:41,792 --> 00:01:51,192 downloaded and executed a payload from internet. And there is no access to internet from 12 00:01:51,208 --> 00:01:57,958 his computer. I mean, about (indiscernible) proxy for example or there is some kind of 13 00:01:57,958 --> 00:02:08,917 restrictions on it. Of course we have shell access to user workstation because our payload 14 00:02:08,917 --> 00:02:17,037 was, I don't know, from Metasploit framework or some kind of rank. And these are rank fully patched 15 00:02:17,042 --> 00:02:26,820 windows and any kind of rank from XP to the latest 8.1. And of course we don't have any 16 00:02:26,820 --> 00:02:36,440 privileges on that workstation. I mean usually running credentials of a user. So, the 17 00:02:36,440 --> 00:02:46,580 admin working have done. Admin drop was done. So our goal was to find an ‑‑ our goal is to 18 00:02:46,583 --> 00:02:56,663 find out a password for user and try to use it that way after that. Why do we need to try to 19 00:02:56,667 --> 00:03:06,042 get user password? First of all, any shell is going to die from day‑to‑day. We use buggy 20 00:03:06,042 --> 00:03:17,875 software. How many of you see Metasploit (indiscernible) unexpectedly dying? So it's - - I see every 21 00:03:17,875 --> 00:03:26,792 day unfortunately. So workstation of the user may be powered off. For example, 22 00:03:26,792 --> 00:03:34,708 during or over the weekends maybe your dock was detected and forensics people start to 23 00:03:34,708 --> 00:03:43,083 instigate a computer. So your shell will die and you will have no access to work station after 24 00:03:43,083 --> 00:03:52,417 that. But if you grab a password for the user, you can use it to connect to, I don't know, web mail, 25 00:03:52,417 --> 00:04:04,833 Citrix, VPN, exchange, any incorporation, and incorporate sources what is available from 26 00:04:04,833 --> 00:04:13,453 the internet. What's the traditional ways to get a password of a user? There are 27 00:04:13,458 --> 00:04:23,078 famous tools like Fgdump or maybe you know Mimikatz or those credentials editor. Or maybe 28 00:04:23,083 --> 00:04:30,958 just extract passwords from, not passwords but hashes of passwords, from registry or SAM 29 00:04:30,958 --> 00:04:40,238 file. But the disadvantages of those ways is that you have to have admin privileges for 30 00:04:40,250 --> 00:04:47,750 example, to grab registry or some debug privileges to extract hashes and passwords from a 31 00:04:47,750 --> 00:04:59,667 memory like Mimikatz or Fgdump. If you remember during the definition of our task, we don't 32 00:04:59,667 --> 00:05:08,507 have Admin privileges on our workstation. So we can't use those tools to perform our 33 00:05:08,507 --> 00:05:18,707 engagement. The second way could be try to elevate privileges in some way, for example, try to 34 00:05:18,708 --> 00:05:30,620 find some third party service. We filed permissions and over write some sensitive files. Or 35 00:05:30,620 --> 00:05:37,917 from DLL hijacking attacks or something else. But, as I mentioned before, we have fully 36 00:05:37,917 --> 00:05:43,792 patched operating system. We have fully patched services. So still no way 37 00:05:43,792 --> 00:05:54,672 to escalate privileges and exploit it and use our favorite tools like Mimikatz. That's sad. 38 00:05:55,520 --> 00:06:04,040 There's some alternative ways. For example, we could try to popup user window could look 39 00:06:04,042 --> 00:06:11,125 like that. It's a standard window from Windows XP. But as I mentioned, there is some 40 00:06:11,125 --> 00:06:18,708 letters in Russian. Just imagine what you are exposing computer sort of staying somewhere in Russia 41 00:06:18,708 --> 00:06:29,220 or China, you couldn't popup a window with the correct word ‑‑ we would call it letters so when 42 00:06:29,220 --> 00:06:38,040 the native speaker will mention it with the letters and he will not trick and he will not enter 43 00:06:38,040 --> 00:06:47,120 his password in that window. So you fail. And you wait, even if you, if you use your real belief 44 00:06:47,125 --> 00:06:54,500 to your window, he will, for example, enter some different words that are not actually user 45 00:06:54,500 --> 00:07:02,083 names or passwords. During my experience, during my engagements, I see a lot of 46 00:07:02,083 --> 00:07:09,625 users were trying to put, for example, some words like, I don't know, get off or something 47 00:07:09,625 --> 00:07:16,250 like that. If they actually realize it was some kind of social engineering attack. We try 48 00:07:16,250 --> 00:07:20,490 to have some fun with you, I don't know. 49 00:07:25,860 --> 00:07:31,700 The second way could be for example, use of script 50 00:07:31,708 --> 00:07:42,292 from Metasploit frame work. It's actually called hash snarfing. Also, this technique is 51 00:07:42,292 --> 00:07:51,192 implemented in a tool called Incognito. How it works, it approaches (indiscernible) 52 00:07:51,208 --> 00:07:59,042 credentials of a current user trying to connect to SMB server that's arriving somewhere in the 53 00:07:59,042 --> 00:08:08,480 network, the local network and authenticate using credentials for current user. 54 00:08:08,480 --> 00:08:19,080 And the attacker should control the SMB server to grab the credentials and somehow extract the passwords from it. 55 00:08:19,083 --> 00:08:25,500 But as I mentioned in the definition of the task, we do not have access to the network. 56 00:08:26,300 --> 00:08:36,800 So we do not have any SMB servers in the networks and we can't execute such kind of attacks. 57 00:08:42,780 --> 00:08:52,980 The third way is try to use Internet Explorer. The default browser could use 58 00:08:52,980 --> 00:09:02,580 credentials from a current user to authenticate you. And you also could grab the hashes but 59 00:09:02,583 --> 00:09:09,833 there are some disadvantages. For example, the host name you should use. Browse with Internet 60 00:09:09,833 --> 00:09:15,542 Explorer should be like everything in the trusted zone of the domain and 61 00:09:15,542 --> 00:09:24,122 that means it should be located in the local net work. Wherever the user is current 62 00:09:24,125 --> 00:09:30,542 located. That's option number one. Or option number two is whether it could change a proxy 63 00:09:30,542 --> 00:09:40,375 server of the browser, and for example, the proxy server will be actually ‑‑ your server and 64 00:09:40,375 --> 00:09:49,833 the whole traffic from the browser will go through that proxy and you could capture the hashes. But it's 65 00:09:49,833 --> 00:09:56,333 quite difficult to perform because actually you could break the whole internet 66 00:09:56,333 --> 00:10:05,933 access for public user, and you know if Internet is not working for the user, he will call help 67 00:10:06,000 --> 00:10:17,760 desk. And your shell or your Metaputuer or something, (indiscernible) will be killed. 68 00:10:17,760 --> 00:10:29,240 You'll be, you're incident will be investigated. Anyway, we're ‑‑ if you want to follow the way 69 00:10:29,250 --> 00:10:42,625 of using internet explorer, all of you know, if you're executing internet browser, it will use a 70 00:10:42,625 --> 00:10:48,625 lot of resources and you'll be very, very slow and user will notice it. 71 00:10:50,880 --> 00:11:01,120 So I think in terms of pace, it's not for us at least. So what is security support provider? Provider interface? 72 00:11:01,120 --> 00:11:11,440 It's some kind of layer. What allows different applications starting from browsers any kind 73 00:11:11,440 --> 00:11:21,860 of applications to talk to security providers what implemented by breaking systems. 74 00:11:22,840 --> 00:11:34,060 So what is it? It's several packages. Simplest of them is Microsoft Negotiate. It just 75 00:11:34,060 --> 00:11:41,680 picks the best security package to handle the current configuration of a computer and 76 00:11:41,680 --> 00:11:52,240 try to use the package was actually configured by admins. The second package is Microsoft 77 00:11:52,240 --> 00:12:00,573 NTLM and everybody thinks, no what is it? Microsoft Kerberos and Microsoft Digest SSP. Digest 78 00:12:00,580 --> 00:12:11,038 SSP currently, not widely used, but in the past it was used to authenticate users of a 79 00:12:11,960 --> 00:12:22,540 mail systems like three POP3 protocol or for example HTTP Digest Authentication. And a Secure 80 00:12:22,542 --> 00:12:29,522 Channel package, it's just implementation of SSL or TLS by Microsoft. 81 00:12:32,080 --> 00:12:45,760 So how does any application talk to any server using SSPI? For example, we have a 82 00:12:45,760 --> 00:12:55,700 client application and the server application. Umm, and the client would like to authenticate on the server using 83 00:12:56,600 --> 00:13:06,340 password of the current user. It will change (indiscernible) some kind of messages and any way ‑‑ 84 00:13:07,440 --> 00:13:14,917 client should generate the message called NTLM. Negotiate and send it to the server. The 85 00:13:14,917 --> 00:13:22,375 main advantage of SSPI interface is at client application shouldn't know 86 00:13:22,375 --> 00:13:29,375 anything about what NTLM negotiate is. It'll just tell SSPI. SSPI please can you write 87 00:13:29,375 --> 00:13:38,000 me that type of message and then client just get it from a buffer and send it to a center and log 88 00:13:38,000 --> 00:13:47,333 any authentication. On the server side, happens the same. Server will talk to SSPI 89 00:13:47,333 --> 00:13:55,958 interface and read the following: Hey SSPI, here is a message from a client. Go read 90 00:13:55,958 --> 00:14:05,538 it from buffer. Please prevent buffer and can you write for me please, NTLM challenge and I 91 00:14:05,540 --> 00:14:12,640 will send it to the client. After that, client will receive NTLM challenge message, also 92 00:14:12,640 --> 00:14:21,940 will send it to SPPI interface. And SPPI will prepare for client the message what should be sent 93 00:14:21,940 --> 00:14:34,417 to the server. So SPPI allows us to extract from implementation of different mechanism currently 94 00:14:34,417 --> 00:14:41,833 running from breaking systems, power (indiscernible). What options are configured? Various 95 00:14:41,833 --> 00:14:48,125 domain controller or within an (indiscernible). What's it current. Where is location, how 96 00:14:48,125 --> 00:14:59,545 many of them? Just ask SSPI to perform authentication and that's solved. So there is three 97 00:14:59,545 --> 00:15:10,000 types of messages as I told before. That message type one is just contains features that 98 00:15:10,000 --> 00:15:19,625 supported by the client. Message type two just contains features that are supported by the server 99 00:15:19,625 --> 00:15:30,145 and it contains a challenge generated by the server. The challenge should be used to 100 00:15:30,145 --> 00:15:37,240 generate the message type three. And the hashes that are contained in the message type 101 00:15:37,245 --> 00:15:48,165 three calculated using the change from a message type two. So let's optimize approaches. 102 00:15:48,600 --> 00:15:57,792 I'll attack the SSPI, for example, implement the server and the client application in the one 103 00:15:57,792 --> 00:16:07,592 process. What does this mean? We will send the message type one message type two, and message 104 00:16:07,600 --> 00:16:15,420 type three from ourself, from client to server in one application. That means that 105 00:16:15,420 --> 00:16:21,480 application actually know what is the challenge, what is sent through the server and what was 106 00:16:21,480 --> 00:16:30,833 captured by the client. So there is not any traffic on the network. And the application 107 00:16:30,833 --> 00:16:41,042 could grab all that information what was passed and use it somehow to calculate and extract 108 00:16:41,042 --> 00:16:55,520 later applications. So how it looks like. Message type one, it's just different bytes. 109 00:16:57,060 --> 00:17:05,660 Umm, using that you could extract the knowns, the challenge. The hashes were calculated by the 110 00:17:05,660 --> 00:17:13,500 challenge and if you grab all the things, you could just format it for different crackers 111 00:17:13,500 --> 00:17:22,920 for example, John the Ripper, and it will crack it for you. And after a little bit of brute 112 00:17:22,920 --> 00:17:36,400 forcing, you will get a password of a user. I did little bit of benchmarking, as you can see. If 113 00:17:36,400 --> 00:17:43,740 you are using different types of protocols for authentication, for example, you could brute 114 00:17:43,750 --> 00:17:56,208 force as fast as one million hashes per second. If you are currently using NTLM version 115 00:17:56,208 --> 00:18:06,948 one, it's about two million hashes and NTLM version two is about 500 hashes per second. 116 00:18:06,948 --> 00:18:17,292 What is mean for us? It means NTLM version one is disabled on the computer we could try to use 117 00:18:17,292 --> 00:18:27,412 HTTP Digest to authenticate the user. It allows us to brute force at double speed. 118 00:18:32,320 --> 00:18:40,160 So what will attack flow actually look like? The pentester will send the user some kind of spear 119 00:18:40,167 --> 00:18:51,100 fishing user will be navigating, clicking on the link or downloading some payload or any 120 00:18:51,100 --> 00:19:01,100 exploited any how. Payload will try to authenticate a user on itself and send the 121 00:19:01,100 --> 00:19:07,792 authentication data and what was extracted on the data flow to a pentester. The pentester will brute 122 00:19:07,792 --> 00:19:16,092 force it and extract the user name and password of the user. Afterward, he will use it to 123 00:19:16,100 --> 00:19:24,720 connect to any incorporated sources and exfiltrate the data what means is the 124 00:19:24,720 --> 00:19:38,940 penetration test was successful. How again exfiltrate code load can send the message to our 125 00:19:38,940 --> 00:19:47,292 common control center with authentication data what was just extracted. Where is, I 126 00:19:47,292 --> 00:19:52,875 think we used ‑‑ everybody will know that some kind of (indiscernible) shells, but 127 00:19:52,875 --> 00:20:02,708 (indiscernible). But it's quite often blocked. And umm, I would like to present you with two 128 00:20:02,708 --> 00:20:09,068 (indiscernible) and (indiscernible). The way number one is using DNS for it. For 129 00:20:09,068 --> 00:20:19,468 example, we could try to use, to ask that DNS server to resolve for us some kind of name like 130 00:20:19,468 --> 00:20:28,292 some information goes here dot to my dot evildomain dot com. That means that our DNS servers 131 00:20:28,292 --> 00:20:38,032 are trying from that domain will capture the data, what was requested. But every time your 132 00:20:38,040 --> 00:20:45,220 payload will try to resolve a domain, window's security alert, for example, or any other 133 00:20:45,240 --> 00:20:54,240 personal firewall will alert it and the user may block your payload. There are some work 134 00:20:54,240 --> 00:21:07,440 arounds for it. For example, a workaround I suggest is using file system. For example, 135 00:21:07,440 --> 00:21:17,400 windows acted like create file or set current directory with a way like slash slash some 136 00:21:17,400 --> 00:21:27,580 information goes here in my domain slash some directory will force operating systems to resolve 137 00:21:27,583 --> 00:21:36,708 the DNS name for you. And it will send a DNS request to your server. And umm, personal 138 00:21:36,708 --> 00:21:46,008 firewall, actually will not block it. And that means you win. If you would like some to 139 00:21:46,008 --> 00:21:55,928 get some information back from DNS server and not using any network connections, you for 140 00:21:55,928 --> 00:22:04,820 example would like, use for example IPConfig slash display DNS. And you will see the result 141 00:22:04,820 --> 00:22:15,740 of DNS replies or test by DNS client for you and you could extract from that and actually 142 00:22:15,750 --> 00:22:26,210 know there's not any personal firewalls that will get you doing such things. It's slowly, 143 00:22:26,210 --> 00:22:32,690 but if you want just to send your user name and password to somewhere in the internet, 144 00:22:32,690 --> 00:22:46,590 that's quite enough. Second way to send the user name and hashes to what you just dropped to your 145 00:22:46,590 --> 00:22:58,850 common control center is using Google. Many times during my penetration testing works I see 146 00:22:58,850 --> 00:23:07,720 the company was using some kind of white listing conveyor or proxy servers and we block any 147 00:23:07,720 --> 00:23:15,660 unknown web sites but Google come in quite often. It's opened for everybody even for 148 00:23:15,667 --> 00:23:25,167 guest of the company. Even for the most unprivileged users so we could use to, we could try 149 00:23:25,167 --> 00:23:38,360 to use it to send data back to home. The trick is using the IP off Google.com and try to ask 150 00:23:38,360 --> 00:23:51,500 Google.com to send the data to a application in China for Google. So to perform that attack we 151 00:23:51,500 --> 00:24:01,167 should install our own application engine and capture the data is and send it to 152 00:24:01,167 --> 00:24:09,667 somewhere else where actually could brute force it. And using that way, any proxy server that 153 00:24:09,667 --> 00:24:18,660 is monitoring the internet of users, could see what user just searching something in internet 154 00:24:18,667 --> 00:24:31,687 and nothing else. So we will win after that. How could we mitigate of those kind of 155 00:24:31,687 --> 00:24:41,407 attacks? First of all, we could try to use two factor authentication. Any kind of 156 00:24:41,407 --> 00:24:51,227 hardware tokens or software tokens, strong passwords as you mentioned. We 157 00:24:51,227 --> 00:24:59,087 should brute force caches that we just drop to extract the passwords. If the password was 158 00:24:59,087 --> 00:25:10,875 quite strong we will fail and passwords wouldn't be extracted. And the last suggestion is just 159 00:25:10,875 --> 00:25:18,995 to try to disable unused packages. For example, as you see the benchmarking slide. 160 00:25:19,000 --> 00:25:27,860 There is it, HTTP Digest package allows you to double the speed of brute forcing the passwords. So 161 00:25:27,860 --> 00:25:40,580 if you disable it, the attackers only, will use only NTLM version second to attack your 162 00:25:40,580 --> 00:25:55,540 users. So what's next? In a week, I will release Metasploit post exploitation model. My 163 00:25:55,540 --> 00:26:02,917 implementation of attacks, of current attacks in the seed currently on a github. But the 164 00:26:02,917 --> 00:26:12,117 Metasploit model is currently in the work. It has some bugs, for example, it doesn't support 165 00:26:12,200 --> 00:26:19,760 fully supported protocol and do not extract hashes from every operating system. I know at 166 00:26:19,760 --> 00:26:30,580 least, I know it where is hashes, but, it's difficult to extract because (indiscernible) 167 00:26:30,583 --> 00:26:37,583 for that protocol is about one hundred pages. So I don't have time to read it full. And umm, I 168 00:26:37,583 --> 00:26:46,880 don't know something else. Something else to improve. So that's all. I am ready to think 169 00:26:46,880 --> 00:26:57,740 maybe answer questions. (Applause.)