SlideShare a Scribd company logo
Exploit Development
@shahenshah9999
OWASP SEASIDES 2020
$whoami
MIHIR SHAH | SHAHENSHAH
Null Bangalore Chapter Leader
Author @VulnDroid - The Vulnerable Android App
Development stuff
Cloud Native projects explorer
OSCP Student
@shahenshah9999
Digital Footprint
Twitter: @shahenshah9999
GitHub: www.github.com/shahenshah99
LinkedIn: www.linkedin.com/in/shahenshah99
Blog: www.medium.com/@shahenshah
Agenda for today
● Understanding the exploitation process
○ Using Buffer Overflow to overwrite the EIP
○ Using msfVenom generated payloads
● Understanding the need for writing Windows Custom shellcode
● Writing Custom Shellcode scripts and integrating it to our POC
○ Pop a Calculator
○ Pop a Text Message with custom body
● What Next?
@shahenshah9999
BASICS OF BUFFER OVERFLOW
Understanding the Stack
Exploiting Buffer Overflow - DEMO
@shahenshah9999
WINDOWS SHELLCODING
Environment Setup
● Exploit Development: Kali
● Debugging Machine: Windows 10 and Windows 7
● Vulnerable Software: Minishare and FreeFloat FTP
● Function locator: Arwin
Things to keep in mind
● The shellcode we write will be OS Specific
● This technique is only possible because the OS DLLs are not subject to Address Space Layout
Randomization
● Google & MSDN are your best friends
What are Windows APIs?
Windows APIs are dynamic-link libraries (DLLs) that are part of the Windows
operating system. You use them to perform tasks when it is difficult to write
equivalent procedures of your own.
For example, Windows provides a function named FlashWindowEx that lets you
make the title bar for an application alternate between light and dark shades.
@shahenshah9999
What is Windows Shellcoding?
Shellcode is basically a list of carefully crafted instructions that can be executed once
the code is injected into a running application.
Windows Shellcoding is the art of writing own custom shellcode scripts to call certain
Windows API Functions.
@shahenshah9999
Why should I learn Windows Shellcoding
● Evade msf signatures
● Get a foothold for ROP
● Prove the vulnerabilities
● Fundamentally understand crafting parameters to Windows API
● Creating a prototype POC
@shahenshah9999
First lets have a look at the shellcode
generated by msfvenom
● Msfvenom –p windows/exec CMD=calc.exe –b “x00x0Ax0D” –f c (For popping calculator)
● msfvenom -p windows/messagebox TEXT="Pop The Box!" TITLE="B33F" -b "x00x0Ax0D" -f c
(for popping Message Box)
Let’s test these payloads on both,
Windows 7 and Windows 10 Machines
Okay, so it failed
The reasons for this now working -
1. Windows SmartScreen protection
2. Windows Defender detecting such naive exploit scripts
3. Windows Advanced Threat Protection detecting the MSF signature against its
database.
@shahenshah9999
Is there no Vulnerability?
No, The Vulnerability does exist at the application level. It is due to the system level
protection that disallows the attacker to run remote commands on the target machine.
Explaining this to a non-tech savvy personnel would be really tough. Hence, it
becomes essential to write a POC for the exploit that is detected.
The only way to evade the signatures of the pre-existing exploit scripts is to write
your own exploit script to execute commands on the target.
@shahenshah9999
Windows API kicks in
The way your shellcode executes commands, or as for that matter, any application in
the Windows OS executes any command is by interacting with Windows API function
calls. There are multiple ways to interact with Windows API function calls.
● Using Powershell commands
● Integrating the C/C++ functions predefined to your application
● Using the libraries which have the C# code, for developing windows app
● Using VB .NET functionality in vbs
● Directly passing the shellcode to the kernel to get executed
@shahenshah9999
Executing the Windows API function call
In this, we will be submitting the Windows API function calls through our exploit
script, instead of executing scripts in powershell, or something similar. In this, we are
writing the preloaded shellcode to get executed by Windows.
@shahenshah9999
Popping Windows Calculator
Hereby, we start by writing our own custom shellcode. There are a series of steps to
be followed before we can finally integrate our custom created shellcode to the exploit
script
@shahenshah9999
Popping a Message Box
@shahenshah9999
ASM and opcode
● When you write your own shellcode you obviously have to deal with assembly and opcode. You will
need some basic knowledge in assembly, nothing too dramatic though. The main point, being that
your shellcode will be written in opcode. So you might have to ask yourself, how do I get the opcode
for an instruction?
● Immunity Debugger does this for you. Put a breakpoint to the NOP Sled of you shellcode and start
writing the shellcode, Immunity will basically act as a dictionary for the shellcode ‘translation’
WinExec
● Before we start to do anything, we must fully understand the functionality of WinExec function by
reading the MSDN page for this.
● Use the Arwin binary to locate the address for the function within the DLL
Understanding how to write ASCII String
Let’s Start Writing our shellcode
Things to remember
● The stack grows downward so we need to push the last argument first
● lpCmdLine contains our ASCII command but WinExec doesn’t want the ASCII itself it want a pointer
to the ASCII string.
Lets do the similar procedure for Popping
a Message Box
Will These Shellcodes Work All The Time?
@shahenshah9999
How to bypass ASLR?
@shahenshah9999
Q & A
@shahenshah9999
Thank You!!
@shahenshah9999

