Steganography consists of hiding a secret message within another message. Unlike cryptography, steganography tries to achieve security through obscurity, hiding the very presence of the message. Ideally, the steganographic message will look identically to a normal message.
This talk examines different techniques to hide messages using steganography from the perspective of a PHP developer. From more classical techniques such as hiding an image within another image using the least significant bits of each pixel, to more advanced ones like using TCP/IP packets.
2. E U Q W E X S A O S L Z U
L R T Z S R P V I Y E P N
H A F H G Z I P L M F I E
G U R I C E R T I F I E D
B L A A Q N T E T O R T T
E K I M A D H S G N O 💩 A
P O L Y G L O T A Y E S U
A J E W H I T E S P A C E
O B R F S A C I L I A P Y
S T E G A N O G R A P H Y
R A M C Y T I R W C P P A
About me
10. • 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
15. Bacon’s Bilateral Cipher
A AAAAA
B AAAAB
C AAABA
D AAABB
E AABAA
F AABAB
G AABBA
H AABBB
I/J ABAAA
K ABAAB
L ABABA
M ABABB
N ABBAA
O ABBAB
P ABBBA
Q ABBBB
R BAAAA
S BAAAB
T BAABA
U/V BAABB
W BABAA
X BABAB
Y BABBA
Z BABBB
Take the red pill
BAABA 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
16. • 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
17. 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.
18. • 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
24. 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
25. 525
Piet
Darkness 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
25
5
27. • 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
29. • 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
30. • 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
32. • St e ga n o g r a p h i c m e t h o d fo 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
34. • 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
35. 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
37. • 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
40. 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.
41. 5
l 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 - 0
Little endian: 0 - 14
strlen()
42. 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.
58. • PHP extension to use the
• It provides high level function to deal
directly with pixels (they will be used to
encode data), such as imagecolorat()
and imagesetpixel().
GD extension
Source: http://libgd.bitbucket.org/
59. Demo #2.1
Embedding text data into
images (+ steganalysis)
/demos/demo2/demo2_1
raulfraile/steganography_talk
62. • A polyglot is a program written in a valid
form of multiple programming
languages.
• Generally are written in a combination of
C (which allows redefinition of tokens
with a preprocessor) and a scripting
language.
Polyglot programs
64. Demo #3.1
Embedding PHP code using
__halt_compiler()
/demos/demo3/demo3_1
raulfraile/steganography_talk
65. __halt_compiler()
• Halts the execution of the compiler.
• The byte position of the data start is
given by the __COMPILER_HALT_OFFSET__
constant.
• PHAR files make use of this function to
separate the stub (loader functionality)
and the rest of the file (manifest, files
and signature).
70. Whitespace
• 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.
72. nikic/php-parser
• A PHP parser written in PHP.
• Useful for static code analysis, manipulation
and generation.
• Converts PHP code into an AST (Abstract
Syntax Tree).
• Uses a PHP 5.6 compliant grammar (backwards
compatible with PHP 5.2+). Also, emulates
tokens from different versions of the one
running (for example, parse 5.6 code from 5.3).
Source: https://github.com/nikic/PHP-Parser
75. nikic/php-parser
• The parser provides two main
components:
• NodeTraverser: For traversing and
visiting the node tree.
• PrettyPrinter: To compile the AST
back to PHP code.