南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Taint Analysis

Taint Analysis
Taint Analysis

Contents Pin Tool Introduction Instrumentation granularity Trace instrumentation Example >Other important features Dynamic Taint Analysis Introduction > Classify of taint analysis Taint procedure Taint analysis for security 2
Contents 2 • Pin Tool ➢ Introduction ➢ Instrumentation granularity ➢ Trace instrumentation ➢ Example ➢ Other important features • Dynamic Taint Analysis ➢ Introduction ➢ Classify of taint analysis ➢ Taint procedure ➢ Taint analysis for security

Pin tools 3
Pin tools 3

Instrumentation A technique that inserts code into a program to collect run- time information Program analysis:performance profiling,error detection,capture replay Architectural study:processor and cache simulation,trace collection Source-Code Instrumentation Static Binary Instrumentation Dynamic Binary Instrumentation Instrumentcode just before itruns (Just In Time-JIT) No need to recompile or re-link Discover code at runtime Handle dynamically-generated code-Attach to running processes 4
Instrumentation • A technique that inserts code into a program to collect runtime information ➢ Program analysis : performance profiling, error detection, capture & replay ➢ Architectural study : processor and cache simulation, trace collection • Source-Code Instrumentation • Static Binary Instrumentation • Dynamic Binary Instrumentation ➢ Instrument code just before it runs ( Just In Time - JIT) ✓ No need to recompile or re-link ✓ Discover code at runtime ✓ Handle dynamically-generated code -Attach to running processes 4

Pin Instrumentation Capability Use Pin APIs to write PinTools that: Replace application functions with your own Call the original application function from within your replacementfunction Fully examine any application instruction,and insert a call to your instrumenting function to be executed whenever that instruction executes Pass parameters to your instrumenting function from a large set of supported parameters Register values(including IP),Register values by reference(for modification) Memory addresses read/written by the instruction Full register context Track function calls including syscalls and examine/change arguments Track application threads ·Interceptsignals .Instrumenta process tree 5 .Many other capabilities
Pin Instrumentation Capability Use Pin APIs to write PinTools that: • Replace application functions with your own ➢ Call the original application function from within your replacement function • Fully examine any application instruction, and insert a call to your instrumenting function to be executed whenever that instruction executes ➢ Pass parameters to your instrumenting function from a large set of supported parameters ✓ Register values (including IP), Register values by reference (for modification) ✓ Memory addresses read/written by the instruction ✓ Full register context ✓ …… • Track function calls including syscalls and examine/change arguments • Track application threads • Intercept signals • Instrument a process tree • Many other capabilities... 5

Modifying Program Behavior Pin allows you not only to observe but also change program behavior Ways to change program behavior: Add/delete instructions Change register values > Change control flow Change memory values 6
Modifying Program Behavior Pin allows you not only to observe but also change program behavior • Ways to change program behavior: ➢ Add/delete instructions ➢ Change register values ➢ Change control flow ➢ Change memory values 6

Pin Invocation Launcher Process ● ● pin.exe -t inscountung26830pt.txt 8 PIN.EXE ● ● ● cation instructions executed, ● ● 上ncprints Gountatcend ● Launcher the eude ● et ● ● icode the into.the Coue Cache ●●●●●●●● kecute Jltfed code Boot Routine inscount.dll Application Process Data: ● First firstApplp, PIN.LIB “nscount.dlI app ● PINVM.DLL Decoder Encoder Code Cache ● Application ● Code and Data ● ● ● System Call Event Thread Dispatcher Dispatcher Dispatcher NTDLL.DLL app lp of 。●.Trace's。● target Windows kernel
Starting at first application IP Read a Trace from Application Code Jit it, adding instrumentation code from inscount.dll Encode the trace into the Code Cache Execute Jitted code Execution of Trace ends Call into PINVM.DLL to Jit next trace Pass in app IP of Trace’s target Source Trace exit branch is modified to directly branch to Destination Trace Pin Invocation gzip.exe input.txt Application Code and Data Application Process System Call Dispatcher Event Dispatcher Thread Dispatcher PINVM.DLL inscount.dll PIN.LIB Code Cache NTDLL.DLL Windows kernel CreateProcess (gzip.exe, input.txt, suspended) Launcher PIN.EXE Launcher Process Boot Routine + Data: firstAppIp, “Inscount.dll” Load PINVM.DLL Inject Pin BootRoutine and Data into application Load inscount.dll and run its main() Start PINVM.DLL running (firstAppIp, “inscount.dll”) pin.exe –t inscount.dll Count 258743109 – gzip.exe input.txt PinTool that counts application instructions executed, prints Count at end Resume at BootRoutine First app IP app Ip of Trace’s target Read a Trace from Application Code Jit it, adding instrumentation code from inscount.dll Encode the jitted trace into the Code Cache WriteProcessMemory(BootRoutine, BootData) SetContext(BootRoutineIp) GetContext(&firstAppIp) Decoder Encoder

