SlideShare a Scribd company logo
Defcamp 0x7DB - Ionut “Nytro” Popescu - Formatul Portable Executable  ...................................................... http://www.rstcenter.com/forum/
Formatul Portable Executable
 
 
 
 
 
 
 
 
 
 
 
 
DLL Injection - Registry - SetWindowHookEx - CreateRemoteThread
Registry
HHOOK SetWindowsHookEx (  int  idHook , HOOKPROC  lpfn , HINSTANCE  hMod , DWORD  dwThreadId  ); WH_CALLWNDPROC Installs a hook procedure that monitors messages before the system sends them to the destination window procedure. For more information, see the CallWndProc hook procedure. WH_CBT Installs a hook procedure that receives notifications useful to a computer-based training (CBT) application. For more information, see the CBTProc hook procedure. WH_KEYBOARD Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure. SetWindowsHookEx
CreateRemoteThread HANDLE WINAPI CreateRemoteThread( __in HANDLE  hProcess ,  __in LPSECURITY_ATTRIBUTES  lpThreadAttributes ,  __in SIZE_T  dwStackSize , __in LPTHREAD_START_ROUTINE  lpStartAddress ,  __in LPVOID  lpParameter ,  __in DWORD  dwCreationFlags ,  __out LPDWORD  lpThreadId  );
API Hooking - Proxy DLL - SSDT (Service Symbol Dispatch Table) - Inline Hooking - IAT Patching
Exemplu API
Load PE File CopyMemory idh, abExeFile(0), Len(idh) If idh.e_magic <> IMAGE_DOS_SIGNATURE Then MsgBox &quot;MZ signature not found!&quot;, vbCritical, &quot;File load error&quot; Exit Sub End If CopyMemory inh, abExeFile(idh.e_lfanew), Len(inh) If inh.Signature <> IMAGE_NT_SIGNATURE Then MsgBox &quot;PE signature not found!&quot;, vbCritical, &quot;File load error&quot; Exit Sub End If si.cb = Len(si) If CreateProcess(vbNullString, fisier, 0, 0, False, CREATE_SUSPENDED, 0, 0, si, pi) = 0 Then Exit Sub context.ContextFlags = CONTEXT86_INTEGER If GetThreadContext(pi.hThread, context) = 0 Then GoTo ClearProcess Call ReadProcessMemory(pi.hProcess, ByVal context.Ebx + 8, addr, 4, 0) If addr = 0 Then GoTo ClearProcess If ZwUnmapViewOfSection(pi.hProcess, addr) Then GoTo ClearProcess ImageBase = VirtualAllocEx(pi.hProcess, ByVal inh.OptionalHeader.ImageBase, inh.OptionalHeader.SizeOfImage, MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE) If ImageBase = 0 Then GoTo ClearProcess Call WriteProcessMemory(pi.hProcess, ByVal ImageBase, abExeFile(0), inh.OptionalHeader.SizeOfHeaders, ret) lOffset = idh.e_lfanew + Len(inh) For i = 0 To inh.FileHeader.NumberOfSections - 1 CopyMemory ish, abExeFile(lOffset + i * Len(ish)), Len(ish) Call WriteProcessMemory(pi.hProcess, ByVal ImageBase + ish.VirtualAddress, abExeFile(ish.PointerToRawData), ish.SizeOfRawData, ret) Call VirtualProtectEx(pi.hProcess, ByVal ImageBase + ish.VirtualAddress, ish.VirtualSize, Protect(ish.characteristics), addr) Next i Call WriteProcessMemory(pi.hProcess, ByVal context.Ebx + 8, ImageBase, 4, ret) context.Eax = ImageBase + inh.OptionalHeader.AddressOfEntryPoint Call SetThreadContext(pi.hThread, context) Call ResumeThread(pi.hThread) Exit Sub

More Related Content

PDF
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
DefCamp
 
PDF
NYU hacknight, april 6, 2016
Mikhail Sosonkin
 
PDF
Sniffing Mach Messages
Mikhail Sosonkin
 
PPT
Unix Programming with Perl
Kazuho Oku
 
PDF
Art of Web Backdoor - Pichaya Morimoto
Pichaya Morimoto
 
PPTX
Using the Power to Prove
Kazuho Oku
 
PDF
iOS Automation Primitives
Synack
 
PDF
Book
luis_lmro
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
DefCamp
 
NYU hacknight, april 6, 2016
Mikhail Sosonkin
 
Sniffing Mach Messages
Mikhail Sosonkin
 
Unix Programming with Perl
Kazuho Oku
 
Art of Web Backdoor - Pichaya Morimoto
Pichaya Morimoto
 
