rozšíření nástroje pro analýzu spustitelných souborů

27
Rozˇ ıˇ ren´ ı n´ astroje pro anal´ yzu spustiteln´ ych soubor˚ u Milan Zavoral vedouc´ ı: Ing. Peter Matula

Upload: milan-zavoral

Post on 14-Apr-2017

165 views

Category:

Software


0 download

TRANSCRIPT

Rozsırenı nastroje pro analyzu spustitelnych souboru

Milan Zavoral

vedoucı: Ing. Peter Matula

Proc analyzator spustitelnych souboru?

zadanı: rozsırit a vylepsitexistujıcı nastroj

projekt Lissom (FIT VUT)

informace pro dekompilaci

souborovy format

architektura

vstupnı bod (entry point)

pouzity prekladac nebo packer

informace o pouzitem prekladaci ci packeru

unpacking

funkce main, instrukcnı idiomy

Rozsırenı nastroje pro analyzu spustitelnych souboru 2 / 8

Proc analyzator spustitelnych souboru?

zadanı: rozsırit a vylepsitexistujıcı nastroj

projekt Lissom (FIT VUT)

informace pro dekompilaci

souborovy format

architektura

vstupnı bod (entry point)

pouzity prekladac nebo packer

Rozsırenı nastroje pro analyzu spustitelnych souboru 2 / 8

Proc analyzator spustitelnych souboru?

zadanı: rozsırit a vylepsitexistujıcı nastroj

projekt Lissom (FIT VUT)

informace pro dekompilaci

souborovy format

architektura

vstupnı bod (entry point)

pouzity prekladac nebo packer

informace o pouzitem prekladaci ci packeru

unpacking

funkce main, instrukcnı idiomy

Rozsırenı nastroje pro analyzu spustitelnych souboru 2 / 8

Existujıcı nastroje

objdump

readelf

PE.Explorer

efd

Rozsırenı nastroje pro analyzu spustitelnych souboru 3 / 8

Existujıcı nastroje

objdump

readelf

PE.Explorer

efd

GNU/GPL

GNU/GPL, ELF

uzavreny kod (x86), PE

uzavreny kod (x86)

spolecne nedetekujı pouzity prekladac (packer)

Rozsırenı nastroje pro analyzu spustitelnych souboru 3 / 8

Nove souborove formaty

Rozsırenı nastroje pro analyzu spustitelnych souboru 4 / 8

Nove souborove formaty

Rozsırenı nastroje pro analyzu spustitelnych souboru 4 / 8

Rychlostnı optimalizace

profilovanı (gprof)

90% casu se travı v 1 funkci (vyhledavanı v signaturach)

0

10

20

30

40

50

60

70

80

fileinfo 1.0 fileinfo 2.0

Čas

(m

in)

Doba vykonávání

∼ 5500 testovacıch souboru

Rozsırenı nastroje pro analyzu spustitelnych souboru 5 / 8

Heuristicka detekce

polymorfnı packery

1C 1C 26 08 3E B0 0F 6D FF 6D F5 35 BF C7 C0

74 08 52 55 66 C1 C4 10 5D 5A 51 51 0A C9 59

51 0F B6 C9 77 05 25 FF FF FF FF F8 E2 F3 59

-- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Rozsırenı nastroje pro analyzu spustitelnych souboru 6 / 8

Heuristicka detekce

polymorfnı packery

1C 1C 26 08 3E B0 0F 6D FF 6D F5 35 BF C7 C0

74 08 52 55 66 C1 C4 10 5D 5A 51 51 0A C9 59

51 0F B6 C9 77 05 25 FF FF FF FF F8 E2 F3 59

-- -- -- -- -- -- -- -- -- -- -- -- -- -- --

if( file_format == PE &&

target_architecture == INTEL X86 &&

EP_file_offset >= 0x400 &&

EP_file_offset <= 0x1400 &&

data_directories[1].size == 0x1000 &&

sections[0].name == ".text" &&

sections[1].name == ".data" &&

sections[2].name == ".idata" &&

sections[2].size == 0x200)

{

return "Morphine 1.2";

}

