Protecting binaries. Andrew Griffiths

Similar documents
T Jarkko Turkulainen, F-Secure Corporation

Reversing. Time to get with the program

The X86 Assembly Language Instruction Nop Means

Who am I? I m a python developer who has been working on OpenStack since I currently work for Aptira, who do OpenStack, SDN, and orchestration

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

The Rise and Fall of

Advanced Systems Security: Ordinary Operating Systems

The Stack, Free Store, and Global Namespace

Obfuscating Transformations. What is Obfuscator? Obfuscation Library. Obfuscation vs. Deobfuscation. Summary

A Security Microcosm Attacking and Defending Shiva

Lecture Notes for 04/04/06: UNTRUSTED CODE Fatima Zarinni.

Linked Lists. What is a Linked List?

Hacking: Ultimate Guide To Ethical Hacking For Beginners PDF

4. Jump to *RA 4. StackGuard 5. Execute code 5. Instruction Set Randomization 6. Make system call 6. System call Randomization

Virtual Memory. ICS332 Operating Systems

Embedded Linux Day 2

UKNova s Getting Connectable Guide

MSRPC Heap Overflow Part II

CS354 gdb Tutorial Written by Chris Feilbach

P1_L3 Operating Systems Security Page 1

Software Security II: Memory Errors - Attacks & Defenses

What is a security measure? Types of security measures. What is a security measure? Name types of security measures

Exploiting the MSRPC Heap Overflow Part I

Inline Reference Monitoring Techniques

Lesson4:CreatinganInterfaceandChecklistService

Proving Dekker with SPIN and PROMELA

Kernel Self Protection

Topic Notes: Building Memory

CS197U: A Hands on Introduction to Unix

Form 4 ICT Literacy Modules Methodist Boys School Kuala Lumpur 1.0 PROCESSING DATA

Information Security II Prof. Kamakoti Department of Computer Science and Engineering Indian Institute of Technology, Madras

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Economies of Scale in Hacking Dave Aitel Immunity

ECE 571 Advanced Microprocessor-Based Design Lecture 9

Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

The Context of Cryptography. Ramki Thurimella

MITOCW watch?v=i0psvvky-44

(a) Which of these two conditions (high or low) is considered more serious? Justify your answer.

Meltdown and Spectre - understanding and mitigating the threats

.NET Secure Coding for Client-Server Applications 4-Day hands on Course. Course Syllabus

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

My malloc: mylloc and mhysa. Johan Montelius HT2016

Blackhat USA 2017 Tools Arsenal - AntiVirus Evasion Tool (AVET)

MITOCW watch?v=9h6muyzjms0

Integrated Software Environment. Part 2

About unchecked management SMM & UEFI. Vulnerability. Patch. Conclusion. Bruno Pujos. July 16, Bruno Pujos

Internet infrastructure

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions?

Low-Level Essentials for Understanding Security Problems Aurélien Francillon

Survey of Cyber Moving Targets. Presented By Sharani Sankaran

Using Tags in Meetings Guidance for including Tags as part of your meetings

Video Game Security. Carter Jones

CTF Workshop. Crim Synopsys, Inc. 1

Important From Last Time

Page 1. Today. Important From Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right?

RIS shading Series #2 Meet The Plugins

Inject malicious code Call any library functions Modify the original code

SECTION 2: HW3 Setup.

Boot Camp. Dave Eckhardt Bruce Maggs

How Rust is Tilde s Competitive Advantage

COMP 3500 Introduction to Operating Systems Project 5 Virtual Memory Manager

Note Takers: Chau, Bao Kham (cs162-bb) and Quang Tran (cs162-bc) Topic: Real time system

Important From Last Time

Guide - The limitations in screen layout using the Item Placement Tool

EasyHook: Down & Dirty with Microsoft Windows

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Building Memory

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

Practical 2: Ray Tracing

Engineering Robust Server Software

Building a Multi-Language Interpreter Engine

