Fax?!
What The
To:
Date:
Subject:
Check Point Research
DEFCON 26
Aug-12 2018
Received OK?
WhoAreWe?
Yaniv Balmas
“This should theoretically work”
Security Researcher
Check Point Software Technologies
@ynvb
Eyal Itkin
“That’s cool.”
Security Researcher
Check Point Software Technologies
@eyalitkin
1860
Caselli
Invents
Machine
Similar to
Today’s FAX
1923
Enter the
RadioFAX.

Used by
Navies
1966
XEROX
Introduces
the First
Commercial
FAX Machine
1980
Group III 

ITU-T Fax
Standards

T.30, T.4, T.6
GammaFAX
Brings
Computers
Into FAX
Network
1985
1846
Alexaner
Bain Sends

An Image
Over a Wire
FAXHistory
Quality
Accessibility
Reliability
Authenticity ?
BackToTheFuture
BackToTheFuture
BackToTheFuture
BackToTheFuture
BackToTheFuture
BackToTheFuture
WTF?!
• Modern FAX is no longer a simple “FAX
Machines”

• The same old FAX technology is now
wrapped inside newer technologies

• ALL-IN-ONE printers are EVERYWHERE
FaxToday
The Security View
ALL-IN-ONE Printers
ALL-IN-ONE Printers
FAX Attack
ALL-IN-ONE Printers
FAX Attack
Challenge
Accepted
What is the
Target?
How to Obtain
the Code?
What is The
OS?
How Does FAX
Even Work?
How can we
Debug it?
Where to look for
vulns?
AndTheWinnerIs
BreakingHW
Flash ROM
SRAMs
(e.g Some More Memory)
BreakingHW
USB
WiFi
SRAM
Electricity
Main
CPU
FAX

Modem
Battery
ShowMeYourFirmware!
SERIAL

DEBUG
JTAG
TooEasy?
FirmwareUpgrade
How do you
upgrade a printer
firmware?!
You Print it!
How do you
upgrade a printer
firmware?!
You Print it!
PrintingTheFirmware
PrintingTheFirmware
NULL Decoder
TIFF Decoder
Delta Raw Decoder
WhenYou’reaHammer…
Sections
Loading Address Section Name Location in Binary
IDon’tUnderstand
…
WhatISThis?!
• Probably a compression algorithm

• A very bad one …

• Some mathematics
Let'sTakeALook
FF 20 72 66 63 75 72 73 69 EF 76 65 6C 79 AE E0
6E 6F 6E DF 70 6F 73 69 74 FE 30 20 73 F7 69 7A
65 0E 32 76 61 72 69 FF 61 62 6C 65 2D 6C 65 6E
F7 67 74 68 AD 33 00 00 56 4C FF 6A 70 65 67 2E
r e c u r s i v e l y
n o n p o s i t s i z
e v a r i a b l e - l e n
g t h V L j p e g .
FF 20 72 66 63 75 72 73 69 EF 76 65 6C 79 AE E0
6E 6F 6E DF 70 6F 73 69 74 FE 30 20 73 F7 69 7A
65 0E 32 76 61 72 69 FF 61 62 6C 65 2D 6C 65 6E
F7 67 74 68 AD 33 00 00 56 4C FF 6A 70 65 67 2E
r e c u r s i v e l y
n o n p o s i t s i z
e v a r i a b l e - l e n
g t h V L j p e g .
Let'sTakeALook
FF EF AE E0
DF FE 30 F7
0E 32 FF
F7 AD 33 FF
APattern?!
FF EF
DF F7
FF
F7 FF
8 Bytes 9 Bytes
9 Bytes
9 Bytes 8 Bytes
9 Bytes 8 Bytes
APattern?!
FF
EF
DF
F7
FF
F7
F
11111111
F
1 1 1 1 1 1 1
F E
1 1 1 1
11111111
F
1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
0
0
0
0
D
F7
FF
F7
DifferentAngle
F7 AD 33
Forward / Backward Pointer