More Related Content

What's hot

Cordova iOS Native Plugin Development
Cordova iOS Native Plugin DevelopmentCordova iOS Native Plugin Development
Cordova iOS Native Plugin Development
Josue Bustos
 
The Ring programming language version 1.7 book - Part 19 of 196
The Ring programming language version 1.7 book - Part 19 of 196The Ring programming language version 1.7 book - Part 19 of 196
The Ring programming language version 1.7 book - Part 19 of 196
Mahmoud Samir Fayed
 
Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)
Chang W. Doh
 
DC Alt.Net: Building Web Apps With node.js
DC Alt.Net: Building Web Apps With node.jsDC Alt.Net: Building Web Apps With node.js
DC Alt.Net: Building Web Apps With node.jsTroy Goode
 
The Ring programming language version 1.10 book - Part 24 of 212
The Ring programming language version 1.10 book - Part 24 of 212The Ring programming language version 1.10 book - Part 24 of 212
The Ring programming language version 1.10 book - Part 24 of 212
Mahmoud Samir Fayed
 
Angular 2 Básico
Angular 2 BásicoAngular 2 Básico
Angular 2 Básico
Romualdo Andre
 
Chapter 06 functions
Chapter 06   functionsChapter 06   functions
Chapter 06 functions
Dhani Ahmad
 
Dynamics demoworkbenchv3
Dynamics demoworkbenchv3Dynamics demoworkbenchv3
Dynamics demoworkbenchv3John Dooley
 
Using Visual Studio to build XAML Universal Apps
Using Visual Studio to build XAML Universal AppsUsing Visual Studio to build XAML Universal Apps
Using Visual Studio to build XAML Universal Apps
Pranav Ainavolu
 
The Ring programming language version 1.8 book - Part 21 of 202
The Ring programming language version 1.8 book - Part 21 of 202The Ring programming language version 1.8 book - Part 21 of 202
The Ring programming language version 1.8 book - Part 21 of 202
Mahmoud Samir Fayed
 

What's hot (10)

Cordova iOS Native Plugin Development
Cordova iOS Native Plugin DevelopmentCordova iOS Native Plugin Development
Cordova iOS Native Plugin Development
 
The Ring programming language version 1.7 book - Part 19 of 196
The Ring programming language version 1.7 book - Part 19 of 196The Ring programming language version 1.7 book - Part 19 of 196
The Ring programming language version 1.7 book - Part 19 of 196
 
Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)
 
DC Alt.Net: Building Web Apps With node.js
DC Alt.Net: Building Web Apps With node.jsDC Alt.Net: Building Web Apps With node.js
DC Alt.Net: Building Web Apps With node.js
 