Instrumentation Granularity Instruction instrumentation ·Basic block A sequence of instructions terminated at a control-flow changing instruction Single entry,single exit Trace instrumentation A sequence of basic blocks terminated at an unconditional control-flow changing instruction Single entry,multiple exits Routine instrumentation Image instrumentation 8
Instrumentation Granularity • Instruction instrumentation • Basic block ➢ A sequence of instructions terminated at a control-flow changing instruction ➢ Single entry, single exit • Trace instrumentation ➢ A sequence of basic blocks terminated at an unconditional control-flow changing instruction ➢ Single entry, multiple exits • Routine instrumentation • Image instrumentation 8

Trace sub $Oxff,%edx cmp %esi,%edx jle mov $0x1,%edi add $0x10,%eax jmp 1 Trace,2 BBs,6 insts 9
Trace 9

Example:Instruction Counting Tool #include "pin.h" UINT64 icount 0; void docount ()icount++; Execution time routine void Instruction(INS ins,void *v) Jitting time routine:Pin CallBack INS InsertCall(ins,IPOINT BEFORE, (AFUNPTR)docount,IARG END); void Fini(INT32 code,void *v) std::cerr <"Count "<icount <endl; int main(int argc,char argv[]) PIN Init (argc,argv); INS AddInstrumentFunction(Instruction,0); PIN AddFiniFunction(Fini,0); PIN StartProgram();//Never returns return 0; 10
Example: Instruction Counting Tool 10
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Program Analysis - Data Flow Analysis.pptx
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Control Flow - Representation, Extraction and Applications.pptx
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Return-Orinted Programming(ROP Attack).ppt
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Format String Attacks.pptx
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Control Flow Integrity.pptx
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Redundant dynamic Canary.ppt
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Defense against Control Flow Hijack Defense - StackGuard, DEP, and ASLR.pdf
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Buffer Overflow Attack.pdf
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Software Security Overview.pptx
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Introduction to the course.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第9章 入侵检测系统.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第8章 抗恶意软件.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第7章 网络边防.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第6章 无线网安全性.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第5章 实用的网络安全协议.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第3章 公钥密码体系与密钥管理.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第4章 数据认证.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第2章 数据加密算法.pdf
- 海南大学:《网络安全技术》课程教学资源(课件讲稿)第1章 网络安全概论(齐琦).pdf
- 电子科技大学:《数字图像处理》课程教学资源(课件讲稿)第十章 图像分割.pdf
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Use-after-free.pptx
- 南京大学:《软件安全 Software Security》课程教学资源(PPT课件讲稿)Byzantine Generals Problem.ppt
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Finite Automata.pptx
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Context Free Grammar.pptx
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Regular Expression.pptx
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Pushdown Automata.pptx
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Properties of CFL(The Pumping Lemma for CFL’s).pptx
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Turing Machine.pptx
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Transition System.pptx
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Petri Net.pptx
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Timed Automata.ppt
- 南京大学:《形式语言与自动机 Formal Languages and Automata》课程教学资源(PPT课件讲稿)Decidability, Complexity(P, NP, NPC and related).pptx
- 《大数据 Big Data》课程教学资源(参考文献)Learning to Hash for Big Data Retrieval and Mining(南京大学:李武军).pdf
- 《大数据 Big Data》课程教学资源(参考文献)Learning to Hash for Big Data Retrieval and Mining(南京大学:李武军).pdf
- 《大数据 Big Data》课程教学资源(参考文献)大数据机器学习 Big Data Machine Learning.pdf
- 《大数据 Big Data》课程教学资源(参考文献)Learning to Hash for Big Data.pdf
- 《大数据 Big Data》课程教学资源(参考文献)Learning to Hash for Big Data.pdf
- 《大数据 Big Data》课程教学资源(参考文献)大数据机器学习 Big Data Machine Learning.pdf
- 《大数据 Big Data》课程教学资源(参考文献)Learning to Hash for Big Data - A Tutorial.pdf
- 《大数据 Big Data》课程教学资源(参考文献)Parallel and Distributed Stochastic Learning - Towards Scalable Learning for Big Data Intelligence(南京大学:李武军).pdf