SlideShare a Scribd company logo
1 of 14
EXPLOITING MS15-034 IN
POWERSHELL
KIERAN JACOBSEN
TECHNICAL LEAD - READIFY
@KJACOBSEN – POSHSECURITY.COM
‘REMOTE CODE EXECUTION’ -
IN HTTP.SYS
IF THE BAD GUY CAN EXECUTE
CODE ON YOUR BOX, IT ISN’T
YOUR BOX ANYMORE.
HTTP.SYS IS EVERYWHERE
IIS KERNEL CACHING MODULE
ARE WE VULNERABLE?
REQUEST -> RESPONSE
GET / HTTP/1.1
HOST: GOOGLE.COM
RANGE: BYTES=0-18446744073709551615
CONNECTION: CLOSE
GET / HTTP/1.1`R`N
HOST: GOOGLE.COM`R`N
RANGE: BYTES=0-18446744073709551615`R`N
CONNECTION: CLOSE `R`N
`R`N
STREAMS
WORKING WITH TCP
MS15034.PSM1
MORE INFORMATION
• MY WEBSITE – HTTP://POSHSECURITY.COM
• TWITTER - @KJACOBSEN
• MS15-034 MODULE – HTTP://GITHUB.COM/POSHSECURITY/MS15034
• MICROSOFT SECURITY BULLETIN - HTTPS://TECHNET.MICROSOFT.COM/EN-
US/LIBRARY/SECURITY/MS15-034.ASPX

More Related Content

Viewers also liked

Viewers also liked (11)

Automating Your Azure Environment
Automating Your Azure EnvironmentAutomating Your Azure Environment
Automating Your Azure Environment
 
Enabling Enterprise Mobility
Enabling Enterprise MobilityEnabling Enterprise Mobility
Enabling Enterprise Mobility
 
Global Azure Bootcamp 2016 - Azure Automation Invades Your Data Centre
Global Azure Bootcamp 2016 - Azure Automation Invades Your Data CentreGlobal Azure Bootcamp 2016 - Azure Automation Invades Your Data Centre
Global Azure Bootcamp 2016 - Azure Automation Invades Your Data Centre
 
DirectAccess, do’s and don’ts
DirectAccess, do’s and don’tsDirectAccess, do’s and don’ts
DirectAccess, do’s and don’ts
 
Infrastructure Saturday 2011 - Understanding PKI and Certificate Services
Infrastructure Saturday 2011 - Understanding PKI and Certificate ServicesInfrastructure Saturday 2011 - Understanding PKI and Certificate Services
Infrastructure Saturday 2011 - Understanding PKI and Certificate Services
 
Dev Breakfast: Level up to DevSecOps
Dev Breakfast: Level up to DevSecOpsDev Breakfast: Level up to DevSecOps
Dev Breakfast: Level up to DevSecOps
 
Advanced PowerShell Automation
Advanced PowerShell AutomationAdvanced PowerShell Automation
Advanced PowerShell Automation
 
Evolving your automation with hybrid workers
Evolving your automation with hybrid workersEvolving your automation with hybrid workers
Evolving your automation with hybrid workers
 
DevSecOps - CrikeyCon 2017
DevSecOps - CrikeyCon 2017DevSecOps - CrikeyCon 2017
DevSecOps - CrikeyCon 2017
 
Infrastructure Saturday - Level Up to DevSecOps
Infrastructure Saturday - Level Up to DevSecOpsInfrastructure Saturday - Level Up to DevSecOps
Infrastructure Saturday - Level Up to DevSecOps
 
DevSecOps in 10 minutes
DevSecOps in 10 minutesDevSecOps in 10 minutes
DevSecOps in 10 minutes
 

More from kieranjacobsen

More from kieranjacobsen (8)

The Boring Security Talk - Azure Global Bootcamp Melbourne 2019
The Boring Security Talk - Azure Global Bootcamp Melbourne 2019The Boring Security Talk - Azure Global Bootcamp Melbourne 2019
The Boring Security Talk - Azure Global Bootcamp Melbourne 2019
 