Using the Power to Prove
Kazuho Oku
 
iOS Automation Primitives
Synack
 
Book
luis_lmro
 

What's hot (20)

PDF
Synack Shakacon OSX Malware Persistence
Ivan Einstein
 
PDF
Codetainer: a Docker-based browser code 'sandbox'
Jen Andre
 
PPT
Unix Programming with Perl 2
Kazuho Oku
 
ODP
Mach-O Internals
Anthony Shoumikhin
 
PDF
DEF CON 23: 'DLL Hijacking' on OS X? #@%& Yeah!
Synack
 
PDF
PHP Secure Programming
Balavignesh Kasinathan
 
PDF
PSR-7 and PSR-15, why can't you ignore them
Sérgio Rafael Siqueira
 
PDF
Debugging: Rules & Tools
Ian Barber
 
TXT
C99[2]
guest8914af
 
PDF
Node.js - iJS 2019
NilsMehlhorn
 
TXT
Simple php backdoor_by_dk
Stan Adrian
 
PDF
[2014 CodeEngn Conference 11] 정든품바 - 웹성코드
Code Engn
 
PDF
Django - Know Your Namespace: Middleware
howiworkdaily
 
KEY
Node.js - Best practices
Felix Geisendörfer
 
PPTX
Introduction to puppet - Hands on Session at HPI Potsdam
Christoph Oelmüller
 
PDF
LibreSSL
Giovanni Bechis
 
PDF
DLL Hijacking on OS X
Synack
 
PDF
ZeroNights: Automating iOS blackbox security scanning
Mikhail Sosonkin
 
PDF
Getting started with TDD - Confoo 2014
Eric Hogue
 
PPTX
Angular js security
Jose Manuel Ortega Candel
 
Synack Shakacon OSX Malware Persistence
Ivan Einstein
 
Codetainer: a Docker-based browser code 'sandbox'
Jen Andre
 
Unix Programming with Perl 2
Kazuho Oku
 
Mach-O Internals
Anthony Shoumikhin
 
DEF CON 23: 'DLL Hijacking' on OS X? #@%& Yeah!
Synack
 
PHP Secure Programming
Balavignesh Kasinathan
 
PSR-7 and PSR-15, why can't you ignore them
Sérgio Rafael Siqueira
 
Debugging: Rules & Tools
Ian Barber
 
C99[2]
guest8914af
 
Node.js - iJS 2019
NilsMehlhorn
 
Simple php backdoor_by_dk
Stan Adrian
 
[2014 CodeEngn Conference 11] 정든품바 - 웹성코드
Code Engn
 
Django - Know Your Namespace: Middleware
howiworkdaily
 
Node.js - Best practices
Felix Geisendörfer
 
Introduction to puppet - Hands on Session at HPI Potsdam
Christoph Oelmüller
 
LibreSSL
Giovanni Bechis
 
DLL Hijacking on OS X
Synack
 
ZeroNights: Automating iOS blackbox security scanning
Mikhail Sosonkin
 
Getting started with TDD - Confoo 2014
Eric Hogue
 
Angular js security
Jose Manuel Ortega Candel
 
Ad

Viewers also liked (7)

PPTX
Quick & Dirty Tips for x64 hooks
용환 노
 
PDF
Userland Hooking in Windows
High-Tech Bridge SA (HTBridge)
 
PPT
2006 03 15_pe & api hook
용환 노
 
PDF
제12회 IT4U 강연회 - 악성코드 분석 잘하고 싶어요
NAVER D2
 
PDF
악성코드 분석 도구
Youngjun Chang
 
PDF
2.악성코드와 분석 방안
Youngjun Chang
 
PDF
제12회 IT4U 강연회 - 화이트햇 해커들의 웹 해킹
NAVER D2
 
Quick & Dirty Tips for x64 hooks
용환 노
 
Userland Hooking in Windows
High-Tech Bridge SA (HTBridge)
 
2006 03 15_pe & api hook
용환 노
 
제12회 IT4U 강연회 - 악성코드 분석 잘하고 싶어요
NAVER D2
 
악성코드 분석 도구
Youngjun Chang
 
2.악성코드와 분석 방안
Youngjun Chang
 
제12회 IT4U 강연회 - 화이트햇 해커들의 웹 해킹
NAVER D2
 
Ad

Similar to Formatul Portable Executable (20)

PPTX
Code Injection in Windows
n|u - The Open Security Community
 
PDF
Arduino、Web 到 IoT
Justin Lin
 
KEY
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Vincenzo Iozzo
 
PDF
Sandboxie process isolation with kernel hooks
KarlFrank99
 
