SlideShare uma empresa Scribd logo
1 de 31
Baixar para ler offline
Automatic Program Analysis
                         with
            Dynamic Binary Instrumentation

                               Sunil Kumar
                     (sunil.kumar@ivizsecurity.com)


http://null.co.in/                                    http://nullcon.net/
#whoami
      •    Research Associate @ iViZ Techno Solutions
      •    MCA(007) from Goa University i.e. GUMCA07.
      •    http://www.linkedin.com/in/sunilkr86
      •    Twitter @_skare; @_ice_22




http://null.co.in/                              http://nullcon.net/
Sections
      •    .program analysis
      •    .dynamic behavior
      •    .dynamic binary instrumentation
      •    .Pin
      •    .puncture
      •    .conclusion



http://null.co.in/                           http://nullcon.net/
program analysis
      • In computer science, program analysis is the
        process of automatically analysing the
        behaviour of computer programs.
                     » http://en.wikipedia.org/wiki/Program_analysis

      • Two approaches:
             – Static Program Analysis.
             – Dynamic Program Analysis.



http://null.co.in/                                                     http://nullcon.net/
program analysis::Static Analysis
      • Static Properties
             – Hash
             – Signature/Byte Patterns
             – Strings
      • Code Analysis
      • Safe because we did not run it?
             – Mostly.
      • Match against known data.

http://null.co.in/                        http://nullcon.net/
program analysis::Static Analysis
      • One side of the coin.
      • May fail if
             – Obfuscated strings.
             – Variants.
             – Code in non-standard sections {.data,…}
             – Self modifying code.
             – Brand new.



http://null.co.in/                                       http://nullcon.net/
program analysis::Dynamic Analysis
      • a.k.a. Behavior Analysis
      • Let Us C (“see”)
      • Dynamic Properties
             – File Operations
             – Registry Operations
             – Network Operations
             – Interaction with other processes…
      • Dangerous unless run in controlled
        environment / sandbox.
http://null.co.in/                                 http://nullcon.net/
instrumentation
      • Instruments that record , analyze, summarize,
        organize, debate in explained information that
        are illustrative, non illustrative hard bound,
        paper bag, jacketed, non jacketed with
        forward introduction, table of content, index,
        that are intended for the enlightenment,
        understanding, enrichment, enhancement,
        education of human brain through sensory
        route of vision...sometimes touch!

http://null.co.in/                              http://nullcon.net/
Dynamic Binary Instrumentation
      • Instrument code just before it runs (Just In
        Time)
      • No need to re-link.
      • Discover code at runtime
      • Handle dynamically generated code.
      • Attach to running process.

                            • [cgo_2010_final.ppt]


http://null.co.in/                                   http://nullcon.net/
• A Dynamic Binary Instrumentation engine
        based on Post-Link Optimizer “Spike”.
      • Developed by Intel Corporation.
      • Oldest available release Pin-2.6-24110 dated
        13/01/2009.
      • Latest release Pin-2.8-39028 dated
        02/02/2011.
      • Alternatives: DynamoRIO, Valgrind

http://null.co.in/                              http://nullcon.net/
Advantages of Pin
      • Provides rich set of APIs in C/C++/Assembly for creating
        instrumentation tools a.k.a PinTools.
      • Multiplatform:
             – Supports IA-32, IA64, Intel64
             – Supports Windows, Linux MacOS
      • Robust:
             –   If you can run it, you can Pin it.
             –   Multithreaded applications
             –   Self modifying code
             –   Support signals and exceptions
      • Efficient
             – Compiler optimization and code inlining.




http://null.co.in/                                           http://nullcon.net/
Advantages of Pin
      • Provides rich set of APIs in C/C++/Assembly for creating
        instrumentation tools a.k.a PinTools.
      • Multiplatform:
             – Supports IA-32, IA64, Intel64
             – Supports Windows, Linux MacOS
      • Robust:
             –   If you can run it, you can Pin it.
             –   Multithreaded applications
             –   Self modifying code
             –   Support signals and exceptions
      • Efficient
             – Compiler optimization and code inlining.
      • Bypass Debug-Protection. (DEMO)


http://null.co.in/                                           http://nullcon.net/
Pin Capabilities
      • Inert code at arbitrary places in executable
        code.
      • Just-In-Time compilation
      • Automatic save/restore registers to avoid
        interference.
      • Dynamic code discovery.
      • Instrument anything ever executed*.


