SlideShare a Scribd company logo
A Dive Into
ELF Binaries
Null Ahmedabad
23rd
Dec 2018
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 sunday 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!

More Related Content

What's hot

Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
AnirudhaGaikwad4
 
An Introduction to Python Programming
An Introduction to Python ProgrammingAn Introduction to Python Programming
An Introduction to Python Programming
Morteza Zakeri
 
Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...
Alexey Diyan
 
Jayse farrell resume
Jayse farrell resumeJayse farrell resume
Jayse farrell resume
Jayse Farrell
 
Schizophrenic files v2
Schizophrenic files v2Schizophrenic files v2
Schizophrenic files v2
Ange Albertini
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
Vanessa Rene
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
ManishJha237
 
An Introduction to ANTLR
An Introduction to ANTLRAn Introduction to ANTLR
An Introduction to ANTLR
Morteza Zakeri
 
TechTalk#3: REST
TechTalk#3: RESTTechTalk#3: REST
TechTalk#3: REST
DA-14
 
Python Assignment Help
Python Assignment HelpPython Assignment Help
Python Assignment Help
Jacob William
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Agung Wahyudi
 
An Overview of LLVM Link Time Optimization
An Overview of LLVM Link Time Optimization An Overview of LLVM Link Time Optimization
An Overview of LLVM Link Time Optimization
Vivek Pandya
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testing
Knoldus Inc.
 
Introduction to python
 Introduction to python Introduction to python
Introduction to python
Learnbay Datascience
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
Kavitha713564
 
Dll hijacking
Dll hijackingDll hijacking
Dll hijacking
antitree
 
Python Pants Build System for Large Codebases
Python Pants Build System for Large CodebasesPython Pants Build System for Large Codebases
Python Pants Build System for Large Codebases
Angad Singh
 

What's hot (20)

Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
An Introduction to Python Programming
An Introduction to Python ProgrammingAn Introduction to Python Programming
An Introduction to Python Programming
 
Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...
 
Jayse farrell resume
Jayse farrell resumeJayse farrell resume
Jayse farrell resume
 
Schizophrenic files v2
Schizophrenic files v2Schizophrenic files v2
Schizophrenic files v2
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
An Introduction to ANTLR
An Introduction to ANTLRAn Introduction to ANTLR
An Introduction to ANTLR
 
TechTalk#3: REST
TechTalk#3: RESTTechTalk#3: REST
TechTalk#3: REST
 
Python Assignment Help
Python Assignment HelpPython Assignment Help
Python Assignment Help
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
An Overview of LLVM Link Time Optimization
An Overview of LLVM Link Time Optimization An Overview of LLVM Link Time Optimization
An Overview of LLVM Link Time Optimization
 
PHP Internals
PHP InternalsPHP Internals
PHP Internals
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testing
 
Introduction to python
 Introduction to python Introduction to python
Introduction to python
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
 
Module 02 ftk imager
Module 02 ftk imagerModule 02 ftk imager
Module 02 ftk imager
 
Dll hijacking
Dll hijackingDll hijacking
Dll hijacking
 
Python Pants Build System for Large Codebases
Python Pants Build System for Large CodebasesPython Pants Build System for Large Codebases
Python Pants Build System for Large Codebases
 

Similar to A Dive Into ELF Binaries

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
Felipe Prado
 
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 multiplexingMark Veltzer
 
Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008
guestd9065
 
Ppt project process migration
Ppt project process migrationPpt project process migration
Ppt project process migration
jaya380
 
File Handling
File HandlingFile Handling
File Handling
AlgeronTongdoTopi
 
File Handling
File HandlingFile Handling
File Handling
AlgeronTongdoTopi
 
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)
Ahmed El-Arabawy
 
Windows internals Essentials
Windows internals EssentialsWindows internals Essentials
Windows internals Essentials
John Ombagi
 
Interoperable PHP
Interoperable PHPInteroperable PHP
Interoperable PHP
weltling
 
Linux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of TechnologyLinux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of Technology
Nugroho Gito
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
Emertxe Information Technologies Pvt Ltd
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
YourHelper1
 
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)
Ahmed El-Arabawy
 
Ganesh naik linux_kernel_internals
Ganesh naik linux_kernel_internalsGanesh naik linux_kernel_internals
Ganesh naik linux_kernel_internals
Ganesh Naik
 
Ganesh naik linux_kernel_internals
Ganesh naik linux_kernel_internalsGanesh naik linux_kernel_internals
Ganesh naik linux_kernel_internals
nullowaspmumbai
 
Operating system
Operating systemOperating system
Operating system
covapretic
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
WondimuBantihun1
 

Similar to A Dive Into ELF Binaries (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
 
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)
 
Windows internals Essentials
Windows internals EssentialsWindows internals Essentials
Windows internals Essentials
 
ELF
ELFELF
ELF
 
Interoperable PHP
Interoperable PHPInteroperable PHP
Interoperable PHP
 
Linux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of TechnologyLinux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of Technology
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
 
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)
 
Ganesh naik linux_kernel_internals
Ganesh naik linux_kernel_internalsGanesh naik linux_kernel_internals
Ganesh naik linux_kernel_internals
 
Ganesh naik linux_kernel_internals
Ganesh naik linux_kernel_internalsGanesh naik linux_kernel_internals
Ganesh naik linux_kernel_internals
 
Intro reverse engineering
Intro reverse engineeringIntro reverse engineering
Intro reverse engineering
 
Operating system
Operating systemOperating system
Operating system
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 

Recently uploaded

bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
RicletoEspinosa1
 
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptxTOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
nikitacareer3
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 

Recently uploaded (20)

bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
 
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptxTOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 

A Dive Into ELF Binaries

  • 1. A Dive Into ELF Binaries Null Ahmedabad 23rd Dec 2018 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 sunday 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