SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Downloaden Sie, um offline zu lesen
JAILBREAKING
                         TECHNIQUES
               WWJC, San Francisco, 29th of september, 2012




                                        @pod2g
dimanche 30 septembre
INTRODUCTION
                            Who am I ?




dimanche 30 septembre
@pod2g
                  • Real name : Cyril (I’ve no last name)
                  • Age : 32
                  • From France (in no particular city)
                  • iOS security researcher since 2009 for a
                        hobby
                  • Blog : http://www.pod2g.org

dimanche 30 septembre
Thank you !




dimanche 30 septembre
When did I get started ?
                  •     Played with a ZX 81 computer at the age of 5. I
                        copied BASIC programs from books without
                        understanding a thing !
                  •     I had an ATARI ST some years later and did some
                        GFA BASIC, 68k assembly and demo making.
                  •     Learned C / C++ at college
                  •     Worked as J2EE expert developer then project
                        manager for 11+ years


dimanche 30 septembre
Hacking ... ?
                  • Improved the performance of the SD driver
                        of the WRT54G router, by writing it in pure
                        MIPS assembly code
                  • Hacked the eten X500+ and « cooked » a
                        new ROM for it (Windows Mobile 6.1)
                        You can see my posts in eten-users.eu
                        forums, login name « Cyril » :-)


dimanche 30 septembre
iOS SECURITY RESEARCH
                        History of my work




dimanche 30 septembre
01/2009 ARM7 GO - IPOD 2G IOS 2.1

                  • Joined « The Chronic Dev » team by
                        helping them to unleash the « arm7 go »
                        iBoot command of the iPod 2G 2.1 which
                        was its first unsigned code execution
                        vector.
                  • Worked on the « 0wnboot » payload to
                        tether jailbreak the iPod 2G.
                  • Dumped the iPod 2G bootrom.
dimanche 30 septembre
01/2009 -> 03/2009 24KPWN - IPOD
                        2G, IPHONE 3GS BOOTROM

                  •     Fully reversed the LLB loading part of the bootrom.
                  •     Found the « 24kpwn » bootrom vulnerability by
                        static analysis.
                  •     Did a proof of concept by modifying the NOR of
                        the device.
                  •     Worked on the bootrom payload with
                        @planetbeing to allow custom LLB loading which
                        was quickly released in the « redsn0w » jailbreak
                        tool.


dimanche 30 septembre
06/2009 -> 09/2009 USB_CONTROL_MSG(0X21, 2) -
                                    IOS 3.1


                  • Worked on adding debugging and
                        breakpoint commands to the iBoot.
                  • Wrote a USB fuzzer using the libusb API
                        and found the usb_control_msg(0x21, 2)
                        vulnerability.
                  • Using a custom iBoot, debugged the
                        vulnerability and wrote an exception vector
                        rewrite payload as a proof of concept.


dimanche 30 septembre
03/2010 -> 09/2010 STEAKS4UCE /
                         SHATTER - IPOD2G / IPHONE 4
                                   BOOTROM
                  •     Reverse engineered the iPod 3G bootrom DFU loading part of a
                        firmware image. Focused on the SHA1 control part.
                  •     Wrote more advanced USB fuzzers.
                  •     Found a DFU heap overflow in the iPod 2G bootrom
                        (steaks4uce), and wrote the exploit code which permitted to
                        execute custom ARM payloads in the bootrom context.
                  •     Figured out using the previous exploit that the addresses 0x20 to
                        0x40 (exception vector addresses) are writable even in a ROM
                        because of the ARM processor data cache.
                  •     Exploited a null dereference vulnerability by overwriting the SHA1
                        processor registers of the iPhone 4 and rewrote the exception
                        vectors. This is the unreleased « SHAtter » exploit.



dimanche 30 septembre
01/2011 -> 02/2011 FEEDFACE - IOS 4.2.1



                  • Found the « HFS volume name stack buffer
                        overflow » vulnerability.
                  • Wrote the exploit payload to do the iOS
                        kernel jailbreak.
                  • Worked on the « greenpois0n » jailbreak
                        tool to include « feedface » for device
                        untethering.


dimanche 30 septembre
07/2011 -> 01/2011 CORONA - IOS 5.0, 5.0.1


                  •     Wrote a HFS fuzzer which found a heap overflow in the OSX 10.7.1
                        kernel HFS B-Tree parser.
                  •     Wrote a proof of concept exploit code on OSX. Relies on heap Feng
                        Shui technics.
                  •     Found a format string vulnerability in the IPsec racoon service.
                  •     Wrote a ROP and format string generator for the racoon vulnerability
                        so that custom code could be executed at iOS 5.0 startup.
                  •     Used the custom code to trigger the HFS kernel vulnerability which
                        lead to the Corona untether jailbreak for iOS 5.0.1.
                  •     Worked with other security researchers to extend the untether to
                        newer devices. Involved finding other exploits to break out the Apple
                        sandbox.



dimanche 30 septembre
ROCKY RACOON,
                          ABSINTHE 2.0
                         Inner workings of the iOS 5.1 jailbreak




dimanche 30 septembre
CVE-2012-3727 : iOS Jailbreak Dream Team
         IPSec
         Available for: iPhone 3GS and later, iPod touch (4th
         generation) and later, iPad 2 and later
         Impact: Loading a maliciously crafted racoon
         configuration file may lead to arbitrary code
         execution
         Description: A buffer overflow existed in the
         handling of racoon configuration files. This issue was
         addressed through improved bounds checking.

dimanche 30 septembre
CVE-2012-3727 : iOS Jailbreak Dream Team
         Kernel
         Available for: iPhone 3GS and later, iPod touch (4th
         generation) and later, iPad 2 and later
         Impact: A local user may be able to execute
         arbitrary code with system privileges
         Description: An invalid pointer dereference issue
         existed in the kernel's handling of packet filter
         ioctls. This may allow an attacker to alter kernel
         memory. This issue was addressed through
         improved error handling.
dimanche 30 septembre
The goldmine of bugs
                  • When I worked on Corona (iOS 5.0
                        jailbreak), I spotted lot of bugs in racoon
                        which may be interresting for iOS 5.1
                  • I did a quick search in the IPsec Tools bug
                        tracker (sourceforge) before looking at the
                        code by myself, and here is what I’ve
                        found !


dimanche 30 septembre
Users are fuzzers
                  • racoon 0.7.3 crashes with Segmentaion
                        Fault just after start - ID: 2987081 :
                        « when I add more than two mode_cfg{}
                        statements in racoon.conf » ... « racoon
                        vanishes just after start without any single
                        error line in log file » ... « "Segmentation
                        fault" »



dimanche 30 septembre
IPsec tools, no support ?

                        • Nobody answered to the bug report,
                          since April 2010
                        • Even after successful exploitation for the
                          iOS 5.1 jailbreak, the bug is still opened
                        • The reporting user siutkowskij (thanks to
                          him) attached a configuration file