ODP
6. processes and threads
Marian Marinov
 
PDF
"Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ...
PROIDEA
 
PDF
Ransomware for fun and non-profit
Youness Zougar
 
PPT
Backdoor coding
abdesslem amri
 
PPTX
How to drive a malware analyst crazy
Michael Boman
 
PPTX
44CON London 2015 - How to drive a malware analyst crazy
44CON
 
PPT
Web application security
Ravi Raj
 
PDF
DEF CON 24 - Patrick Wardle - 99 problems little snitch
Felipe Prado
 
PDF
[DefCon 2016] I got 99 Problems, but 
Little Snitch ain’t one!
Synack
 
PPTX
Random numbers
Positive Hack Days
 
PDF
Reutov, yunusov, nagibin random numbers take ii
DefconRussia
 
PDF
Strategies to design FUD malware
Pedro Tavares
 
ODP
Virtually Pwned
Claudio Criscione
 
PDF
6.Web Servers
Mayank Joneja
 
PPT
PHPUG Presentation
Damon Cortesi
 
Code Injection in Windows
n|u - The Open Security Community
 
Arduino、Web 到 IoT
Justin Lin
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Vincenzo Iozzo
 
Sandboxie process isolation with kernel hooks
KarlFrank99
 
6. processes and threads
Marian Marinov
 
"Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ...
PROIDEA
 
Ransomware for fun and non-profit
Youness Zougar
 
Backdoor coding
abdesslem amri
 
How to drive a malware analyst crazy
Michael Boman
 
44CON London 2015 - How to drive a malware analyst crazy
44CON
 
Web application security
Ravi Raj
 
DEF CON 24 - Patrick Wardle - 99 problems little snitch
Felipe Prado
 
[DefCon 2016] I got 99 Problems, but 
Little Snitch ain’t one!
Synack
 
Random numbers
Positive Hack Days
 
Reutov, yunusov, nagibin random numbers take ii
DefconRussia
 
Strategies to design FUD malware
Pedro Tavares
 
Virtually Pwned
Claudio Criscione
 
6.Web Servers
Mayank Joneja
 
PHPUG Presentation
Damon Cortesi
 

More from DefCamp (20)

PDF
Remote Yacht Hacking
DefCamp
 
PDF
Mobile, IoT, Clouds… It’s time to hire your own risk manager!
DefCamp
 
PPTX
The Charter of Trust
DefCamp
 
PPTX
Internet Balkanization: Why Are We Raising Borders Online?
DefCamp
 
PPTX
Bridging the gap between CyberSecurity R&D and UX
DefCamp
 
PPTX
Secure and privacy-preserving data transmission and processing using homomorp...
DefCamp
 
PPTX
Drupalgeddon 2 – Yet Another Weapon for the Attacker
DefCamp
 
PPTX
Economical Denial of Sustainability in the Cloud (EDOS)
DefCamp
 
PPTX
Trust, but verify – Bypassing MFA
DefCamp
 
PPTX
Threat Hunting: From Platitudes to Practical Application
DefCamp
 
PPTX
Building application security with 0 money down
DefCamp
 
PPTX
Implementation of information security techniques on modern android based Kio...
DefCamp
 
PPTX
Lattice based Merkle for post-quantum epoch
DefCamp
 
PPTX
The challenge of building a secure and safe digital environment in healthcare
DefCamp
 
PPTX
Timing attacks against web applications: Are they still practical?
DefCamp
 
PPTX
Tor .onions: The Good, The Rotten and The Misconfigured
DefCamp
 
PPTX
Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...
DefCamp
 
PPTX
We will charge you. How to [b]reach vendor’s network using EV charging station.
DefCamp
 
PPTX
Connect & Inspire Cyber Security
DefCamp
 
PPTX
The lions and the watering hole
DefCamp
 
Remote Yacht Hacking
DefCamp
 
Mobile, IoT, Clouds… It’s time to hire your own risk manager!
DefCamp
 
The Charter of Trust
DefCamp
 
Internet Balkanization: Why Are We Raising Borders Online?
DefCamp
 
Bridging the gap between CyberSecurity R&D and UX
DefCamp
 
Secure and privacy-preserving data transmission and processing using homomorp...
DefCamp
 
Drupalgeddon 2 – Yet Another Weapon for the Attacker
DefCamp
 
Economical Denial of Sustainability in the Cloud (EDOS)
DefCamp
 
Trust, but verify – Bypassing MFA
DefCamp
 
Threat Hunting: From Platitudes to Practical Application
DefCamp
 
Building application security with 0 money down
DefCamp
 