CrikeyCon VI - The Boring Security Talk
CrikeyCon VI - The Boring Security TalkCrikeyCon VI - The Boring Security Talk
CrikeyCon VI - The Boring Security Talk
 
The Boring Security Talk
The Boring Security TalkThe Boring Security Talk
The Boring Security Talk
 
The Boring Security Talk
The Boring Security TalkThe Boring Security Talk
The Boring Security Talk
 
Secure Azure Deployment Patterns
Secure Azure Deployment PatternsSecure Azure Deployment Patterns
Secure Azure Deployment Patterns
 
Ransomware 0, Admins 1
Ransomware 0, Admins 1Ransomware 0, Admins 1
Ransomware 0, Admins 1
 
Ransomware 0 admins 1
Ransomware 0 admins 1Ransomware 0 admins 1
Ransomware 0 admins 1
 
DecSecOps in 10 minutes
DecSecOps in 10 minutesDecSecOps in 10 minutes
DecSecOps in 10 minutes
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

Exploiting MS15-034 In PowerShell

Editor's Notes

  1. Hi everyone, my name is Kieran Jacobsen, I am a Technical Lead at Readify. Tonight I am hear to talk about working with TCP connections and how we can use this to exploit the vulnerability described in MS15034.
  2. So who here knows about MS15034, can I just see some hands? So the bulletin has this for its brief description: “A remote code execution vulnerability exists in the HTTP protocol stack (HTTP.sys) that is caused when HTTP.sys improperly parses specially crafted HTTP requests. An attacker who successfully exploited this vulnerability could execute arbitrary code in the context of the System account.” Wow, that doesn’t sound too good. Remote code executing as the system account, that doesn’t sound good, or is it?
  3. A remote code execution vulnerability, or RCE, allows a successful attacker to execute the code of their choosing on your system. Now as the old security adage says, if the bad guy can execute code on your box, it isn’t your box anymore. Now when we discuss RCEs, there is one important factor that we should consider. Authentication. 15034 is an unauthenticated RCE, and this means that an attacker does not require any previous valid credentials to be able to perform a successful attack. These sorts of vulnerabilities are quite prevalent, and are always a serious risk to our systems.
  4. One thing that came out about this vulnerability, is that a significant portion of the community, both infrastructure and security community, don’t quite understand what HTTP.SYS is, and what it does. HTTP.SYS is a server protocol stack, and was first introduced by Microsoft back in Windows Server 2003. It was Microsoft’s response to the scrutiny that had occurred over its security practices in light of events like the Code Red worm. It was also Microsoft’s aim for this protocol stack to allow for faster, lightweight and more securely deployed web server environments. The first place HTTP.SYS appeared was obviously, IIS, however it can now be found in a wide range of places. Direct Access, the SSTP VPN, the Web Application proxy and later versions of ADFS and SSRS. Mostly importantly however, Windows Remoting is based upon HTTP.SYS. At this point, you should be getting just a little bit worried. I am describing an unauthenticated remote code execution vulnerability across a wide range of systems deployed in your environment, some of which are public facing. Also, consider how many systems have WinRM publicly exposed, and you wouldn’t be blamed for thinking the whole situation is just a little bit terrifying.
  5. Thankfully, this vulnerability isn’t quite a simple as it first looks. This vulnerability requires the presence of the IIS Kernel Caching module and that is typically only found in IIS installations. Most importantly, WinRM doesn’t use this module. At this moment, you can start to relax a little. Now the security community has always be quick to reverse engineer patches like this, and in this case, they were exceptionally fast. It was quickly discovered that the issue was in the way HTTP.SYS parses the RANGE HTTP header in a HTTP request. If the range specified was suitably large, this could result in a buffer overflow. Just as a matter of knowledge, the range header allows a client to request only part of a file or entity. Say we just wanted the first 100 bytes of that jpg image, well, we could use the range header to specify that. Now it turns out, RCE from just this header alone, isn’t easy.
  6. This, thankfully is the worst thing that an attacker can do to a vulnerable system. Whilst there was some claims that there were ways of using this vulnerability to actually execute code, most of the time, the result is an instant bluescreen of death like this one. A denial of service vulnerability like this one is definitely nowhere near as bad as remote code execution, but no matter what, if someone is doing this to your servers, you are going to have a bad day. Any attack, which can be performed easily, anonymously and requires little to no technical knowledge or ability that results in a denial of service, is pretty serious.
  7. So whenever you read about a vulnerability, or your CISO, CIO or CTO read about one, the first thing you will be asked, or want to know, is are we vulnerable? Now there were websites that you could use to check if a server was vulnerable, but that isn’t something we would all be comfortable with. There were perl and python scripts as well, and for those who know metasploit, there was a module for that. But I wanted to use Powershell. Let’s take a quick look at using PowerShell to test for the vulnerability.
  8. There are two things that make working with TCP connections in PowerShell wonderfully simple. The first is the fact that HTTP is a text based protocol. Meaning that we will send some strings as a request, and the server responds back in kind. The other thing that makes the whole thing easy is the .Net framework. The .Net framework will take care of almost everything at the TCP layer, leaving us with just the HTTP protocol to worry about. All we need to do is make an appropriate HTTP request, and the server should respond with what we want. So what does that request look like?
  9. So this is an average HTTP request, however it has been modified to exploit the MS15034 vulnerability. The request starts with our METHOD, in this case, we want to get the document root as you can see. We are also specifying that we will be using the HTTP 1.1 protocol. Then we have the HOST header, this is mandatory in HTTP 1.1 and lets a server know which website we actually want to browse. Next up is the pesky RANGE header. Notice that massive value? That is a widely accepted value for testing if a server is actually vulnerable. Changing the start of the range to 18 triggers the bluescreen. Finally, I am specifying the optional header CONNECTION and specifying CLOSE. Normally a server will keep the TCP connection with the client open after serving a request, however in this case, I am happy for the connection to be closed, and have said so via this header value. Each header element needs to be separated by a carriage return and a new line, and we need to finish the request with empty line as well.
  10. So just to highlight, if we specify those carriage returns and new lines, we get something like this. I just wanted to point out that the escape character for PowerShell is the backtick, and not the forward slash. If you are working of example online, maybe those written in c#, they will probably use forward slash r forward slash n, if you don’t change this when moving to PowerShell, you might end up sending a garbage request to the server. Also note that there is an empty or blank line at the end. This is to indicate to the server that our request is complete.
  11. The next thing we need to understand is how to send and receive information over our TCP connection. When we connect using the TCP client, it provides us with something called the TCPStream. We send our requests, and recieve the responses over this stream. We can either write and read directly to the stream, however we will need to encode our strings to either ASCII or UTF byte arrays; or we could use the StreamWriter and StreamReader objects from .Net. The choice is yours with this one, I have used both methods and they are equally reliable. Today I will show you the use of StreamWriter and StreamReader, overall I found these to be a bit easier and the code produced seems to be easier to understand. There is one other stream that can be used, the SSLStream. The SSLStream makes the process of connecting to SSL services much, much easier. Implementing SSL requires a change to one line of code, and an additional line to verify the server’s certificates. Piece of cake! I really did expect this to be much harder, and was utterly astounded at how easy Microsoft has made it.
  12. So lets take a look <code demos>
  13. So as part of my work on the MS15034, I developed a PowerShell module that allows us to firstly test if a server is vulnerable, and secondly invoke the denial of service. I have made this code publicly available, and have been surprised at its popularity. Let’s take a look at the module in action.
  14. That is all for me tonight, if you want more information, my website is PoshSecurity.com. I write mostly about security, PowerShell and automation. I will put up the slides and demos from tonight’s presentation on there in the coming days. You can contact me on my site, or I can be found via Twitter, @kjacobsen. The module I developed for MS15-034 can be found on GitHub, and I have also put up a link to the original Microsoft KB. Thank you all for listening to me tonight. Does anyone have any questions?