Computer Architecture Prof. Mainak Chaudhuri Department of Computer Science & Engineering Indian Institute of Technology, Kanpur

How to Break Software by James Whittaker

ZFS STORAGE POOL LAYOUT. Storage and Servers Driven by Open Source.

BEGINNER PHP Table of Contents

Inside Code Virtualizer

Visual Basic Primer A. A. Cousins

COSC 2P95 Lab 9 Signals, Mutexes, and Threads

Executing Legacy Applications on a Java Operating System

ECE 571 Advanced Microprocessor-Based Design Lecture 7

The Case for Office 365 Backup. Uncovering critical reasons why organizations need to backup Office 365 data

Firewalls Network Security: Firewalls and Virtual Private Networks CS 239 Computer Software March 3, 2003

Cyber Moving Targets. Yashar Dehkan Asl

Speech 2 Part 2 Transcript: The role of DB2 in Web 2.0 and in the IOD World

Buffer Overflows Defending against arbitrary code insertion and execution

Introduction to Cloud Computing and Virtualization. Mayank Mishra Sujesha Sudevalayam PhD Students CSE, IIT Bombay

Reserve Engineering & Buffer Overflow Attacks. Tom Chothia Computer Security, Lecture 17

Blitz2D Newbies: Definitive Guide to Types by MutteringGoblin

CSE 380 Computer Operating Systems

Introducing C# After this discussion, we'll move on to a simple description of C# itself, including its origins and similarities to C++.

Lecture 3 - Passwords and Authentication

Reliable programming

Secure Programming Lecture 1: Introduction

Android Programming Family Fun Day using AppInventor

Attacks Against Websites 3 The OWASP Top 10. Tom Chothia Computer Security, Lecture 14

An introduction to the Katsuni theorem and its application to sandboxing and software emulation. Jonathan Brossard (Toucan System)

Chapter 1 Introduction

Software Design and Analysis for Engineers

Secure Programming Lecture 3: Memory Corruption I (Stack Overflows)

crush malware that hasn't even been seen before. Alright, so not really like traditional antivirus. Cleans an already infected Mac, 14- day Premium

Lecture 1: Overview

Transcription:

Protecting binaries Andrew Griffiths andrewg@felinemenace.org

Introduction This presentation is meant to be useful for people of all skill levels. Hopefully everyone will get something out of this presentation. This talk focuses on strategies, and mindsets, not products. Technical details will mainly refer to Linux unless otherwise specified, although the concepts are portable to other operating systems.

Defence in depth Determining the threat model / what problems you're trying to solve Casual copying Determining who leaked a copy Determined crackers Determining what measures will be suitable to avoid problems, and be feasible to implement Code obfuscation Watermarking Licensing types

Defence in depth (cont) Defence requires you to think like an attacker, and how to best defend them from offence. Offensive measures? Chang Yu said: "Knowing the enemy enables you to take the offensive, knowing yourself enables you to stand on the defensive." He adds: "Attack is the secret of defense; defense is the planning of an attack." As opposed to just displaying a message when something has gone bad, wouldn't it be better to mislead an attacker and waste some of their time/resources?

Defence in depth (cont) Standard implementations Can usually be analysed separately Lends itself to individual pieces being analysed, without impacting the rest of the binary. Idealistic defence in depth for binaries When pieces are removed, it impacts the correct operation of other parts of the binary. Layers are tightly integrated so that everything must be considered at once. Assumes layers will be broken.

Watermarking Why watermark? Watermarking does not prevent against fraud. Fragile vs Robust watermarks Visible vs Invisible watermarks Watermarking values Counter Code constructs / code ordering Data initialisation values Tamperproofing?

Obfuscation Source code Assembly level Junk code? Not unlike what viruses have contained (f.e Junkcomp) Not really applicable in this case. (Preventing signatures / on access detection) Various aspects to obfuscation Code layout Data obfuscation Control obfuscation Preventative