dimanche 30 septembre
Let’s try it out


                        • iOS 5.1.1 is vulnerable :-)
                        • OSX 10.7.4 also, interresting to play with
                          the vulnerability
                        • Let’s play with the supplied configuration
                          file and try to isolate the problem



dimanche 30 septembre
...
            mode_cfg {
            	

 conf_source local;
            	

 auth_groups "investments";
            	

 group_source system;
            	

 auth_source system;
            	

 accounting system;
            	

 network4 172.31.40.1;
            	

 netmask4 255.255.255.0;
            	

 pool_size 253;
            	

 dns4 172.31.3.144;
            	

 dns4 172.31.3.237;
            	

 default_domain "somedomain.pl";
            	

 banner "/etc/racoon/motd";
            	

 pfs_group 2;
            	

 save_passwd on;
            }
            mode_cfg {                            ...
            	

 conf_source local;                mode_cfg {
            	

 auth_groups "admins";             	

 dns4 172.31.3.144;   ...
            	

 group_source system;              	

 dns4 172.31.3.237;   mode_cfg {
            	

 auth_source system;               }                        	

 dns4 172.31.3.144;
            	

 accounting system;                mode_cfg {               	

 dns4 172.31.3.237;
            	

 network4 172.31.41.1;             	

 dns4 172.31.3.144;   	

 dns4 172.31.3.144;
            	

 netmask4 255.255.255.0;           	

 dns4 172.31.3.237;   	

 dns4 172.31.3.237;
            	

 pool_size 253;                    }                        	

 dns4 172.31.3.144;
            	

 dns4 172.31.3.144;                mode_cfg {               	

 dns4 172.31.3.237;
            	

 dns4 172.31.3.237;                	

 dns4 172.31.3.144;   }
            	

 default_domain "somedomain.pl";   	

 dns4 172.31.3.237;   ...
            	

 banner "/etc/racoon/motd";        }
            	

 pfs_group 2;                      ...
            	

 save_passwd on;
            }
            mode_cfg {
            	

 conf_source local;
            	

 auth_groups "somegroup";
            	

 group_source system;
            	

 auth_source system;
            	

 accounting system;
            	

 network4 172.31.42.1;
            	

 netmask4 255.255.255.0;
            	

 dns4 172.31.3.144;
            	

 dns4 172.31.3.237;
            	

 default_domain "asseco.pl";
            	

 banner "/etc/racoon/motd";
            	

 pfs_group 2;
            	

 save_passwd on;
            }
            ...

dimanche 30 septembre
What do we know ?

                  • Actually, it has nothing to do with the
                        multiple mode_cfg sections
                  • Crash happens when the number of dns4
                        statements is greater than 4
                  • Buffer overflow ? Let’s look at the IPsec
                        Tools source code (opensource software)



dimanche 30 septembre
Code excerpt
                                           cfparse.y
          ... addrdns
                  :       ADDRSTRING
                          {
          #ifdef ENABLE_HYBRID
                                  struct isakmp_cfg_config *icc = &isakmp_cfg_config;

                                  if (icc->dns4_index > MAXNS)
                                          yyerror("No more than %d DNS", MAXNS);
                                  if (inet_pton(AF_INET, $1->v,
                                      &icc->dns4[icc->dns4_index++]) != 1)
                                          yyerror("bad IPv4 DNS address.");

                                  vfree($1);
          #else
                                  yyerror("racoon not configured with --enable-hybrid");
          #endif
                            }
                        ;
          ...




dimanche 30 septembre
Code excerpt
                                            isakmp_cfg.h
                        struct isakmp_cfg_config {
                                in_addr_t               network4;
                                in_addr_t               netmask4;
                                in_addr_t               dns4[MAXNS];
                                int                     dns4_index;
                                in_addr_t               nbns4[MAXWINS];
                                int                     nbns4_index;
                                struct isakmp_cfg_port *port_pool;
                                int                     authsource;
                                int                     groupsource;
                                char                    **grouplist;
                                int                     groupcount;
                                int                     confsource;
                                int                     accounting;
                                size_t                  pool_size;
                                int                     auth_throttle;
                                /* XXX move this to a unity specific sub-structure */
                                char                    default_domain[MAXPATHLEN + 1];
                                char                    motd[MAXPATHLEN + 1];
                                struct unity_netentry   *splitnet_list;
                                int                     splitnet_count;
                                int                     splitnet_type;
                                char                    *splitdns_list;
                                int                     splitdns_len;
                                int                     pfs_group;
                                int                     save_passwd;
                        };




dimanche 30 septembre
What to do with it ?
                  • Overflowing dns4 array allows to control
                        the dns4_index variable
                  • Next dns4 statement will write the IP
                        address to an arbitrary index of the array
                  • It’s indeed an arbitrary memory write kind of
                        vulnerability
                  • fixed in iOS 6.0
dimanche 30 septembre
Limitations

                  • using the dns4 statement only, the
                        modification of the dns4_index can only be
                        done a single time
                  • which means only one block (any size) of
                        memory can be controlled




dimanche 30 septembre
Copy / Paste FTW

                  • Wait ! They did exactly the same mistakes
                        with the wins statement
                  • No more limitations !
                  • Let’s see how to exploit it completely now


dimanche 30 septembre
Code excerpt
                                           cfparse.y
          ... addrwins
                  :       ADDRSTRING
                          {
          #ifdef ENABLE_HYBRID
                                  struct isakmp_cfg_config *icc = &isakmp_cfg_config;

                                  if (icc->nbns4_index > MAXNS)
                                          yyerror("No more than %d WINS", MAXNS);
                                  if (inet_pton(AF_INET, $1->v,
                                      &icc->nbns4[icc->nbns4_index++]) != 1)
                                          yyerror("bad IPv4 WINS address.");

                                  vfree($1);
          #else
                                  yyerror("racoon not configured with --enable-hybrid");
          #endif
                            }
                        ;
          ...




dimanche 30 septembre
Code excerpt
                                            isakmp_cfg.h
                        struct isakmp_cfg_config {
                                in_addr_t               network4;
                                in_addr_t               netmask4;
                                in_addr_t               dns4[MAXNS];
                                int                     dns4_index;
                                in_addr_t               nbns4[MAXWINS];
                                int                     nbns4_index;
                                struct isakmp_cfg_port *port_pool;
                                int                     authsource;
                                int                     groupsource;
                                char                    **grouplist;
                                int                     groupcount;
                                int                     confsource;
                                int                     accounting;
                                size_t                  pool_size;
                                int                     auth_throttle;
                                /* XXX move this to a unity specific sub-structure */
                                char                    default_domain[MAXPATHLEN + 1];
                                char                    motd[MAXPATHLEN + 1];
                                struct unity_netentry   *splitnet_list;
                                int                     splitnet_count;
                                int                     splitnet_type;
                                char                    *splitdns_list;
                                int                     splitdns_len;
                                int                     pfs_group;
                                int                     save_passwd;
                        };




dimanche 30 septembre
Exploitation
                          dns4[0]        Statements :
                          dns4[1]
                          dns4[2]
                          dns4[3]
                        dns4_index   0
                          nbns[0]
                          nbns[1]
                          nbns[2]
                          nbns[3]
                        nbns_index   0