Rozsırenı nastroje pro analyzu spustitelnych souboru 6 / 8

Experimentalnı vysledky

PE

0

20

40

60

80

100

fileinfo 2.0 RDG fileinfo 1.0 PEiD PID Exeinfo PEDetect FastScan DiE

Pře

snos

t (%

)

Detekce názvu (např. UPX)Detekce hlavní verze (např. UPX 3.xx)

Detekce přesné verze (např. UPX 3.05)

ELF

0

20

40

60

80

100

fileinfo 2.0 DiE fileinfo 1.0

Pře

snost(%

)

Rozsırenı nastroje pro analyzu spustitelnych souboru 7 / 8

Zaver

rozsırenı poctu zıskavanych informacı

architekturne specificke analyzy

nove souborove formaty

rychlostnı optimalizace

heuristiky

experimentalnı vysledky

J. Kroustek, P. Matula, D. Kolar, and M. ZavoralAdvanced Preprocessing of Binary Executable Files and its Usage inRetargetable DecompilationIn: International Journal on Advances in Software, 2014

Rozsırenı nastroje pro analyzu spustitelnych souboru 8 / 8

Zaver

rozsırenı poctu zıskavanych informacı

architekturne specificke analyzy

nove souborove formaty

rychlostnı optimalizace

heuristiky

experimentalnı vysledky

J. Kroustek, P. Matula, D. Kolar, and M. ZavoralAdvanced Preprocessing of Binary Executable Files and its Usage inRetargetable DecompilationIn: International Journal on Advances in Software, 2014

decompiler.fit.vutbr.cz/fileinfoRozsırenı nastroje pro analyzu spustitelnych souboru 8 / 8

Otazky oponenta

”Pri detekciı viacerych prekladacov su relevantnejsie tie, ktore bolidetekovane na zaklade heuristık. Preco su detekcie pomocou heuristıkpovazovane za viac relevantne ako detekcie pomocou signatur?“

experimentalnı vysledky

nekolik pravidel pro razenı

zdroj

shoda v nazvu nastroje

komparator verzı

”V rozsiahlej databaze signatur moze dochadzat’ ku kolıziam medzijednotlivymi signaturami. Ako by ste tento problem riesili?“

trıdenı signatur

detektor kolizı (NtCore PE Detective, vlastnı detektor)

stromy

Otazky oponenta

”Pri detekciı viacerych prekladacov su relevantnejsie tie, ktore bolidetekovane na zaklade heuristık. Preco su detekcie pomocou heuristıkpovazovane za viac relevantne ako detekcie pomocou signatur?“

experimentalnı vysledky

nekolik pravidel pro razenı

zdroj

shoda v nazvu nastroje

komparator verzı

”V rozsiahlej databaze signatur moze dochadzat’ ku kolıziam medzijednotlivymi signaturami. Ako by ste tento problem riesili?“

trıdenı signatur

detektor kolizı (NtCore PE Detective, vlastnı detektor)

stromy

Otazky oponenta

”Pri detekciı viacerych prekladacov su relevantnejsie tie, ktore bolidetekovane na zaklade heuristık. Preco su detekcie pomocou heuristıkpovazovane za viac relevantne ako detekcie pomocou signatur?“

experimentalnı vysledky

nekolik pravidel pro razenı

zdroj

shoda v nazvu nastroje

komparator verzı

”V rozsiahlej databaze signatur moze dochadzat’ ku kolıziam medzijednotlivymi signaturami. Ako by ste tento problem riesili?“

trıdenı signatur

detektor kolizı (NtCore PE Detective, vlastnı detektor)

stromy

Zıskavane informace

souborovy format

architektura

vstupnı bod

prekladac nebo packer

informace z hlavicek

prıznaky (flags)

typ souboru

endianita

OS, kontrolnı soucet...

sekce, segmenty

symboly

relokace

dynamicke sekce (ELF)

adresare dat (PE)

specificke analyzy (ARM)

originalnı jazyk

Format signatur

{

" ExePack",

"1.4",

"by 6aHguT",

"000,0FF ,33C08BC0--68---C;",

},

Format signatur

