SlideShare una empresa de Scribd logo
1 de 21
A Dive Into
ELF Binaries
Null Mumbai
12rd
Jan 2019
By Bhashit Pandya
Who am I
● Information Security Consultant
● Scriptologist
● Not a bug hunter!!
● Explorer
Today we will:
● ask, why to understand them?
● know about executable files.
● peep into the internals.
● see, how to read and analyse it.
● check out some tools.
Its a Saturday morning!!!
I knew..
Motivation
● What if you encounter a linux bin?
● What if you are given a file to reverse and
patch the file?
● What if you have a software to crack?
● What if you know that this file is vulnerable
which can grant you a root access?
What are executables?
● Not a simple text files.
● Complied and linked against the syscall or
WinAPI.
● Has relocatable tables.
● Number of sections to define itself.
What are some binary file formats?
ELF Binary
● Initially developed by Unix System
Laboratories for ABI support for unix os.
● Named as System V Release 4 (SVR4)
● Quickly adopted by different vendors of unix
systems because of its support for
endiannesses and address size.
● Independent of CPU and instruction sets.
● In 1999, it was chosen as a standard binary
file format
ELF Binary Format
● It is just one of the binary format.
● Short abbrevation for Executable and Linkable
Format.
● Mostly linux executables are in ELF Format.
How to detect them? Will See..
ELF Structure
ELF Header
Section Headers
Program Headers
Symbol Table*
readelf -a <file>
About
Linking and
relocation
mmap()
Debuging purpose
It Worked!!
Volunteers Required
1.Candidate
2.Security Guard
3.Hiring Manager
ELF Parsing
1. Examine ELF Header {load_elf_binary()}
2. Loops into Program Header entries to check
for an interpreter and executable stack.
3. Initialize Program headers attributes to a
new program.
4. {flush_old_exec()} It clears up state in the
kernel that refers to prev program.
5. Location of the executable file for the
program is updated at /proc/pid/exe
6. Thread name is created using
{_set_task_comm()}
7. Kernel Memory tracking structure is
created.
ELF Parsing (Cont..)
1. Code loops through PT_LOAD seg and
maps to process addr space.
2.Additional pages are also being loaded such
as virtual dynamic shared object (vDSO) and
empty page for backward compatibility
reasons.
3.Security attributes are being added.
4.Final preparation for running is to setup the
rest of the stack {create_elf_tables()}
Loading ELF
● Check format information of ELF Header.
● Read the ELF Program Header.
● Map all the values of PT_LOAD segment into
new program memory.
● Leave space for interpreter BSS segment
(object or statically allocated var).
Basically Loading ELF
● Base Address
● It helps the code to load into memory.
● When ESP values are assigned to base
address, the execution of the program starts.
● The code segment of the ELF File is loaded
into the memory to execute.
Patching The Imported
Calls!
1. Most programs are dynamically linked.
(shared libs are to be located and linked in
run-time.)
2. The ELF Handler write ELF Interpreter
filename to a new space.
3. Loads the ELF program into memory.
4. ELF Interpreter take care of the linkage
program from the user space and resolves
the program undefined symbols.
5. The interpreter starts the execution of the
new program itself. (AT_ENTRY which holds
the entry point of text seg. which was set
during preparation)
Patching the calls
● Execution begins with ELF interpreter.
● Finds the linkage requirements.
● Loads those shared libs.
● Resolves the undefined symbols.
● Starts the execution of the new program.
Resources
Reversing and Exploiting Resources
● Infecting the Procedure Linkage Table.
● http://phrack.org/issues/56/7.html
● More about ELF
● https://smshaker.files.wordpress.com/2008/0
1/reveng-02.pdf
Thank you!

Más contenido relacionado

La actualidad más candente

OPEN SOURCE SOFTWARE
OPEN SOURCE SOFTWAREOPEN SOURCE SOFTWARE
OPEN SOURCE SOFTWARE
ritajindal2
 
11 scripting languages
11 scripting languages11 scripting languages
11 scripting languages
cherrybear2014
 
14 file handling
14 file handling14 file handling
14 file handling
APU
 