Implementation of information security techniques on modern android based Kio...
DefCamp
 
Lattice based Merkle for post-quantum epoch
DefCamp
 
The challenge of building a secure and safe digital environment in healthcare
DefCamp
 
Timing attacks against web applications: Are they still practical?
DefCamp
 
Tor .onions: The Good, The Rotten and The Misconfigured
DefCamp
 
Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...
DefCamp
 
We will charge you. How to [b]reach vendor’s network using EV charging station.
DefCamp
 
Connect & Inspire Cyber Security
DefCamp
 
The lions and the watering hole
DefCamp
 

Recently uploaded (20)

PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Software Development Methodologies in 2025
KodekX
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Software Development Methodologies in 2025
KodekX
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 

Formatul Portable Executable

  • 1. Defcamp 0x7DB - Ionut “Nytro” Popescu - Formatul Portable Executable ...................................................... http://www.rstcenter.com/forum/
  • 3.  
  • 4.  
  • 5.  
  • 6.  
  • 7.  
  • 8.  
  • 9.  
  • 10.  
  • 11.  
  • 12.  
  • 13.  
  • 14.  
  • 15. DLL Injection - Registry - SetWindowHookEx - CreateRemoteThread
  • 17. HHOOK SetWindowsHookEx ( int idHook , HOOKPROC lpfn , HINSTANCE hMod , DWORD dwThreadId ); WH_CALLWNDPROC Installs a hook procedure that monitors messages before the system sends them to the destination window procedure. For more information, see the CallWndProc hook procedure. WH_CBT Installs a hook procedure that receives notifications useful to a computer-based training (CBT) application. For more information, see the CBTProc hook procedure. WH_KEYBOARD Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure. SetWindowsHookEx
  • 18. CreateRemoteThread HANDLE WINAPI CreateRemoteThread( __in HANDLE hProcess , __in LPSECURITY_ATTRIBUTES lpThreadAttributes , __in SIZE_T dwStackSize , __in LPTHREAD_START_ROUTINE lpStartAddress , __in LPVOID lpParameter , __in DWORD dwCreationFlags , __out LPDWORD lpThreadId );
  • 19. API Hooking - Proxy DLL - SSDT (Service Symbol Dispatch Table) - Inline Hooking - IAT Patching
  • 21. Load PE File CopyMemory idh, abExeFile(0), Len(idh) If idh.e_magic <> IMAGE_DOS_SIGNATURE Then MsgBox &quot;MZ signature not found!&quot;, vbCritical, &quot;File load error&quot; Exit Sub End If CopyMemory inh, abExeFile(idh.e_lfanew), Len(inh) If inh.Signature <> IMAGE_NT_SIGNATURE Then MsgBox &quot;PE signature not found!&quot;, vbCritical, &quot;File load error&quot; Exit Sub End If si.cb = Len(si) If CreateProcess(vbNullString, fisier, 0, 0, False, CREATE_SUSPENDED, 0, 0, si, pi) = 0 Then Exit Sub context.ContextFlags = CONTEXT86_INTEGER If GetThreadContext(pi.hThread, context) = 0 Then GoTo ClearProcess Call ReadProcessMemory(pi.hProcess, ByVal context.Ebx + 8, addr, 4, 0) If addr = 0 Then GoTo ClearProcess If ZwUnmapViewOfSection(pi.hProcess, addr) Then GoTo ClearProcess ImageBase = VirtualAllocEx(pi.hProcess, ByVal inh.OptionalHeader.ImageBase, inh.OptionalHeader.SizeOfImage, MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE) If ImageBase = 0 Then GoTo ClearProcess Call WriteProcessMemory(pi.hProcess, ByVal ImageBase, abExeFile(0), inh.OptionalHeader.SizeOfHeaders, ret) lOffset = idh.e_lfanew + Len(inh) For i = 0 To inh.FileHeader.NumberOfSections - 1 CopyMemory ish, abExeFile(lOffset + i * Len(ish)), Len(ish) Call WriteProcessMemory(pi.hProcess, ByVal ImageBase + ish.VirtualAddress, abExeFile(ish.PointerToRawData), ish.SizeOfRawData, ret) Call VirtualProtectEx(pi.hProcess, ByVal ImageBase + ish.VirtualAddress, ish.VirtualSize, Protect(ish.characteristics), addr) Next i Call WriteProcessMemory(pi.hProcess, ByVal context.Ebx + 8, ImageBase, 4, ret) context.Eax = ImageBase + inh.OptionalHeader.AddressOfEntryPoint Call SetThreadContext(pi.hThread, context) Call ResumeThread(pi.hThread) Exit Sub