dimanche 30 septembre
Exploitation
                          dns4[0]          Statements :
                          dns4[1]
                                           mode_cfg {
                          dns4[2]          wins4 0.0.0.0;
                          dns4[3]          }

                        dns4_index    0
                          nbns[0]    0x0
                          nbns[1]
                          nbns[2]
                          nbns[3]
                        nbns_index    1

dimanche 30 septembre
Exploitation
                          dns4[0]          Statements :
                          dns4[1]
                                           mode_cfg {
                          dns4[2]          wins4 0.0.0.0;
                          dns4[3]          wins4 0.0.0.0;
                                           }
                        dns4_index    0
                          nbns[0]    0x0
                          nbns[1]    0x0
                          nbns[2]
                          nbns[3]
                        nbns_index    2

dimanche 30 septembre
Exploitation
                          dns4[0]          Statements :
                          dns4[1]
                                           mode_cfg {
                          dns4[2]          wins4 0.0.0.0;
                          dns4[3]          wins4 0.0.0.0;
                                           wins4 0.0.0.0;
                        dns4_index    0    }

                         nbns4[0]    0x0
                         nbns4[1]    0x0
                         nbns4[2]    0x0
                         nbns4[3]
                        nbns_index    3

dimanche 30 septembre
Exploitation
                      dns4[0]           Statements :
                      dns4[1]
                                        mode_cfg {
                      dns4[2]           wins4 0.0.0.0;
                      dns4[3]           wins4 0.0.0.0;
                                        wins4 0.0.0.0;
                    dns4_index     0    wins4 0.0.0.0;
                                        }
                      nbns4[0]    0x0
                      nbns4[1]    0x0
                      nbns4[2]    0x0
                      nbns4[3]    0x0
                    nbns4_index    4

dimanche 30 septembre
Exploitation
                      dns4[0]           Statements :
                      dns4[1]
                                        mode_cfg {
                      dns4[2]           wins4 0.0.0.0;
                      dns4[3]           wins4 0.0.0.0;
                                        wins4 0.0.0.0;
                    dns4_index      0   wins4 0.0.0.0;
                                        wins4 255.255.255.255;
                      nbns4[0]    0x0   }
                      nbns4[1]    0x0
                      nbns4[2]    0x0
                      nbns4[3]    0x0
                    nbns4_index    -1

dimanche 30 septembre
Exploitation
                      dns4[0]           Statements :
                      dns4[1]
                                        mode_cfg {
                      dns4[2]           wins4 0.0.0.0;
                      dns4[3]           wins4 0.0.0.0;
                                        wins4 0.0.0.0;
                    dns4_index      x   wins4 0.0.0.0;
                                        wins4 255.255.255.255;
                      nbns4[0]    0x0   wins4 x1.x2.x3.x4;
                                        }
                      nbns4[1]    0x0
                      nbns4[2]    0x0
                      nbns4[3]    0x0
                    nbns4_index    -1

dimanche 30 septembre
Exploitation done !
                      dns4[0]           Statements :
                      dns4[1]
                                        mode_cfg {
                      dns4[2]           wins4 0.0.0.0;
                      dns4[3]           wins4 0.0.0.0;
                                        wins4 0.0.0.0;
                    dns4_index      x   wins4 0.0.0.0;
                                        wins4 255.255.255.255;
                      nbns4[0]    0x0   wins4 x1.x2.x3.x4;
                                        dns4 y1.y2.y3.y4;
                      nbns4[1]    0x0   }
                      nbns4[2]    0x0
                      nbns4[3]    0x0
                    nbns4_index    -1
   dns4[x] = y
dimanche 30 septembre
Exploitation done (2) !
                      dns4[0]               Statements :
                      dns4[1]
                                            mode_cfg {
                      dns4[2]               wins4 0.0.0.0;
                      dns4[3]               wins4 0.0.0.0;
                                            wins4 0.0.0.0;
                    dns4_index     x2       wins4 0.0.0.0;
                                            wins4 255.255.255.255;
                      nbns4[0]    0x0       wins4 x1.x2.x3.x4;
                                            dns4 y1.y2.y3.y4;
                      nbns4[1]    0x0       wins4 0.0.0.0;
                      nbns4[2]    0x0       wins4 0.0.0.0;
                                            wins4 0.0.0.0;
                      nbns4[3]    0x0       wins4 0.0.0.0;
                                            wins4 255.255.255.255;
                    nbns4_index    -1       wins4 x21.x22.x23.x24;
                                            dns4 y21.y22.y23.y24;
   dns4[x] = y              dns4[x2] = y2   }
dimanche 30 septembre
One small step...
                  • We can overwrite every writable page in
                        the address space of the racoon binary
                        with precise control
                        => we can write our ROP payload
                  • Our goal is code execution
                        => we need to control the PC to start our
                        ROP payload


dimanche 30 septembre
Usual targets

                  • Overwrite a saved PC in stack
                  • Overwrite a function pointer in memory
                  • So we’re done ?


dimanche 30 septembre
Oh no, ASLR
                  • Because of ASLR, memory layout is
                        randomized at every start of the racoon
                        binary
                  • We don’t know where are our targets
                  • ( The dyld cache mapping is randomized
                        only every boot, but that doesn’t help to
                        control the PC )


dimanche 30 septembre
ASLR details

                  • The binary image and the stack are shifted
                        with the same slide
                  • The heap is slided with another value
                  • dyld shared cache is mapped at a different
                        address every boot



dimanche 30 septembre
ASLR fail...

                  • The binary image / stack slide can only take
                        256 possible values : 0xss000
                  • The stack map is far bigger than the
                        maximum slide of 0xff000
                  • How is this a fail ?

dimanche 30 septembre
Zoom on the layout
                        slide                Binary image



          same slide                         Stack
                                same slide
                                                saved PC
                                                shifted saved PC




dimanche 30 septembre
If we bruteforce, ...
                                       Stack
                                          saved PC
                                          saved PC + 0x01000
                                          saved PC + 0x02000
                                          saved PC + 0x03000
                                          saved PC + 0x04000

                                                 ...

                                          saved PC + 0xff000


dimanche 30 septembre
... what would happen ?

                  • because the mapped stack is greater than
                        the maximum slide, we won’t fail to write
                        with a bad address exception
                  • when we hit the correctly shifted PC, the
                        processor jumps to the specified address
                  • best of all : we can detect the slide

dimanche 30 septembre
256 different pathes
                  • The idea is to use 256 different bootstrap
                        ROP payloads
                  • The bootstrap ROP payload needs to be as
                        small as possible to avoid writing too much
                        data to memory (256 times the size !)
                  • The bootstrap loads the final ROP payload,
                        shifted with the correct slide