Character stream classes .52
Character stream classes .52Character stream classes .52
Character stream classes .52
myrajendra
 
Various io stream classes .47
Various io stream classes .47Various io stream classes .47
Various io stream classes .47
myrajendra
 

La actualidad más candente (20)

An Introduction to Python Programming
An Introduction to Python ProgrammingAn Introduction to Python Programming
An Introduction to Python Programming
 
C# Common Type System & Common Language Specification
C# Common Type System & Common Language Specification C# Common Type System & Common Language Specification
C# Common Type System & Common Language Specification
 
OPEN SOURCE SOFTWARE
OPEN SOURCE SOFTWAREOPEN SOURCE SOFTWARE
OPEN SOURCE SOFTWARE
 
Analysis of malicious pdf
Analysis of malicious pdfAnalysis of malicious pdf
Analysis of malicious pdf
 
Introduction to python
 Introduction to python Introduction to python
Introduction to python
 
Schizophrenic files v2
Schizophrenic files v2Schizophrenic files v2
Schizophrenic files v2
 
Introduction to phython programming
Introduction to phython programmingIntroduction to phython programming
Introduction to phython programming
 
TechTalk#3: REST
TechTalk#3: RESTTechTalk#3: REST
TechTalk#3: REST
 
Introduction to .NET Programming
Introduction to .NET ProgrammingIntroduction to .NET Programming
Introduction to .NET Programming
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
ODT to Daisy (AEGIS project)
ODT to Daisy (AEGIS project)ODT to Daisy (AEGIS project)
ODT to Daisy (AEGIS project)
 
Cimbalino Toolkit and Multilingual App Toolkit
Cimbalino Toolkit and Multilingual App ToolkitCimbalino Toolkit and Multilingual App Toolkit
Cimbalino Toolkit and Multilingual App Toolkit
 
11 scripting languages
11 scripting languages11 scripting languages
11 scripting languages
 
Vuls & VulsRepo: A Highly Flexible Vulnerability Scanner and Visualizer
Vuls & VulsRepo: A Highly Flexible Vulnerability Scanner and VisualizerVuls & VulsRepo: A Highly Flexible Vulnerability Scanner and Visualizer
Vuls & VulsRepo: A Highly Flexible Vulnerability Scanner and Visualizer
 
Python part1
Python part1Python part1
Python part1
 
14 file handling
14 file handling14 file handling
14 file handling
 
Module 02 ftk imager
Module 02 ftk imagerModule 02 ftk imager
Module 02 ftk imager
 
Dll hijacking
Dll hijackingDll hijacking
Dll hijacking
 
Character stream classes .52
Character stream classes .52Character stream classes .52
Character stream classes .52
 
Various io stream classes .47
Various io stream classes .47Various io stream classes .47
Various io stream classes .47
 

Similar a Null

2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf
cifoxo
 
Linux multiplexing
Linux multiplexingLinux multiplexing
Linux multiplexing
Mark Veltzer
 
Ppt project process migration
Ppt project process migrationPpt project process migration
Ppt project process migration
jaya380
 
Operating system
Operating systemOperating system
Operating system
covapretic
 

Similar a Null (20)

DEF CON 23 - Ryan o'neil - advances in linux forensics with ecfs
DEF CON 23 - Ryan o'neil - advances in linux forensics with ecfsDEF CON 23 - Ryan o'neil - advances in linux forensics with ecfs
DEF CON 23 - Ryan o'neil - advances in linux forensics with ecfs
 
2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf
 
Linux multiplexing
Linux multiplexingLinux multiplexing
Linux multiplexing
 
Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008
 
Ppt project process migration
Ppt project process migrationPpt project process migration
Ppt project process migration
 
File Handling
File HandlingFile Handling
File Handling
 
File Handling
File HandlingFile Handling
File Handling
 
ELF
ELFELF
ELF
 
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
 
Java and its features
Java and its featuresJava and its features
Java and its features
 
Interoperable PHP
Interoperable PHPInteroperable PHP
Interoperable PHP
 