Obfuscation (cont) Potency How hard is it to analyse by a human Resiliency Protection against: Cost Attackers effort to write the un-obfuscator The program attempting to un-obfuscater What impact does implementing the measures involve?

Obfuscation (cont) Control flow obfuscation Opaque conditionals Used to mislead attackers, increase their workload, decrease what can be done automatically Control flow Absolutely trivial example: xor eax, eax ; jnz 0xaddy Usually a lot more involved. rewriting instruction context Determine context of the registers If they're important to that section of code you're analysing The relationship to other pieces of nearby code

Converting static data to functions Obfuscation (cont) Insert new instructions that modify the unimportant registers / memory locations Usually there is just mov's, shifts, add / sub etc. If you add a section in memory and load/store from it, the analysis tools now have to do a lot more work in order to remove those constructs, if its possible at all (depending on how its implemented). This is because the program now looks a lot more like a proper program behaviour. Usually done before the program is compiled completely (ie, operates on object files). Makes analysis by humans harder Loops Data obfuscation

Obfuscation (cont) Inserting more cross-references Inserting new functions into object orientated classes Adding new data to structures, loading / storing to it. Convert variables to classes, and have functions which do the various operators on it, such as multiplication, addition. Code layout obfuscation Basic blocks Re-ordering of instructions Independent obfuscation Blocks need to converge in the end

Obfuscation (cont) Register usage example mov eax, 1 mov ebx, 2 add eax, ebx Code flow reduction Switch tables Disadvantages to obfuscation Performance impact Time to implement mov eax, 1 and mov ebx, 2 would be the first basic block. add eax, ebx would be the second basic block.

License scheme implementation Effort needed to implement If they are not meant to have certain pieces of code, don't compile it in. If they aren't meant to have some data, don't include it in the distribution. Combine the license aspect with the program aspect, so that attempting to break the license implementation has flow on effects to the correct operation with the program. Use license information for logic and data choices.

License schemes (cont) Small checksums can be used to ensure people have not mistyped a license code without giving anything away about the correctness of the key. In general, do not sanity-check the license data, just use it for it's respective operations. Think like an attacker, find your weak spots, and patch them.

Virtual Machines What are they? Java,.NET assembly (CLR) Either: Completely byte code driven Or translates to CPU for native execution (JIT) Increases analysis time, as they have to fully understand what the VM is doing. A lot of custom development may need to be done, depending what you want to implement. Disadvantages

Virtual Machines Only needs to be analysed once, so it loses its effectiveness. Can be improved limitedly by randomising what bytes map to what instructions, how the instruction is made up, and how parameters are accessed. The VM instructions to be executed could configure the VM, making it a bit harder to analyse.

Bastardising the file format Generally aims to: Cause an analysis application to behave unexpectedly, while the Operating system loads it fine be exploited / caused to crash generate incorrect output Standard arms race Only effective for a while. Can be useful against tools widely used but not currently actively supported by their author (Ollydbg v1 for example)

Bastardising the file format Disadvantages Portability Different OS releases (Win 98 vs Win NT) Emulator programs, such as WINE. Sometimes its useful to debug your own programs Some AV's make pick up on the changes

Summary Use multiple layers of protections that rely on each other Don't check values for consistency / correctness, just use them straight away Learn to attack your own implementation, in order to identify weaknesses Perhaps keep an eye out on various reverse engineering forums / cracking forums. Realise when and where to focus your efforts. Have fun in the process :)

Summary (cont) Given enough time, skill and resources, pretty much everything can be broken.

Questions? Thanks for attending If you have any feedback, please contact me. andrewg@felinemenace.org Thanks to all the FM and PTP people.

Bonus slide (don't worry if you don't get these) gcc dmeiswrong.c -o dmeiswrong 13:21 < nemo> buf = malloc(size * 12); </3 http://church.felinemenace.org rm -rf diary.of.pike It's ok, $ACTIVITY isn't for everyone. IPv6-compatible Poodles Melting fish This is your warning shot. Sometimes you hurt me. In internet it's everytime Deaths of civilisations.