SlideShare une entreprise Scribd logo
1  sur  12
Télécharger pour lire hors ligne
C for Linux

          Session 3

BY:
      Eng.Ahmed Teirelbar
        Software Engineer
        Shuja' Consulting
gdb Basics
    -g
●


    In execution
●


         run
    ●


         continue
    ●


         step
    ●



         breakpoint
    ●


         variables
    ●


         directives
    ●


         execute code
    ●
Pointer Concepts

    An array is a pointer to the first element
●


    Pointer subscript access
●


    Scope issues – Back to the stack picture
●


    NULL pointer
●
Pointers
    SEGV
●


    Memory overwrites – “but it worked before!!!”
●


    null termination issues
●


    Core dump
●
Debugging and Detection
    More gdb
●


        dumping memory
    ●


        Casting
    ●


        Watchpoints
    ●



    Detection
●


        Sanity checks
    ●


        Macros with sizeof
    ●


        Magic numbers in Structures
    ●
Allocation and Memory
    The Heap data structure
●



    Back to the process picture
●



    Very brief overview of system memory allocation
●


        brk()
    ●



        Granularity & page size
    ●



        Allocation algorithms
    ●



        Block data
    ●



        Alignment
    ●


        Swapping
    ●
Memory Leaks
    What is it?
●


    Why do we care? what is the OOM killer?
●


    Detection
●


        Your own code, macros
    ●


        top and /proc/meminfo
    ●


        Valgrind and profiling
    ●


        http://valgrind.org/
    ●


        http://www.advancedlinuxprogramming.com/ (Appendix A.2)
    ●
Structures/Unions in Memory
    Alignment
●


        Sizeof struct, union, pointer
    ●



    Casting
●


    Traversals of pointers
●
Functions & the Stack
    Overview
●


        Base offset/Frame pointer
    ●



        RET
    ●



        Local variables
    ●



    objdump
●



    gdb & stack trace
●


        where
    ●


        up/down
    ●



        Huge for core dumps
    ●



    Recursion & your stack
●
The Infamous Stack Overflow Attack

    Overview of Concept
●


    How it works?
●


        The vulnerability
    ●


        Integrate the whole stack picture
    ●


        How you place the exploiting code –high level
    ●



    How do you protect against it?
●


    Heap overflow
●
Structures w/Functions:
                     Data Abstraction
    Higher level of operation
●


        Object and Interface
    ●



    Modularity of a defined interface
●


        Easier implementation per piece
    ●



        Unit test
    ●



        Module-level behavioral Changes
    ●
Data Abstraction Cont'd
    Data Hiding
●


        Extension of type
    ●



        Type-level behavioral changes (decoupling)
    ●



    Can be taken too far – be sensible
●

Contenu connexe

Similaire à sysprog3 Part2

Data Science Challenge presentation given to the CinBITools Meetup Group
Data Science Challenge presentation given to the CinBITools Meetup GroupData Science Challenge presentation given to the CinBITools Meetup Group
Data Science Challenge presentation given to the CinBITools Meetup Group
Doug Needham
 
My Sql And Search At Craigslist
My Sql And Search At CraigslistMy Sql And Search At Craigslist
My Sql And Search At Craigslist
MySQLConference
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
MySQLConference
 
Web 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web AppsWeb 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web Apps
adunne
 

Similaire à sysprog3 Part2 (20)

sysprog2 Part2
sysprog2 Part2sysprog2 Part2
sysprog2 Part2
 
Accelerometer and Open GL
Accelerometer and Open GLAccelerometer and Open GL
Accelerometer and Open GL
 
Accelerometer and OpenGL
Accelerometer and OpenGLAccelerometer and OpenGL
Accelerometer and OpenGL
 
Os Wilhelm
Os WilhelmOs Wilhelm
Os Wilhelm
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With Terracotta
 
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
 
Qcon
QconQcon
Qcon
 
Qure Tech Presentation
Qure Tech PresentationQure Tech Presentation
Qure Tech Presentation
 
Using ScyllaDB with JanusGraph for Cyber Security
Using ScyllaDB with JanusGraph for Cyber SecurityUsing ScyllaDB with JanusGraph for Cyber Security
Using ScyllaDB with JanusGraph for Cyber Security
 
Data Science Challenge presentation given to the CinBITools Meetup Group
Data Science Challenge presentation given to the CinBITools Meetup GroupData Science Challenge presentation given to the CinBITools Meetup Group
Data Science Challenge presentation given to the CinBITools Meetup Group
 
Cloudera Data Science Challenge
Cloudera Data Science ChallengeCloudera Data Science Challenge
Cloudera Data Science Challenge
 
Computer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming IComputer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming I
 
My Sql And Search At Craigslist
My Sql And Search At CraigslistMy Sql And Search At Craigslist
My Sql And Search At Craigslist
 
All The Little Pieces
All The Little PiecesAll The Little Pieces
All The Little Pieces
 
Workflowsim escience12
Workflowsim escience12Workflowsim escience12
Workflowsim escience12
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
 
[CB20] Vulnerabilities of Machine Learning Infrastructure by Sergey Gordeychik
[CB20] Vulnerabilities of Machine Learning Infrastructure by Sergey Gordeychik[CB20] Vulnerabilities of Machine Learning Infrastructure by Sergey Gordeychik
[CB20] Vulnerabilities of Machine Learning Infrastructure by Sergey Gordeychik
 
