dmayer / idb

idb is a tool to simplify some common tasks for iOS pentesting and research
MIT License
942 stars 156 forks source link

App Selection fails to retrieve Info.plist #8

Closed sanitybit closed 10 years ago

sanitybit commented 10 years ago

iOS 7.0.4 - gidb built from master on 1/20/14

Several applications fail to show up in the App Selection Dialog and instead display as "[Error] => [Error]". Console dialog shows:

[INFO] 2014-01-21 12:24:40 :: gidb ::  Info.plist found at /private/var/mobile/Applications/07774123-C107-46C4-95C1-7DEE14F676AC/PBSPlayeriPad.app/Info.plist
[ERROR] 2014-01-21 12:24:40 :: gidb ::  Error getting plist file /private/var/mobile/Applications/07774123-C107-46C4-95C1-7DEE14F676AC/PBSPlayeriPad.app/Info.plist
[INFO] 2014-01-21 12:24:53 :: gidb ::  Info.plist found at /private/var/mobile/Applications/A84F021D-5C27-4B97-8554-2F1973009561/procreate.app/Info.plist
[ERROR] 2014-01-21 12:24:53 :: gidb ::  Error getting plist file /private/var/mobile/Applications/A84F021D-5C27-4B97-8554-2F1973009561/procreate.app/Info.plist
[INFO] 2014-01-21 12:24:53 :: gidb ::  Info.plist found at /private/var/mobile/Applications/A96C042E-8B3A-4D3F-B68A-44F4A5B8C64F/TetrisApp.app/Info.plist
[ERROR] 2014-01-21 12:24:53 :: gidb ::  Error getting plist file /private/var/mobile/Applications/A96C042E-8B3A-4D3F-B68A-44F4A5B8C64F/TetrisApp.app/Info.plist

I verified that the current user (root) can see access these files on the device over SSH. Aside from the 7 failed applications, the rest of the installed applications are populated correctly.

dmayer commented 10 years ago

Hi,

I installed the PBS app on my iPad which is running iOS 6 and it works. Same for PBS on an iPhone with iOS 7. To debug this, I added some additional output to the exception handler for the Info.plist parsing. (Commit: 9b05520f792ffc5ee49b9d9204b74d6cece52349). Could you pull the update and run it again to see what exactly is failing? You should get an exact error and a backtrace now.

Thanks, Daniel

sanitybit commented 10 years ago

Sure thing:

INFO] 2014-01-21 14:31:36 :: gidb ::  Info.plist found at /private/var/mobile/Applications/07774123-C107-46C4-95C1-7DEE14F676AC/PBSPlayeriPad.app/Info.plist
[INFO] 2014-01-21 14:31:36 :: gidb ::  Parsing plist file..
[ERROR] 2014-01-21 14:31:36 :: gidb ::  Error parsing plist file tmp/07774123-C107-46C4-95C1-7DEE14F676AC//PBSPlayeriPad.app/Info.plist.
[DEBUG] 2014-01-21 14:31:36 :: gidb ::  Exception Details: invalid byte sequence in UTF-8.
[DEBUG] 2014-01-21 14:31:36 :: gidb ::  Backtrace: /usr/local/rvm/gems/ruby-1.9.3-p429/gems/plist-3.1.0/lib/plist/parser.rb:91:in `scan'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/plist-3.1.0/lib/plist/parser.rb:91:in `parse'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/plist-3.1.0/lib/plist/parser.rb:29:in `parse_xml'
/home/sanitybit/.sources/idb/lib/plist_util.rb:44:in `parse_plist_file'
/home/sanitybit/.sources/idb/lib/plist_util.rb:18:in `initialize'
/home/sanitybit/.sources/idb/lib/app.rb:216:in `new'
/home/sanitybit/.sources/idb/lib/app.rb:216:in `parse_info_plist'
/home/sanitybit/.sources/idb/lib/app.rb:14:in `initialize'
/home/sanitybit/.sources/idb/gui/app_list_dialog.rb:51:in `new'
/home/sanitybit/.sources/idb/gui/app_list_dialog.rb:51:in `block in refresh_app_list'
/home/sanitybit/.sources/idb/gui/app_list_dialog.rb:50:in `each'
/home/sanitybit/.sources/idb/gui/app_list_dialog.rb:50:in `refresh_app_list'
/home/sanitybit/.sources/idb/gui/app_list_dialog.rb:18:in `initialize'
/home/sanitybit/.sources/idb/gui/app_details_group_box.rb:24:in `new'
/home/sanitybit/.sources/idb/gui/app_details_group_box.rb:24:in `block in initialize'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/qtbindings-4.8.3.0/lib/Qt/qtruby4.rb:2427:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/qtbindings-4.8.3.0/lib/Qt/qtruby4.rb:2427:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/qtbindings-4.8.3.0/lib/Qt/qtruby4.rb:469:in `qt_metacall'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/qtbindings-4.8.3.0/lib/Qt/qtruby4.rb:469:in `method_missing'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/qtbindings-4.8.3.0/lib/Qt/qtruby4.rb:469:in `exec'
gidb.rb:244:in `<main>'.

It looks like the Info.plist is being corrupted during the SSH transfer? Inset terminal, top panel is Info.plist on device, bottom panel is Info.plist in idb's tmp directory. I am using SSH over the network instead of usbmuxd - usbmuxd hasn't worked for me on iOS 7 (constant "Trust this computer?" message); going to try building something more recent.

Deleting idb's corrupted copy of Info.plist out of the tmp directory and running App Selection again just results in a corrupted Info.plist showing back up.

error

dmayer commented 10 years ago

Okay thanks. So there is two potential issues with this. The first is that you may not have plutil installed and the binary plist cannot be converted to an XML version. Or you do and there is some error in the conversion. I just change the plist gem that idb uses to plist4r which should be able to handle binary plists directly. Give a shot please. If it works we can remove the call to plutil entirely and just parse the binary plist using ruby.

If that doesn't work, it may be that those Info.plists contain invalid UTF-8 chars and we may need to force ruby to ignore those invalid bytes. Lets hope its the first.

Daniel

sanitybit commented 10 years ago

I do have the plutil binary in my path (from the Ubuntu libplist-utils 1.8-2 package). It does appear to differ in functionality from the Apple version included with Xcode (and the version installed to my iPad).

Updating to the latest commit with plist4r fixes the issue, all Info.plist are processed correctly. Closing this bug.

dmayer commented 10 years ago

Great, thanks for the quick turnaround.