The Ring programming language version 1.10 book - Part 24 of 212
The Ring programming language version 1.10 book - Part 24 of 212The Ring programming language version 1.10 book - Part 24 of 212
The Ring programming language version 1.10 book - Part 24 of 212
 
Angular 2 Básico
Angular 2 BásicoAngular 2 Básico
Angular 2 Básico
 
Chapter 06 functions
Chapter 06   functionsChapter 06   functions
Chapter 06 functions
 
Dynamics demoworkbenchv3
Dynamics demoworkbenchv3Dynamics demoworkbenchv3
Dynamics demoworkbenchv3
 
Using Visual Studio to build XAML Universal Apps
Using Visual Studio to build XAML Universal AppsUsing Visual Studio to build XAML Universal Apps
Using Visual Studio to build XAML Universal Apps
 
The Ring programming language version 1.8 book - Part 21 of 202
The Ring programming language version 1.8 book - Part 21 of 202The Ring programming language version 1.8 book - Part 21 of 202
The Ring programming language version 1.8 book - Part 21 of 202
 

Similar to Windows custom shellcoding

ITB2019 CommandBox vs Node.js - Nolan Erck
ITB2019  CommandBox vs Node.js - Nolan ErckITB2019  CommandBox vs Node.js - Nolan Erck
ITB2019 CommandBox vs Node.js - Nolan Erck
Ortus Solutions, Corp
 
MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1晟 沈
 
Hacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass FirewallsHacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass Firewalls
Netsparker
 
Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for starters
Bruce Li
 
Nodejs
NodejsNodejs
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript Here
Laurence Svekis ✔
 
Building an Empire with PowerShell
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShell
Will Schroeder
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
Vlatko Kosturjak
 
2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new
BradDesAulniers2
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.js
Prabin Silwal
 
DEF CON 27 - workshop - MAURICIO VELAZCO - writing custom paylods
DEF CON 27 - workshop - MAURICIO VELAZCO - writing  custom paylodsDEF CON 27 - workshop - MAURICIO VELAZCO - writing  custom paylods
DEF CON 27 - workshop - MAURICIO VELAZCO - writing custom paylods
Felipe Prado
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
Laurence Svekis ✔
 
Adventures in Asymmetric Warfare
Adventures in Asymmetric WarfareAdventures in Asymmetric Warfare
Adventures in Asymmetric Warfare
Will Schroeder
 