Web 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web AppsWeb 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web Apps
 
Driver Debugging Basics
Driver Debugging BasicsDriver Debugging Basics
Driver Debugging Basics
 
PPW2007 - Continuity Project
PPW2007 - Continuity ProjectPPW2007 - Continuity Project
PPW2007 - Continuity Project
 

Plus de Ahmed Mekkawy

Virtualization Techniques & Cloud Compting
Virtualization Techniques & Cloud ComptingVirtualization Techniques & Cloud Compting
Virtualization Techniques & Cloud Compting
Ahmed Mekkawy
 
A look at computer security
A look at computer securityA look at computer security
A look at computer security
Ahmed Mekkawy
 
Networking in Gnu/Linux
Networking in Gnu/LinuxNetworking in Gnu/Linux
Networking in Gnu/Linux
Ahmed Mekkawy
 

Plus de Ahmed Mekkawy (20)

Encrypted Traffic in Egypt - an attempt to understand
Encrypted Traffic in Egypt - an attempt to understandEncrypted Traffic in Egypt - an attempt to understand
Encrypted Traffic in Egypt - an attempt to understand
 
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
 
OpenData for governments
OpenData for governmentsOpenData for governments
OpenData for governments
 
Infrastructure as a Code
Infrastructure as a Code Infrastructure as a Code
Infrastructure as a Code
 
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحةشركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
 
Everything is a Game
Everything is a GameEverything is a Game
Everything is a Game
 
Why Cloud Computing has to go the FOSS way
Why Cloud Computing has to go the FOSS wayWhy Cloud Computing has to go the FOSS way
Why Cloud Computing has to go the FOSS way
 
FOSS Enterpreneurship
FOSS EnterpreneurshipFOSS Enterpreneurship
FOSS Enterpreneurship
 
Intro to FOSS & using it in development
Intro to FOSS & using it in developmentIntro to FOSS & using it in development
Intro to FOSS & using it in development
 
FOSS, history and philosophy
FOSS, history and philosophyFOSS, history and philosophy
FOSS, history and philosophy
 
Virtualization Techniques & Cloud Compting
Virtualization Techniques & Cloud ComptingVirtualization Techniques & Cloud Compting
Virtualization Techniques & Cloud Compting
 
A look at computer security
A look at computer securityA look at computer security
A look at computer security
 
Networking in Gnu/Linux
Networking in Gnu/LinuxNetworking in Gnu/Linux
Networking in Gnu/Linux
 
Foss Movement In Egypt
Foss Movement In EgyptFoss Movement In Egypt
Foss Movement In Egypt
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
 
Sysprog 15
Sysprog 15Sysprog 15
Sysprog 15
 
Sysprog 9
Sysprog 9Sysprog 9
Sysprog 9
 
Sysprog 12
Sysprog 12Sysprog 12
Sysprog 12
 
Sysprog 14
Sysprog 14Sysprog 14
Sysprog 14
 
Sysprog 11
Sysprog 11Sysprog 11
Sysprog 11
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

sysprog3 Part2

  • 1. C for Linux Session 3 BY: Eng.Ahmed Teirelbar Software Engineer Shuja' Consulting
  • 2. gdb Basics -g ● In execution ● run ● continue ● step ● breakpoint ● variables ● directives ● execute code ●
  • 3. Pointer Concepts An array is a pointer to the first element ● Pointer subscript access ● Scope issues – Back to the stack picture ● NULL pointer ●
  • 4. Pointers SEGV ● Memory overwrites – “but it worked before!!!” ● null termination issues ● Core dump ●
  • 5. Debugging and Detection More gdb ● dumping memory ● Casting ● Watchpoints ● Detection ● Sanity checks ● Macros with sizeof ● Magic numbers in Structures ●
  • 6. Allocation and Memory The Heap data structure ● Back to the process picture ● Very brief overview of system memory allocation ● brk() ● Granularity & page size ● Allocation algorithms ● Block data ● Alignment ● Swapping ●
  • 7. Memory Leaks What is it? ● Why do we care? what is the OOM killer? ● Detection ● Your own code, macros ● top and /proc/meminfo ● Valgrind and profiling ● http://valgrind.org/ ● http://www.advancedlinuxprogramming.com/ (Appendix A.2) ●
  • 8. Structures/Unions in Memory Alignment ● Sizeof struct, union, pointer ● Casting ● Traversals of pointers ●
  • 9. Functions & the Stack Overview ● Base offset/Frame pointer ● RET ● Local variables ● objdump ● gdb & stack trace ● where ● up/down ● Huge for core dumps ● Recursion & your stack ●
  • 10. The Infamous Stack Overflow Attack Overview of Concept ● How it works? ● The vulnerability ● Integrate the whole stack picture ● How you place the exploiting code –high level ● How do you protect against it? ● Heap overflow ●
  • 11. Structures w/Functions: Data Abstraction Higher level of operation ● Object and Interface ● Modularity of a defined interface ● Easier implementation per piece ● Unit test ● Module-level behavioral Changes ●
  • 12. Data Abstraction Cont'd Data Hiding ● Extension of type ● Type-level behavioral changes (decoupling) ● Can be taken too far – be sensible ●