Intro reverse engineering
Intro reverse engineeringIntro reverse engineering
Intro reverse engineering
 
Anatomy of PHP Shells
Anatomy of PHP ShellsAnatomy of PHP Shells
Anatomy of PHP Shells
 
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
 
Getting Started with Python
Getting Started with PythonGetting Started with Python
Getting Started with Python
 
Inferno
InfernoInferno
Inferno
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging Techniques
 
Operating system
Operating systemOperating system
Operating system
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 

Último

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 

Último (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 

Null

  • 1. A Dive Into ELF Binaries Null Mumbai 12rd Jan 2019 By Bhashit Pandya
  • 2. Who am I ● Information Security Consultant ● Scriptologist ● Not a bug hunter!! ● Explorer
  • 3. Today we will: ● ask, why to understand them? ● know about executable files. ● peep into the internals. ● see, how to read and analyse it. ● check out some tools.
  • 4. Its a Saturday morning!!!
  • 6. Motivation ● What if you encounter a linux bin? ● What if you are given a file to reverse and patch the file? ● What if you have a software to crack? ● What if you know that this file is vulnerable which can grant you a root access?
  • 7. What are executables? ● Not a simple text files. ● Complied and linked against the syscall or WinAPI. ● Has relocatable tables. ● Number of sections to define itself. What are some binary file formats?
  • 8. ELF Binary ● Initially developed by Unix System Laboratories for ABI support for unix os. ● Named as System V Release 4 (SVR4) ● Quickly adopted by different vendors of unix systems because of its support for endiannesses and address size. ● Independent of CPU and instruction sets. ● In 1999, it was chosen as a standard binary file format
  • 9. ELF Binary Format ● It is just one of the binary format. ● Short abbrevation for Executable and Linkable Format. ● Mostly linux executables are in ELF Format. How to detect them? Will See..
  • 10. ELF Structure ELF Header Section Headers Program Headers Symbol Table* readelf -a <file> About Linking and relocation mmap() Debuging purpose
  • 11.
  • 14. ELF Parsing 1. Examine ELF Header {load_elf_binary()} 2. Loops into Program Header entries to check for an interpreter and executable stack. 3. Initialize Program headers attributes to a new program. 4. {flush_old_exec()} It clears up state in the kernel that refers to prev program. 5. Location of the executable file for the program is updated at /proc/pid/exe 6. Thread name is created using {_set_task_comm()} 7. Kernel Memory tracking structure is created.
  • 15. ELF Parsing (Cont..) 1. Code loops through PT_LOAD seg and maps to process addr space. 2.Additional pages are also being loaded such as virtual dynamic shared object (vDSO) and empty page for backward compatibility reasons. 3.Security attributes are being added. 4.Final preparation for running is to setup the rest of the stack {create_elf_tables()}
  • 16. Loading ELF ● Check format information of ELF Header. ● Read the ELF Program Header. ● Map all the values of PT_LOAD segment into new program memory. ● Leave space for interpreter BSS segment (object or statically allocated var).
  • 17. Basically Loading ELF ● Base Address ● It helps the code to load into memory. ● When ESP values are assigned to base address, the execution of the program starts. ● The code segment of the ELF File is loaded into the memory to execute.
  • 18. Patching The Imported Calls! 1. Most programs are dynamically linked. (shared libs are to be located and linked in run-time.) 2. The ELF Handler write ELF Interpreter filename to a new space. 3. Loads the ELF program into memory. 4. ELF Interpreter take care of the linkage program from the user space and resolves the program undefined symbols. 5. The interpreter starts the execution of the new program itself. (AT_ENTRY which holds the entry point of text seg. which was set during preparation)
  • 19. Patching the calls ● Execution begins with ELF interpreter. ● Finds the linkage requirements. ● Loads those shared libs. ● Resolves the undefined symbols. ● Starts the execution of the new program.
  • 20. Resources Reversing and Exploiting Resources ● Infecting the Procedure Linkage Table. ● http://phrack.org/issues/56/7.html ● More about ELF ● https://smshaker.files.wordpress.com/2008/0 1/reveng-02.pdf