dimanche 30 septembre
Bootstrap payload
                  •     uses gadgets from the racoon binary image (shifted
                        differently for every payload)

                  •     fd = open( <file> , O_RDONLY );
                        read ( fd, <absolute address>, <size> );
                        stack pivot to <absolute address>

                  •     <file> is different for every bruteforced slide.
                        « 00 », « 01 », « 02 » ... , « ff »

                  •     <absolute address> points to the heap (which map
                        size > max slide), same for every bruteforced slide

                  •     <size> is constant also, the loaded payload size
dimanche 30 septembre
Final payload
                  • slided accordingly to the bootstrap payload
                  • computes the dyld shared cache slide (to
                        have more gadgets available)
                  • executes the kernel exploit to disable
                        M.C.S. => jailbreak
                  • execve the jb-install binary if it exists in the
                        filesystem


dimanche 30 septembre
Kernel exploit details
                  •     A special sequence of opcodes sent to the
                        OpenBSD packet filter ( /dev/pf ) allowed us to
                        decrement an arbitrary byte in kernel memory
                  •     @planetbeing ‘s idea was to use it to change the
                        NX bit enable flag from 1 to 0
                  •     then to change the highest byte of a syscall to
                        point to a user land address and map the actual
                        payload to that address with RWX permissions
                  •     This is fixed in iOS 6.0


dimanche 30 septembre
jb-install binary
                              (simplified)
                  • remounts system partition rw
                  • installs a modified fstab
                  • extracts Cydia to the system partition
                  • adds the AFC 2 service
                  • switches the way rocky-racoon is started
                    to /etc/launchd.conf (so that it’s the first
                        thing called by the system at bootup. MS
                        related.)
                  •     removes itself
dimanche 30 septembre
Injection vector
                  • @pimskeks messed around with AFC and
                        mobile backup service to achieve a
                        directory traversal
                  • the idea was to create symlinks with AFC
                        pointing to outside of the AFC chroot and
                        have mobile backup restore files to that
                        symlinks
                  • used in Absinthe 2.0. This is fixed in iOS 6.0
dimanche 30 septembre
Injection vector (2)
                  • This allowed us to modify the file /var/db/
                        launchd.db/com.apple.launchd/overrides.plist
                  • Basically it permits to modify existing
                        daemon configurations. We altered the
                        original com.apple.racoon setup so that it
                        starts at bootup loading the jailbreak config
                        file.
                  • This is fixed in iOS 6.0
dimanche 30 septembre
THE FUTURE
              « When will you fucking release the iOS 6.0 jailbreak ? »
                                        :-)




dimanche 30 septembre
What do we have ?
                  • Some partial injection vector
                  • It seems to be that the KASLR is partially
                        broken
                  • a developer only « failbreak » that allows to
                        start custom signed binaries as root
                  • the urge to work on a jailbreak together
                        again after that nice BBQ !!! :-)


dimanche 30 septembre
Questions ?


                  • OMG this gonna be hard for me to
                        understand poeple again :/




dimanche 30 septembre

Weitere ähnliche Inhalte

Was ist angesagt?

Tizen main loop 이해
Tizen main loop 이해Tizen main loop 이해
Tizen main loop 이해Hermet Park
 
Icloud computing seminar
Icloud computing seminarIcloud computing seminar
Icloud computing seminarmunaani
 
Windows internals
Windows internalsWindows internals
Windows internalsPiyush Jain
 
Présentation ios Ragheb Gmira
Présentation ios  Ragheb GmiraPrésentation ios  Ragheb Gmira
Présentation ios Ragheb GmiraRagheb Gmira
 
Deep Dive Into Android Security
Deep Dive Into Android SecurityDeep Dive Into Android Security
Deep Dive Into Android SecurityMarakana Inc.
 
Cross platform app development with flutter
Cross platform app development with flutterCross platform app development with flutter
Cross platform app development with flutterHwan Jo
 
Windows internals Essentials
Windows internals EssentialsWindows internals Essentials
Windows internals EssentialsJohn Ombagi
 
The Hack Spectrum: Tips, Tricks, and Hacks for Unity
The Hack Spectrum: Tips, Tricks, and Hacks for UnityThe Hack Spectrum: Tips, Tricks, and Hacks for Unity
The Hack Spectrum: Tips, Tricks, and Hacks for UnityRyan Hipple
 
Ios operating system
Ios operating systemIos operating system
Ios operating systemTIB Academy
 
Cours photo filtre - collège pilote - Tunisie
Cours photo filtre - collège pilote - TunisieCours photo filtre - collège pilote - Tunisie
Cours photo filtre - collège pilote - TunisieTunisie collège
 

Was ist angesagt? (20)

Tizen main loop 이해
Tizen main loop 이해Tizen main loop 이해
Tizen main loop 이해
 
Icloud computing seminar
Icloud computing seminarIcloud computing seminar
Icloud computing seminar
 
Windows internals
Windows internalsWindows internals
Windows internals
 
Présentation ios Ragheb Gmira
Présentation ios  Ragheb GmiraPrésentation ios  Ragheb Gmira
Présentation ios Ragheb Gmira
 
Deep Dive Into Android Security
Deep Dive Into Android SecurityDeep Dive Into Android Security
Deep Dive Into Android Security
 
18csl67 vtu lab manual
18csl67 vtu lab manual18csl67 vtu lab manual
18csl67 vtu lab manual
 
Net core
Net coreNet core
Net core
 
Cross platform app development with flutter
Cross platform app development with flutterCross platform app development with flutter
Cross platform app development with flutter
 
CEIS110 final project
CEIS110 final projectCEIS110 final project
CEIS110 final project
 
Introduction to ios
Introduction to iosIntroduction to ios
Introduction to ios
 
Windows internals Essentials
Windows internals EssentialsWindows internals Essentials
Windows internals Essentials
 
Mac Operating System
Mac Operating SystemMac Operating System
Mac Operating System
 
Android JNI
Android JNIAndroid JNI
Android JNI
 
The Hack Spectrum: Tips, Tricks, and Hacks for Unity
The Hack Spectrum: Tips, Tricks, and Hacks for UnityThe Hack Spectrum: Tips, Tricks, and Hacks for Unity
The Hack Spectrum: Tips, Tricks, and Hacks for Unity
 
Linux Device Driver’s
Linux Device Driver’sLinux Device Driver’s
Linux Device Driver’s
 
Windows 8
Windows 8Windows 8
Windows 8
 
Ios operating system
Ios operating systemIos operating system
Ios operating system
 
Android Virtualization: Opportunity and Organization
Android Virtualization: Opportunity and OrganizationAndroid Virtualization: Opportunity and Organization
Android Virtualization: Opportunity and Organization
 
icloud
icloudicloud
icloud
 
Cours photo filtre - collège pilote - Tunisie
Cours photo filtre - collège pilote - TunisieCours photo filtre - collège pilote - Tunisie
Cours photo filtre - collège pilote - Tunisie
 

Ähnlich wie 108484130 pod2g-jailbreak-techniques-wwjc-2012

Toorcon 2010: IPhone Rootkits? There's an App for That
Toorcon 2010: IPhone Rootkits? There's an App for ThatToorcon 2010: IPhone Rootkits? There's an App for That
Toorcon 2010: IPhone Rootkits? There's an App for ThatEric Monti
 