http://null.co.in/                                http://nullcon.net/
Pin Capabilities
      • Inert code at arbitrary places in executable
        code.
      • Just-In-Time compilation
      • Automatic save/restore registers to avoid
        interference.
      • Dynamic code discovery.
      • Instrument anything ever executed*.
                            • (*User Mode)


http://null.co.in/                                http://nullcon.net/
Pin Capabilities
      • Inert code at arbitrary places in executable
        code.
      • Just-In-Time compilation
      • Automatic save/restore registers to avoid
        interference.
      • Dynamic code discovery.
      • Instrument anything ever executed*.
                     If Pin doesn’t have it, you don’t want it

http://null.co.in/                                               http://nullcon.net/
but I do want these too…
      • Kernel Mode
      • Isolated I/O.
      • Handling exceptions of PinTools.




http://null.co.in/                              http://nullcon.net/
What for me but?
      Read                   Write
          Instructions         Instructions
          Operands             Operands
          Operations           Operations
          Methods              Methods
          Parameters           Parameters
          Return Values        Return Values
          Modules


http://null.co.in/                               http://nullcon.net/
Pin Design




http://null.co.in/                http://nullcon.net/
Pin Workflow




http://null.co.in/                  http://nullcon.net/
Pin Instrumentation
                             Modes
      • JIT
             – Using Code-Cache
             – All Instrumentation granularities
             – Flexible
      • Probe
             – Binary modified in place.
             – Limited to Routine level instrumentation.
             – Less flexible.
             – Faster than JIT in some cases.
http://null.co.in/                                         http://nullcon.net/
Pin Instrumentation
                         Granularities
      •    INS
      •    BBL
      •    Trace
      •    RTN
             – Requires symbol support- dbghelp.dll v6.11.1.404.
      • IMG



http://null.co.in/                                        http://nullcon.net/
a Simple PinTool
      #include “pin.H”
      int main(int argc, char *argv[])
      {
           if(PIN_Init(argc,argv))
                     return -1;
           IMG_AddInstrumentFunction(Image, 0);
           PIN_AddFiniFunction(Fini,0);


           PIN_StartProgram();
           return 0;
      }

http://null.co.in/                                http://nullcon.net/
.puncture
      • A PinTool for behavior analysis.
      • 3 Stage:
             – A text file of call logs.
             – XML of categorized events.
             – HTML Report = XML+XSL+CSS
      • Instrumentation Methods
             – Instrumentation at boundary
             – ReplaceSignature

http://null.co.in/                           http://nullcon.net/
Instrumentation at Boundary
      • UnPinned


                      FOO            BAAR
                      BAAR(x,x)          retn




                             *Conceptual View

http://null.co.in/                              http://nullcon.net/
Instrumentation at Boundary
      • Pinned

                       FOO            BAAR


    b4BAAR
                      b4BAAR(W,x,Z)                      afterBAAR
                                      afterBAAR(X,Y,Z)
                        BAAR(x,x)
                                           return




                             *Conceptual View

http://null.co.in/                                           http://nullcon.net/
ReplaceSignature
      • UnPinned


                     FOO            BAAR
                     call BAAR          retn




                            *Conceptual View

http://null.co.in/                             http://nullcon.net/
ReplaceSignature
      • Pinned


               FOO           wrappedBAAR                   BAAR
                call BAAR    PIN_CallApplicationFunction
                                                              retn




                                 *Conceptual View

http://null.co.in/                                                http://nullcon.net/
Logger Requirements
      • 3 Modules
             – Registry Logger       (ADVAPI32.DLL)
             – File Logger           (KERNEL32.DLL)
             – Network Logger        (WS2_32.DLL)
      • Final Output
             – A PinTool : Call Log in plain text.
             – PinParser : RawText => XML}
             – XSLT+CSS+JS for Visualization
      • [DEMO]
http://null.co.in/                                    http://nullcon.net/
.conclusion
      • Although DBI Frameworks like Pin are not
        primarily developed to test and optimize
        performance, code coverage etc., they have
        enough capabilities to be used as software
        security research tool too.




http://null.co.in/                             http://nullcon.net/
Contacts
      • Pin http://www.pintool.org
      • Pin user group pinheades@yahoo-groups
      • Me: badboy16a@gmail.com




http://null.co.in/                          http://nullcon.net/
Thanks…




http://null.co.in/             http://nullcon.net/

Mais conteúdo relacionado

Destaque

Destaque (9)

