Top Banner

Click here to load reader

Steganography: Hiding your secrets with PHP

Jul 15, 2015

ReportDownload

Technology

  • Ral Fraile #PHPDS15

    SteganographyHiding your secrets with PHP

  • E U Q W E X S A O S L Z UL R T Z S R P V I Y E P NH A F H G Z I P L M F I EG U R I C E R T I F I E DB L A A Q N T E T O R T TE K I M A D H S G N O AP O L Y G L O T A Y E S UA J E W H I T E S P A C EO B R F S A C I L I A P YS T E G A N O G R A P H YR A M C Y T I R W C P P A

    About me

  • Introduction to Steganography

  • Steganography is the science of concealing a hidden message in plain sight in order to avoid detection.

    Introduction

  • Introduction

    steganosgraphein

    covered, concealed, protected writing

  • Terminology

    Embedding (E)

    Extracting (D)

    Cover (C) Message (M)

    Stego-Object (S)

    Key (K)

  • Steganography: Hide the data from a third party.

    Cryptography: Make data unreadable by a third party.

    Steganography / Cryptography

  • Prisoners problem

  • Esoteric programming language with only three lexical tokens: Space (ASCII 32), Tab (ASCII 9) and Line Feed (ASCII 10).

    Stack based language with support for I/O, flow control and arithmetic operations.

    Motivation

    Source: http://youtu.be/u_kqM0gn63M

  • Motivation

    Source: http://uk.businessinsider.com/david-cameron-encryption-apple-pgp-2015-1?r=US

  • Protection of data alteration (digital watermarking).

    Secretly communicate information.

    Anti-forensics mechanism.

    Applications

  • Techniques

  • Classical Steganography

  • Bacons Bilateral CipherA AAAAAB AAAABC AAABAD AAABBE AABAAF AABABG AABBAH AABBB

    I/J ABAAAK ABAABL ABABAM ABABBN ABBAAO ABBABP ABBBAQ ABBBBR BAAAAS BAAABT BAABA

    U/V BAABBW BABAAX BABABY BABBAZ BABBB

    Take the red pillBAABA AAAAA ABAAB AABAA BAABA AABBB AABAA BAAAA AABAA AAABB ABBBA ABAAA ABABA ABABA

    Steganography is the art or practice of concealing messages within other messages

    S t e g a n o g r a p h y i s t h e a r t o r p r a c t i c e o f c o n c e a l i n g

    m e s s a g e s w i t h i n o t h e r m e s s a g e s

    70

  • Backmasking is a technique in which a sound or message is recorded backward onto a track that is meant to be played forward.

    It is a deliberate process, whereas a message found through phonetic reversal may be unintentional.

    Backmasking

  • Backmasking

    If there's a bustle in your hedgerow, don't be alarmed now, it's just a spring clean for the May queen. Yes there are two paths you can go by, but in the long run there's still time to change the road you're on.

    Oh here's to my sweet Satan. The one whose little path would make me sad, whose power is satan. He'll give those with him 666, there was a little toolshed where he made us suffer, sad Satan.

  • Some brand color laser printers add tiny yellow dots to each page, that contain encoded printer serial numbers and timestamps.

    Monochrome printers and copiers from major manufacturers also include the markings.

    Most printers' codes have not been decoded.

    Printer steganography

  • Printer steganography

    Source: https://w2.eff.org/Privacy/printers/docucolor/

  • Morse code

  • Morse code

    T O R T U R E

    Source: http://youtu.be/BgelmcOdS38

  • Digital Steganography

  • Digital SteganographyLSB IN IMAGES

    144 141 81

    10010000 10001101 01010001

    Hidden message: 101001

    145 140 81

    10010001 10001100 01010001

    146 142 81

    10010010 10001110 01010001

  • Piet is a programming language in which programs look like abstract paintings.

    Piet

    Composition with Red, Yellow and Blue. 1921, Piet Mondrian

    Source: http://www.dangermouse.net/esoteric/piet.html

  • 525

    PietDarkness change

    Hue change None 1 2

    None push pop

    1 step add substract multiply

    2 steps divide mod not

    3 steps greater pointer switch

    4 steps duplicate roll in(number)

    5 steps in(char) out(number) out(char)

    DP right CC left

    $ npiet example1.png

    ? 5

    255

  • Piet

  • We already have filesystems with support for encryption, so they only can be read with the password. But the attacker may obtain it illegally or torture the user to give it up.

    The steganographic filesystem goes one step further: it does not even show the existence of sensitive information (even when raw sectors of the hard disc are accessed).

    Steganographic filesystem

  • Steganographic filesystem

    0 1 2 3 4 5 6 7 8

    1.txt 2

    2.txt 5

    3.txt 7

    3 4 EOF EOF EOF6 8

    Boot FATFilesystem

    Boot FATFilesystem-level encryption

    PartitionSteganographic filesystem

  • Network steganography uses communication protocols and are harder to detect.

    Techniques:

    Steganophony: Delayed or corrupted packets that would normally be ignored by the receiver.

    WLAN Steganography: Transmission of steganograms in Wireless Local Area Networks

    Network Steganography

  • Custom HTTP headers to include geeky messages or as a recruiting tool.

    For example, booking.com:

    X-Recruiting: Like HTTP headers? C o m e w r i t e o u r s : h t t p s : / /workingatbooking.com

    HTTP headers

  • SkyDe (Skype Hide)

    Source: http://arxiv.org/pdf/1301.3632.pdf

  • S t e g a n o g r a p h i c m e t h o d f o r t h e BitTorrent P2P file transfer service.

    It is based on modifying the order of data packets in the peer-peer data exchange protocol.

    Steganographic bandwidth of up to 270 b/s while introducing little transmission distortion and providing difficult detectability.

    StegTorrent

  • StegTorrent

    Source: http://www.computer.org/csdl/proceedings/spw/2013/5017/00/5017a151-abs.html

    0 1

    4 5

    2

    6

    3

    7

    1100 10

  • Spammimic embeds a message into spam.

    There is tons of spam. Also, real spam is usually dumb, so it's sometimes hard to tell if it was written by a human or a machine.

    Spammimic

  • Spammimic

    Dear Professional , Your email address has been submitted to us indicating your interest in our newsletter ! This is a one time mailing there is no need to request removal if you won't want any more ! This mail is being sent in compliance with Senate bill 2516 , Title 9 , Section 303 . Do NOT confuse us with Internet scam artists . Why work for somebody else when you can become rich in 16 days . Have you ever noticed most everyone has a cellphone and nearly every commercial on television has a .com on in it ! Well, now is your chance to capitalize on this ! We will help you decrease perceived waiting time by 190% and deliver goods right to the customer's doorstep ! The best thing about our system is that it is absolutely risk free for you ! But don't believe us . Mrs Simpson of Maryland tried us and says "I was skeptical but it worked for me" . We assure you that we operate within all applicable laws ! We implore you - act now ! Sign up a friend and you get half off . Thanks .

    Message: attack

    Source: http://www.spammimic.com

    Disappearing Cryptography. Information Hiding: Steganography & Watermarking

  • Steganalysis

  • Steganalysis is the study of detecting messages hidden using steganography.

    The goal of steganalysis is to identify suspected packages, determine whether or not they have a payload encoded into them, and, if possible, recover that payload.

    The problem is generally handled with statistical analysis.

    Steganalysis

  • Steganalysis

    144 141 81

    10010000 10001101 01010001

    Random

    0

    0,2

    0,4

    0,6

    0,8

    0 1

  • What about PHP?

  • Binary strings

    In PHP, strings are just a sequence of bytes (C char type).

    PHP stores the length of strings explicitly. Unlike C it does not need a zero termination to find the end of a string.

  • 5l l oh e*val

    len

    Binary strings

    typedef union _zvalue_value { long lval; double dval; struct { char *val; int len; } str; HashTable *ht; zend_object_value obj; } zvalue_value;

    6

    \091 21314 0123 88

    $str[5]

    Big endian: 14 - 0Little endian: 0 - 14

    strlen()

  • pack()/unpack()

    pack() packs data into a binary string according to a given format.

    unpack() unpacks from a binary string into an array according to a given format.

  • pack()/unpack()

    $now = new \DateTime(); $id1 = 0x1f; $id2 = 0x8b; $cm = 0x08; $flags = 0x00; $mtime = $now->getTimestamp(); //0x54c13374 /* * Format: * - C4: 4 bytes. * - V: Unsigned long, 32 bit, little endian byte order */ $binStr = pack('C4V', $id1, $id2, $cm, $flags, $mtime); file_put_contents(__DIR__ . '/test.gz', $binStr);

    74 3308 001f 8b c1 54

  • pack()/unpack()$gzip = file_get_contents(__DIR__ . '/test.gz'); /* * Format: * - C2: 2 bytes (id1, id2). * - C1: 1 byte (cm), 1 byte (flags). * - V: Unsigned long, 32 bit, little endian byte order */ list($id1, $id2, $cm, $flags, $mtime) = array_values( unpack('C2id/C1cm/C1flags/Vmtime', $gzip) );

    var_dump( dechex($id1), // 1f dechex($id2), // 8b dechex($cm), // 8 dechex($flags), // 0 dechex($mtime) // 54c13374 );

  • Bitwise operators

    Bitwise operators allow evaluation and manipulation of specific bits within an integer.

    PHP provides 6 bitwise operators: &, |, ^, ~, >.

  • Bitwise operators

    1