Getting started with .net on openSUSE (asp.net with c#)
Getting started with .net on openSUSE  (asp.net with c#)Getting started with .net on openSUSE  (asp.net with c#)
Getting started with .net on openSUSE (asp.net with c#)
Alin Alifah
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
Chris Cowan
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile Apps
John M. Wargo
 
Raising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityRaising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code Quality
Thomas Moulard
 
Xamarin for (not only) Android developers
Xamarin for (not only) Android developersXamarin for (not only) Android developers
Xamarin for (not only) Android developers
Aleksander Piotrowski
 

Similar to Windows custom shellcoding (20)

ITB2019 CommandBox vs Node.js - Nolan Erck
ITB2019  CommandBox vs Node.js - Nolan ErckITB2019  CommandBox vs Node.js - Nolan Erck
ITB2019 CommandBox vs Node.js - Nolan Erck
 
MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1
 
Hacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass FirewallsHacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass Firewalls
 
Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for starters
 
Nodejs
NodejsNodejs
Nodejs
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript Here
 
Building an Empire with PowerShell
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShell
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
 
2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new
 
Proposal
ProposalProposal
Proposal
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.js
 
DEF CON 27 - workshop - MAURICIO VELAZCO - writing custom paylods
DEF CON 27 - workshop - MAURICIO VELAZCO - writing  custom paylodsDEF CON 27 - workshop - MAURICIO VELAZCO - writing  custom paylods
DEF CON 27 - workshop - MAURICIO VELAZCO - writing custom paylods
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
 
Adventures in Asymmetric Warfare
Adventures in Asymmetric WarfareAdventures in Asymmetric Warfare
Adventures in Asymmetric Warfare
 
Getting started with .net on openSUSE (asp.net with c#)
Getting started with .net on openSUSE  (asp.net with c#)Getting started with .net on openSUSE  (asp.net with c#)
Getting started with .net on openSUSE (asp.net with c#)
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile Apps
 
Raising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityRaising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code Quality
 
Xamarin for (not only) Android developers
Xamarin for (not only) Android developersXamarin for (not only) Android developers
Xamarin for (not only) Android developers
 

More from Mihir Shah

Seh based attack
Seh based attackSeh based attack
Seh based attack
Mihir Shah
 
Kubernetes
KubernetesKubernetes
Kubernetes
Mihir Shah
 
Post exploitation using powershell
Post exploitation using powershellPost exploitation using powershell
Post exploitation using powershell
Mihir Shah
 
Securing docker containers
Securing docker containersSecuring docker containers
Securing docker containers
Mihir Shah
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
Mihir Shah
 
Cracking the crypto
Cracking the cryptoCracking the crypto
Cracking the crypto
Mihir Shah
 
Stego.ppt
Stego.pptStego.ppt
Stego.ppt
Mihir Shah
 
Wi fi pentesting
Wi fi pentestingWi fi pentesting
Wi fi pentesting
Mihir Shah
 
Reversing with gdb
Reversing with gdbReversing with gdb
Reversing with gdb
Mihir Shah
 
ROP
ROPROP
Return Oriented Programming - ROP
Return Oriented Programming - ROPReturn Oriented Programming - ROP
Return Oriented Programming - ROP
Mihir Shah
 
PMKID ATTACK!!
PMKID ATTACK!!PMKID ATTACK!!
PMKID ATTACK!!
Mihir Shah
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
Mihir Shah
 

More from Mihir Shah (13)

Seh based attack
Seh based attackSeh based attack
Seh based attack
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Post exploitation using powershell
Post exploitation using powershellPost exploitation using powershell
Post exploitation using powershell
 
Securing docker containers
Securing docker containersSecuring docker containers
Securing docker containers
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
 
Cracking the crypto
Cracking the cryptoCracking the crypto
Cracking the crypto
 
Stego.ppt
Stego.pptStego.ppt
Stego.ppt
 
Wi fi pentesting
Wi fi pentestingWi fi pentesting
Wi fi pentesting
 
Reversing with gdb
Reversing with gdbReversing with gdb
Reversing with gdb
 
ROP
ROPROP
ROP
 
Return Oriented Programming - ROP
Return Oriented Programming - ROPReturn Oriented Programming - ROP
Return Oriented Programming - ROP
 
PMKID ATTACK!!
PMKID ATTACK!!PMKID ATTACK!!
PMKID ATTACK!!
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 

Recently uploaded

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

Windows custom shellcoding

  • 2. $whoami MIHIR SHAH | SHAHENSHAH Null Bangalore Chapter Leader Author @VulnDroid - The Vulnerable Android App Development stuff Cloud Native projects explorer OSCP Student @shahenshah9999
  • 3. Digital Footprint Twitter: @shahenshah9999 GitHub: www.github.com/shahenshah99 LinkedIn: www.linkedin.com/in/shahenshah99 Blog: www.medium.com/@shahenshah
  • 4. Agenda for today ● Understanding the exploitation process ○ Using Buffer Overflow to overwrite the EIP ○ Using msfVenom generated payloads ● Understanding the need for writing Windows Custom shellcode ● Writing Custom Shellcode scripts and integrating it to our POC ○ Pop a Calculator ○ Pop a Text Message with custom body ● What Next? @shahenshah9999
  • 5. BASICS OF BUFFER OVERFLOW
  • 6.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. Exploiting Buffer Overflow - DEMO @shahenshah9999
  • 14. Environment Setup ● Exploit Development: Kali ● Debugging Machine: Windows 10 and Windows 7 ● Vulnerable Software: Minishare and FreeFloat FTP ● Function locator: Arwin
  • 15. Things to keep in mind ● The shellcode we write will be OS Specific ● This technique is only possible because the OS DLLs are not subject to Address Space Layout Randomization ● Google & MSDN are your best friends
  • 16. What are Windows APIs? Windows APIs are dynamic-link libraries (DLLs) that are part of the Windows operating system. You use them to perform tasks when it is difficult to write equivalent procedures of your own. For example, Windows provides a function named FlashWindowEx that lets you make the title bar for an application alternate between light and dark shades. @shahenshah9999
  • 17. What is Windows Shellcoding? Shellcode is basically a list of carefully crafted instructions that can be executed once the code is injected into a running application. Windows Shellcoding is the art of writing own custom shellcode scripts to call certain Windows API Functions. @shahenshah9999
  • 18. Why should I learn Windows Shellcoding ● Evade msf signatures ● Get a foothold for ROP ● Prove the vulnerabilities ● Fundamentally understand crafting parameters to Windows API ● Creating a prototype POC @shahenshah9999
  • 19. First lets have a look at the shellcode generated by msfvenom ● Msfvenom –p windows/exec CMD=calc.exe –b “x00x0Ax0D” –f c (For popping calculator) ● msfvenom -p windows/messagebox TEXT="Pop The Box!" TITLE="B33F" -b "x00x0Ax0D" -f c (for popping Message Box)
  • 20. Let’s test these payloads on both, Windows 7 and Windows 10 Machines
  • 21. Okay, so it failed The reasons for this now working - 1. Windows SmartScreen protection 2. Windows Defender detecting such naive exploit scripts 3. Windows Advanced Threat Protection detecting the MSF signature against its database. @shahenshah9999
  • 22. Is there no Vulnerability? No, The Vulnerability does exist at the application level. It is due to the system level protection that disallows the attacker to run remote commands on the target machine. Explaining this to a non-tech savvy personnel would be really tough. Hence, it becomes essential to write a POC for the exploit that is detected. The only way to evade the signatures of the pre-existing exploit scripts is to write your own exploit script to execute commands on the target. @shahenshah9999
  • 23. Windows API kicks in The way your shellcode executes commands, or as for that matter, any application in the Windows OS executes any command is by interacting with Windows API function calls. There are multiple ways to interact with Windows API function calls. ● Using Powershell commands ● Integrating the C/C++ functions predefined to your application ● Using the libraries which have the C# code, for developing windows app ● Using VB .NET functionality in vbs ● Directly passing the shellcode to the kernel to get executed @shahenshah9999
  • 24. Executing the Windows API function call In this, we will be submitting the Windows API function calls through our exploit script, instead of executing scripts in powershell, or something similar. In this, we are writing the preloaded shellcode to get executed by Windows. @shahenshah9999
  • 25. Popping Windows Calculator Hereby, we start by writing our own custom shellcode. There are a series of steps to be followed before we can finally integrate our custom created shellcode to the exploit script @shahenshah9999
  • 26. Popping a Message Box @shahenshah9999
  • 27. ASM and opcode ● When you write your own shellcode you obviously have to deal with assembly and opcode. You will need some basic knowledge in assembly, nothing too dramatic though. The main point, being that your shellcode will be written in opcode. So you might have to ask yourself, how do I get the opcode for an instruction? ● Immunity Debugger does this for you. Put a breakpoint to the NOP Sled of you shellcode and start writing the shellcode, Immunity will basically act as a dictionary for the shellcode ‘translation’
  • 28. WinExec ● Before we start to do anything, we must fully understand the functionality of WinExec function by reading the MSDN page for this. ● Use the Arwin binary to locate the address for the function within the DLL
  • 29. Understanding how to write ASCII String
  • 30. Let’s Start Writing our shellcode
  • 31. Things to remember ● The stack grows downward so we need to push the last argument first ● lpCmdLine contains our ASCII command but WinExec doesn’t want the ASCII itself it want a pointer to the ASCII string.
  • 32. Lets do the similar procedure for Popping a Message Box
  • 33. Will These Shellcodes Work All The Time? @shahenshah9999
  • 34. How to bypass ASLR? @shahenshah9999