nullcon 2011 - Building an intelligence analysis systems using open source tools
nullcon 2011 - Building an intelligence analysis systems using open source toolsnullcon 2011 - Building an intelligence analysis systems using open source tools
nullcon 2011 - Building an intelligence analysis systems using open source tools
 
Sthack 2015 - Jonathan "@JonathanSalwan" Salwan - Dynamic Behavior Analysis U...
Sthack 2015 - Jonathan "@JonathanSalwan" Salwan - Dynamic Behavior Analysis U...Sthack 2015 - Jonathan "@JonathanSalwan" Salwan - Dynamic Behavior Analysis U...
Sthack 2015 - Jonathan "@JonathanSalwan" Salwan - Dynamic Behavior Analysis U...
 
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
 
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentation
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentationnullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentation
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentation
 
Covering a function using a Dynamic Symbolic Execution approach
Covering a function using a Dynamic Symbolic Execution approach Covering a function using a Dynamic Symbolic Execution approach
Covering a function using a Dynamic Symbolic Execution approach
 
Введение в динамический анализ приложений на примере Intel Pin
Введение в динамический анализ приложений на примере Intel PinВведение в динамический анализ приложений на примере Intel Pin
Введение в динамический анализ приложений на примере Intel Pin
 
PANDEMONIUM: Automated Identification of Cryptographic Algorithms using Dynam...
PANDEMONIUM: Automated Identification of Cryptographic Algorithms using Dynam...PANDEMONIUM: Automated Identification of Cryptographic Algorithms using Dynam...
PANDEMONIUM: Automated Identification of Cryptographic Algorithms using Dynam...
 
TMPA-2015: The dynamic Analysis of Executable Code in ELF Format Based on Sta...
TMPA-2015: The dynamic Analysis of Executable Code in ELF Format Based on Sta...TMPA-2015: The dynamic Analysis of Executable Code in ELF Format Based on Sta...
TMPA-2015: The dynamic Analysis of Executable Code in ELF Format Based on Sta...
 
Dynamic Binary Instrumentation
Dynamic Binary Instrumentation	Dynamic Binary Instrumentation
Dynamic Binary Instrumentation
 

Semelhante a Nullcon 2011- Behaviour Analysis with DBI

Reversing Microsoft patches to reveal vulnerable code
Reversing Microsoft patches to reveal vulnerable codeReversing Microsoft patches to reveal vulnerable code
Reversing Microsoft patches to reveal vulnerable code
Harsimran Walia
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
OpenBlend society
 
Property and MM with ARC in Objective-C
Property and MM with ARC in Objective-CProperty and MM with ARC in Objective-C
Property and MM with ARC in Objective-C
Yo Yo Chen
 

Semelhante a Nullcon 2011- Behaviour Analysis with DBI (20)

Demystifying Binary Reverse Engineering - Pixels Camp
Demystifying Binary Reverse Engineering - Pixels CampDemystifying Binary Reverse Engineering - Pixels Camp
Demystifying Binary Reverse Engineering - Pixels Camp
 
Reversing Microsoft patches to reveal vulnerable code
Reversing Microsoft patches to reveal vulnerable codeReversing Microsoft patches to reveal vulnerable code
Reversing Microsoft patches to reveal vulnerable code
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon china
 
Reverse Engineering Malware - A Practical Guide
Reverse Engineering Malware - A Practical GuideReverse Engineering Malware - A Practical Guide
Reverse Engineering Malware - A Practical Guide
 
Running trusted payloads with Nomad and Waypoint
Running trusted payloads with Nomad and WaypointRunning trusted payloads with Nomad and Waypoint
Running trusted payloads with Nomad and Waypoint
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
 
Zenoh Tutorial
Zenoh TutorialZenoh Tutorial
Zenoh Tutorial
 
Property and MM with ARC in Objective-C
Property and MM with ARC in Objective-CProperty and MM with ARC in Objective-C
Property and MM with ARC in Objective-C
 
Scalable Automatic Machine Learning with H2O
Scalable Automatic Machine Learning with H2OScalable Automatic Machine Learning with H2O
Scalable Automatic Machine Learning with H2O
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript Programming
 
Static-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxStatic-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptx
 
Qtp - Introduction to synchronization
Qtp -  Introduction to synchronizationQtp -  Introduction to synchronization
Qtp - Introduction to synchronization
 