{

" ExePack",

"1.4",

"by 6aHguT",

"000,0FF ,33C08BC0--68---C;",

},

novy format signatur

{

" ExePack",

"1.4",

"by 6aHguT",

0,

255,

"33C08BC0 --68---C;",

},

Pouzite nastroje a metodiky

C++

knihovny

PeLib

ELFIO

Codasip SDK

libdwarf

TinyXml

OllyDbg (reverznı inzenyrstvı)

Diagram trıd UML

Experimentalnı merenı uspesnosti detekce

nastroj

jmeno verze pocet signatur

fileinfo 2.0 2224RDG Packer Detector 0.7.2 ?fileinfo 1.0 2181PEiD 0.95 2446ProtectionID (PID) 0.6.5.5 543Exeinfo PE 0.0.3.4 7794NtCore PE Detective 1.2.1.1 2806FastScanner 3.0 3437Detect It Easy (DiE) 0.81 ?

Instrukcnı idiomy

#include <stdio.h>

int main()

{

int a;

scanf("%d", &a);

printf("%d\n",

-(a >= 0));

return 0;

}

Instrukcnı idiomy

#include <stdio.h>

int main()

{

int a;

scanf("%d", &a);

printf("%d\n",

-(a >= 0));

return 0;

}

# include <stdint.h>

# include <stdio.h>

int main()

{

int apple = 0;

scanf("%d", &apple);

printf("%d\n",

-(apple >> 31 ^ 1));

return 0;

}

J. Kroustek and F. PokornyReconstruction of Instruction Idioms in a Retargetable DecompilerIn: WAPL, Krakow, PL, 2013

Ukazka vystupu

Input file : fileName

File format : ELF

File class : 64-bit

File type : Executable file

Architecture : x86 -64

Endianness : Little endian

Entry point address : 0x405d10

Entry point offset : 0x5d10

Entry point section index: 12

Entry point section name : .text

Bytes on entry point : 554889 e541554c...

Detected compiler/packer : GHC (7.6.3)

Original language : Haskell

Ukazka vystupu

i type flags offset vaddr memsize align

-------------------------------------------------------------------------------

i - index

type - type of segment

flags - segment flags

offset - offset in file

vaddr - virtual address in memory

memsize - size in memory

align - alignment in memory and in file

-------------------------------------------------------------------------------

i type flags offset vaddr memsize align

-------------------------------------------------------------------------------

0 PHDR rx 0x00040 0x400040 0x001c0 0x000008

1 INTERP r 0x00200 0x400200 0x00015 0x000001

2 LOADABLE rx 0 0x400000 0xabfcc 0x200000

3 LOADABLE rw 0xac000 0x6ac000 0x15488 0x200000

4 DYNAMIC rw 0xac030 0x6ac030 0x001d0 0x000008

5 NOTE r 0x00218 0x400218 0x00018 0x000004

6 OS -specific r 0xa5898 0x4a5898 0x0138c 0x000004

7 OS -specific rwx 0 0 0 0x000010

-------------------------------------------------------------------------------

Flags:

r - readable

x - executable

w - writable

Ukazka vystupu

i type flags offset vaddr memsize align

-------------------------------------------------------------------------------

i - index

type - type of segment

flags - segment flags

offset - offset in file

vaddr - virtual address in memory

memsize - size in memory

align - alignment in memory and in file

-------------------------------------------------------------------------------

i type flags offset vaddr memsize align

-------------------------------------------------------------------------------

0 PHDR rx 0x00040 0x400040 0x001c0 0x000008

1 INTERP r 0x00200 0x400200 0x00015 0x000001

2 LOADABLE rx 0 0x400000 0xabfcc 0x200000

3 LOADABLE rw 0xac000 0x6ac000 0x15488 0x200000

4 DYNAMIC rw 0xac030 0x6ac030 0x001d0 0x000008

5 NOTE r 0x00218 0x400218 0x00018 0x000004

6 OS -specific r 0xa5898 0x4a5898 0x0138c 0x000004

7 OS -specific rwx 0 0 0 0x000010

-------------------------------------------------------------------------------

Flags :

r - readable

x - executable

w - writable