SlideShare a Scribd company logo
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech
Milan Zavoral
vedouc´ı: Ing. Peter Matula
Struktura zpˇetn´eho pˇrekladaˇce
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 2 / 10
Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci
zad´an´ı
sjednotit a vylepˇsit existuj´ıc´ı
metody detekce vzor˚u
doplnit metody pro detekci
nov´ych typ˚u vzor˚u
pouˇzit´y pˇrekladaˇc ˇci packer
staticky linkovan´y k´od (pomal´a
detekce)
odliˇsn´e form´aty signatur
chybˇej´ıc´ı detekce
kryptografick´ych konstrukc´ı
chybˇej´ıc´ı detekce zranitelnost´ı a
ˇskodliv´eho k´odu
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci
zad´an´ı
sjednotit a vylepˇsit existuj´ıc´ı
metody detekce vzor˚u
doplnit metody pro detekci
nov´ych typ˚u vzor˚u
pouˇzit´y pˇrekladaˇc ˇci packer
staticky linkovan´y k´od (pomal´a
detekce)
odliˇsn´e form´aty signatur
chybˇej´ıc´ı detekce
kryptografick´ych konstrukc´ı
chybˇej´ıc´ı detekce zranitelnost´ı a
ˇskodliv´eho k´odu
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci
zad´an´ı
sjednotit a vylepˇsit existuj´ıc´ı
metody detekce vzor˚u
doplnit metody pro detekci
nov´ych typ˚u vzor˚u
pouˇzit´y pˇrekladaˇc ˇci packer
staticky linkovan´y k´od (pomal´a
detekce)
odliˇsn´e form´aty signatur
chybˇej´ıc´ı detekce
kryptografick´ych konstrukc´ı
chybˇej´ıc´ı detekce zranitelnost´ı a
ˇskodliv´eho k´odu
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci
zad´an´ı
sjednotit a vylepˇsit existuj´ıc´ı
metody detekce vzor˚u
doplnit metody pro detekci
nov´ych typ˚u vzor˚u
pouˇzit´y pˇrekladaˇc ˇci packer
staticky linkovan´y k´od (pomal´a
detekce)
odliˇsn´e form´aty signatur
chybˇej´ıc´ı detekce
kryptografick´ych konstrukc´ı
chybˇej´ıc´ı detekce zranitelnost´ı a
ˇskodliv´eho k´odu
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci
zad´an´ı
sjednotit a vylepˇsit existuj´ıc´ı
metody detekce vzor˚u
doplnit metody pro detekci
nov´ych typ˚u vzor˚u
pouˇzit´y pˇrekladaˇc ˇci packer
staticky linkovan´y k´od (pomal´a
detekce)
odliˇsn´e form´aty signatur
chybˇej´ıc´ı detekce
kryptografick´ych konstrukc´ı
chybˇej´ıc´ı detekce zranitelnost´ı a
ˇskodliv´eho k´odu
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
P˚uvodn´ı detekce vzor˚u
pouˇzit´y pˇrekladaˇc ˇci packer
signatury
{
"ExePack",
"1.4",
"by Jon Snow",
0,
0,
"33C08BC0 --68---C;",
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 4 / 10
P˚uvodn´ı detekce vzor˚u
pouˇzit´y pˇrekladaˇc ˇci packer
signatury
{
"ExePack",
"1.4",
"by Jon Snow",
0,
0,
"33C08BC0 --68---C;",
}
heuristiky
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 4 / 10
P˚uvodn´ı detekce vzor˚u
pouˇzit´y pˇrekladaˇc ˇci packer
signatury
{
"ExePack",
"1.4",
"by Jon Snow",
0,
0,
"33C08BC0 --68---C;",
}
heuristiky
staticky linkovan´y k´od
.0001111000011111010110111110000111100101101110000011110
| 1 N 20 D4ED 005C 1 0000 __do_global_dtors
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 4 / 10
Sjednocen´ı signatur — YARA pravidla
{
"ExePack ",
"1.4 ",
"by Jon Snow",
0,
0,
"33C08BC0 --68--- C;",
}
rule exe_pack {
meta:
name = "ExePack "
version = "1.4"
comment = "by Jon Snow"
strings :
$1 = { 33 C0 8B C0 ?? 68 ?? ?C }
condition :
$1 at entrypoint
}
.0001111000011111010110111110000111100101101110000011110
| 1 N 20 D4ED 005C 1 0000 __do_global_dtors
rule do_global_dtors_aux {
meta:
patternSet = "1 N 20 D4ED 005C 1 0000 __do_global_dtors"
strings :
$1 = { ( 0F | 8F ) 0F AD F0 F2 DC 1E }
condition :
$1
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 5 / 10
Sjednocen´ı signatur — YARA pravidla
{
"ExePack ",
"1.4 ",
"by Jon Snow",
0,
0,
"33C08BC0 --68--- C;",
}
rule exe_pack {
meta:
name = "ExePack "
version = "1.4 "
comment = "by Jon Snow"
strings :
$1 = { 33 C0 8B C0 ?? 68 ?? ?C }
condition :
$1 at entrypoint
}
.0001111000011111010110111110000111100101101110000011110
| 1 N 20 D4ED 005C 1 0000 __do_global_dtors
rule do_global_dtors_aux {
meta:
patternSet = "1 N 20 D4ED 005C 1 0000 __do_global_dtors"
strings :
$1 = { ( 0F | 8F ) 0F AD F0 F2 DC 1E }
condition :
$1
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 5 / 10
Sjednocen´ı signatur — YARA pravidla
{
"ExePack ",
"1.4 ",
"by Jon Snow",
0,
0,
"33C08BC0 --68--- C;",
}
rule exe_pack {
meta:
name = "ExePack "
version = "1.4 "
comment = "by Jon Snow"
strings :
$1 = { 33 C0 8B C0 ?? 68 ?? ?C }
condition :
$1 at entrypoint
}
.0001111000011111010110111110000111100101101110000011110
| 1 N 20 D4ED 005C 1 0000 __do_global_dtors
rule do_global_dtors_aux {
meta:
patternSet = "1 N 20 D4ED 005C 1 0000 __do_global_dtors"
strings :
$1 = { ( 0F | 8F ) 0F AD F0 F2 DC 1E }
condition :
$1
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 5 / 10
Sjednocen´ı signatur — YARA pravidla
{
"ExePack ",
"1.4 ",
"by Jon Snow",
0,
0,
"33C08BC0 --68--- C;",
}
rule exe_pack {
meta:
name = "ExePack "
version = "1.4 "
comment = "by Jon Snow"
strings :
$1 = { 33 C0 8B C0 ?? 68 ?? ?C }
condition :
$1 at entrypoint
}
.0001111000011111010110111110000111100101101110000011110
| 1 N 20 D4ED 005C 1 0000 __do_global_dtors
rule do_global_dtors_aux {
meta:
patternSet = "1 N 20 D4ED 005 C 1 0000 __do_global_dtors"
strings :
$1 = { ( 0F | 8F ) 0F AD F0 F2 DC 1E }
condition :
$1
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 5 / 10
Sjednocen´ı signatur — v´ysledky
detekce pˇrekladaˇce ˇci packeru
vyˇsˇs´ı vyjadˇrovac´ı s´ıla, rozˇs´ıˇren´ı o 28 nov´ych heuristik
detekce staticky linkovan´eho k´odu
urychlen´ı detekce
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 6 / 10
Sjednocen´ı signatur — v´ysledky
detekce pˇrekladaˇce ˇci packeru
vyˇsˇs´ı vyjadˇrovac´ı s´ıla, rozˇs´ıˇren´ı o 28 nov´ych heuristik
detekce staticky linkovan´eho k´odu
urychlen´ı detekce
0
50
100
150
200
250
300
350
400
stacofinl 1.0 stacofinl 2.0
Minuty
Doba vykonávání
∼ 10 000 testovac´ıch soubor˚u
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 6 / 10
Detekce dalˇs´ıch vzor˚u
kryptografick´e a kompresn´ı funkce
2368 pravidel
ˇskodliv´y k´od a zranitelnosti
2181 pravidel
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 7 / 10
Detekce dalˇs´ıch vzor˚u
kryptografick´e a kompresn´ı funkce
2368 pravidel
ˇskodliv´y k´od a zranitelnosti
2181 pravidel
rule laudanum {
strings :
$s1 = "public function __activate ()" fullword ascii
$s2 = " register_activation_hook (__FILE__ , array(’
WP_Laudanum ’, ’activate ’))" fullword ascii
condition :
filesize < 5KB and all of them
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 7 / 10
Detekce dalˇs´ıch vzor˚u
kryptografick´e a kompresn´ı funkce
2368 pravidel
ˇskodliv´y k´od a zranitelnosti
2181 pravidel
rule laudanum {
strings :
$s1 = "public function __activate ()" fullword ascii
$s2 = " register_activation_hook (__FILE__ , array(’
WP_Laudanum ’, ’activate ’))" fullword ascii
condition :
filesize < 5KB and all of them
}
v´ystup pro uˇzivatele (text)
informace pro zpˇetn´y pˇrekladaˇc (JSON)
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 7 / 10
Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu
origin´aln´ı k´od
static unsigned int crc_32_tab [] = {...};
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 8 / 10
Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu
origin´aln´ı k´od
static unsigned int crc_32_tab [] = {...};
p˚uvodn´ı ˇreˇsen´ı
int32_t g1 = 0;
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 8 / 10
Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu
origin´aln´ı k´od
static unsigned int crc_32_tab [] = {...};
p˚uvodn´ı ˇreˇsen´ı
int32_t g1 = 0;
nov´e ˇreˇsen´ı
{
" endian" : " little ",
" matches " : [
{
"address " : 4231264 ,
"entrySize " : 4,
"offset " : 28768 ,
"size " : 1024 ,
"type " : " integral "
}
],
"name " : " CRC_32_IEEE_802_3_poly_0x04C11DB7 ",
"type " : " crypto"
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 8 / 10
Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu
origin´aln´ı k´od
static unsigned int crc_32_tab [] = {...};
p˚uvodn´ı ˇreˇsen´ı
int32_t g1 = 0;
nov´e ˇreˇsen´ı
{
" endian" : " little ",
" matches " : [
{
"address " : 4231264 ,
"entrySize " : 4,
"offset " : 28768 ,
"size " : 1024 ,
"type " : " integral "
}
],
"name " : " CRC_32_IEEE_802_3_poly_0x04C11DB7 ",
"type " : " crypto"
}
// Detected cryptographic pattern : CRC_32_IEEE_802_3_poly_0x04C11DB7
int32_t CRC_32_IEEE_802_3_poly_0x04C11DB7_at_409060 [256] = {...};
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 8 / 10
Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu
int32_t __do_global_ctors (void );
int32_t __do_global_dtors (void );
int32_t __main (void );
int32_t __mingw_get_msvcrt_han ( int32_t a1)
;
int32_t __mingw_TLScallback ( int32_t a1);
...
int32_t function_401560 (char * a1 , int32_t
a2) {
int32_t v1 = 4 * a2 , v2 = 0 x186a0 ;
int32_t v3 = -1, v4 = ( int32_t )a1;
while (true ) {
int32_t v5 = v3 , v6 = v4;
if (a2 != 0) {
uint32_t v7 = v3 , v8 = v4;
unsigned char v9 = *( char *)v8;
int32_t v10 = *( int32_t *) (4 * ((
int32_t )v9 ^ v7 % 256) + (
int32_t )&g2);
int32_t v11 = v10 ^ v7 / 256;
while (a2 != 1) {
a2 --; v7 = v11 , v8 += 4;
v9 = *( char *) v8;
v10 = *( int32_t *) (4 * ((
int32_t )v9 ^ v7 % 256) +
( int32_t )&g2);
v11 = v10 ^ v7 / 256;
}
...
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 9 / 10
Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu
int32_t __do_global_ctors (void );
int32_t __do_global_dtors (void );
int32_t __main (void );
int32_t __mingw_get_msvcrt_han ( int32_t a1)
;
int32_t __mingw_TLScallback ( int32_t a1);
...
int32_t function_401560 (char * a1 , int32_t
a2) {
int32_t v1 = 4 * a2 , v2 = 0 x186a0 ;
int32_t v3 = -1, v4 = ( int32_t )a1;
while (true ) {
int32_t v5 = v3 , v6 = v4;
if (a2 != 0) {
uint32_t v7 = v3 , v8 = v4;
unsigned char v9 = *( char *)v8;
int32_t v10 = *( int32_t *) (4 * ((
int32_t )v9 ^ v7 % 256) + (
int32_t )&g2);
int32_t v11 = v10 ^ v7 / 256;
while (a2 != 1) {
a2 --; v7 = v11 , v8 += 4;
v9 = *( char *) v8;
v10 = *( int32_t *) (4 * ((
int32_t )v9 ^ v7 % 256) +
( int32_t )&g2);
v11 = v10 ^ v7 / 256;
}
...
}
int32_t CRC 32(char * a1 , int32_t a2) {
int32_t v1 = 4 * a2 , v2 = 0x186a0 ;
int32_t v3 = -1, v4 = ( int32_t )a1;
while (true ) {
int32_t v5 = v3 , v6 = v4;
if (a2 != 0) {
uint32_t v7 = v3 , v8 = v4;
unsigned char v9 = *( char *)
v8;
int32_t v10 = *( int32_t *)(4
* (( int32_t )v9 ^ v7 %
256) + ( int32_t )&
CRC 32 at 409060) ;
int32_t v11 = v10 ^ v7 / 256;
while (a2 != 1) {
a2 --; v7 = v11 , v8 += 4;
v9 = *( char *)v8;
v10 = *( int32_t *)(4 * ((
int32_t )v9 ^ v7 %
256) + ( int32_t )&
CRC 32 at 409060) ;
v11 = v10 ^ v7 / 256;
}
...
}
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 9 / 10
Z´avˇer
sjednocen´ı r˚uzn´ych form´at˚u signatur
jednotn´a detekce vzor˚u (YARA)
rozd´ıln´a interpretace detekovan´ych vzor˚u (metadata)
urychlen´ı detekce staticky linkovan´eho k´odu
detekce kryptografick´ych konstrukc´ı
detekce ˇskodliv´eho k´odu a zranitelnost´ı
zv´yˇsen´ı ˇcitelnosti v´ystupn´ıho k´odu
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 10 / 10
Z´avˇer
sjednocen´ı r˚uzn´ych form´at˚u signatur
jednotn´a detekce vzor˚u (YARA)
rozd´ıln´a interpretace detekovan´ych vzor˚u (metadata)
urychlen´ı detekce staticky linkovan´eho k´odu
detekce kryptografick´ych konstrukc´ı
detekce ˇskodliv´eho k´odu a zranitelnost´ı
zv´yˇsen´ı ˇcitelnosti v´ystupn´ıho k´odu
https://retdec.com
Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 10 / 10
Ot´azky oponenta
”
V pr´aci popisujete, ˇze pro detekci ˇskodliv´eho k´odu je nutn´e nejprve zjistit
informace o pouˇzit´em pˇrekladaˇci a packeru (coˇz lze prov´est napˇr´ıklad na
z´akladˇe signatur). Co se stane v pˇr´ıpadˇe, ˇze se ´utoˇcn´ık pokus´ı tyto
informace podvrhnout za ´uˇcelem zmaten´ı detektoru?“
Ot´azky oponenta
”
V pr´aci popisujete, ˇze pro detekci ˇskodliv´eho k´odu je nutn´e nejprve zjistit
informace o pouˇzit´em pˇrekladaˇci a packeru (coˇz lze prov´est napˇr´ıklad na
z´akladˇe signatur). Co se stane v pˇr´ıpadˇe, ˇze se ´utoˇcn´ık pokus´ı tyto
informace podvrhnout za ´uˇcelem zmaten´ı detektoru?“
detekce pˇrekladaˇce ˇci packeru nen´ı obecnˇe nutn´a
nˇekolik zdroj˚u detekce pˇrekladaˇce ˇci packeru
signatury
importovan´e funkce a knihovny
resources
kontroln´ı souˇcty
ˇretˇezcov´e liter´aly, regul´arn´ı v´yrazy...
vlastnosti sekc´ı a datov´ych struktur (r˚uzn´e hlaviˇcky a odd´ıly v souboru)
behavior´aln´ı popis (Cuckoo Sandbox + YARA)
Ot´azky oponenta
”
V z´avˇeru pr´ace se zmiˇnujete, ˇze dosaˇzen´e v´ysledky bude moˇzn´e vyuˇz´ıt i
mimo rekonfigurovateln´y zpˇetn´y pˇrekladaˇc (napˇr. v syst´emu pro
automatickou shlukovou anal´yzu ˇskodliv´eho k´odu). Pokuste se myˇslenku
podrobnˇeji pˇribl´ıˇzit.“
Ot´azky oponenta
”
V z´avˇeru pr´ace se zmiˇnujete, ˇze dosaˇzen´e v´ysledky bude moˇzn´e vyuˇz´ıt i
mimo rekonfigurovateln´y zpˇetn´y pˇrekladaˇc (napˇr. v syst´emu pro
automatickou shlukovou anal´yzu ˇskodliv´eho k´odu). Pokuste se myˇslenku
podrobnˇeji pˇribl´ıˇzit.“
AVG: 150 000 vzork˚u / den
informace o vstupn´ım souboru + detekovan´a YARA pravidla
hashov´an´ı, vytvoˇren´ı popisu vzorku
anal´yza shluk˚u a tˇr´ıdˇen´ı do skupin dle virov´ych rodin
usnadˇnuje pr´aci analytik˚u
Z´ısk´avan´e informace
souborov´y form´at
architektura, bitov´a ˇs´ıˇrka
vstupn´ı bod
pˇrekladaˇc nebo packer
informace z hlaviˇcek
pˇr´ıznaky (flags)
typ souboru
endianita
OS, kontroln´ı souˇcet...
sekce, segmenty
symboly
importy, exporty
relokace
dynamick´e sekce (ELF)
adres´aˇre dat (PE)
resources (PE)
rich header (PE)
informace o PDB (PE)
specifick´e anal´yzy (ARM, MIPS)
origin´aln´ı jazyk
obsah souboru
CRC32, MD5, SHA-256
Heuristick´a detekce pˇrekladaˇce ˇci packeru
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
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Heuristick´a detekce pˇrekladaˇce ˇci packeru
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";
}
Detekce pˇrekladaˇce ˇci packeru
Detekce staticky linkovan´eho k´odu
Detekce dalˇs´ıch vzor˚u
Pouˇzit´e n´astroje a metodiky
C++
yara
OllyDbg (reverzn´ı inˇzen´yrstv´ı)
diagram tˇr´ıd UML
testov´an´ı
jednotkov´e testy
regresn´ı testy
srovn´avac´ı testy
v´ykonnostn´ı testy
knihovny
ELFIO
PeLib
LLVM
libyara
libdwarf
Portable C++ Hashing Library
TinyXml-2
JsonCpp
Google Test
Uk´azka v´ystupu n´astroje fileinfo
Input file : fileName
CRC32 : e7cb47b5
MD5 : 81513 f15b771280ffd0e...
SHA256 : fd3c77fc24415923a9b5...
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
Uk´azka v´ystupu n´astroje fileinfo
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 0 x00040 0 x400040 0x001c0 0 x000008
1 INTERP r 0 x00200 0 x400200 0x00015 0 x000001
2 LOADABLE rx 0 0 x400000 0xabfcc 0 x200000
3 LOADABLE rw 0 xac000 0 x6ac000 0x15488 0 x200000
4 DYNAMIC rw 0 xac030 0 x6ac030 0x001d0 0 x000008
5 NOTE r 0 x00218 0 x400218 0x00018 0 x000004
6 OS - specific r 0 xa5898 0 x4a5898 0x0138c 0 x000004
7 OS - specific rwx 0 0 0 0 x000010
-------------------------------------------------------------------------------
Flags:
r - readable
x - executable
w - writable
Uk´azka v´ystupu n´astroje fileinfo
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 0 x00040 0 x400040 0x001c0 0 x000008
1 INTERP r 0 x00200 0 x400200 0x00015 0 x000001
2 LOADABLE rx 0 0 x400000 0xabfcc 0 x200000
3 LOADABLE rw 0 xac000 0 x6ac000 0x15488 0 x200000
4 DYNAMIC rw 0 xac030 0 x6ac030 0x001d0 0 x000008
5 NOTE r 0 x00218 0 x400218 0x00018 0 x000004
6 OS - specific r 0 xa5898 0 x4a5898 0x0138c 0 x000004
7 OS - specific rwx 0 0 0 0 x000010
-------------------------------------------------------------------------------
Flags :
r - readable
x - executable
w - writable
Uk´azka v´ystupu n´astroje stacofin
4016b0 10 0 ___udiv_w_sdiv
4019f0 10 0 ___udiv_w_sdiv
402740 2c 0 ???
405dcd 10 0 ___bid_truncdddf - alternatives:
___bid_fixdddi ___bid_truncddsf ___bid_fixddsi
___bid_extendddxf ___bid_gtdd2 _isinfd64
___bid_nedd2 ___bid_extendsddf
___bid_truncsdsf ___bid_extendsdxf
___bid_unorddd2
40723f 10 0 ___clear_cache
407570 140 0 ___umoddi3
4076b0 110 0 ___udivdi3

More Related Content

Viewers also liked

MLCF Review
MLCF ReviewMLCF Review
BY115_PracticeExam1
BY115_PracticeExam1BY115_PracticeExam1
BY115_PracticeExam1
Megan Sugrue
 
(Youthlab indo) Survey Report: Are You a Moviegoers?
(Youthlab indo) Survey Report: Are You a Moviegoers?(Youthlab indo) Survey Report: Are You a Moviegoers?
(Youthlab indo) Survey Report: Are You a Moviegoers?
youth laboratory indonesia
 
Pemanfaatan tik pada riset keperawatan
Pemanfaatan tik pada riset keperawatanPemanfaatan tik pada riset keperawatan
Pemanfaatan tik pada riset keperawatan
Sumadin1112
 
RESUME
RESUMERESUME
Struktur Kelompok BUKAN Patil Lele
Struktur Kelompok BUKAN Patil LeleStruktur Kelompok BUKAN Patil Lele
Struktur Kelompok BUKAN Patil Lele
AM-PRA
 
Concentraciones Fisicas y Quimicas de las Soluciones
Concentraciones Fisicas y Quimicas de las SolucionesConcentraciones Fisicas y Quimicas de las Soluciones
Concentraciones Fisicas y Quimicas de las Soluciones
alexis castellon
 
EHSS Compliance Assurance
EHSS Compliance AssuranceEHSS Compliance Assurance
EHSS Compliance Assurance
Vaibhav Nautiyal
 
Report on "IFFCO-KANDLA UNIT by Darshan-JEC KUKAS,JAIPUR
Report on "IFFCO-KANDLA UNIT by Darshan-JEC KUKAS,JAIPURReport on "IFFCO-KANDLA UNIT by Darshan-JEC KUKAS,JAIPUR
Report on "IFFCO-KANDLA UNIT by Darshan-JEC KUKAS,JAIPUR
Darshan Singh
 
GLOBAL CORPORATE CATALOG
GLOBAL CORPORATE CATALOGGLOBAL CORPORATE CATALOG
GLOBAL CORPORATE CATALOG
Geophrey Tenganamba
 
8051 i/o port circuit
8051 i/o port circuit8051 i/o port circuit
8051 i/o port circuit
dharmendrawaghjipur007
 
Brexit : Points de vue comparés (UK, FR, DE, ES, PL)
Brexit : Points de vue comparés (UK, FR, DE, ES, PL)Brexit : Points de vue comparés (UK, FR, DE, ES, PL)
Brexit : Points de vue comparés (UK, FR, DE, ES, PL)
Kantar
 
Bone cement,Cementing Generations, Complications & Recent advances
Bone cement,Cementing Generations, Complications & Recent advancesBone cement,Cementing Generations, Complications & Recent advances
Bone cement,Cementing Generations, Complications & Recent advances
Sameer Ashar
 
свято 5 травня зош №14
свято 5 травня зош №14свято 5 травня зош №14
свято 5 травня зош №14
jekah
 

Viewers also liked (14)

MLCF Review
MLCF ReviewMLCF Review
MLCF Review
 
BY115_PracticeExam1
BY115_PracticeExam1BY115_PracticeExam1
BY115_PracticeExam1
 
(Youthlab indo) Survey Report: Are You a Moviegoers?
(Youthlab indo) Survey Report: Are You a Moviegoers?(Youthlab indo) Survey Report: Are You a Moviegoers?
(Youthlab indo) Survey Report: Are You a Moviegoers?
 
Pemanfaatan tik pada riset keperawatan
Pemanfaatan tik pada riset keperawatanPemanfaatan tik pada riset keperawatan
Pemanfaatan tik pada riset keperawatan
 
RESUME
RESUMERESUME
RESUME
 
Struktur Kelompok BUKAN Patil Lele
Struktur Kelompok BUKAN Patil LeleStruktur Kelompok BUKAN Patil Lele
Struktur Kelompok BUKAN Patil Lele
 
Concentraciones Fisicas y Quimicas de las Soluciones
Concentraciones Fisicas y Quimicas de las SolucionesConcentraciones Fisicas y Quimicas de las Soluciones
Concentraciones Fisicas y Quimicas de las Soluciones
 
EHSS Compliance Assurance
EHSS Compliance AssuranceEHSS Compliance Assurance
EHSS Compliance Assurance
 
Report on "IFFCO-KANDLA UNIT by Darshan-JEC KUKAS,JAIPUR
Report on "IFFCO-KANDLA UNIT by Darshan-JEC KUKAS,JAIPURReport on "IFFCO-KANDLA UNIT by Darshan-JEC KUKAS,JAIPUR
Report on "IFFCO-KANDLA UNIT by Darshan-JEC KUKAS,JAIPUR
 
GLOBAL CORPORATE CATALOG
GLOBAL CORPORATE CATALOGGLOBAL CORPORATE CATALOG
GLOBAL CORPORATE CATALOG
 
8051 i/o port circuit
8051 i/o port circuit8051 i/o port circuit
8051 i/o port circuit
 
Brexit : Points de vue comparés (UK, FR, DE, ES, PL)
Brexit : Points de vue comparés (UK, FR, DE, ES, PL)Brexit : Points de vue comparés (UK, FR, DE, ES, PL)
Brexit : Points de vue comparés (UK, FR, DE, ES, PL)
 
Bone cement,Cementing Generations, Complications & Recent advances
Bone cement,Cementing Generations, Complications & Recent advancesBone cement,Cementing Generations, Complications & Recent advances
Bone cement,Cementing Generations, Complications & Recent advances
 
свято 5 травня зош №14
свято 5 травня зош №14свято 5 травня зош №14
свято 5 травня зош №14
 

Detekce vzorů v binárních spustitelných souborech

  • 1. Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech Milan Zavoral vedouc´ı: Ing. Peter Matula
  • 2. Struktura zpˇetn´eho pˇrekladaˇce Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 2 / 10
  • 3. Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci zad´an´ı sjednotit a vylepˇsit existuj´ıc´ı metody detekce vzor˚u doplnit metody pro detekci nov´ych typ˚u vzor˚u pouˇzit´y pˇrekladaˇc ˇci packer staticky linkovan´y k´od (pomal´a detekce) odliˇsn´e form´aty signatur chybˇej´ıc´ı detekce kryptografick´ych konstrukc´ı chybˇej´ıc´ı detekce zranitelnost´ı a ˇskodliv´eho k´odu Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
  • 4. Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci zad´an´ı sjednotit a vylepˇsit existuj´ıc´ı metody detekce vzor˚u doplnit metody pro detekci nov´ych typ˚u vzor˚u pouˇzit´y pˇrekladaˇc ˇci packer staticky linkovan´y k´od (pomal´a detekce) odliˇsn´e form´aty signatur chybˇej´ıc´ı detekce kryptografick´ych konstrukc´ı chybˇej´ıc´ı detekce zranitelnost´ı a ˇskodliv´eho k´odu Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
  • 5. Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci zad´an´ı sjednotit a vylepˇsit existuj´ıc´ı metody detekce vzor˚u doplnit metody pro detekci nov´ych typ˚u vzor˚u pouˇzit´y pˇrekladaˇc ˇci packer staticky linkovan´y k´od (pomal´a detekce) odliˇsn´e form´aty signatur chybˇej´ıc´ı detekce kryptografick´ych konstrukc´ı chybˇej´ıc´ı detekce zranitelnost´ı a ˇskodliv´eho k´odu Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
  • 6. Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci zad´an´ı sjednotit a vylepˇsit existuj´ıc´ı metody detekce vzor˚u doplnit metody pro detekci nov´ych typ˚u vzor˚u pouˇzit´y pˇrekladaˇc ˇci packer staticky linkovan´y k´od (pomal´a detekce) odliˇsn´e form´aty signatur chybˇej´ıc´ı detekce kryptografick´ych konstrukc´ı chybˇej´ıc´ı detekce zranitelnost´ı a ˇskodliv´eho k´odu Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
  • 7. Detekce vzor˚u ve zpˇetn´em pˇrekladaˇci zad´an´ı sjednotit a vylepˇsit existuj´ıc´ı metody detekce vzor˚u doplnit metody pro detekci nov´ych typ˚u vzor˚u pouˇzit´y pˇrekladaˇc ˇci packer staticky linkovan´y k´od (pomal´a detekce) odliˇsn´e form´aty signatur chybˇej´ıc´ı detekce kryptografick´ych konstrukc´ı chybˇej´ıc´ı detekce zranitelnost´ı a ˇskodliv´eho k´odu Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 3 / 10
  • 8. P˚uvodn´ı detekce vzor˚u pouˇzit´y pˇrekladaˇc ˇci packer signatury { "ExePack", "1.4", "by Jon Snow", 0, 0, "33C08BC0 --68---C;", } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 4 / 10
  • 9. P˚uvodn´ı detekce vzor˚u pouˇzit´y pˇrekladaˇc ˇci packer signatury { "ExePack", "1.4", "by Jon Snow", 0, 0, "33C08BC0 --68---C;", } heuristiky Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 4 / 10
  • 10. P˚uvodn´ı detekce vzor˚u pouˇzit´y pˇrekladaˇc ˇci packer signatury { "ExePack", "1.4", "by Jon Snow", 0, 0, "33C08BC0 --68---C;", } heuristiky staticky linkovan´y k´od .0001111000011111010110111110000111100101101110000011110 | 1 N 20 D4ED 005C 1 0000 __do_global_dtors Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 4 / 10
  • 11. Sjednocen´ı signatur — YARA pravidla { "ExePack ", "1.4 ", "by Jon Snow", 0, 0, "33C08BC0 --68--- C;", } rule exe_pack { meta: name = "ExePack " version = "1.4" comment = "by Jon Snow" strings : $1 = { 33 C0 8B C0 ?? 68 ?? ?C } condition : $1 at entrypoint } .0001111000011111010110111110000111100101101110000011110 | 1 N 20 D4ED 005C 1 0000 __do_global_dtors rule do_global_dtors_aux { meta: patternSet = "1 N 20 D4ED 005C 1 0000 __do_global_dtors" strings : $1 = { ( 0F | 8F ) 0F AD F0 F2 DC 1E } condition : $1 } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 5 / 10
  • 12. Sjednocen´ı signatur — YARA pravidla { "ExePack ", "1.4 ", "by Jon Snow", 0, 0, "33C08BC0 --68--- C;", } rule exe_pack { meta: name = "ExePack " version = "1.4 " comment = "by Jon Snow" strings : $1 = { 33 C0 8B C0 ?? 68 ?? ?C } condition : $1 at entrypoint } .0001111000011111010110111110000111100101101110000011110 | 1 N 20 D4ED 005C 1 0000 __do_global_dtors rule do_global_dtors_aux { meta: patternSet = "1 N 20 D4ED 005C 1 0000 __do_global_dtors" strings : $1 = { ( 0F | 8F ) 0F AD F0 F2 DC 1E } condition : $1 } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 5 / 10
  • 13. Sjednocen´ı signatur — YARA pravidla { "ExePack ", "1.4 ", "by Jon Snow", 0, 0, "33C08BC0 --68--- C;", } rule exe_pack { meta: name = "ExePack " version = "1.4 " comment = "by Jon Snow" strings : $1 = { 33 C0 8B C0 ?? 68 ?? ?C } condition : $1 at entrypoint } .0001111000011111010110111110000111100101101110000011110 | 1 N 20 D4ED 005C 1 0000 __do_global_dtors rule do_global_dtors_aux { meta: patternSet = "1 N 20 D4ED 005C 1 0000 __do_global_dtors" strings : $1 = { ( 0F | 8F ) 0F AD F0 F2 DC 1E } condition : $1 } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 5 / 10
  • 14. Sjednocen´ı signatur — YARA pravidla { "ExePack ", "1.4 ", "by Jon Snow", 0, 0, "33C08BC0 --68--- C;", } rule exe_pack { meta: name = "ExePack " version = "1.4 " comment = "by Jon Snow" strings : $1 = { 33 C0 8B C0 ?? 68 ?? ?C } condition : $1 at entrypoint } .0001111000011111010110111110000111100101101110000011110 | 1 N 20 D4ED 005C 1 0000 __do_global_dtors rule do_global_dtors_aux { meta: patternSet = "1 N 20 D4ED 005 C 1 0000 __do_global_dtors" strings : $1 = { ( 0F | 8F ) 0F AD F0 F2 DC 1E } condition : $1 } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 5 / 10
  • 15. Sjednocen´ı signatur — v´ysledky detekce pˇrekladaˇce ˇci packeru vyˇsˇs´ı vyjadˇrovac´ı s´ıla, rozˇs´ıˇren´ı o 28 nov´ych heuristik detekce staticky linkovan´eho k´odu urychlen´ı detekce Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 6 / 10
  • 16. Sjednocen´ı signatur — v´ysledky detekce pˇrekladaˇce ˇci packeru vyˇsˇs´ı vyjadˇrovac´ı s´ıla, rozˇs´ıˇren´ı o 28 nov´ych heuristik detekce staticky linkovan´eho k´odu urychlen´ı detekce 0 50 100 150 200 250 300 350 400 stacofinl 1.0 stacofinl 2.0 Minuty Doba vykonávání ∼ 10 000 testovac´ıch soubor˚u Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 6 / 10
  • 17. Detekce dalˇs´ıch vzor˚u kryptografick´e a kompresn´ı funkce 2368 pravidel ˇskodliv´y k´od a zranitelnosti 2181 pravidel Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 7 / 10
  • 18. Detekce dalˇs´ıch vzor˚u kryptografick´e a kompresn´ı funkce 2368 pravidel ˇskodliv´y k´od a zranitelnosti 2181 pravidel rule laudanum { strings : $s1 = "public function __activate ()" fullword ascii $s2 = " register_activation_hook (__FILE__ , array(’ WP_Laudanum ’, ’activate ’))" fullword ascii condition : filesize < 5KB and all of them } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 7 / 10
  • 19. Detekce dalˇs´ıch vzor˚u kryptografick´e a kompresn´ı funkce 2368 pravidel ˇskodliv´y k´od a zranitelnosti 2181 pravidel rule laudanum { strings : $s1 = "public function __activate ()" fullword ascii $s2 = " register_activation_hook (__FILE__ , array(’ WP_Laudanum ’, ’activate ’))" fullword ascii condition : filesize < 5KB and all of them } v´ystup pro uˇzivatele (text) informace pro zpˇetn´y pˇrekladaˇc (JSON) Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 7 / 10
  • 20. Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu origin´aln´ı k´od static unsigned int crc_32_tab [] = {...}; Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 8 / 10
  • 21. Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu origin´aln´ı k´od static unsigned int crc_32_tab [] = {...}; p˚uvodn´ı ˇreˇsen´ı int32_t g1 = 0; Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 8 / 10
  • 22. Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu origin´aln´ı k´od static unsigned int crc_32_tab [] = {...}; p˚uvodn´ı ˇreˇsen´ı int32_t g1 = 0; nov´e ˇreˇsen´ı { " endian" : " little ", " matches " : [ { "address " : 4231264 , "entrySize " : 4, "offset " : 28768 , "size " : 1024 , "type " : " integral " } ], "name " : " CRC_32_IEEE_802_3_poly_0x04C11DB7 ", "type " : " crypto" } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 8 / 10
  • 23. Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu origin´aln´ı k´od static unsigned int crc_32_tab [] = {...}; p˚uvodn´ı ˇreˇsen´ı int32_t g1 = 0; nov´e ˇreˇsen´ı { " endian" : " little ", " matches " : [ { "address " : 4231264 , "entrySize " : 4, "offset " : 28768 , "size " : 1024 , "type " : " integral " } ], "name " : " CRC_32_IEEE_802_3_poly_0x04C11DB7 ", "type " : " crypto" } // Detected cryptographic pattern : CRC_32_IEEE_802_3_poly_0x04C11DB7 int32_t CRC_32_IEEE_802_3_poly_0x04C11DB7_at_409060 [256] = {...}; Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 8 / 10
  • 24. Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu int32_t __do_global_ctors (void ); int32_t __do_global_dtors (void ); int32_t __main (void ); int32_t __mingw_get_msvcrt_han ( int32_t a1) ; int32_t __mingw_TLScallback ( int32_t a1); ... int32_t function_401560 (char * a1 , int32_t a2) { int32_t v1 = 4 * a2 , v2 = 0 x186a0 ; int32_t v3 = -1, v4 = ( int32_t )a1; while (true ) { int32_t v5 = v3 , v6 = v4; if (a2 != 0) { uint32_t v7 = v3 , v8 = v4; unsigned char v9 = *( char *)v8; int32_t v10 = *( int32_t *) (4 * (( int32_t )v9 ^ v7 % 256) + ( int32_t )&g2); int32_t v11 = v10 ^ v7 / 256; while (a2 != 1) { a2 --; v7 = v11 , v8 += 4; v9 = *( char *) v8; v10 = *( int32_t *) (4 * (( int32_t )v9 ^ v7 % 256) + ( int32_t )&g2); v11 = v10 ^ v7 / 256; } ... } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 9 / 10
  • 25. Vyuˇzit´ı pˇri zpˇetn´em pˇrekladu int32_t __do_global_ctors (void ); int32_t __do_global_dtors (void ); int32_t __main (void ); int32_t __mingw_get_msvcrt_han ( int32_t a1) ; int32_t __mingw_TLScallback ( int32_t a1); ... int32_t function_401560 (char * a1 , int32_t a2) { int32_t v1 = 4 * a2 , v2 = 0 x186a0 ; int32_t v3 = -1, v4 = ( int32_t )a1; while (true ) { int32_t v5 = v3 , v6 = v4; if (a2 != 0) { uint32_t v7 = v3 , v8 = v4; unsigned char v9 = *( char *)v8; int32_t v10 = *( int32_t *) (4 * (( int32_t )v9 ^ v7 % 256) + ( int32_t )&g2); int32_t v11 = v10 ^ v7 / 256; while (a2 != 1) { a2 --; v7 = v11 , v8 += 4; v9 = *( char *) v8; v10 = *( int32_t *) (4 * (( int32_t )v9 ^ v7 % 256) + ( int32_t )&g2); v11 = v10 ^ v7 / 256; } ... } int32_t CRC 32(char * a1 , int32_t a2) { int32_t v1 = 4 * a2 , v2 = 0x186a0 ; int32_t v3 = -1, v4 = ( int32_t )a1; while (true ) { int32_t v5 = v3 , v6 = v4; if (a2 != 0) { uint32_t v7 = v3 , v8 = v4; unsigned char v9 = *( char *) v8; int32_t v10 = *( int32_t *)(4 * (( int32_t )v9 ^ v7 % 256) + ( int32_t )& CRC 32 at 409060) ; int32_t v11 = v10 ^ v7 / 256; while (a2 != 1) { a2 --; v7 = v11 , v8 += 4; v9 = *( char *)v8; v10 = *( int32_t *)(4 * (( int32_t )v9 ^ v7 % 256) + ( int32_t )& CRC 32 at 409060) ; v11 = v10 ^ v7 / 256; } ... } Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 9 / 10
  • 26. Z´avˇer sjednocen´ı r˚uzn´ych form´at˚u signatur jednotn´a detekce vzor˚u (YARA) rozd´ıln´a interpretace detekovan´ych vzor˚u (metadata) urychlen´ı detekce staticky linkovan´eho k´odu detekce kryptografick´ych konstrukc´ı detekce ˇskodliv´eho k´odu a zranitelnost´ı zv´yˇsen´ı ˇcitelnosti v´ystupn´ıho k´odu Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 10 / 10
  • 27. Z´avˇer sjednocen´ı r˚uzn´ych form´at˚u signatur jednotn´a detekce vzor˚u (YARA) rozd´ıln´a interpretace detekovan´ych vzor˚u (metadata) urychlen´ı detekce staticky linkovan´eho k´odu detekce kryptografick´ych konstrukc´ı detekce ˇskodliv´eho k´odu a zranitelnost´ı zv´yˇsen´ı ˇcitelnosti v´ystupn´ıho k´odu https://retdec.com Detekce vzor˚u v bin´arn´ıch spustiteln´ych souborech 10 / 10
  • 28. Ot´azky oponenta ” V pr´aci popisujete, ˇze pro detekci ˇskodliv´eho k´odu je nutn´e nejprve zjistit informace o pouˇzit´em pˇrekladaˇci a packeru (coˇz lze prov´est napˇr´ıklad na z´akladˇe signatur). Co se stane v pˇr´ıpadˇe, ˇze se ´utoˇcn´ık pokus´ı tyto informace podvrhnout za ´uˇcelem zmaten´ı detektoru?“
  • 29. Ot´azky oponenta ” V pr´aci popisujete, ˇze pro detekci ˇskodliv´eho k´odu je nutn´e nejprve zjistit informace o pouˇzit´em pˇrekladaˇci a packeru (coˇz lze prov´est napˇr´ıklad na z´akladˇe signatur). Co se stane v pˇr´ıpadˇe, ˇze se ´utoˇcn´ık pokus´ı tyto informace podvrhnout za ´uˇcelem zmaten´ı detektoru?“ detekce pˇrekladaˇce ˇci packeru nen´ı obecnˇe nutn´a nˇekolik zdroj˚u detekce pˇrekladaˇce ˇci packeru signatury importovan´e funkce a knihovny resources kontroln´ı souˇcty ˇretˇezcov´e liter´aly, regul´arn´ı v´yrazy... vlastnosti sekc´ı a datov´ych struktur (r˚uzn´e hlaviˇcky a odd´ıly v souboru) behavior´aln´ı popis (Cuckoo Sandbox + YARA)
  • 30. Ot´azky oponenta ” V z´avˇeru pr´ace se zmiˇnujete, ˇze dosaˇzen´e v´ysledky bude moˇzn´e vyuˇz´ıt i mimo rekonfigurovateln´y zpˇetn´y pˇrekladaˇc (napˇr. v syst´emu pro automatickou shlukovou anal´yzu ˇskodliv´eho k´odu). Pokuste se myˇslenku podrobnˇeji pˇribl´ıˇzit.“
  • 31. Ot´azky oponenta ” V z´avˇeru pr´ace se zmiˇnujete, ˇze dosaˇzen´e v´ysledky bude moˇzn´e vyuˇz´ıt i mimo rekonfigurovateln´y zpˇetn´y pˇrekladaˇc (napˇr. v syst´emu pro automatickou shlukovou anal´yzu ˇskodliv´eho k´odu). Pokuste se myˇslenku podrobnˇeji pˇribl´ıˇzit.“ AVG: 150 000 vzork˚u / den informace o vstupn´ım souboru + detekovan´a YARA pravidla hashov´an´ı, vytvoˇren´ı popisu vzorku anal´yza shluk˚u a tˇr´ıdˇen´ı do skupin dle virov´ych rodin usnadˇnuje pr´aci analytik˚u
  • 32. Z´ısk´avan´e informace souborov´y form´at architektura, bitov´a ˇs´ıˇrka vstupn´ı bod pˇrekladaˇc nebo packer informace z hlaviˇcek pˇr´ıznaky (flags) typ souboru endianita OS, kontroln´ı souˇcet... sekce, segmenty symboly importy, exporty relokace dynamick´e sekce (ELF) adres´aˇre dat (PE) resources (PE) rich header (PE) informace o PDB (PE) specifick´e anal´yzy (ARM, MIPS) origin´aln´ı jazyk obsah souboru CRC32, MD5, SHA-256
  • 33. Heuristick´a detekce pˇrekladaˇce ˇci packeru 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 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  • 34. Heuristick´a detekce pˇrekladaˇce ˇci packeru 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"; }
  • 38. Pouˇzit´e n´astroje a metodiky C++ yara OllyDbg (reverzn´ı inˇzen´yrstv´ı) diagram tˇr´ıd UML testov´an´ı jednotkov´e testy regresn´ı testy srovn´avac´ı testy v´ykonnostn´ı testy knihovny ELFIO PeLib LLVM libyara libdwarf Portable C++ Hashing Library TinyXml-2 JsonCpp Google Test
  • 39. Uk´azka v´ystupu n´astroje fileinfo Input file : fileName CRC32 : e7cb47b5 MD5 : 81513 f15b771280ffd0e... SHA256 : fd3c77fc24415923a9b5... 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
  • 40. Uk´azka v´ystupu n´astroje fileinfo 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 0 x00040 0 x400040 0x001c0 0 x000008 1 INTERP r 0 x00200 0 x400200 0x00015 0 x000001 2 LOADABLE rx 0 0 x400000 0xabfcc 0 x200000 3 LOADABLE rw 0 xac000 0 x6ac000 0x15488 0 x200000 4 DYNAMIC rw 0 xac030 0 x6ac030 0x001d0 0 x000008 5 NOTE r 0 x00218 0 x400218 0x00018 0 x000004 6 OS - specific r 0 xa5898 0 x4a5898 0x0138c 0 x000004 7 OS - specific rwx 0 0 0 0 x000010 ------------------------------------------------------------------------------- Flags: r - readable x - executable w - writable
  • 41. Uk´azka v´ystupu n´astroje fileinfo 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 0 x00040 0 x400040 0x001c0 0 x000008 1 INTERP r 0 x00200 0 x400200 0x00015 0 x000001 2 LOADABLE rx 0 0 x400000 0xabfcc 0 x200000 3 LOADABLE rw 0 xac000 0 x6ac000 0x15488 0 x200000 4 DYNAMIC rw 0 xac030 0 x6ac030 0x001d0 0 x000008 5 NOTE r 0 x00218 0 x400218 0x00018 0 x000004 6 OS - specific r 0 xa5898 0 x4a5898 0x0138c 0 x000004 7 OS - specific rwx 0 0 0 0 x000010 ------------------------------------------------------------------------------- Flags : r - readable x - executable w - writable
  • 42. Uk´azka v´ystupu n´astroje stacofin 4016b0 10 0 ___udiv_w_sdiv 4019f0 10 0 ___udiv_w_sdiv 402740 2c 0 ??? 405dcd 10 0 ___bid_truncdddf - alternatives: ___bid_fixdddi ___bid_truncddsf ___bid_fixddsi ___bid_extendddxf ___bid_gtdd2 _isinfd64 ___bid_nedd2 ___bid_extendsddf ___bid_truncsdsf ___bid_extendsdxf ___bid_unorddd2 40723f 10 0 ___clear_cache 407570 140 0 ___umoddi3 4076b0 110 0 ___udivdi3