SlideShare a Scribd company logo
1 of 36
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 DevelopmentJosue 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 196Mahmoud 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 212Mahmoud Samir Fayed
 
Chapter 06 functions
Chapter 06   functionsChapter 06   functions
Chapter 06 functionsDhani 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 AppsPranav 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 202Mahmoud 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 ErckOrtus 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 FirewallsNetsparker
 
Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for startersBruce Li
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereLaurence Svekis ✔
 
Building an Empire with PowerShell
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShellWill 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 AndroidVlatko 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-newBradDesAulniers2
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.jsPrabin 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 paylodsFelipe Prado
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptLaurence Svekis ✔
 
Adventures in Asymmetric Warfare
Adventures in Asymmetric WarfareAdventures in Asymmetric Warfare
Adventures in Asymmetric WarfareWill 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.jsChris Cowan
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsJohn 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 QualityThomas Moulard
 
Xamarin for (not only) Android developers
Xamarin for (not only) Android developersXamarin for (not only) Android developers
Xamarin for (not only) Android developersAleksander 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 attackMihir Shah
 
Post exploitation using powershell
Post exploitation using powershellPost exploitation using powershell
Post exploitation using powershellMihir Shah
 
Securing docker containers
Securing docker containersSecuring docker containers
Securing docker containersMihir Shah
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflowMihir Shah
 
Cracking the crypto
Cracking the cryptoCracking the crypto
Cracking the cryptoMihir Shah
 
Wi fi pentesting
Wi fi pentestingWi fi pentesting
Wi fi pentestingMihir Shah
 
Reversing with gdb
Reversing with gdbReversing with gdb
Reversing with gdbMihir Shah
 
Return Oriented Programming - ROP
Return Oriented Programming - ROPReturn Oriented Programming - ROP
Return Oriented Programming - ROPMihir Shah
 
PMKID ATTACK!!
PMKID ATTACK!!PMKID ATTACK!!
PMKID ATTACK!!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

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Recently uploaded (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

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