Dictionary

Sliding Window
?
??
?
TheMissingLink
Softdisk
TheMissingLink
AD 33
1 0 1 0 1 1 0 1 0 0 1 1 0 0 1 1
A D 3 3
2771 3
Window
Location
Data

Length
A BCDABEF
Input Text
Sliding Window
G
Output Text
MysterySolved
A BCDABEF
Input Text
Sliding Window
A
G
Output Text
A
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B
G
Output Text
A B
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B C
G
Output Text
A B C
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B C D
G
Output Text
A B C D
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B C D
G
Output Text
A B C D
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B C D
G
Output Text
A B C D
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B C D
G
Output Text
A B C D 00 02
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B C D E
G
Output Text
A B C D E00 02
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B C D E F
G
Output Text
A B C D E F00 02
MysterySolved
A BCDABEF
Input Text
Sliding Window
A B C D E F
G
G
Output Text
A B C D E F G00 02
MysterySolved
A BCDABEF
Input Text
Output Text
Sliding Window
A
A
B
B
C
C
D
D
E
E
F
F
G
G
G
00 02
1 1 1 1 1 1 10
MysterySolved
A BCDABEF
Input Text
Output Text
Sliding Window
A
A
B
B
C
C
D
D
E
E
F
F
G
G
G
EF 00 02
MysterySolved
ThePrintingBeast
• 64,709 Functions

• Most of the code not parsed by IDA

• Indirect Calls, Dynamic Tables, BootLoader Functions
ThreadX
- ARM9/
Green
Hills
Treck (IP, TCP/UDP, DNS, HTTP, …)
libpng 1.2.29 (2008) tTB, tHTML, …
gSOAP 2.7
OpenSSL 1.0.1j (2014)
Spidermonkey
mDNSResponder
2 Staged Boot Loader
tModem
tFaxLog
tT30
tPrintFax
Common Libraries Tasks
System n’ Stuff
MakingSomeSense
ThreadX
- ARM9/
Green
Hills
Treck (IP, TCP/UDP, DNS, HTTP, …)
libpng 1.2.29 (2008) tTB, tHTML, …
gSOAP 2.7
OpenSSL 1.0.1j (2014)
mDNSResponder
2 Staged Boot Loader
tModem
tFaxLog
tT30
tPrintFax
Common Libraries Tasks
System n’ Stuff
Spidermonkey
MakingSomeSense
JSOnAPrinter?!
• JavaScript is used in a module called PAC.

• PAC - Proxy Auto Configuration

• Used by a URL linking to a JS file in DHCP settings 

• Top layer functionality was designed by HP
FakeURL
Yep…
T30
• aka “ITU-T Recommendation T.30” 

• Procedures for document facsimile transmission in the
general switched telephone network 

• Defined the “heavy lifting” procedures relevant for all fax
sending functionality

• Designed at 1985

• Last update at 2005
DynamicHell
TheUndebuggable
• How do we debug this hostile environment?

• There are no native debugging facilities

• We have no control over the execution flow

• Hardware watch-dog is a serious problem
LuckyBreak
• Luck is a fundamental part of every research project

• At July 19, SENRIO published an exploit dubbed “Devil’s
Ivy”

• CVE-2017-9765 - RCE in gSOAP 2.7 - 2.8.47

• And it seems our printer is vulnerable!
Devil’sIvy
DebuggingChallenges
• Need to read/write memory

• Need to Execute code

• Create a network tunnel between debugger/debuggee
DebuggingChallenges
• We have control over execution flow

• Need to load our own code

• Bypass memory protection

• Embed debugging stub into current firmware
Scout
• We created our own instruction based debugger

• Called - ‘Scout’

• Supports x86, x64, ARM (ARM and Thumb mode)

• Embedded mode for firmware

• Linux kernel mode
HowDoesAFAX?
PHASE 1
Network

Interaction
PHASE 2
Probing/

Ranging
Equalizer

and