EkoParty 2010: iPhone Rootkit? There's an App for that.
EkoParty 2010: iPhone Rootkit? There's an App for that.EkoParty 2010: iPhone Rootkit? There's an App for that.
EkoParty 2010: iPhone Rootkit? There's an App for that.Eric Monti
 
Linux Kernel Exploitation
Linux Kernel ExploitationLinux Kernel Exploitation
Linux Kernel ExploitationScio Security
 
Android and ios cracking, hackintosh included !
Android and ios cracking, hackintosh included !Android and ios cracking, hackintosh included !
Android and ios cracking, hackintosh included !Veduruparthy Bharat
 
Flash security past_present_future_final_en
Flash security past_present_future_final_enFlash security past_present_future_final_en
Flash security past_present_future_final_enSunghun Kim
 
Jailbreaking iOS
Jailbreaking iOSJailbreaking iOS
Jailbreaking iOSKai Aras
 
Playing with fuzz bunch and danderspritz
Playing with fuzz bunch and danderspritzPlaying with fuzz bunch and danderspritz
Playing with fuzz bunch and danderspritzDeepanshu Gajbhiye
 
BlackHat USA 2011 - Stefan Esser - iOS Kernel Exploitation
BlackHat USA 2011 - Stefan Esser - iOS Kernel ExploitationBlackHat USA 2011 - Stefan Esser - iOS Kernel Exploitation
BlackHat USA 2011 - Stefan Esser - iOS Kernel ExploitationStefan Esser
 
History of Android Security – from linux to jelly bean
History of Android Security – from linux to jelly beanHistory of Android Security – from linux to jelly bean
History of Android Security – from linux to jelly beanJung Pil (J.P.) Choi
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testingeightbit
 
What's in a Jailbreak? - BSides 2019 keynote
What's in a Jailbreak? - BSides 2019 keynoteWhat's in a Jailbreak? - BSides 2019 keynote
What's in a Jailbreak? - BSides 2019 keynoteMarkDowd13
 
Find your own iOS kernel bug
Find your own iOS kernel bugFind your own iOS kernel bug
Find your own iOS kernel bugGustavo Martinez
 
OWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testingeightbit
 
Introduction to OpenBricks: an Embedded Linux Framework
Introduction to OpenBricks: an Embedded Linux FrameworkIntroduction to OpenBricks: an Embedded Linux Framework
Introduction to OpenBricks: an Embedded Linux FrameworkBenjamin Zores
 
Welcome to the Symfony2 World - FOSDEM 2013
 Welcome to the Symfony2 World - FOSDEM 2013 Welcome to the Symfony2 World - FOSDEM 2013
Welcome to the Symfony2 World - FOSDEM 2013Lukas Smith
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONLyon Yang
 
Italian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionItalian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionChris Hardy
 
Cigarette VS Bubble Gum
Cigarette VS Bubble GumCigarette VS Bubble Gum
Cigarette VS Bubble GumNaruenart
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesLinaro
 

Ähnlich wie 108484130 pod2g-jailbreak-techniques-wwjc-2012 (20)

Toorcon 2010: IPhone Rootkits? There's an App for That
Toorcon 2010: IPhone Rootkits? There's an App for ThatToorcon 2010: IPhone Rootkits? There's an App for That
Toorcon 2010: IPhone Rootkits? There's an App for That
 
EkoParty 2010: iPhone Rootkit? There's an App for that.
EkoParty 2010: iPhone Rootkit? There's an App for that.EkoParty 2010: iPhone Rootkit? There's an App for that.
EkoParty 2010: iPhone Rootkit? There's an App for that.
 
Linux Kernel Exploitation
Linux Kernel ExploitationLinux Kernel Exploitation
Linux Kernel Exploitation
 
Android and ios cracking, hackintosh included !
Android and ios cracking, hackintosh included !Android and ios cracking, hackintosh included !
Android and ios cracking, hackintosh included !
 
Flash security past_present_future_final_en
Flash security past_present_future_final_enFlash security past_present_future_final_en
Flash security past_present_future_final_en
 
Jailbreaking iOS
Jailbreaking iOSJailbreaking iOS
Jailbreaking iOS
 
Playing with fuzz bunch and danderspritz
Playing with fuzz bunch and danderspritzPlaying with fuzz bunch and danderspritz
Playing with fuzz bunch and danderspritz
 
BlackHat USA 2011 - Stefan Esser - iOS Kernel Exploitation
BlackHat USA 2011 - Stefan Esser - iOS Kernel ExploitationBlackHat USA 2011 - Stefan Esser - iOS Kernel Exploitation
BlackHat USA 2011 - Stefan Esser - iOS Kernel Exploitation
 
History of Android Security – from linux to jelly bean
History of Android Security – from linux to jelly beanHistory of Android Security – from linux to jelly bean
History of Android Security – from linux to jelly bean
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testing
 
What's in a Jailbreak? - BSides 2019 keynote
What's in a Jailbreak? - BSides 2019 keynoteWhat's in a Jailbreak? - BSides 2019 keynote
What's in a Jailbreak? - BSides 2019 keynote
 
Find your own iOS kernel bug
Find your own iOS kernel bugFind your own iOS kernel bug
Find your own iOS kernel bug
 
OWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testing
 
Introduction to OpenBricks: an Embedded Linux Framework
Introduction to OpenBricks: an Embedded Linux FrameworkIntroduction to OpenBricks: an Embedded Linux Framework
Introduction to OpenBricks: an Embedded Linux Framework
 
Welcome to the Symfony2 World - FOSDEM 2013
 Welcome to the Symfony2 World - FOSDEM 2013 Welcome to the Symfony2 World - FOSDEM 2013
Welcome to the Symfony2 World - FOSDEM 2013
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCON
 
Sonatype DevSecOps Leadership forum 2020
Sonatype DevSecOps Leadership forum 2020Sonatype DevSecOps Leadership forum 2020
Sonatype DevSecOps Leadership forum 2020
 
Italian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionItalian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch Session
 
Cigarette VS Bubble Gum
Cigarette VS Bubble GumCigarette VS Bubble Gum
Cigarette VS Bubble Gum
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
 

Mehr von wtreterte

Riattivazionecarriera
RiattivazionecarrieraRiattivazionecarriera
Riattivazionecarrierawtreterte
 
Catalogo colori osmo
Catalogo colori osmoCatalogo colori osmo
Catalogo colori osmowtreterte
 
Dj68 00518 c
Dj68 00518 cDj68 00518 c
Dj68 00518 cwtreterte
 
Olsrd linux nl80211_extension
Olsrd linux nl80211_extensionOlsrd linux nl80211_extension
Olsrd linux nl80211_extensionwtreterte
 
Lf who writes_linux_2012
Lf who writes_linux_2012Lf who writes_linux_2012
Lf who writes_linux_2012wtreterte
 
Spectrum wall chart_aug2011
Spectrum wall chart_aug2011Spectrum wall chart_aug2011
Spectrum wall chart_aug2011wtreterte
 