Dmitriy D1g1 Evdokimov - DBI Intro
Dmitriy D1g1 Evdokimov - DBI IntroDmitriy D1g1 Evdokimov - DBI Intro
Dmitriy D1g1 Evdokimov - DBI Intro
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCON
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Embedded Rust
Embedded RustEmbedded Rust
Embedded Rust
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming Language
 

Mais de Sunil Kumar (7)

Basics of Cryptography
Basics of CryptographyBasics of Cryptography
Basics of Cryptography
 
3Es of Ransomware
3Es of Ransomware3Es of Ransomware
3Es of Ransomware
 
Http2 Security Perspective
Http2 Security PerspectiveHttp2 Security Perspective
Http2 Security Perspective
 
Memory forensics
Memory forensicsMemory forensics
Memory forensics
 
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokdenn|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
 
Jsonp null-meet-02-2015
Jsonp null-meet-02-2015Jsonp null-meet-02-2015
Jsonp null-meet-02-2015
 
Dt5 varenni win_pcapdosdonts
Dt5 varenni win_pcapdosdontsDt5 varenni win_pcapdosdonts
Dt5 varenni win_pcapdosdonts
 

Último

+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@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
+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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Nullcon 2011- Behaviour Analysis with DBI

  • 1. Automatic Program Analysis with Dynamic Binary Instrumentation Sunil Kumar (sunil.kumar@ivizsecurity.com) http://null.co.in/ http://nullcon.net/
  • 2. #whoami • Research Associate @ iViZ Techno Solutions • MCA(007) from Goa University i.e. GUMCA07. • http://www.linkedin.com/in/sunilkr86 • Twitter @_skare; @_ice_22 http://null.co.in/ http://nullcon.net/
  • 3. Sections • .program analysis • .dynamic behavior • .dynamic binary instrumentation • .Pin • .puncture • .conclusion http://null.co.in/ http://nullcon.net/
  • 4. program analysis • In computer science, program analysis is the process of automatically analysing the behaviour of computer programs. » http://en.wikipedia.org/wiki/Program_analysis • Two approaches: – Static Program Analysis. – Dynamic Program Analysis. http://null.co.in/ http://nullcon.net/
  • 5. program analysis::Static Analysis • Static Properties – Hash – Signature/Byte Patterns – Strings • Code Analysis • Safe because we did not run it? – Mostly. • Match against known data. http://null.co.in/ http://nullcon.net/
  • 6. program analysis::Static Analysis • One side of the coin. • May fail if – Obfuscated strings. – Variants. – Code in non-standard sections {.data,…} – Self modifying code. – Brand new. http://null.co.in/ http://nullcon.net/
  • 7. program analysis::Dynamic Analysis • a.k.a. Behavior Analysis • Let Us C (“see”) • Dynamic Properties – File Operations – Registry Operations – Network Operations – Interaction with other processes… • Dangerous unless run in controlled environment / sandbox. http://null.co.in/ http://nullcon.net/
  • 8. instrumentation • Instruments that record , analyze, summarize, organize, debate in explained information that are illustrative, non illustrative hard bound, paper bag, jacketed, non jacketed with forward introduction, table of content, index, that are intended for the enlightenment, understanding, enrichment, enhancement, education of human brain through sensory route of vision...sometimes touch! http://null.co.in/ http://nullcon.net/
  • 9. Dynamic Binary Instrumentation • Instrument code just before it runs (Just In Time) • No need to re-link. • Discover code at runtime • Handle dynamically generated code. • Attach to running process. • [cgo_2010_final.ppt] http://null.co.in/ http://nullcon.net/
  • 10. • A Dynamic Binary Instrumentation engine based on Post-Link Optimizer “Spike”. • Developed by Intel Corporation. • Oldest available release Pin-2.6-24110 dated 13/01/2009. • Latest release Pin-2.8-39028 dated 02/02/2011. • Alternatives: DynamoRIO, Valgrind http://null.co.in/ http://nullcon.net/
  • 11. Advantages of Pin • Provides rich set of APIs in C/C++/Assembly for creating instrumentation tools a.k.a PinTools. • Multiplatform: – Supports IA-32, IA64, Intel64 – Supports Windows, Linux MacOS • Robust: – If you can run it, you can Pin it. – Multithreaded applications – Self modifying code – Support signals and exceptions • Efficient – Compiler optimization and code inlining. http://null.co.in/ http://nullcon.net/
  • 12. Advantages of Pin • Provides rich set of APIs in C/C++/Assembly for creating instrumentation tools a.k.a PinTools. • Multiplatform: – Supports IA-32, IA64, Intel64 – Supports Windows, Linux MacOS • Robust: – If you can run it, you can Pin it. – Multithreaded applications – Self modifying code – Support signals and exceptions • Efficient – Compiler optimization and code inlining. • Bypass Debug-Protection. (DEMO) http://null.co.in/ http://nullcon.net/
  • 13. Pin Capabilities • Inert code at arbitrary places in executable code. • Just-In-Time compilation • Automatic save/restore registers to avoid interference. • Dynamic code discovery. • Instrument anything ever executed*. http://null.co.in/ http://nullcon.net/
  • 14. Pin Capabilities • Inert code at arbitrary places in executable code. • Just-In-Time compilation • Automatic save/restore registers to avoid interference. • Dynamic code discovery. • Instrument anything ever executed*. • (*User Mode) http://null.co.in/ http://nullcon.net/
  • 15. Pin Capabilities • Inert code at arbitrary places in executable code. • Just-In-Time compilation • Automatic save/restore registers to avoid interference. • Dynamic code discovery. • Instrument anything ever executed*. If Pin doesn’t have it, you don’t want it http://null.co.in/ http://nullcon.net/
  • 16. but I do want these too… • Kernel Mode • Isolated I/O. • Handling exceptions of PinTools. http://null.co.in/ http://nullcon.net/
  • 17. What for me but? Read Write  Instructions  Instructions  Operands  Operands  Operations  Operations  Methods  Methods  Parameters  Parameters  Return Values  Return Values  Modules http://null.co.in/ http://nullcon.net/
  • 18. Pin Design http://null.co.in/ http://nullcon.net/
  • 19. Pin Workflow http://null.co.in/ http://nullcon.net/
  • 20. Pin Instrumentation Modes • JIT – Using Code-Cache – All Instrumentation granularities – Flexible • Probe – Binary modified in place. – Limited to Routine level instrumentation. – Less flexible. – Faster than JIT in some cases. http://null.co.in/ http://nullcon.net/
  • 21. Pin Instrumentation Granularities • INS • BBL • Trace • RTN – Requires symbol support- dbghelp.dll v6.11.1.404. • IMG http://null.co.in/ http://nullcon.net/
  • 22. a Simple PinTool #include “pin.H” int main(int argc, char *argv[]) { if(PIN_Init(argc,argv)) return -1; IMG_AddInstrumentFunction(Image, 0); PIN_AddFiniFunction(Fini,0); PIN_StartProgram(); return 0; } http://null.co.in/ http://nullcon.net/
  • 23. .puncture • A PinTool for behavior analysis. • 3 Stage: – A text file of call logs. – XML of categorized events. – HTML Report = XML+XSL+CSS • Instrumentation Methods – Instrumentation at boundary – ReplaceSignature http://null.co.in/ http://nullcon.net/
  • 24. Instrumentation at Boundary • UnPinned FOO BAAR BAAR(x,x) retn *Conceptual View http://null.co.in/ http://nullcon.net/
  • 25. Instrumentation at Boundary • Pinned FOO BAAR b4BAAR b4BAAR(W,x,Z) afterBAAR afterBAAR(X,Y,Z) BAAR(x,x) return *Conceptual View http://null.co.in/ http://nullcon.net/
  • 26. ReplaceSignature • UnPinned FOO BAAR call BAAR retn *Conceptual View http://null.co.in/ http://nullcon.net/
  • 27. ReplaceSignature • Pinned FOO wrappedBAAR BAAR call BAAR PIN_CallApplicationFunction retn *Conceptual View http://null.co.in/ http://nullcon.net/
  • 28. Logger Requirements • 3 Modules – Registry Logger (ADVAPI32.DLL) – File Logger (KERNEL32.DLL) – Network Logger (WS2_32.DLL) • Final Output – A PinTool : Call Log in plain text. – PinParser : RawText => XML} – XSLT+CSS+JS for Visualization • [DEMO] http://null.co.in/ http://nullcon.net/
  • 29. .conclusion • Although DBI Frameworks like Pin are not primarily developed to test and optimize performance, code coverage etc., they have enough capabilities to be used as software security research tool too. http://null.co.in/ http://nullcon.net/
  • 30. Contacts • Pin http://www.pintool.org • Pin user group pinheades@yahoo-groups • Me: badboy16a@gmail.com http://null.co.in/ http://nullcon.net/
  • 31. Thanks… http://null.co.in/ http://nullcon.net/