Echo
Canceller
Training
PHASE 3
Training
Phase
PHASE 4
HowDoesAFAX?
CallerID
PHASE A
SenderCaps

(DIS)
ReceiverCaps

(DTC)
PHASE B
Tunnel
HDLC
Endofpage

(EOP)
MsgConfirm

(MCF)
PHASE D
DataTransfer
PHASE C
HowDoesAFAX?
PHASEA
PHASEB
PHASEC
PHASED
Tunnel
T.30
HDLC
HowDoesAFAX?
PHASEA
PHASEB
PHASEC
PHASED
Tunnel
FAX
T.30
HDLC
HowDoesAFAX?
PHASEA
PHASEB
PHASEC
PHASED
Tunnel
TIFF

Body
TIFF

Header
T.30
HDLC
G.3/G.4
HowDoesAFAX?
PHASEA
PHASEB
PHASEC
PHASED
Tunnel
FAX
T.30
Color Extension
HDLC
HowDoesAFAX?
PHASEA
PHASEB
PHASEC
PHASED
Tunnel JPEG
Header
and
Body
Color Extension
T.30
HDLC
HowDoesAFAX?
Vulnerability
• All the layers we showed can contain possible
vulnerabilities.

• The most convenient layer is the application one.

• We started by inspecting the JPEG parsing capabilities.
JPEG
FF D8 FF E0 00 10 4A 46 49 46 00 01 02 00 00 64
00 64 00 00 FF C4 0A 02 34 D3 2A 78 80 42 6D 2B
FF DA 12 28 2A 6F 2B 81 6A 16 0F C8 9A 13 FF D9
. . . . . . . J F I F . . . . d
. d . . . . . . 4 . * x . Bm+
. . . ( * 0 + . j . . . . . . .
EOI - End Of Image
DHT - Define Huffman Table
APP0 - Application Specific
SOI - Start Of Image
SOS - Start Of Scan
Data
Size
Data
Size
Data
DHT
FF C4 20 00 01 00 00 00 00 02 00 01 02 00 00 00
00 00 00 FF FF C4 0A 02 34 D3 2A 78 80 42 6D 2B
• Define Huffman Table

• Defines 4X4 comparison matrix for the JPEG Image
HEADER SIZE 4X4 MATRIX DATA
DHT
FF C4 20 00 01 00 00 00 00 02 00 01 02 00 00 00
00 00 00 FF FF C4 0A 02 34 D3 2A 78 80 42 6D 2B
∑(
)=6
• 4X4 Matrix values are summed

• The product is used as a size value for data bytes

• The data bytes are copied into a 256 bytes array located
on the stack
Stack
FF FF C4 0A 02 34
DHT
256
6
FF C4 20 00 01 00 00 00 00 02 00 01 02 00 00 00
00 00 00 FF FF C4 0A 02 34 D3 2A 78 80 42 6D 2B
CanYouSpotIt?
FF C4 20 FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF C4 0A 02 34 D3 2A 78 80 42 … 2B
DHT
Stack
256
Stack
FF FF C4 0A 02 34 D3 2A 78 80 42 … 2B
DHT
4000
256
Overflow!!
FF C4 20 FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF C4 0A 02 34 D3 2A 78 80 42 … 2B
ExploitChain
• Trivial stack overflow

• No constraints (“forbidden bytes”)

• ~4,000 user controlled bytes

• The file contains even more information we control…
Demo Time
Conclusions
• PSTN is still a valid attack surface in 2018!

• FAX can be used as a gateway to internal networks

• Old outdated protocols are not good for you…
WhatCanIDo?
• Patch your printers

• Don't connect FAX where not needed

• Segregate your printers from the rest of the network
STOP

USING

FAX
LittleHelpFromMyFriends
Lior
Oppenheim
Yannay
Livneh
Yoav
Alon
Tamir
Bahar
oppenheim1
tmr232
Yannayli
yoavalon
fin.
ynvb
EyalItkin

What the Fax!?