Spectrum use summary_master-06212010
Spectrum use summary_master-06212010Spectrum use summary_master-06212010
Spectrum use summary_master-06212010wtreterte
 

Mehr von wtreterte (8)

Riattivazionecarriera
RiattivazionecarrieraRiattivazionecarriera
Riattivazionecarriera
 
Catalogo colori osmo
Catalogo colori osmoCatalogo colori osmo
Catalogo colori osmo
 
Dj68 00518 c
Dj68 00518 cDj68 00518 c
Dj68 00518 c
 
Document
DocumentDocument
Document
 
Olsrd linux nl80211_extension
Olsrd linux nl80211_extensionOlsrd linux nl80211_extension
Olsrd linux nl80211_extension
 
Lf who writes_linux_2012
Lf who writes_linux_2012Lf who writes_linux_2012
Lf who writes_linux_2012
 
Spectrum wall chart_aug2011
Spectrum wall chart_aug2011Spectrum wall chart_aug2011
Spectrum wall chart_aug2011
 
Spectrum use summary_master-06212010
Spectrum use summary_master-06212010Spectrum use summary_master-06212010
Spectrum use summary_master-06212010
 

108484130 pod2g-jailbreak-techniques-wwjc-2012

  • 1. JAILBREAKING TECHNIQUES WWJC, San Francisco, 29th of september, 2012 @pod2g dimanche 30 septembre
  • 2. INTRODUCTION Who am I ? dimanche 30 septembre
  • 3. @pod2g • Real name : Cyril (I’ve no last name) • Age : 32 • From France (in no particular city) • iOS security researcher since 2009 for a hobby • Blog : http://www.pod2g.org dimanche 30 septembre
  • 4. Thank you ! dimanche 30 septembre
  • 5. When did I get started ? • Played with a ZX 81 computer at the age of 5. I copied BASIC programs from books without understanding a thing ! • I had an ATARI ST some years later and did some GFA BASIC, 68k assembly and demo making. • Learned C / C++ at college • Worked as J2EE expert developer then project manager for 11+ years dimanche 30 septembre
  • 6. Hacking ... ? • Improved the performance of the SD driver of the WRT54G router, by writing it in pure MIPS assembly code • Hacked the eten X500+ and « cooked » a new ROM for it (Windows Mobile 6.1) You can see my posts in eten-users.eu forums, login name « Cyril » :-) dimanche 30 septembre
  • 7. iOS SECURITY RESEARCH History of my work dimanche 30 septembre
  • 8. 01/2009 ARM7 GO - IPOD 2G IOS 2.1 • Joined « The Chronic Dev » team by helping them to unleash the « arm7 go » iBoot command of the iPod 2G 2.1 which was its first unsigned code execution vector. • Worked on the « 0wnboot » payload to tether jailbreak the iPod 2G. • Dumped the iPod 2G bootrom. dimanche 30 septembre
  • 9. 01/2009 -> 03/2009 24KPWN - IPOD 2G, IPHONE 3GS BOOTROM • Fully reversed the LLB loading part of the bootrom. • Found the « 24kpwn » bootrom vulnerability by static analysis. • Did a proof of concept by modifying the NOR of the device. • Worked on the bootrom payload with @planetbeing to allow custom LLB loading which was quickly released in the « redsn0w » jailbreak tool. dimanche 30 septembre
  • 10. 06/2009 -> 09/2009 USB_CONTROL_MSG(0X21, 2) - IOS 3.1 • Worked on adding debugging and breakpoint commands to the iBoot. • Wrote a USB fuzzer using the libusb API and found the usb_control_msg(0x21, 2) vulnerability. • Using a custom iBoot, debugged the vulnerability and wrote an exception vector rewrite payload as a proof of concept. dimanche 30 septembre
  • 11. 03/2010 -> 09/2010 STEAKS4UCE / SHATTER - IPOD2G / IPHONE 4 BOOTROM • Reverse engineered the iPod 3G bootrom DFU loading part of a firmware image. Focused on the SHA1 control part. • Wrote more advanced USB fuzzers. • Found a DFU heap overflow in the iPod 2G bootrom (steaks4uce), and wrote the exploit code which permitted to execute custom ARM payloads in the bootrom context. • Figured out using the previous exploit that the addresses 0x20 to 0x40 (exception vector addresses) are writable even in a ROM because of the ARM processor data cache. • Exploited a null dereference vulnerability by overwriting the SHA1 processor registers of the iPhone 4 and rewrote the exception vectors. This is the unreleased « SHAtter » exploit. dimanche 30 septembre
  • 12. 01/2011 -> 02/2011 FEEDFACE - IOS 4.2.1 • Found the « HFS volume name stack buffer overflow » vulnerability. • Wrote the exploit payload to do the iOS kernel jailbreak. • Worked on the « greenpois0n » jailbreak tool to include « feedface » for device untethering. dimanche 30 septembre
  • 13. 07/2011 -> 01/2011 CORONA - IOS 5.0, 5.0.1 • Wrote a HFS fuzzer which found a heap overflow in the OSX 10.7.1 kernel HFS B-Tree parser. • Wrote a proof of concept exploit code on OSX. Relies on heap Feng Shui technics. • Found a format string vulnerability in the IPsec racoon service. • Wrote a ROP and format string generator for the racoon vulnerability so that custom code could be executed at iOS 5.0 startup. • Used the custom code to trigger the HFS kernel vulnerability which lead to the Corona untether jailbreak for iOS 5.0.1. • Worked with other security researchers to extend the untether to newer devices. Involved finding other exploits to break out the Apple sandbox. dimanche 30 septembre
  • 14. ROCKY RACOON, ABSINTHE 2.0 Inner workings of the iOS 5.1 jailbreak dimanche 30 septembre
  • 15. CVE-2012-3727 : iOS Jailbreak Dream Team IPSec Available for: iPhone 3GS and later, iPod touch (4th generation) and later, iPad 2 and later Impact: Loading a maliciously crafted racoon configuration file may lead to arbitrary code execution Description: A buffer overflow existed in the handling of racoon configuration files. This issue was addressed through improved bounds checking. dimanche 30 septembre
  • 16. CVE-2012-3727 : iOS Jailbreak Dream Team Kernel Available for: iPhone 3GS and later, iPod touch (4th generation) and later, iPad 2 and later Impact: A local user may be able to execute arbitrary code with system privileges Description: An invalid pointer dereference issue existed in the kernel's handling of packet filter ioctls. This may allow an attacker to alter kernel memory. This issue was addressed through improved error handling. dimanche 30 septembre
  • 17. The goldmine of bugs • When I worked on Corona (iOS 5.0 jailbreak), I spotted lot of bugs in racoon which may be interresting for iOS 5.1 • I did a quick search in the IPsec Tools bug tracker (sourceforge) before looking at the code by myself, and here is what I’ve found ! dimanche 30 septembre
  • 18. Users are fuzzers • racoon 0.7.3 crashes with Segmentaion Fault just after start - ID: 2987081 : « when I add more than two mode_cfg{} statements in racoon.conf » ... « racoon vanishes just after start without any single error line in log file » ... « "Segmentation fault" » dimanche 30 septembre
  • 19. IPsec tools, no support ? • Nobody answered to the bug report, since April 2010 • Even after successful exploitation for the iOS 5.1 jailbreak, the bug is still opened • The reporting user siutkowskij (thanks to him) attached a configuration file dimanche 30 septembre
  • 20. Let’s try it out • iOS 5.1.1 is vulnerable :-) • OSX 10.7.4 also, interresting to play with the vulnerability • Let’s play with the supplied configuration file and try to isolate the problem dimanche 30 septembre
  • 21. ... mode_cfg { conf_source local; auth_groups "investments"; group_source system; auth_source system; accounting system; network4 172.31.40.1; netmask4 255.255.255.0; pool_size 253; dns4 172.31.3.144; dns4 172.31.3.237; default_domain "somedomain.pl"; banner "/etc/racoon/motd"; pfs_group 2; save_passwd on; } mode_cfg { ... conf_source local; mode_cfg { auth_groups "admins"; dns4 172.31.3.144; ... group_source system; dns4 172.31.3.237; mode_cfg { auth_source system; } dns4 172.31.3.144; accounting system; mode_cfg { dns4 172.31.3.237; network4 172.31.41.1; dns4 172.31.3.144; dns4 172.31.3.144; netmask4 255.255.255.0; dns4 172.31.3.237; dns4 172.31.3.237; pool_size 253; } dns4 172.31.3.144; dns4 172.31.3.144; mode_cfg { dns4 172.31.3.237; dns4 172.31.3.237; dns4 172.31.3.144; } default_domain "somedomain.pl"; dns4 172.31.3.237; ... banner "/etc/racoon/motd"; } pfs_group 2; ... save_passwd on; } mode_cfg { conf_source local; auth_groups "somegroup"; group_source system; auth_source system; accounting system; network4 172.31.42.1; netmask4 255.255.255.0; dns4 172.31.3.144; dns4 172.31.3.237; default_domain "asseco.pl"; banner "/etc/racoon/motd"; pfs_group 2; save_passwd on; } ... dimanche 30 septembre
  • 22. What do we know ? • Actually, it has nothing to do with the multiple mode_cfg sections • Crash happens when the number of dns4 statements is greater than 4 • Buffer overflow ? Let’s look at the IPsec Tools source code (opensource software) dimanche 30 septembre
  • 23. Code excerpt cfparse.y ... addrdns : ADDRSTRING { #ifdef ENABLE_HYBRID struct isakmp_cfg_config *icc = &isakmp_cfg_config; if (icc->dns4_index > MAXNS) yyerror("No more than %d DNS", MAXNS); if (inet_pton(AF_INET, $1->v, &icc->dns4[icc->dns4_index++]) != 1) yyerror("bad IPv4 DNS address."); vfree($1); #else yyerror("racoon not configured with --enable-hybrid"); #endif } ; ... dimanche 30 septembre
  • 24. Code excerpt isakmp_cfg.h struct isakmp_cfg_config { in_addr_t network4; in_addr_t netmask4; in_addr_t dns4[MAXNS]; int dns4_index; in_addr_t nbns4[MAXWINS]; int nbns4_index; struct isakmp_cfg_port *port_pool; int authsource; int groupsource; char **grouplist; int groupcount; int confsource; int accounting; size_t pool_size; int auth_throttle; /* XXX move this to a unity specific sub-structure */ char default_domain[MAXPATHLEN + 1]; char motd[MAXPATHLEN + 1]; struct unity_netentry *splitnet_list; int splitnet_count; int splitnet_type; char *splitdns_list; int splitdns_len; int pfs_group; int save_passwd; }; dimanche 30 septembre
  • 25. What to do with it ? • Overflowing dns4 array allows to control the dns4_index variable • Next dns4 statement will write the IP address to an arbitrary index of the array • It’s indeed an arbitrary memory write kind of vulnerability • fixed in iOS 6.0 dimanche 30 septembre
  • 26. Limitations • using the dns4 statement only, the modification of the dns4_index can only be done a single time • which means only one block (any size) of memory can be controlled dimanche 30 septembre
  • 27. Copy / Paste FTW • Wait ! They did exactly the same mistakes with the wins statement • No more limitations ! • Let’s see how to exploit it completely now dimanche 30 septembre
  • 28. Code excerpt cfparse.y ... addrwins : ADDRSTRING { #ifdef ENABLE_HYBRID struct isakmp_cfg_config *icc = &isakmp_cfg_config; if (icc->nbns4_index > MAXNS) yyerror("No more than %d WINS", MAXNS); if (inet_pton(AF_INET, $1->v, &icc->nbns4[icc->nbns4_index++]) != 1) yyerror("bad IPv4 WINS address."); vfree($1); #else yyerror("racoon not configured with --enable-hybrid"); #endif } ; ... dimanche 30 septembre
  • 29. Code excerpt isakmp_cfg.h struct isakmp_cfg_config { in_addr_t network4; in_addr_t netmask4; in_addr_t dns4[MAXNS]; int dns4_index; in_addr_t nbns4[MAXWINS]; int nbns4_index; struct isakmp_cfg_port *port_pool; int authsource; int groupsource; char **grouplist; int groupcount; int confsource; int accounting; size_t pool_size; int auth_throttle; /* XXX move this to a unity specific sub-structure */ char default_domain[MAXPATHLEN + 1]; char motd[MAXPATHLEN + 1]; struct unity_netentry *splitnet_list; int splitnet_count; int splitnet_type; char *splitdns_list; int splitdns_len; int pfs_group; int save_passwd; }; dimanche 30 septembre
  • 30. Exploitation dns4[0] Statements : dns4[1] dns4[2] dns4[3] dns4_index 0 nbns[0] nbns[1] nbns[2] nbns[3] nbns_index 0 dimanche 30 septembre
  • 31. Exploitation dns4[0] Statements : dns4[1] mode_cfg { dns4[2] wins4 0.0.0.0; dns4[3] } dns4_index 0 nbns[0] 0x0 nbns[1] nbns[2] nbns[3] nbns_index 1 dimanche 30 septembre
  • 32. Exploitation dns4[0] Statements : dns4[1] mode_cfg { dns4[2] wins4 0.0.0.0; dns4[3] wins4 0.0.0.0; } dns4_index 0 nbns[0] 0x0 nbns[1] 0x0 nbns[2] nbns[3] nbns_index 2 dimanche 30 septembre
  • 33. Exploitation dns4[0] Statements : dns4[1] mode_cfg { dns4[2] wins4 0.0.0.0; dns4[3] wins4 0.0.0.0; wins4 0.0.0.0; dns4_index 0 } nbns4[0] 0x0 nbns4[1] 0x0 nbns4[2] 0x0 nbns4[3] nbns_index 3 dimanche 30 septembre
  • 34. Exploitation dns4[0] Statements : dns4[1] mode_cfg { dns4[2] wins4 0.0.0.0; dns4[3] wins4 0.0.0.0; wins4 0.0.0.0; dns4_index 0 wins4 0.0.0.0; } nbns4[0] 0x0 nbns4[1] 0x0 nbns4[2] 0x0 nbns4[3] 0x0 nbns4_index 4 dimanche 30 septembre
  • 35. Exploitation dns4[0] Statements : dns4[1] mode_cfg { dns4[2] wins4 0.0.0.0; dns4[3] wins4 0.0.0.0; wins4 0.0.0.0; dns4_index 0 wins4 0.0.0.0; wins4 255.255.255.255; nbns4[0] 0x0 } nbns4[1] 0x0 nbns4[2] 0x0 nbns4[3] 0x0 nbns4_index -1 dimanche 30 septembre
  • 36. Exploitation dns4[0] Statements : dns4[1] mode_cfg { dns4[2] wins4 0.0.0.0; dns4[3] wins4 0.0.0.0; wins4 0.0.0.0; dns4_index x wins4 0.0.0.0; wins4 255.255.255.255; nbns4[0] 0x0 wins4 x1.x2.x3.x4; } nbns4[1] 0x0 nbns4[2] 0x0 nbns4[3] 0x0 nbns4_index -1 dimanche 30 septembre
  • 37. Exploitation done ! dns4[0] Statements : dns4[1] mode_cfg { dns4[2] wins4 0.0.0.0; dns4[3] wins4 0.0.0.0; wins4 0.0.0.0; dns4_index x wins4 0.0.0.0; wins4 255.255.255.255; nbns4[0] 0x0 wins4 x1.x2.x3.x4; dns4 y1.y2.y3.y4; nbns4[1] 0x0 } nbns4[2] 0x0 nbns4[3] 0x0 nbns4_index -1 dns4[x] = y dimanche 30 septembre
  • 38. Exploitation done (2) ! dns4[0] Statements : dns4[1] mode_cfg { dns4[2] wins4 0.0.0.0; dns4[3] wins4 0.0.0.0; wins4 0.0.0.0; dns4_index x2 wins4 0.0.0.0; wins4 255.255.255.255; nbns4[0] 0x0 wins4 x1.x2.x3.x4; dns4 y1.y2.y3.y4; nbns4[1] 0x0 wins4 0.0.0.0; nbns4[2] 0x0 wins4 0.0.0.0; wins4 0.0.0.0; nbns4[3] 0x0 wins4 0.0.0.0; wins4 255.255.255.255; nbns4_index -1 wins4 x21.x22.x23.x24; dns4 y21.y22.y23.y24; dns4[x] = y dns4[x2] = y2 } dimanche 30 septembre
  • 39. One small step... • We can overwrite every writable page in the address space of the racoon binary with precise control => we can write our ROP payload • Our goal is code execution => we need to control the PC to start our ROP payload dimanche 30 septembre
  • 40. Usual targets • Overwrite a saved PC in stack • Overwrite a function pointer in memory • So we’re done ? dimanche 30 septembre
  • 41. Oh no, ASLR • Because of ASLR, memory layout is randomized at every start of the racoon binary • We don’t know where are our targets • ( The dyld cache mapping is randomized only every boot, but that doesn’t help to control the PC ) dimanche 30 septembre
  • 42. ASLR details • The binary image and the stack are shifted with the same slide • The heap is slided with another value • dyld shared cache is mapped at a different address every boot dimanche 30 septembre
  • 43. ASLR fail... • The binary image / stack slide can only take 256 possible values : 0xss000 • The stack map is far bigger than the maximum slide of 0xff000 • How is this a fail ? dimanche 30 septembre
  • 44. Zoom on the layout slide Binary image same slide Stack same slide saved PC shifted saved PC dimanche 30 septembre
  • 45. If we bruteforce, ... Stack saved PC saved PC + 0x01000 saved PC + 0x02000 saved PC + 0x03000 saved PC + 0x04000 ... saved PC + 0xff000 dimanche 30 septembre
  • 46. ... what would happen ? • because the mapped stack is greater than the maximum slide, we won’t fail to write with a bad address exception • when we hit the correctly shifted PC, the processor jumps to the specified address • best of all : we can detect the slide dimanche 30 septembre
  • 47. 256 different pathes • The idea is to use 256 different bootstrap ROP payloads • The bootstrap ROP payload needs to be as small as possible to avoid writing too much data to memory (256 times the size !) • The bootstrap loads the final ROP payload, shifted with the correct slide dimanche 30 septembre
  • 48. Bootstrap payload • uses gadgets from the racoon binary image (shifted differently for every payload) • fd = open( <file> , O_RDONLY ); read ( fd, <absolute address>, <size> ); stack pivot to <absolute address> • <file> is different for every bruteforced slide. « 00 », « 01 », « 02 » ... , « ff » • <absolute address> points to the heap (which map size > max slide), same for every bruteforced slide • <size> is constant also, the loaded payload size dimanche 30 septembre
  • 49. Final payload • slided accordingly to the bootstrap payload • computes the dyld shared cache slide (to have more gadgets available) • executes the kernel exploit to disable M.C.S. => jailbreak • execve the jb-install binary if it exists in the filesystem dimanche 30 septembre
  • 50. Kernel exploit details • A special sequence of opcodes sent to the OpenBSD packet filter ( /dev/pf ) allowed us to decrement an arbitrary byte in kernel memory • @planetbeing ‘s idea was to use it to change the NX bit enable flag from 1 to 0 • then to change the highest byte of a syscall to point to a user land address and map the actual payload to that address with RWX permissions • This is fixed in iOS 6.0 dimanche 30 septembre
  • 51. jb-install binary (simplified) • remounts system partition rw • installs a modified fstab • extracts Cydia to the system partition • adds the AFC 2 service • switches the way rocky-racoon is started to /etc/launchd.conf (so that it’s the first thing called by the system at bootup. MS related.) • removes itself dimanche 30 septembre
  • 52. Injection vector • @pimskeks messed around with AFC and mobile backup service to achieve a directory traversal • the idea was to create symlinks with AFC pointing to outside of the AFC chroot and have mobile backup restore files to that symlinks • used in Absinthe 2.0. This is fixed in iOS 6.0 dimanche 30 septembre
  • 53. Injection vector (2) • This allowed us to modify the file /var/db/ launchd.db/com.apple.launchd/overrides.plist • Basically it permits to modify existing daemon configurations. We altered the original com.apple.racoon setup so that it starts at bootup loading the jailbreak config file. • This is fixed in iOS 6.0 dimanche 30 septembre
  • 54. THE FUTURE « When will you fucking release the iOS 6.0 jailbreak ? » :-) dimanche 30 septembre
  • 55. What do we have ? • Some partial injection vector • It seems to be that the KASLR is partially broken • a developer only « failbreak » that allows to start custom signed binaries as root • the urge to work on a jailbreak together again after that nice BBQ !!! :-) dimanche 30 septembre
  • 56. Questions ? • OMG this gonna be hard for me to understand poeple again :/ dimanche 30 septembre