├── .gitignore ├── libplist ├── Makefile └── src │ ├── libplist.1.1.3.dylib │ ├── Makefile │ ├── Real.cpp │ ├── plist.h │ ├── Boolean.cpp │ ├── Integer.cpp │ ├── String.cpp │ ├── Date.cpp │ ├── Data.cpp │ ├── Structure.cpp │ ├── Node.cpp │ ├── Array.cpp │ └── Dictionary.cpp ├── libusbmuxd ├── Makefile ├── tools │ ├── iproxy │ └── Makefile ├── src │ ├── libusbmuxd.a │ ├── libusbmuxd.1.0.7.dylib │ ├── Makefile │ ├── sock_stuff.h │ ├── utils.h │ ├── usbmuxd-proto.h │ └── utils.c ├── python-client │ ├── usbmux.pyc │ └── tcprelay.py └── README ├── libimobiledevice ├── Makefile ├── tools │ ├── idevice_id │ ├── idevicebackup │ ├── idevicedate │ ├── ideviceinfo │ ├── idevicepair │ ├── idevicesyslog │ ├── idevicebackup2 │ ├── ipa │ │ ├── ARCHIVE.ipa │ │ └── README │ ├── ideviceinstaller │ ├── idevicescreenshot │ ├── ideviceenterrecovery │ ├── ideviceimagemounter │ ├── Makefile │ ├── ideviceenterrecovery.c │ ├── idevice_id.c │ ├── idevicescreenshot.c │ └── idevicesyslog.c └── src │ ├── libimobiledevice.2.dylib │ ├── Makefile │ ├── mobilebackup.h │ ├── screenshotr.h │ ├── mobilebackup2.h │ ├── sbservices.h │ ├── restore.h │ ├── mobile_image_mounter.h │ ├── installation_proxy.h │ ├── notification_proxy.h │ ├── house_arrest.h │ ├── mobilesync.h │ ├── file_relay.h │ ├── lockdown.h │ ├── idevice.h │ ├── debug.h │ ├── userpref.h │ ├── property_list_service.h │ ├── device_link_service.h │ ├── afc.h │ └── debug.c ├── idevicerestore ├── Makefile └── src │ ├── idevicerestore │ ├── libirecovery.dylib │ ├── Makefile │ ├── tss.h │ ├── dfu.h │ ├── ipsw.h │ ├── asr.h │ ├── normal.h │ ├── idevicerestore.h │ ├── recovery.h │ ├── restore.h │ ├── common.c │ ├── img3.h │ └── dfu.c ├── amai ├── apticket.der ├── pbsync │ ├── pbsync_01.plist │ ├── pbsync_02.plist │ ├── pbsync_03.plist │ ├── pbsync_04.plist │ ├── pbsync_05.plist │ ├── pbsync_06.plist │ ├── pbsync_07.plist │ ├── pbsync_08.plist │ ├── pbsync_08r.plist │ ├── pbsync_09.plist │ └── pbsync_10.plist ├── gc-request.plist ├── README └── receipt.plist ├── ribusb ├── ext │ ├── ribusb_ext.bundle │ └── extconf.rb ├── Manifest.txt ├── History.txt ├── test │ ├── test_ribusb_gc.rb │ ├── test_ribusb.rb │ └── test_ribusb_compat.rb └── README.rdoc ├── ideviceactivate ├── src │ ├── ideviceactivate │ ├── Makefile │ ├── idevice.h │ ├── cache.h │ ├── activate.h │ ├── util.h │ ├── util.c │ └── cache.c ├── Makefile ├── TODO └── README ├── osx-plist ├── ext │ └── plist │ │ ├── plist_ext.bundle │ │ └── extconf.rb ├── test │ ├── suite.rb │ ├── fixtures │ │ └── xml_plist │ └── test_plist.rb ├── Manifest.txt ├── History.txt ├── Rakefile ├── lib │ └── osx │ │ └── plist.rb ├── osx-plist.gemspec └── README.txt ├── .rvmrc ├── tsslocal ├── config.ru └── tsslocal.rb ├── .gitmodules ├── test_bplist.rb ├── test_ipa.rb ├── ideviceinfo.rb ├── utils.rb ├── inotify.rb ├── README ├── img3file.rb ├── ssl_cert.rb ├── irecoverymode.rb ├── iactivate.rb └── tss_blob.rb /.gitignore: -------------------------------------------------------------------------------- 1 | *.o -------------------------------------------------------------------------------- /libplist/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | make -C src 3 | -------------------------------------------------------------------------------- /libusbmuxd/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | make -C src 3 | make -C tools -------------------------------------------------------------------------------- /libimobiledevice/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | make -C src 3 | make -C tools -------------------------------------------------------------------------------- /idevicerestore/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | make -C libirecovery 3 | make -C src -------------------------------------------------------------------------------- /amai/apticket.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/apticket.der -------------------------------------------------------------------------------- /libusbmuxd/tools/iproxy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libusbmuxd/tools/iproxy -------------------------------------------------------------------------------- /amai/pbsync/pbsync_01.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_01.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_02.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_02.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_03.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_03.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_04.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_04.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_05.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_05.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_06.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_06.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_07.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_07.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_08.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_08.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_08r.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_08r.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_09.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_09.plist -------------------------------------------------------------------------------- /amai/pbsync/pbsync_10.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/amai/pbsync/pbsync_10.plist -------------------------------------------------------------------------------- /libusbmuxd/src/libusbmuxd.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libusbmuxd/src/libusbmuxd.a -------------------------------------------------------------------------------- /ribusb/ext/ribusb_ext.bundle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/ribusb/ext/ribusb_ext.bundle -------------------------------------------------------------------------------- /idevicerestore/src/idevicerestore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/idevicerestore/src/idevicerestore -------------------------------------------------------------------------------- /libimobiledevice/tools/idevice_id: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/idevice_id -------------------------------------------------------------------------------- /libplist/src/libplist.1.1.3.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libplist/src/libplist.1.1.3.dylib -------------------------------------------------------------------------------- /ideviceactivate/src/ideviceactivate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/ideviceactivate/src/ideviceactivate -------------------------------------------------------------------------------- /libimobiledevice/tools/idevicebackup: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/idevicebackup -------------------------------------------------------------------------------- /libimobiledevice/tools/idevicedate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/idevicedate -------------------------------------------------------------------------------- /libimobiledevice/tools/ideviceinfo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/ideviceinfo -------------------------------------------------------------------------------- /libimobiledevice/tools/idevicepair: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/idevicepair -------------------------------------------------------------------------------- /libimobiledevice/tools/idevicesyslog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/idevicesyslog -------------------------------------------------------------------------------- /libusbmuxd/python-client/usbmux.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libusbmuxd/python-client/usbmux.pyc -------------------------------------------------------------------------------- /osx-plist/ext/plist/plist_ext.bundle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/osx-plist/ext/plist/plist_ext.bundle -------------------------------------------------------------------------------- /idevicerestore/src/libirecovery.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/idevicerestore/src/libirecovery.dylib -------------------------------------------------------------------------------- /libimobiledevice/tools/idevicebackup2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/idevicebackup2 -------------------------------------------------------------------------------- /libimobiledevice/tools/ipa/ARCHIVE.ipa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/ipa/ARCHIVE.ipa -------------------------------------------------------------------------------- /libusbmuxd/src/libusbmuxd.1.0.7.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libusbmuxd/src/libusbmuxd.1.0.7.dylib -------------------------------------------------------------------------------- /libimobiledevice/tools/ideviceinstaller: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/ideviceinstaller -------------------------------------------------------------------------------- /libimobiledevice/tools/idevicescreenshot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/idevicescreenshot -------------------------------------------------------------------------------- /libimobiledevice/tools/ideviceenterrecovery: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/ideviceenterrecovery -------------------------------------------------------------------------------- /libimobiledevice/tools/ideviceimagemounter: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/tools/ideviceimagemounter -------------------------------------------------------------------------------- /libimobiledevice/src/libimobiledevice.2.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/irestore/master/libimobiledevice/src/libimobiledevice.2.dylib -------------------------------------------------------------------------------- /.rvmrc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | rvm --create use 1.9.2@irestore-win32 4 | 5 | if ! command -v bundle ; then 6 | gem install bundler 7 | fi 8 | -------------------------------------------------------------------------------- /osx-plist/test/suite.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | 3 | tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"] 4 | tests.each do |file| 5 | require file 6 | end 7 | -------------------------------------------------------------------------------- /ideviceactivate/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | make -C src 3 | 4 | install: 5 | cp src/ideviceactivate /usr/local/bin/ideviceactivate 6 | 7 | clean: 8 | rm src/ideviceactivate 9 | -------------------------------------------------------------------------------- /osx-plist/Manifest.txt: -------------------------------------------------------------------------------- 1 | History.txt 2 | Manifest.txt 3 | README.txt 4 | Rakefile 5 | ext/plist/extconf.rb 6 | ext/plist/plist.c 7 | lib/osx/plist.rb 8 | test/fixtures/xml_plist 9 | test/suite.rb 10 | test/test_plist.rb 11 | -------------------------------------------------------------------------------- /osx-plist/ext/plist/extconf.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | require 'mkmf' 3 | $CFLAGS += ' -DNUM2LL' 4 | $LDFLAGS += ' -framework CoreFoundation -undefined suppress -flat_namespace' 5 | $LIBRUBYARG_SHARED="" 6 | create_makefile("plist_ext") 7 | -------------------------------------------------------------------------------- /ideviceactivate/TODO: -------------------------------------------------------------------------------- 1 | TODO List 2 | ------------------------------------------------ 3 | 4 | Unclaimed, feel free to work on these! 5 | 1) Integrate the phonebook sim trick in for hacktivation 6 | 7 | Work started... 8 | 2) Everything could use a bit more cleaning... 9 | -------------------------------------------------------------------------------- /amai/gc-request.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | category 4 | SMW_Adv_USA1 5 | score-value 6 | 55 7 | timestamp 8 | 1301553284461 9 | 10 | -------------------------------------------------------------------------------- /ribusb/Manifest.txt: -------------------------------------------------------------------------------- 1 | .autotest 2 | COPYING 3 | History.txt 4 | Manifest.txt 5 | README.rdoc 6 | Rakefile 7 | ext/extconf.rb 8 | ext/ribusb.c 9 | lib/ribusb.rb 10 | lib/ribusb/compat.rb 11 | test/test_ribusb.rb 12 | test/test_ribusb_gc.rb 13 | test/test_ribusb_mass_storage.rb 14 | -------------------------------------------------------------------------------- /tsslocal/config.ru: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | $: << File.join(File.dirname(__FILE__), '.') 5 | 6 | require 'tsslocal' 7 | 8 | run TssLocal 9 | 10 | #thin start -p 8080 -R config.ru -D -V 11 | 12 | # set :bind, 'localhost' 13 | # set :port, 8080 14 | -------------------------------------------------------------------------------- /libusbmuxd/tools/Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | CFLAGS=-g -D__CYGWIN__ -I../src 3 | LDFLAGS= -L/usr/lib -L/usr/local/lib -L../src -lusbmuxd 4 | 5 | all: iproxy 6 | 7 | iproxy: iproxy.o 8 | $(CC) -o $@ $^ $(LDFLAGS) 9 | 10 | %.o: %.c 11 | $(CC) -c -o $@ $< $(CFLAGS) 12 | 13 | clean: 14 | -rm -rf *.o iproxy 15 | 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/mitmproxy"] 2 | path = tools/mitmproxy 3 | url = git://github.com/cortesi/mitmproxy.git 4 | [submodule "tools/rverse"] 5 | path = tools/rverse 6 | url = git://github.com/copumpkin/rverse.git 7 | [submodule "libirecovery"] 8 | path = libirecovery 9 | url = git://github.com/Chronic-Dev/libirecovery.git 10 | -------------------------------------------------------------------------------- /osx-plist/History.txt: -------------------------------------------------------------------------------- 1 | == 1.0.3 / 2009-09-21 2 | * Add two new methods OSX::PropertyList.load_file and OSX::PropertyList.dump_file 3 | * Clean up the RDoc documentation 4 | 5 | == 1.0.2 / 2009-09-17 6 | * Build properly under Mac OS X 10.6 7 | 8 | == 1.0.1 / 2009-02-05 9 | * Ruby 1.9.1 compatibility 10 | 11 | == 1.0 / 2008-04-25 12 | * First public release 13 | -------------------------------------------------------------------------------- /test_bplist.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | $: << File.join(File.dirname(__FILE__), './osx-plist/lib') 5 | 6 | require 'pp' 7 | require 'stringio' 8 | require 'osx/plist' 9 | 10 | Dir["./amai/pbsync/*.plist"].each do |s| 11 | buffer = File.open(s).read 12 | obj = OSX::PropertyList.load(StringIO.new(buffer), :binary1)[0] 13 | pp "====", s, obj 14 | end -------------------------------------------------------------------------------- /ideviceactivate/src/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -g -pthread -I/usr/local/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 2 | LDFLAGS := -pthread -L/usr/local/lib -limobiledevice -lplist -lusbmuxd -lgthread-2.0 -lgnutls -ltasn1 -lxml2 -lglib-2.0 -lcurl 3 | 4 | all: 5 | gcc -o ideviceactivate ideviceactivate.c activate.c cache.c util.c $(CFLAGS) $(LDFLAGS) 6 | -rm -rf *.dSYM 7 | -------------------------------------------------------------------------------- /libusbmuxd/README: -------------------------------------------------------------------------------- 1 | #gdb ./iproxy 2 | 3 | $i sharedlibrary 4 | $b iproxy.c:197 5 | $i breakpoints 6 | $d breakpoints 7 | $add-symbol-file ../src/libusbmuxd.o 8 | $directory ../src 9 | $b libusbmuxd.c:793 10 | $r 2222 32498 11 | 12 | $p/d port 13 | $p payload_size 14 | $set print elements 0 15 | $x/s payload 16 | 17 | #./iproxy 2222 62078 18 | 19 | # gdb ./ideviceinfo 20 | $b xplist.c:387 21 | $commands 8 22 | >p tmp 23 | >c 24 | >end 25 | $c -------------------------------------------------------------------------------- /ribusb/History.txt: -------------------------------------------------------------------------------- 1 | === 0.1.0 / 2011-04-xx 2 | 3 | * add test suite based on mass storage devices 4 | * usable async transfers 5 | * migration to rake-compiler and hoe 6 | * cross compiled Windows gems 7 | * distinct exception classes 8 | * new compatibility layer for ruby-usb.gem 9 | * many helper methods for different USB descriptors 10 | * add LIBUSB constants 11 | * downcase methods names 12 | 13 | === 0.0.1 / 2009-06-23 14 | 15 | * first public release 16 | -------------------------------------------------------------------------------- /osx-plist/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'hoe' 3 | 4 | Hoe.spec 'osx-plist' do 5 | developer("Kevin Ballard", "kevin@sb.org") 6 | self.version = "1.0.3" 7 | self.summary = "Property List manipulation for OS X" 8 | self.spec_extras = {:extensions => "ext/plist/extconf.rb"} 9 | end 10 | 11 | # override Hoe's default :test task 12 | Rake::Task["test"].clear 13 | desc "Run the unit tests" 14 | task :test do 15 | ruby "test/test_plist.rb" 16 | end 17 | -------------------------------------------------------------------------------- /amai/README: -------------------------------------------------------------------------------- 1 | MITM on iTunes 2 | ==== 3 | 4 | [mitmproxy]http://corte.si/posts/code/mitmproxy/tute-30-seconds.html 5 | 6 | mitmdump 7 | ---- 8 | + mitmdump -w gc-apple-dump 9 | + set proxy 127.0.0.1 8080 10 | + open ituens 11 | + ctrl+c 12 | 13 | mitmproxy 14 | ---- 15 | + set proxy none 16 | + mimtproxy 17 | 18 | ``` 19 | c gc-apple-dump --client replay 20 | r - replay 21 | Enter - detail 22 | e - edit 23 | tab - swith 24 | b - save body 25 | ``` 26 | -------------------------------------------------------------------------------- /ribusb/ext/extconf.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | require "mkmf" 4 | 5 | dir_config("libusb") 6 | 7 | if enable_config("win32-static-build") 8 | have_library 'ole32', 'CLSIDFromString' 9 | have_library 'setupapi', 'SetupDiEnumDeviceInfo', 'setupapi.h' 10 | 11 | abort "libusb-1.0 not found" unless 12 | have_header('libusb.h') && 13 | have_library( 'usb-1.0', 'libusb_open', 'libusb.h' ) 14 | else 15 | pkg_config("libusb-1.0") 16 | end 17 | 18 | $CFLAGS += " -Wall" 19 | have_func 'rb_hash_lookup' 20 | 21 | create_makefile("ribusb_ext") 22 | -------------------------------------------------------------------------------- /libimobiledevice/tools/Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | CFLAGS=-g -DHAVE_LIBIMOBILEDEVICE_1_0 -DHAVE_LIBIMOBILEDEVICE_1_1 -I../src -I/usr/local/Cellar/glib/2.28.6/include/glib-2.0 -I/usr/local/Cellar/glib/2.28.6/lib/glib-2.0/include 3 | LDFLAGS= -L/usr/lib -L/usr/local/lib -limobiledevice -lplist -lglib-2.0 -lgcrypt -lzip 4 | 5 | SOURCE=$(wildcard *.c ) 6 | TARGETS = $(patsubst %.c,%,$(SOURCE)) 7 | 8 | all: $(TARGETS) 9 | -rm -rf *.dSYM 10 | 11 | .c: 12 | $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) 13 | 14 | clean: 15 | -rm -rf $(TARGETS) *.dSYM 16 | 17 | display: 18 | @echo $(TARGETS) 19 | -------------------------------------------------------------------------------- /ribusb/test/test_ribusb_gc.rb: -------------------------------------------------------------------------------- 1 | # These tests should be started with valgrind to check for 2 | # invalid memmory access. 3 | 4 | require "test/unit" 5 | require "ribusb" 6 | 7 | class TestRibusbGc < Test::Unit::TestCase 8 | include RibUSB 9 | 10 | def get_some_endpoint 11 | Context.new.find do |dev| 12 | return dev.endpoints.last 13 | end 14 | end 15 | 16 | def test_descriptors 17 | ep = get_some_endpoint 18 | ps = ep.wMaxPacketSize 19 | GC.start 20 | assert_equal ps, ep.wMaxPacketSize, "GC should not free EndpointDescriptor" 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /idevicerestore/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=idevicerestore 2 | CC=gcc 3 | CFLAGS=-g -I. 4 | LDFLAGS= -L/usr/lib -L/usr/local/lib -L../libirecovery -lplist -lSystem -limobiledevice -lzip -lcurl -lirecovery -lusb-1.0 5 | 6 | ODIR=./obj 7 | SOURCE=$(wildcard *.c ) 8 | OBJS=$(patsubst %.c,$(ODIR)/%.o,$(SOURCE)) 9 | 10 | all: display $(TARGET) 11 | -rm -rf *.dSYM 12 | 13 | $(ODIR)/%.o: %.c 14 | $(CC) -c -o $@ $< $(CFLAGS) 15 | 16 | $(TARGET): $(OBJS) 17 | $(CC) -o $@ $^ $(LDFLAGS) 18 | 19 | 20 | clean: 21 | -rm -rf $(ODIR) 22 | 23 | display: 24 | -mkdir -p $(ODIR) 25 | @echo $(OBJS) 26 | -------------------------------------------------------------------------------- /libusbmuxd/src/Makefile: -------------------------------------------------------------------------------- 1 | COMPVER=1.0.0 2 | CURRVER=1.0.7 3 | CC=gcc 4 | AR =ar 5 | CFLAGS=-g -D__CYGWIN__ -DHAVE_PLIST -I. 6 | LDFLAGS= -static -L/usr/lib -L/usr/local/lib -lplist -lSystem -compatibility_version ${COMPVER} -current_version ${CURRVER} 7 | OBJS = sock_stuff.o libusbmuxd.o utils.o 8 | 9 | all: libusbmuxd.a libusbmuxd.1.0.7.dylib 10 | 11 | libusbmuxd.1.0.7.dylib: $(OBJS) 12 | $(CC) -shared -static -o $@ $^ $(LDFLAGS) 13 | 14 | libusbmuxd.a: libusbmuxd.o 15 | $(AR) -r -cv $@ $^ 16 | 17 | %.o: %.c 18 | $(CC) -c -o $@ $< $(CFLAGS) 19 | 20 | clean: 21 | -rm -rf *.o *.a *.dylib 22 | 23 | -------------------------------------------------------------------------------- /test_ipa.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | $: << File.join(File.dirname(__FILE__), '.') 5 | 6 | require 'rubygems' 7 | require 'zip/zipfilesystem' 8 | require 'pp' 9 | 10 | ipa_path = "./libimobiledevice/tools/ipa/ARCHIVE.ipa" 11 | 12 | # pp entry_path 13 | 14 | zip_file = Zip::ZipFile.open(ipa_path) 15 | entry = zip_file.find_entry("*.sinf") 16 | # p entry 17 | 18 | Zip::ZipFile.open(ipa_path) {|zipfile| 19 | Zip::ZipFile.foreach(ipa_path) do | entry | 20 | # p entry 21 | if entry.to_s == "iTunesMetadata.plist" 22 | puts zipfile.read(entry) 23 | elsif entry.to_s =~ /Payload\/.+app\/SC_Info\/.+sinf/ 24 | puts zipfile.read(entry) 25 | end 26 | end 27 | } 28 | -------------------------------------------------------------------------------- /osx-plist/test/fixtures/xml_plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | string! 6 | indeedy 7 | bar 8 | 9 | 1 10 | 2 11 | 3 12 | 13 | foo 14 | 15 | correct? 16 | 17 | pi 18 | 3.14159265 19 | random 20 | 21 | I0VniQ== 22 | 23 | today 24 | 2005-04-28T06:32:56Z 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /osx-plist/lib/osx/plist.rb: -------------------------------------------------------------------------------- 1 | $: << File.join(File.dirname(__FILE__), "../../ext/plist") 2 | 3 | require 'rubygems' 4 | require "plist_ext" 5 | 6 | module OSX 7 | module PropertyList 8 | # Loads a property list from the file at +filepath+ using OSX::PropertyList.load. 9 | def self.load_file(filepath, format = false) 10 | File.open(filepath, "r") do |f| 11 | OSX::PropertyList.load(f, format) 12 | end 13 | end 14 | # Writes the property list representation of +obj+ to the file at +filepath+ using OSX::PropertyList.dump. 15 | def self.dump_file(filepath, obj, format = :xml1) 16 | File.open(filepath, "w") do |f| 17 | OSX::PropertyList.dump(f, obj, format) 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /libplist/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=libplist.1.1.3.dylib 2 | COMPVER=1.0.0 3 | CURRVER=1.1.3 4 | CC=gcc 5 | CFLAGS=-g -I. -I/usr/local/Cellar/glib/2.28.6/include/glib-2.0 -I/usr/local/Cellar/glib/2.28.6/lib/glib-2.0/include -I/usr/local/Cellar/libxml2/2.7.8/include/libxml2 6 | LDFLAGS= -static -L/usr/lib -L/usr/local/lib -lxml2 -lglib-2.0 -lSystem -compatibility_version ${COMPVER} -current_version ${CURRVER} 7 | 8 | ODIR=./obj 9 | SOURCE=$(wildcard *.c ) 10 | OBJS=$(patsubst %.c,$(ODIR)/%.o,$(SOURCE)) 11 | 12 | all: display $(TARGET) 13 | 14 | $(ODIR)/%.o: %.c 15 | $(CC) -c -o $@ $< $(CFLAGS) 16 | 17 | $(TARGET): $(OBJS) 18 | $(CC) -shared -static -o $@ $^ $(LDFLAGS) 19 | 20 | 21 | clean: 22 | -rm -rf $(ODIR) *.dylib 23 | 24 | display: 25 | -mkdir -p $(ODIR) 26 | @echo $(OBJS) 27 | -------------------------------------------------------------------------------- /ideviceinfo.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | $: << File.join(File.dirname(__FILE__), '.') 5 | 6 | require 'pp' 7 | require 'iservice' 8 | 9 | if __FILE__ == $0 10 | l = DeviceRelay.new 11 | 12 | l.query_type 13 | 14 | # pub_key = l.get_value("DevicePublicKey").read 15 | pub_key = l.get_value("DevicePublicKey") 16 | p "pub_key:", pub_key 17 | # 18 | l.pair_device(pub_key) 19 | 20 | # l.validate_pair(pub_key) 21 | 22 | @session_id = l.start_session 23 | p "session_id:", @session_id 24 | 25 | # ssl_enable 26 | l.ssl_enable(true) 27 | d = l.get_value 28 | pp d 29 | l.ssl_enable(false) 30 | # 31 | l.stop_session(@session_id) 32 | end 33 | 34 | __END__ 35 | -------------------------------------------------------------------------------- /libimobiledevice/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=libimobiledevice.2.dylib 2 | COMPVER=3.0.0 3 | CURRVER=3.1.0 4 | CC=gcc 5 | CFLAGS=-g -I. -I/usr/local/Cellar/glib/2.28.6/include/glib-2.0 -I/usr/local/Cellar/glib/2.28.6/lib/glib-2.0/include 6 | LDFLAGS= -static -L/usr/lib -L/usr/local/lib -lplist -lSystem -lgnutls -lglib-2.0 -lgthread-2.0 -lusbmuxd -ltasn1 -lgcrypt -compatibility_version ${COMPVER} -current_version ${CURRVER} 7 | 8 | ODIR=./obj 9 | SOURCE=$(wildcard *.c ) 10 | OBJS=$(patsubst %.c,$(ODIR)/%.o,$(SOURCE)) 11 | 12 | all: display $(TARGET) 13 | 14 | $(ODIR)/%.o: %.c 15 | $(CC) -c -o $@ $< $(CFLAGS) 16 | 17 | $(TARGET): $(OBJS) 18 | $(CC) -shared -static -o $@ $^ $(LDFLAGS) 19 | 20 | 21 | clean: 22 | -rm -rf $(ODIR) *.dylib 23 | 24 | display: 25 | -mkdir -p $(ODIR) 26 | @echo $(OBJS) 27 | -------------------------------------------------------------------------------- /tsslocal/tsslocal.rb: -------------------------------------------------------------------------------- 1 | require "rubygems" 2 | require 'pp' 3 | require 'sinatra/base' 4 | 5 | class TssLocal < Sinatra::Base 6 | # ... app code here ... 7 | tssresp_fn = "../amai/debug/tss-response.plist" 8 | 9 | post '/TSS/*' do 10 | # pp request 11 | # pp request.body.read 12 | "MESSAGE=SUCCESS\r\nBODY=#{File.open(tssresp_fn).read}" 13 | end 14 | 15 | get '/TSS/*' do 16 | # pp request 17 | # pp request.body.read 18 | "MESSAGE=SUCCESS\r\nBODY=#{File.open(tssresp_fn).read}" 19 | end 20 | 21 | # start the server if ruby file executed directly 22 | run! if app_file == $0 23 | end 24 | 25 | # POST /TSS/controller?action=2 HTTP/1.1 26 | # User-Agent: InetURL/1.0 27 | # Host: 127.0.0.1:8080 28 | # Accept: */* 29 | # Content-type: text/xml 30 | # Content-Length: 8190 31 | # Expect: 100-continue 32 | -------------------------------------------------------------------------------- /ideviceactivate/src/idevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * idevice.h 3 | * Handles stuff like freeing up & starting connections 4 | * 5 | * Copyright (c) 2010 boxingsquirrel. All Rights Reserved. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef IDEVICE_H 22 | #define IDEVICE_H 23 | 24 | extern void init_lockdownd(char* uuid); 25 | extern void free_up(); 26 | #endif 27 | -------------------------------------------------------------------------------- /utils.rb: -------------------------------------------------------------------------------- 1 | def rand_hex_3(l) 2 | "%0#{l}x" % rand(1 << l*4) 3 | end 4 | 5 | def gen_uuid 6 | [8,4,4,4,12].map {|n| rand_hex_3(n)}.join('-') 7 | end 8 | 9 | class String 10 | def hexdump 11 | buffer = "" 12 | (0..length).step(16) do |i| 13 | first_half = self[i, 8].unpack("C*").map{|x| "%02x" % x}.join(" ") 14 | second_half = (self[i + 8, 8] || "").unpack("C*").map{|x| "%02x" % x}.join(" ") 15 | first_half += " " * (8 * 2 + (8 - 1) - first_half.length) 16 | second_half += " " * (8 * 2 + (8 - 1) - second_half.length) 17 | buffer += first_half + " " + second_half + "\t" + self[i, 16].unpack("C*").map{|x| ((32..128).include?(x) ? x : ?.).chr}.join + "\n" 18 | end 19 | puts buffer 20 | end 21 | 22 | def printable? 23 | self.unpack("C*").all?{|x| ((32..128).entries + [9, 10]).include?(x)} 24 | end 25 | 26 | # def to_hex 27 | # self.unpack("C*").map{|x| "%02x" % x}.join 28 | # end 29 | 30 | def to_hex 31 | self.unpack("H*")[0] 32 | end 33 | 34 | def from_hex 35 | [self].pack("H*") 36 | end 37 | end 38 | 39 | 40 | -------------------------------------------------------------------------------- /libimobiledevice/src/mobilebackup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mobilebackup.h 3 | * Definitions for the mobilebackup service 4 | * 5 | * Copyright (c) 2009 Martin Szulecki All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef MOBILEBACKUP_H 22 | #define MOBILEBACKUP_H 23 | 24 | #include "libimobiledevice/mobilebackup.h" 25 | #include "device_link_service.h" 26 | 27 | struct mobilebackup_client_private { 28 | device_link_service_client_t parent; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libimobiledevice/src/screenshotr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * screenshotr.h 3 | * com.apple.mobile.screenshotr service header file. 4 | * 5 | * Copyright (c) 2010 Nikias Bassen All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef SCREENSHOTR_H 22 | #define SCREENSHOTR_H 23 | 24 | #include "libimobiledevice/screenshotr.h" 25 | #include "device_link_service.h" 26 | 27 | struct screenshotr_client_private { 28 | device_link_service_client_t parent; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libimobiledevice/src/mobilebackup2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mobilebackup2.h 3 | * Definitions for the mobilebackup2 service (iOS4+) 4 | * 5 | * Copyright (c) 2010 Nikias Bassen All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef MOBILEBACKUP2_H 22 | #define MOBILEBACKUP2_H 23 | 24 | #include "libimobiledevice/mobilebackup2.h" 25 | #include "device_link_service.h" 26 | 27 | struct mobilebackup2_client_private { 28 | device_link_service_client_t parent; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libimobiledevice/src/sbservices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sbservices.h 3 | * com.apple.springboardservices service header file. 4 | * 5 | * Copyright (c) 2009 Nikias Bassen, All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef ISBSERVICES_H 22 | #define ISBSERVICES_H 23 | 24 | #include 25 | 26 | #include "libimobiledevice/sbservices.h" 27 | #include "property_list_service.h" 28 | 29 | struct sbservices_client_private { 30 | property_list_service_client_t parent; 31 | GMutex *mutex; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libimobiledevice/src/restore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * restore.h 3 | * Defines restore stuff, like the client struct. 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef RESTORED_H 23 | #define RESTORED_H 24 | 25 | #include 26 | 27 | #include "libimobiledevice/restore.h" 28 | #include "property_list_service.h" 29 | 30 | struct restored_client_private { 31 | property_list_service_client_t parent; 32 | char *uuid; 33 | char *label; 34 | plist_t info; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libimobiledevice/src/mobile_image_mounter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mobile_image_mounter.h 3 | * com.apple.mobile.mobile_image_mounter service header file. 4 | * 5 | * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef IMOBILE_IMAGE_MOUNTER_H 22 | #define IMOBILE_IMAGE_MOUNTER_H 23 | 24 | #include 25 | 26 | #include "libimobiledevice/mobile_image_mounter.h" 27 | #include "property_list_service.h" 28 | 29 | struct mobile_image_mounter_client_private { 30 | property_list_service_client_t parent; 31 | GMutex *mutex; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libimobiledevice/src/installation_proxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * installation_proxy.h 3 | * com.apple.mobile.installation_proxy service header file. 4 | * 5 | * Copyright (c) 2009 Nikias Bassen, All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef IINSTALLATION_PROXY_H 22 | #define IINSTALLATION_PROXY_H 23 | 24 | #include 25 | 26 | #include "libimobiledevice/installation_proxy.h" 27 | #include "property_list_service.h" 28 | 29 | struct instproxy_client_private { 30 | property_list_service_client_t parent; 31 | GMutex *mutex; 32 | GThread *status_updater; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /ideviceactivate/src/cache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cache.h 3 | * Load data from/add data to the activation info cache. 4 | * 5 | * Copyright (c) 2010 boxingsquirrel. All Rights Reserved. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #include 22 | 23 | #define BUFSIZE 0x200000 24 | 25 | extern char* cachedir; 26 | extern int use_cache; 27 | extern int backup_to_cache; 28 | 29 | extern int write_file(const char *filename, char data[BUFSIZE]); 30 | extern int cache(const char *fname, const char *what); 31 | extern int cache_plist(const char *fname, plist_t plist); 32 | extern char* get_from_cache(const char *what); 33 | 34 | extern void cache_warning(); 35 | 36 | extern int check_cache(lockdownd_client_t c); 37 | -------------------------------------------------------------------------------- /libimobiledevice/src/notification_proxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * notification_proxy.h 3 | * com.apple.mobile.notification_proxy service header file. 4 | * 5 | * Copyright (c) 2009 Nikias Bassen, All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef INOTIFICATION_PROXY_H 22 | #define INOTIFICATION_PROXY_H 23 | 24 | #include 25 | 26 | #include "libimobiledevice/notification_proxy.h" 27 | #include "property_list_service.h" 28 | 29 | struct np_client_private { 30 | property_list_service_client_t parent; 31 | GMutex *mutex; 32 | GThread *notifier; 33 | }; 34 | 35 | gpointer np_notifier(gpointer arg); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /ideviceactivate/src/activate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * activate.h 3 | * Functions to fetch activation records from Apple's servers 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef ACTIVATE_H 23 | #define ACTIVATE_H 24 | 25 | #include 26 | #include 27 | 28 | extern int activate_fetch_record(lockdownd_client_t client, plist_t* record, char* cust_imei, char* cust_imsi, char* cust_iccid, char* cust_serial_num); 29 | extern int do_activation(lockdownd_client_t client, plist_t activation_record); 30 | 31 | extern void deactivate_device(lockdownd_client_t client); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libimobiledevice/src/house_arrest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * house_arrest.h 3 | * com.apple.mobile.house_arrest service header file. 4 | * 5 | * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef IHOUSE_ARREST_H 22 | #define IHOUSE_ARREST_H 23 | 24 | #include 25 | 26 | #include "libimobiledevice/house_arrest.h" 27 | #include "property_list_service.h" 28 | 29 | enum house_arrest_client_mode { 30 | HOUSE_ARREST_CLIENT_MODE_NORMAL = 0, 31 | HOUSE_ARREST_CLIENT_MODE_AFC, 32 | }; 33 | 34 | struct house_arrest_client_private { 35 | property_list_service_client_t parent; 36 | enum house_arrest_client_mode mode; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libimobiledevice/src/mobilesync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mobilesync.h 3 | * Definitions for the built-in MobileSync client 4 | * 5 | * Copyright (c) 2010 Bryan Forbes All Rights Reserved. 6 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | #ifndef MOBILESYNC_H 23 | #define MOBILESYNC_H 24 | 25 | #include "libimobiledevice/mobilesync.h" 26 | #include "device_link_service.h" 27 | 28 | typedef enum { 29 | MOBILESYNC_SYNC_DIR_DEVICE_TO_COMPUTER, 30 | MOBILESYNC_SYNC_DIR_COMPUTER_TO_DEVICE 31 | } mobilesync_sync_direction_t; 32 | 33 | struct mobilesync_client_private { 34 | device_link_service_client_t parent; 35 | mobilesync_sync_direction_t direction; 36 | char *data_class; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libimobiledevice/src/file_relay.h: -------------------------------------------------------------------------------- 1 | /* 2 | * file_relay.h 3 | * com.apple.mobile.file_relay service header file. 4 | * 5 | * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef FILE_RELAY_H 22 | #define FILE_RELAY_H 23 | 24 | #include "libimobiledevice/file_relay.h" 25 | #include "property_list_service.h" 26 | 27 | /* Error Codes */ 28 | #define FILE_RELAY_E_SUCCESS 0 29 | #define FILE_RELAY_E_INVALID_ARG -1 30 | #define FILE_RELAY_E_PLIST_ERROR -2 31 | #define FILE_RELAY_E_MUX_ERROR -3 32 | 33 | #define FILE_RELAY_E_UNKNOWN_ERROR -256 34 | 35 | 36 | struct file_relay_client_private { 37 | property_list_service_client_t parent; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /idevicerestore/src/tss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ipsw.c 3 | * Definitions for communicating with Apple's TSS server. 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_TSS_H 23 | #define IDEVICERESTORE_TSS_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | 31 | plist_t tss_send_request(plist_t request); 32 | plist_t tss_create_request(plist_t build_identity, uint64_t ecid); 33 | int tss_get_entry_path(plist_t tss, const char* entry, char** path); 34 | int tss_get_blob_by_path(plist_t tss, const char* path, char** blob); 35 | int tss_get_blob_by_name(plist_t tss, const char* entry, char** blob); 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /ideviceactivate/README: -------------------------------------------------------------------------------- 1 | ideviceactivate is a small utility to activate iDevices from the comfort of your GNU/Linux box. 2 | 3 | Users not comfortable with using a shell should wait for iDeviceActivator, which provides an easier way to do all this. 4 | 5 | ===Credits=== 6 | 7 | Almost all of the code, with the major exception of the caching code, was written by p0sixninja. 8 | The caching code and the documentation was written by boxingsquirrel. 9 | 10 | ===Building=== 11 | 12 | Fetch your dependencies. Because these vary from distro to distro, I won't list specific packages here, that said you need developement packages for: libimobiledevice, libplist, usbmuxd, libgthread2, librt, gnutls, libtasn1, libxml2, libglib2, and libcurl. 13 | 14 | Then: 15 | git clone git://github.com/boxingsquirrel/ideviceactivate.git 16 | cd ideviceactivate 17 | make 18 | sudo make install 19 | 20 | ===Running=== 21 | 22 | For straight-up activation with nothing fancy: ideviceactivate 23 | For the same, but deactivating: ideviceactivate -x 24 | 25 | Now, to run with the caching stuff: 26 | 27 | Create the cache and activate the device: 28 | ideviceactivate -c 29 | 30 | Use an already created cache to activate the device: 31 | ideviceactivate -r 32 | 33 | Notes: 34 | The -u flag can be used to target a device by its UUID. 35 | If you have an activation record lying around, you can specify it along with the -f flag. 36 | 37 | The IMEI, IMSI, ICCID, and SerialNumber can be specified on the command line with the -e, -s, -i, and -n flags respectively. 38 | -------------------------------------------------------------------------------- /idevicerestore/src/dfu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dfu.h 3 | * Functions for handling idevices in normal mode 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_DFU_H 23 | #define IDEVICERESTORE_DFU_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | #include "common.h" 31 | 32 | struct dfu_client_t { 33 | irecv_client_t client; 34 | const char* ipsw; 35 | plist_t tss; 36 | }; 37 | 38 | int dfu_client_new(struct idevicerestore_client_t* client, uint32_t timeout); 39 | void dfu_client_free(struct idevicerestore_client_t* client); 40 | int dfu_enter_recovery(struct idevicerestore_client_t* client, plist_t build_identity); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /ideviceactivate/src/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * util.h 3 | * Just utility functions ;) 4 | * 5 | * Copyright (c) 2010 Joshua Hill and boxingsquirrel. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | 24 | // These just wrap p0sixninja's original code, just trying to clean up... 25 | extern int plist_read_from_filename(plist_t *plist, const char *filename); 26 | extern int buffer_read_from_filename(const char *filename, char **buffer, uint32_t *length); 27 | extern void lockdownd_get_string_value(lockdownd_client_t client, const char *what, char *val); 28 | 29 | // The main purpose of these two is to provide a way to mod the behavior, plus a bit of shorthand ;) 30 | extern void info(const char *m); 31 | extern void error(const char *m); 32 | extern void task(const char *m); 33 | -------------------------------------------------------------------------------- /idevicerestore/src/ipsw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ipsw.c 3 | * Definitions for IPSW utilities 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_IPSW_H 23 | #define IDEVICERESTORE_IPSW_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | typedef struct { 34 | int index; 35 | char* name; 36 | unsigned int size; 37 | unsigned char* data; 38 | } ipsw_file; 39 | 40 | int ipsw_extract_to_memory(const char* ipsw, const char* infile, char** pbuffer, uint32_t* psize); 41 | int ipsw_extract_build_manifest(const char* ipsw, plist_t* buildmanifest, int *tss_enabled); 42 | void ipsw_free_file(ipsw_file* file); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /osx-plist/osx-plist.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | 3 | Gem::Specification.new do |s| 4 | s.name = %q{osx-plist} 5 | s.version = "1.0.3" 6 | 7 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 8 | s.authors = ["Kevin Ballard"] 9 | s.date = %q{2009-09-21} 10 | s.description = %q{osx-plist is a Ruby library for manipulating Property Lists natively using the built-in support in OS X.} 11 | s.email = ["kevin@sb.org"] 12 | s.extensions = ["ext/plist/extconf.rb"] 13 | s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"] 14 | s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "ext/plist/extconf.rb", "ext/plist/plist.c", "lib/osx/plist.rb", "test/fixtures/xml_plist", "test/suite.rb", "test/test_plist.rb"] 15 | s.homepage = %q{http://github.com/kballard/osx-plist} 16 | s.rdoc_options = ["--main", "README.txt"] 17 | s.require_paths = ["lib", "ext"] 18 | s.rubyforge_project = %q{osx-plist} 19 | s.rubygems_version = %q{1.3.5} 20 | s.summary = %q{Property List manipulation for OS X} 21 | s.test_files = ["test/test_plist.rb"] 22 | 23 | if s.respond_to? :specification_version then 24 | current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION 25 | s.specification_version = 3 26 | 27 | if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then 28 | s.add_development_dependency(%q, [">= 2.3.3"]) 29 | else 30 | s.add_dependency(%q, [">= 2.3.3"]) 31 | end 32 | else 33 | s.add_dependency(%q, [">= 2.3.3"]) 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /libimobiledevice/src/lockdown.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lockdownd.h 3 | * Defines lockdown stuff, like the client struct. 4 | * 5 | * Copyright (c) 2008 Zach C. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef LOCKDOWND_H 23 | #define LOCKDOWND_H 24 | 25 | #include 26 | 27 | #include "libimobiledevice/lockdown.h" 28 | #include "property_list_service.h" 29 | 30 | struct lockdownd_client_private { 31 | property_list_service_client_t parent; 32 | int ssl_enabled; 33 | char *session_id; 34 | char *uuid; 35 | char *label; 36 | }; 37 | 38 | lockdownd_error_t lockdownd_get_device_public_key(lockdownd_client_t client, gnutls_datum_t * public_key); 39 | lockdownd_error_t lockdownd_gen_pair_cert(gnutls_datum_t public_key, gnutls_datum_t * device_cert, 40 | gnutls_datum_t * host_cert, gnutls_datum_t * root_cert); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /idevicerestore/src/asr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asr.h 3 | * Functions for handling asr connections 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_ASR_H 23 | #define IDEVICERESTORE_ASR_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | 31 | int asr_open_with_timeout(idevice_t device, idevice_connection_t* asr); 32 | int asr_send(idevice_connection_t asr, plist_t* data); 33 | int asr_receive(idevice_connection_t asr, plist_t* data); 34 | int asr_send_buffer(idevice_connection_t asr, const char* data, uint32_t size); 35 | void asr_close(idevice_connection_t asr); 36 | int asr_perform_validation(idevice_connection_t asr, const char* filesystem); 37 | int asr_send_payload(idevice_connection_t asr, const char* filesystem); 38 | int asr_handle_oob_data_request(idevice_connection_t asr, plist_t packet, FILE* file); 39 | 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /libplist/src/Real.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Real.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace PList 25 | { 26 | 27 | Real::Real(Node* parent) : Node(PLIST_REAL, parent) 28 | { 29 | } 30 | 31 | Real::Real(plist_t node, Node* parent) : Node(node, parent) 32 | { 33 | } 34 | 35 | Real::Real(PList::Real& d) : Node(PLIST_UINT) 36 | { 37 | plist_set_real_val(_node, d.GetValue()); 38 | } 39 | 40 | Real& Real::operator=(PList::Real& d) 41 | { 42 | plist_free(_node); 43 | _node = plist_copy(d.GetPlist()); 44 | return *this; 45 | } 46 | 47 | Real::Real(double d) : Node(PLIST_REAL) 48 | { 49 | plist_set_real_val(_node, d); 50 | } 51 | 52 | Real::~Real() 53 | { 54 | } 55 | 56 | Node* Real::Clone() 57 | { 58 | return new Real(*this); 59 | } 60 | 61 | void Real::SetValue(double d) 62 | { 63 | plist_set_real_val(_node, d); 64 | } 65 | 66 | double Real::GetValue() 67 | { 68 | double d = 0.; 69 | plist_get_real_val(_node, &d); 70 | return d; 71 | } 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /libplist/src/plist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * plist.h 3 | * contains structures and the like for plists 4 | * 5 | * Copyright (c) 2008 Zach C. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef PLIST_H 23 | #define PLIST_H 24 | 25 | #include "plist/plist.h" 26 | 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #ifdef _MSC_VER 33 | #pragma warning(disable:4996) 34 | #pragma warning(disable:4244) 35 | #endif 36 | 37 | 38 | struct plist_data_s 39 | { 40 | union 41 | { 42 | char boolval; 43 | uint64_t intval; 44 | double realval; 45 | char *strval; 46 | uint8_t *buff; 47 | GTimeVal timeval; 48 | }; 49 | uint64_t length; 50 | plist_type type; 51 | }; 52 | 53 | typedef struct plist_data_s *plist_data_t; 54 | 55 | G_GNUC_INTERNAL plist_t plist_new_node(plist_data_t data); 56 | G_GNUC_INTERNAL plist_data_t plist_get_data(const plist_t node); 57 | G_GNUC_INTERNAL plist_data_t plist_new_plist_data(void); 58 | G_GNUC_INTERNAL gboolean plist_data_compare(gconstpointer a, gconstpointer b); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libplist/src/Boolean.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Boolean.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace PList 25 | { 26 | 27 | Boolean::Boolean(Node* parent) : Node(PLIST_BOOLEAN, parent) 28 | { 29 | } 30 | 31 | Boolean::Boolean(plist_t node, Node* parent) : Node(node, parent) 32 | { 33 | } 34 | 35 | Boolean::Boolean(PList::Boolean& b) : Node(PLIST_BOOLEAN) 36 | { 37 | plist_set_bool_val(_node, b.GetValue()); 38 | } 39 | 40 | Boolean& Boolean::operator=(PList::Boolean& b) 41 | { 42 | plist_free(_node); 43 | _node = plist_copy(b.GetPlist()); 44 | return *this; 45 | } 46 | 47 | Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN) 48 | { 49 | plist_set_bool_val(_node, b); 50 | } 51 | 52 | Boolean::~Boolean() 53 | { 54 | } 55 | 56 | Node* Boolean::Clone() 57 | { 58 | return new Boolean(*this); 59 | } 60 | 61 | void Boolean::SetValue(bool b) 62 | { 63 | plist_set_bool_val(_node, b); 64 | } 65 | 66 | bool Boolean::GetValue() 67 | { 68 | uint8_t b = 0; 69 | plist_get_bool_val(_node, &b); 70 | return b != 0 ; 71 | } 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /libplist/src/Integer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Integer.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace PList 25 | { 26 | 27 | Integer::Integer(Node* parent) : Node(PLIST_UINT, parent) 28 | { 29 | } 30 | 31 | Integer::Integer(plist_t node, Node* parent) : Node(node, parent) 32 | { 33 | } 34 | 35 | Integer::Integer(PList::Integer& i) : Node(PLIST_UINT) 36 | { 37 | plist_set_uint_val(_node, i.GetValue()); 38 | } 39 | 40 | Integer& Integer::operator=(PList::Integer& i) 41 | { 42 | plist_free(_node); 43 | _node = plist_copy(i.GetPlist()); 44 | return *this; 45 | } 46 | 47 | Integer::Integer(uint64_t i) : Node(PLIST_UINT) 48 | { 49 | plist_set_uint_val(_node, i); 50 | } 51 | 52 | Integer::~Integer() 53 | { 54 | } 55 | 56 | Node* Integer::Clone() 57 | { 58 | return new Integer(*this); 59 | } 60 | 61 | void Integer::SetValue(uint64_t i) 62 | { 63 | plist_set_uint_val(_node, i); 64 | } 65 | 66 | uint64_t Integer::GetValue() 67 | { 68 | uint64_t i = 0; 69 | plist_get_uint_val(_node, &i); 70 | return i; 71 | } 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /libusbmuxd/src/sock_stuff.h: -------------------------------------------------------------------------------- 1 | /* 2 | libusbmuxd - client library to talk to usbmuxd 3 | 4 | Copyright (C) 2009 Nikias Bassen 5 | Copyright (C) 2009 Paul Sladen 6 | Copyright (C) 2009 Martin Szulecki 7 | 8 | This library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as 10 | published by the Free Software Foundation, either version 2.1 of the 11 | License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this program; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef __SOCK_STUFF_H 25 | #define __SOCK_STUFF_H 26 | 27 | #include 28 | 29 | enum fd_mode { 30 | FDM_READ, 31 | FDM_WRITE, 32 | FDM_EXCEPT 33 | }; 34 | typedef enum fd_mode fd_mode; 35 | 36 | #ifndef WIN32 37 | int create_unix_socket(const char *filename); 38 | int connect_unix_socket(const char *filename); 39 | #endif 40 | int create_socket(uint16_t port); 41 | #if defined(WIN32) || defined(__CYGWIN__) 42 | int connect_socket(const char *addr, uint16_t port); 43 | #endif 44 | int check_fd(int fd, fd_mode fdm, unsigned int timeout); 45 | 46 | int close_socket(int fd); 47 | 48 | int recv_buf(int fd, void *data, size_t size); 49 | int peek_buf(int fd, void *data, size_t size); 50 | int recv_buf_timeout(int fd, void *data, size_t size, int flags, 51 | unsigned int timeout); 52 | 53 | int send_buf(int fd, void *data, size_t size); 54 | 55 | void sock_stuff_set_verbose(int level); 56 | 57 | #endif /* __SOCK_STUFF_H */ 58 | -------------------------------------------------------------------------------- /libimobiledevice/src/idevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * idevice.h 3 | * Device discovery and communication interface -- header file. 4 | * 5 | * Copyright (c) 2008 Zach C. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef IDEVICE_H 22 | #define IDEVICE_H 23 | 24 | #include 25 | #include 26 | 27 | #include "libimobiledevice/libimobiledevice.h" 28 | 29 | enum connection_type { 30 | CONNECTION_USBMUXD = 1 31 | }; 32 | 33 | struct ssl_data_private { 34 | gnutls_certificate_credentials_t certificate; 35 | gnutls_session_t session; 36 | gnutls_x509_privkey_t root_privkey; 37 | gnutls_x509_crt_t root_cert; 38 | gnutls_x509_privkey_t host_privkey; 39 | gnutls_x509_crt_t host_cert; 40 | }; 41 | typedef struct ssl_data_private *ssl_data_t; 42 | 43 | struct idevice_connection_private { 44 | enum connection_type type; 45 | void *data; 46 | ssl_data_t ssl_data; 47 | }; 48 | 49 | struct idevice_private { 50 | char *uuid; 51 | enum connection_type conn_type; 52 | void *conn_data; 53 | }; 54 | 55 | idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection); 56 | idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /idevicerestore/src/normal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * normal.h 3 | * Functions for handling idevices in normal mode 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_NORMAL_H 23 | #define IDEVICERESTORE_NORMAL_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | struct normal_client_t { 34 | idevice_t device; 35 | lockdownd_client_t client; 36 | const char* ipsw; 37 | plist_t tss; 38 | }; 39 | 40 | 41 | int normal_check_mode(const char* uuid); 42 | int normal_check_device(const char* uuid); 43 | int normal_client_new(struct idevicerestore_client_t* client); 44 | void normal_client_free(struct idevicerestore_client_t* client); 45 | int normal_open_with_timeout(struct idevicerestore_client_t* client); 46 | int normal_enter_recovery(struct idevicerestore_client_t* client); 47 | int normal_get_cpid(const char* uuid, uint32_t* cpid); 48 | int normal_get_bdid(const char* uuid, uint32_t* cpid); 49 | int normal_get_ecid(const char* uuid, uint64_t* ecid); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libplist/src/String.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * String.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace PList 25 | { 26 | 27 | String::String(Node* parent) : Node(PLIST_STRING, parent) 28 | { 29 | } 30 | 31 | String::String(plist_t node, Node* parent) : Node(node, parent) 32 | { 33 | } 34 | 35 | String::String(PList::String& s) : Node(PLIST_UINT) 36 | { 37 | plist_set_string_val(_node, s.GetValue().c_str()); 38 | } 39 | 40 | String& String::operator=(PList::String& s) 41 | { 42 | plist_free(_node); 43 | _node = plist_copy(s.GetPlist()); 44 | return *this; 45 | } 46 | 47 | String::String(const std::string& s) : Node(PLIST_STRING) 48 | { 49 | plist_set_string_val(_node, s.c_str()); 50 | } 51 | 52 | String::~String() 53 | { 54 | } 55 | 56 | Node* String::Clone() 57 | { 58 | return new String(*this); 59 | } 60 | 61 | void String::SetValue(const std::string& s) 62 | { 63 | plist_set_string_val(_node, s.c_str()); 64 | } 65 | 66 | std::string String::GetValue() 67 | { 68 | char* s = NULL; 69 | plist_get_string_val(_node, &s); 70 | std::string ret = s; 71 | free(s); 72 | return ret; 73 | } 74 | 75 | }; 76 | -------------------------------------------------------------------------------- /libplist/src/Date.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Date.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace PList 25 | { 26 | 27 | Date::Date(Node* parent) : Node(PLIST_DATE, parent) 28 | { 29 | } 30 | 31 | Date::Date(plist_t node, Node* parent) : Node(node, parent) 32 | { 33 | } 34 | 35 | Date::Date(PList::Date& d) : Node(PLIST_DATE) 36 | { 37 | timeval t = d.GetValue(); 38 | plist_set_date_val(_node, t.tv_sec, t.tv_usec); 39 | } 40 | 41 | Date& Date::operator=(PList::Date& d) 42 | { 43 | plist_free(_node); 44 | _node = plist_copy(d.GetPlist()); 45 | return *this; 46 | } 47 | 48 | Date::Date(timeval t) : Node(PLIST_DATE) 49 | { 50 | plist_set_date_val(_node, t.tv_sec, t.tv_usec); 51 | } 52 | 53 | Date::~Date() 54 | { 55 | } 56 | 57 | Node* Date::Clone() 58 | { 59 | return new Date(*this); 60 | } 61 | 62 | void Date::SetValue(timeval t) 63 | { 64 | plist_set_date_val(_node, t.tv_sec, t.tv_usec); 65 | } 66 | 67 | timeval Date::GetValue() 68 | { 69 | int32_t tv_sec = 0; 70 | int32_t tv_usec = 0; 71 | plist_get_date_val(_node, &tv_sec, &tv_usec); 72 | timeval t = {tv_sec, tv_usec}; 73 | return t; 74 | } 75 | 76 | }; 77 | -------------------------------------------------------------------------------- /inotify.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | $: << File.join(File.dirname(__FILE__), '.') 5 | 6 | require 'iservice' 7 | require 'observer' 8 | 9 | NOFITY_TYPE = [ 10 | "com.apple.itunes-mobdev.syncWillStart", 11 | "com.apple.itunes-mobdev.syncDidStart", 12 | "com.apple.itunes-mobdev.syncDidFinish", 13 | ] 14 | 15 | class INotifyService < DeviceService 16 | include Observable 17 | 18 | def notify(t_notify) 19 | obj = {"Command"=>"PostNotification", "Name" => t_notify } 20 | write_plist(@socket, obj) 21 | end 22 | 23 | def observe(t_event) 24 | obj = {"Command"=>"ObserveNotification", "Name" => t_event } 25 | write_plist(@socket, obj) 26 | end 27 | 28 | def run 29 | lastPrice = nil 30 | loop do 31 | obj = read_plist(@socket) 32 | # {"Command"=>"RelayNotification", "Name"=>"com.apple.mobile.application_uninstalled"} 33 | if obj.include?("Command") and obj.include?("Name") 34 | if obj["Command"] == "RelayNotification" 35 | changed # notify observers 36 | notify_observers(obj["Name"]) 37 | end 38 | end 39 | sleep 1 40 | end 41 | end 42 | end 43 | 44 | if __FILE__ == $0 45 | l = DeviceRelay.new 46 | 47 | l.query_type 48 | 49 | # pub_key = l.get_value("DevicePublicKey").read 50 | pub_key = l.get_value("DevicePublicKey") 51 | p "pub_key:", pub_key 52 | # 53 | l.pair_device(pub_key) 54 | 55 | # l.validate_pair(pub_key) 56 | 57 | @session_id = l.start_session 58 | p "session_id:", @session_id 59 | 60 | # ssl_enable 61 | @port = l.start_service(AMSVC_NOTIFICATION_PROXY) 62 | # 63 | l.stop_session(@session_id) 64 | # 65 | if @port 66 | port = @port>>8 | (@port & 0xff)<<8 67 | 68 | p = INotifyService.new(port) 69 | case ARGV[0] 70 | when "nofity" 71 | t_notify = NOFITY_TYPE[ARGV[2].to_i] 72 | p.notify(t_notify) 73 | else 74 | t_event = "com.apple.mobile.application_uninstalled" 75 | p.observe(t_event) 76 | p.output 77 | end 78 | end 79 | end 80 | 81 | __END__ -------------------------------------------------------------------------------- /libusbmuxd/src/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | usbmuxd - iPhone/iPod Touch USB multiplex server daemon 3 | 4 | Copyright (C) 2009 Hector Martin "marcan" 5 | Copyright (C) 2009 Nikias Bassen 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 2 or version 3. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | */ 21 | 22 | #ifndef __UTILS_H__ 23 | #define __UTILS_H__ 24 | 25 | #ifdef USBMUXD_DAEMON 26 | #include 27 | 28 | enum fdowner { 29 | FD_LISTEN, 30 | FD_CLIENT, 31 | FD_USB 32 | }; 33 | 34 | struct fdlist { 35 | int count; 36 | int capacity; 37 | enum fdowner *owners; 38 | struct pollfd *fds; 39 | }; 40 | 41 | void fdlist_create(struct fdlist *list); 42 | void fdlist_add(struct fdlist *list, enum fdowner owner, int fd, short events); 43 | void fdlist_free(struct fdlist *list); 44 | void fdlist_reset(struct fdlist *list); 45 | #endif 46 | 47 | struct collection { 48 | void **list; 49 | int capacity; 50 | }; 51 | 52 | void collection_init(struct collection *col); 53 | void collection_add(struct collection *col, void *element); 54 | void collection_remove(struct collection *col, void *element); 55 | int collection_count(struct collection *col); 56 | void collection_free(struct collection *col); 57 | 58 | #define FOREACH(var, col) \ 59 | do { \ 60 | int _iter; \ 61 | for(_iter=0; _iter<(col)->capacity; _iter++) { \ 62 | if(!(col)->list[_iter]) continue; \ 63 | var = (col)->list[_iter]; 64 | 65 | #define ENDFOREACH \ 66 | } \ 67 | } while(0); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /libplist/src/Data.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Data.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace PList 25 | { 26 | 27 | Data::Data(Node* parent) : Node(PLIST_DATA, parent) 28 | { 29 | } 30 | 31 | Data::Data(plist_t node, Node* parent) : Node(node, parent) 32 | { 33 | } 34 | 35 | Data::Data(PList::Data& d) : Node(PLIST_DATA) 36 | { 37 | std::vector b = d.GetValue(); 38 | plist_set_data_val(_node, &b[0], b.size()); 39 | } 40 | 41 | Data& Data::operator=(PList::Data& b) 42 | { 43 | plist_free(_node); 44 | _node = plist_copy(b.GetPlist()); 45 | return *this; 46 | } 47 | 48 | Data::Data(const std::vector& buff) : Node(PLIST_DATA) 49 | { 50 | plist_set_data_val(_node, &buff[0], buff.size()); 51 | } 52 | 53 | Data::~Data() 54 | { 55 | } 56 | 57 | Node* Data::Clone() 58 | { 59 | return new Data(*this); 60 | } 61 | 62 | void Data::SetValue(const std::vector& buff) 63 | { 64 | plist_set_data_val(_node, &buff[0], buff.size()); 65 | } 66 | 67 | std::vector Data::GetValue() 68 | { 69 | char* buff = NULL; 70 | uint64_t length = 0; 71 | plist_get_data_val(_node, &buff, &length); 72 | std::vector ret(buff, buff + length); 73 | free(buff); 74 | return ret; 75 | } 76 | 77 | 78 | 79 | }; 80 | -------------------------------------------------------------------------------- /libimobiledevice/src/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * debug.h 3 | * contains utilitary functions for debugging 4 | * 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. 6 | * Copyright (c) 2010 Martin S. All Rights Reserved. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef DEBUG_H 24 | #define DEBUG_H 25 | 26 | #include 27 | #include 28 | 29 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && !defined(STRIP_DEBUG_CODE) 30 | #define debug_info(...) debug_info_real (__func__, __FILE__, __LINE__, __VA_ARGS__) 31 | #define debug_plist(a) debug_plist_real (__func__, __FILE__, __LINE__, a) 32 | #elif defined(__GNUC__) && __GNUC__ >= 3 && !defined(STRIP_DEBUG_CODE) 33 | #define debug_info(...) debug_info_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) 34 | #define debug_plist(a) debug_plist_real (__FUNCTION__, __FILE__, __LINE__, a) 35 | #else 36 | #define debug_info(...) 37 | #define debug_plist(a) 38 | #endif 39 | 40 | G_GNUC_INTERNAL inline void debug_info_real(const char *func, 41 | const char *file, 42 | int line, 43 | const char *format, ...); 44 | 45 | G_GNUC_INTERNAL inline void debug_buffer(const char *data, const int length); 46 | G_GNUC_INTERNAL inline void debug_buffer_to_file(const char *file, const char *data, const int length); 47 | G_GNUC_INTERNAL inline void debug_plist_real(const char *func, 48 | const char *file, 49 | int line, 50 | plist_t plist); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /libimobiledevice/src/userpref.h: -------------------------------------------------------------------------------- 1 | /* 2 | * userpref.h 3 | * contains methods to access user specific certificates IDs and more. 4 | * 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef USERPREF_H 23 | #define USERPREF_H 24 | 25 | #include 26 | #include 27 | 28 | #define USERPREF_E_SUCCESS 0 29 | #define USERPREF_E_INVALID_ARG -1 30 | #define USERPREF_E_INVALID_CONF -2 31 | #define USERPREF_E_SSL_ERROR -3 32 | 33 | #define USERPREF_E_UNKNOWN_ERROR -256 34 | 35 | typedef int16_t userpref_error_t; 36 | 37 | G_GNUC_INTERNAL userpref_error_t userpref_get_keys_and_certs(gnutls_x509_privkey_t root_privkey, gnutls_x509_crt_t root_crt, gnutls_x509_privkey_t host_privkey, gnutls_x509_crt_t host_crt); 38 | G_GNUC_INTERNAL userpref_error_t userpref_set_keys_and_certs(gnutls_datum_t * root_key, gnutls_datum_t * root_cert, gnutls_datum_t * host_key, gnutls_datum_t * host_cert); 39 | G_GNUC_INTERNAL userpref_error_t userpref_get_certs_as_pem(gnutls_datum_t *pem_root_cert, gnutls_datum_t *pem_host_cert); 40 | G_GNUC_INTERNAL userpref_error_t userpref_set_device_public_key(const char *uuid, gnutls_datum_t public_key); 41 | userpref_error_t userpref_remove_device_public_key(const char *uuid); 42 | G_GNUC_INTERNAL int userpref_has_device_public_key(const char *uuid); 43 | userpref_error_t userpref_get_paired_uuids(char ***list, unsigned int *count); 44 | void userpref_get_host_id(char **host_id); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /idevicerestore/src/idevicerestore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * idevicerestore.h 3 | * Restore device firmware and filesystem 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_H 23 | #define IDEVICERESTORE_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | #include "common.h" 33 | 34 | void usage(int argc, char* argv[]); 35 | int check_mode(struct idevicerestore_client_t* client); 36 | int check_device(struct idevicerestore_client_t* client); 37 | int get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid); 38 | int get_bdid(struct idevicerestore_client_t* client, uint32_t* bdid); 39 | int get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid); 40 | int get_shsh_blobs(struct idevicerestore_client_t* client, uint64_t ecid, plist_t build_identity, plist_t* tss); 41 | void build_manifest_print_information(plist_t build_manifest); 42 | plist_t build_manifest_get_build_identity(plist_t build_manifest, uint32_t identity); 43 | int build_manifest_get_build_count(plist_t build_manifest); 44 | void build_identity_print_information(plist_t build_identity); 45 | int build_identity_get_component_path(plist_t build_identity, const char* component, char** path); 46 | int ipsw_extract_filesystem(const char* ipsw, plist_t build_identity, char** filesystem); 47 | int ipsw_get_component_by_path(const char* ipsw, plist_t tss, const char* path, char** data, uint32_t* size); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | INFO 2 | ---- 3 | #libimobiledevice 4 | /usr/local/Cellar/libimobiledevice/1.1.1/lib/libimobiledevice.2.dylib 5 | b lockdownd_client_new_with_handshake 6 | b lockdownd_client_new 7 | 8 | #libplist 9 | /usr/local/Cellar/libplist/1.3/lib/libplist.1.1.3.dylib 10 | set print elements 0 11 | b xplist.c:387 12 | command 1 13 | >p tmp 14 | >c 15 | >end 16 | b plist_to_bin 17 | b plist_to_xml 18 | 19 | #libusbmuxd 20 | /usr/local/Cellar/usbmuxd/1.0.7/lib/libusbmuxd.1.0.7.dylib 21 | tcp 27015, not /var/run/usbmuxd 22 | 23 | #ribusb 24 | ln -sf ribusb/lib lib 25 | 26 | #use socat and idevicesyslog 27 | ``` 28 | sudo /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/Resources/usbmuxd & 29 | socat -x -v tcp-l:27015,reuseaddr,fork unix:/var/run/usbmuxd & 30 | idevicesyslog 31 | ``` 32 | 33 | # idevicerestore 34 | https://github.com/boxingsquirrel/idevicerestore 35 | ./idevicerestore -s -d ~/ipad/jailbreak/iPhone2,1_4.3.3_8J2_Restore.ipsw 36 | 37 | # ideviceactivate 38 | https://github.com/boxingsquirrel/ideviceactivate 39 | 40 | # ideviceinstaller 41 | http://git.sukimashita.com/ideviceinstaller.git 42 | 43 | # osx-plist 44 | https://github.com/kballard/osx-plist 45 | 46 | # gistfile1.rb 47 | https://gist.github.com/raw/149443/6b6519981f83c31c10db722ea31c069ef089aa31/gistfile1.rb 48 | 49 | # saurik 50 | http://svn.saurik.com/repos/menes/trunk/ 51 | 52 | # theOS 53 | https://github.com/DHowett/theos 54 | 55 | # FirmExtract 56 | https://github.com/boxingsquirrel/FirmExtract 57 | 58 | # Chameleon 59 | https://github.com/BigZaphod/Chameleon.git 60 | 61 | # ARMBootloader 62 | https://github.com/AlJaMa/ARMBootloader 63 | 64 | # chronic-dev 65 | https://github.com/Chronic-Dev/ 66 | https://github.com/Chronic-Dev/greenpois0n 67 | 68 | # comex 69 | https://github.com/comex 70 | 71 | # msftguy 72 | https://github.com/msftguy 73 | 74 | # posixninja 75 | https://github.com/posixninja 76 | 77 | # iH8sn0w 78 | https://github.com/iH8sn0w 79 | https://github.com/iH8sn0w/sn0wbreeze/tree/master/Resources 80 | 81 | # planetbeing 82 | https://github.com/planetbeing 83 | 84 | # cmwdotme 85 | https://github.com/cmwdotme 86 | 87 | # Gojohnnyboi 88 | https://github.com/Gojohnnyboi 89 | 90 | # libirecovery 91 | https://github.com/Chronic-Dev/libirecovery 92 | -------------------------------------------------------------------------------- /idevicerestore/src/recovery.h: -------------------------------------------------------------------------------- 1 | /* 2 | * recovery.h 3 | * Functions for handling idevices in recovery mode 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_RECOVERY_H 23 | #define IDEVICERESTORE_RECOVERY_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | #include "common.h" 33 | 34 | #include "libirecovery.h" 35 | 36 | //struct irecv_client; 37 | //typedef struct irecv_client* irecv_client_t; 38 | struct recovery_client_t { 39 | irecv_client_t client; 40 | const char* ipsw; 41 | plist_t tss; 42 | }; 43 | 44 | int recovery_check_mode(); 45 | int recovery_open_with_timeout(struct idevicerestore_client_t* client); 46 | int recovery_client_new(struct idevicerestore_client_t* client); 47 | void recovery_client_free(struct idevicerestore_client_t* client); 48 | int recovery_send_component(struct idevicerestore_client_t* client, plist_t build_identity, const char* component); 49 | int recovery_send_ibec(struct idevicerestore_client_t* client, plist_t build_identity); 50 | int recovery_send_applelogo(struct idevicerestore_client_t* client, plist_t build_identity); 51 | int recovery_send_devicetree(struct idevicerestore_client_t* client, plist_t build_identity); 52 | int recovery_send_ramdisk(struct idevicerestore_client_t* client, plist_t build_identity); 53 | int recovery_send_kernelcache(struct idevicerestore_client_t* client, plist_t build_identity); 54 | int recovery_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid); 55 | int recovery_get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid); 56 | int recovery_get_bdid(struct idevicerestore_client_t* client, uint32_t* bdid); 57 | 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /amai/receipt.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alignment 6 | 7 | AllFlash 8 | Firmware/all_flash/all_flash.n88ap.production 9 | DFUFileType 10 | RELEASE 11 | DeviceTree 12 | Firmware/all_flash/all_flash.n88ap.production/DeviceTree.n88ap.img3 13 | KernelCache 14 | kernelcache.release.n88 15 | OS 16 | 038-1417-003.dmg 17 | RestoreDeviceTree 18 | Firmware/all_flash/all_flash.n88ap.production/DeviceTree.n88ap.img3 19 | RestoreKernelCache 20 | kernelcache.release.n88 21 | RestoreRamDisk 22 | 038-1447-003.dmg 23 | 24 | Linked 25 | 26 | 038-1417-003.dmg 27 | Restore.plist 28 | BuildManifest.plist 29 | Firmware/device_map.txt 30 | Firmware/all_flash/all_flash.n88ap.production/manifest 31 | 32 | Personalized 33 | 34 | Firmware/all_flash/all_flash.n88ap.production/applelogo.s5l8920x.img3 35 | Firmware/all_flash/all_flash.n88ap.production/DeviceTree.n88ap.img3 36 | kernelcache.release.n88 37 | 038-1447-003.dmg 38 | Firmware/dfu/iBEC.n88ap.RELEASE.dfu 39 | Firmware/dfu/iBSS.n88ap.RELEASE.dfu 40 | Firmware/all_flash/all_flash.n88ap.production/batterylow1.s5l8920x.img3 41 | Firmware/all_flash/all_flash.n88ap.production/batterylow0.s5l8920x.img3 42 | Firmware/all_flash/all_flash.n88ap.production/LLB.n88ap.RELEASE.img3 43 | Firmware/all_flash/all_flash.n88ap.production/iBoot.n88ap.RELEASE.img3 44 | Firmware/all_flash/all_flash.n88ap.production/batterycharging1.s5l8920x.img3 45 | Firmware/all_flash/all_flash.n88ap.production/glyphcharging.s5l8920x.img3 46 | Firmware/all_flash/all_flash.n88ap.production/glyphplugin.s5l8920x.img3 47 | Firmware/all_flash/all_flash.n88ap.production/batteryfull.s5l8920x.img3 48 | Firmware/all_flash/all_flash.n88ap.production/batterycharging0.s5l8920x.img3 49 | Firmware/all_flash/all_flash.n88ap.production/recoverymode.s5l8920x.img3 50 | amai/apticket.der 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /idevicerestore/src/restore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * restore.h 3 | * Functions for handling idevices in restore mode 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_RESTORE_H 23 | #define IDEVICERESTORE_RESTORE_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | struct restore_client_t { 34 | plist_t tss; 35 | idevice_t device; 36 | const char* uuid; 37 | unsigned int operation; 38 | const char* filesystem; 39 | restored_client_t client; 40 | }; 41 | 42 | int restore_check_mode(const char* uuid); 43 | int restore_check_device(const char* uuid); 44 | int restore_client_new(struct idevicerestore_client_t* client); 45 | void restore_client_free(struct idevicerestore_client_t* client); 46 | int restore_reboot(struct idevicerestore_client_t* client); 47 | const char* restore_progress_string(unsigned int operation); 48 | int restore_handle_status_msg(restored_client_t client, plist_t msg); 49 | int restore_handle_progress_msg(restored_client_t client, plist_t msg); 50 | int restore_handle_data_request_msg(struct idevicerestore_client_t* client, idevice_t device, restored_client_t restore, plist_t message, plist_t build_identity, const char* filesystem); 51 | int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* client, plist_t build_identity); 52 | int restore_send_kernelcache(restored_client_t restore, struct idevicerestore_client_t* client, plist_t build_identity); 53 | int restore_device(struct idevicerestore_client_t* client, plist_t build_identity, const char* filesystem); 54 | int restore_open_with_timeout(struct idevicerestore_client_t* client); 55 | int restore_send_filesystem(idevice_t device, const char* filesystem); 56 | 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /osx-plist/test/test_plist.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'osx/plist' 3 | require 'stringio' 4 | require 'tempfile' 5 | require 'test/unit' 6 | 7 | class TestPlist < Test::Unit::TestCase 8 | def test_string 9 | plist = OSX::PropertyList.load("{foo = bar; }") 10 | assert_equal( { "foo" => "bar" }, plist ) 11 | 12 | plist, format = OSX::PropertyList.load("{foo = bar; }", true) 13 | assert_equal( { "foo" => "bar" }, plist ) 14 | assert_equal( :openstep, format ) 15 | 16 | # make sure sources < 6 characters work 17 | plist = OSX::PropertyList.load("foo") 18 | assert_equal( "foo", plist ) 19 | 20 | # make sure it works with format too 21 | plist, format = OSX::PropertyList.load("foo", true) 22 | assert_equal( "foo", plist ) 23 | assert_equal( :openstep, format ) 24 | 25 | assert_raise(OSX::PropertyListError) { OSX::PropertyList.load("") } 26 | end 27 | 28 | def setup_hash 29 | time = Time.gm(2005, 4, 28, 6, 32, 56) 30 | random = "\x23\x45\x67\x89" 31 | random.blob = true 32 | { 33 | "string!" => "indeedy", 34 | "bar" => [ 1, 2, 3 ], 35 | "foo" => { 36 | "correct?" => true, 37 | "pi" => 3.14159265, 38 | "random" => random, 39 | "today" => time, 40 | } 41 | } 42 | end 43 | 44 | def test_io 45 | plist, format = OSX::PropertyList.load(File.read("#{File.dirname(__FILE__)}/fixtures/xml_plist"), true) 46 | 47 | hash = setup_hash 48 | 49 | assert_equal(hash, plist) 50 | assert_equal(true, plist['foo']['random'].blob?) 51 | assert_equal(false, plist['string!'].blob?) 52 | 53 | assert_equal(:xml1, format) 54 | end 55 | 56 | def test_dump 57 | str = StringIO.new("", "w") 58 | hash = setup_hash 59 | OSX::PropertyList.dump(str, hash) 60 | hash2 = OSX::PropertyList.load(str.string) 61 | assert_equal(hash, hash2) 62 | end 63 | 64 | def test_to_plist 65 | assert_raise(OSX::PropertyListError) { "foo".to_plist(:openstep) } 66 | assert_equal("foo", OSX::PropertyList.load("foo".to_plist)) 67 | hash = setup_hash() 68 | assert_equal(hash, OSX::PropertyList.load(hash.to_plist)) 69 | end 70 | 71 | def test_load_file 72 | plist, format = OSX::PropertyList.load_file("#{File.dirname(__FILE__)}/fixtures/xml_plist", true) 73 | 74 | hash = setup_hash 75 | 76 | assert_equal(hash, plist) 77 | assert_equal(:xml1, format) 78 | end 79 | 80 | def test_dump_file 81 | hash = setup_hash 82 | Tempfile.open("test_plist") do |temp| 83 | OSX::PropertyList.dump_file(temp.path, hash) 84 | hash2 = OSX::PropertyList.load_file(temp.path) 85 | assert_equal(hash, hash2) 86 | end 87 | end 88 | end 89 | -------------------------------------------------------------------------------- /libimobiledevice/src/property_list_service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * property_list_service.h 3 | * Definitions for the PropertyList service 4 | * 5 | * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef PROPERTY_LIST_SERVICE_H 22 | #define PROPERTY_LIST_SERVICE_H 23 | 24 | #include "idevice.h" 25 | 26 | /* Error Codes */ 27 | #define PROPERTY_LIST_SERVICE_E_SUCCESS 0 28 | #define PROPERTY_LIST_SERVICE_E_INVALID_ARG -1 29 | #define PROPERTY_LIST_SERVICE_E_PLIST_ERROR -2 30 | #define PROPERTY_LIST_SERVICE_E_MUX_ERROR -3 31 | #define PROPERTY_LIST_SERVICE_E_SSL_ERROR -4 32 | 33 | #define PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR -256 34 | 35 | struct property_list_service_client_private { 36 | idevice_connection_t connection; 37 | }; 38 | 39 | typedef struct property_list_service_client_private *property_list_service_client_t; 40 | 41 | typedef int16_t property_list_service_error_t; 42 | 43 | /* creation and destruction */ 44 | property_list_service_error_t property_list_service_client_new(idevice_t device, uint16_t port, property_list_service_client_t *client); 45 | property_list_service_error_t property_list_service_client_free(property_list_service_client_t client); 46 | 47 | /* sending */ 48 | property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist); 49 | property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist); 50 | 51 | /* receiving */ 52 | property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout); 53 | property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist); 54 | 55 | /* misc */ 56 | property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client); 57 | property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /libusbmuxd/src/usbmuxd-proto.h: -------------------------------------------------------------------------------- 1 | /* 2 | libusbmuxd - client library to talk to usbmuxd 3 | 4 | Copyright (C) 2009 Paul Sladen 5 | Copyright (C) 2009 Nikias Bassen 6 | Copyright (C) 2009 Hector Martin "marcan" 7 | 8 | This library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as 10 | published by the Free Software Foundation, either version 2.1 of the 11 | License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this program; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | 22 | */ 23 | 24 | /* Protocol defintion for usbmuxd proxy protocol */ 25 | #ifndef __USBMUXD_PROTO_H 26 | #define __USBMUXD_PROTO_H 27 | 28 | #include 29 | #define USBMUXD_PROTOCOL_VERSION 0 30 | 31 | #if defined(WIN32) || defined(__CYGWIN__) 32 | #define USBMUXD_SOCKET_PORT 27015 33 | #else 34 | #define USBMUXD_SOCKET_FILE "/var/run/usbmuxd" 35 | #endif 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | enum usbmuxd_result { 42 | RESULT_OK = 0, 43 | RESULT_BADCOMMAND = 1, 44 | RESULT_BADDEV = 2, 45 | RESULT_CONNREFUSED = 3, 46 | // ??? 47 | // ??? 48 | RESULT_BADVERSION = 6, 49 | }; 50 | 51 | enum usbmuxd_msgtype { 52 | MESSAGE_RESULT = 1, 53 | MESSAGE_CONNECT = 2, 54 | MESSAGE_LISTEN = 3, 55 | MESSAGE_DEVICE_ADD = 4, 56 | MESSAGE_DEVICE_REMOVE = 5, 57 | //??? 58 | //??? 59 | MESSAGE_PLIST = 8, 60 | }; 61 | 62 | struct usbmuxd_header { 63 | uint32_t length; // length of message, including header 64 | uint32_t version; // protocol version 65 | uint32_t message; // message type 66 | uint32_t tag; // responses to this query will echo back this tag 67 | } __attribute__((__packed__)); 68 | 69 | struct usbmuxd_result_msg { 70 | struct usbmuxd_header header; 71 | uint32_t result; 72 | } __attribute__((__packed__)); 73 | 74 | struct usbmuxd_connect_request { 75 | struct usbmuxd_header header; 76 | uint32_t device_id; 77 | uint16_t port; // TCP port number 78 | uint16_t reserved; // set to zero 79 | } __attribute__((__packed__)); 80 | 81 | struct usbmuxd_listen_request { 82 | struct usbmuxd_header header; 83 | } __attribute__((__packed__)); 84 | 85 | struct usbmuxd_device_record { 86 | uint32_t device_id; 87 | uint16_t product_id; 88 | char serial_number[256]; 89 | uint16_t padding; 90 | uint32_t location; 91 | } __attribute__((__packed__)); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* __USBMUXD_PROTO_H */ 98 | -------------------------------------------------------------------------------- /libimobiledevice/src/device_link_service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * device_link_service.h 3 | * Definitions for the DeviceLink service 4 | * 5 | * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef DEVICE_LINK_SERVICE_H 22 | #define DEVICE_LINK_SERVICE_H 23 | 24 | #include "property_list_service.h" 25 | 26 | /* Error Codes */ 27 | #define DEVICE_LINK_SERVICE_E_SUCCESS 0 28 | #define DEVICE_LINK_SERVICE_E_INVALID_ARG -1 29 | #define DEVICE_LINK_SERVICE_E_PLIST_ERROR -2 30 | #define DEVICE_LINK_SERVICE_E_MUX_ERROR -3 31 | #define DEVICE_LINK_SERVICE_E_BAD_VERSION -4 32 | 33 | #define DEVICE_LINK_SERVICE_E_UNKNOWN_ERROR -256 34 | 35 | /** Represents an error code. */ 36 | typedef int16_t device_link_service_error_t; 37 | 38 | struct device_link_service_client_private { 39 | property_list_service_client_t parent; 40 | }; 41 | 42 | typedef struct device_link_service_client_private *device_link_service_client_t; 43 | 44 | device_link_service_error_t device_link_service_client_new(idevice_t device, uint16_t port, device_link_service_client_t *client); 45 | device_link_service_error_t device_link_service_client_free(device_link_service_client_t client); 46 | device_link_service_error_t device_link_service_version_exchange(device_link_service_client_t client, uint64_t version_major, uint64_t version_minor); 47 | device_link_service_error_t device_link_service_send_ping(device_link_service_client_t client, const char *message); 48 | device_link_service_error_t device_link_service_receive_message(device_link_service_client_t client, plist_t *msg_plist, char **dlmessage); 49 | device_link_service_error_t device_link_service_send_process_message(device_link_service_client_t client, plist_t message); 50 | device_link_service_error_t device_link_service_receive_process_message(device_link_service_client_t client, plist_t *message); 51 | device_link_service_error_t device_link_service_disconnect(device_link_service_client_t client, const char *message); 52 | device_link_service_error_t device_link_service_send(device_link_service_client_t client, plist_t plist); 53 | device_link_service_error_t device_link_service_receive(device_link_service_client_t client, plist_t *plist); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /img3file.rb: -------------------------------------------------------------------------------- 1 | require 'bit-struct' 2 | require 'pp' 3 | 4 | class Header < BitStruct 5 | default_options :endian=>:native 6 | unsigned :signature, 32, "signature" 7 | unsigned :full_size, 32, "full_size" 8 | unsigned :data_size, 32, "data_size" 9 | unsigned :shsh_offset, 32, "shsh_offset" 10 | unsigned :image_type, 32, "image_type" 11 | end 12 | 13 | class ElementHeader < BitStruct 14 | default_options :endian=>:native 15 | unsigned :signature, 32, "signature" 16 | unsigned :full_size, 32, "full_size" 17 | unsigned :data_size, 32, "data_size" 18 | end 19 | 20 | class Element < BitStruct 21 | default_options :endian=>:native 22 | nest :header, ElementHeader 23 | rest :data, "data" 24 | end 25 | 26 | class Img3File 27 | attr_accessor :header, :elements, :elementkeys 28 | 29 | def parse(input) 30 | data = input.read(Header.round_byte_length) 31 | @header = Header.new data 32 | @elements, @elementkeys = self.parse_elements(input, @header.full_size) 33 | end 34 | 35 | def parse_elements(input, total_len) 36 | elements = [] 37 | elementkeys = [] 38 | # 39 | pos = Header.round_byte_length 40 | while pos < total_len do 41 | #p "#{pos}/#{@header.full_size}" 42 | data = input.read(ElementHeader.round_byte_length) 43 | if data.nil? 44 | break 45 | end 46 | h = ElementHeader.new data 47 | elementkeys += [h.signature] 48 | element = Element.new 49 | element.header = h 50 | element.data = input.read(h.full_size-ElementHeader.round_byte_length) 51 | elements += [element] 52 | pos += h.full_size 53 | end 54 | # self 55 | [elements, elementkeys] 56 | end 57 | 58 | def update_elements(input, total_len) 59 | # parse 60 | elements, elementkeys = parse_elements(input, total_len) 61 | pp elementkeys 62 | # update keys 63 | tmp = [] 64 | @elements.each do |e| 65 | if not elementkeys.include?(e.header.signature) 66 | tmp += [e] 67 | end 68 | end 69 | # update 70 | @elements = tmp + elements 71 | @elementkeys = elementkeys 72 | end 73 | 74 | def to_s 75 | tmp = StringIO.new 76 | header = Header.new 77 | pos = 0 78 | @elements.each do |e| 79 | #p "#{pos}/#{@header.full_size} #{e.header.signature}" 80 | if e.header.signature == "SHSH".reverse.unpack("i*")[0] # 0x53485348, 1397248840 81 | # 53485348 82 | header.shsh_offset = pos 83 | end 84 | tmp << e.to_s 85 | pos += e.header.full_size 86 | end 87 | header.signature = @header.signature 88 | header.full_size = pos + Header.round_byte_length 89 | header.data_size = pos 90 | header.image_type = @header.image_type 91 | 92 | output = StringIO.new 93 | output << header.to_s 94 | output << tmp.string 95 | output.rewind 96 | output.read 97 | end 98 | 99 | end 100 | 101 | -------------------------------------------------------------------------------- /libimobiledevice/tools/ideviceenterrecovery.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ideviceenterrecovery.c 3 | * Simple utility to make a device in normal mode enter recovery mode. 4 | * 5 | * Copyright (c) 2009 Martin Szulecki All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | static void print_usage(int argc, char **argv) 31 | { 32 | char *name = NULL; 33 | 34 | name = strrchr(argv[0], '/'); 35 | printf("Usage: %s [OPTIONS] UUID\n", (name ? name + 1: argv[0])); 36 | printf("Makes a device with the supplied 40-digit UUID enter recovery mode immediately.\n\n"); 37 | printf(" -d, --debug\t\tenable communication debugging\n"); 38 | printf(" -h, --help\t\tprints usage information\n"); 39 | printf("\n"); 40 | } 41 | 42 | int main(int argc, char *argv[]) 43 | { 44 | lockdownd_client_t client = NULL; 45 | idevice_t phone = NULL; 46 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; 47 | int i; 48 | char uuid[41]; 49 | uuid[0] = 0; 50 | 51 | /* parse cmdline args */ 52 | for (i = 1; i < argc; i++) { 53 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { 54 | idevice_set_debug_level(1); 55 | continue; 56 | } 57 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { 58 | print_usage(argc, argv); 59 | return 0; 60 | } 61 | } 62 | 63 | i--; 64 | if (!argv[i] || (strlen(argv[i]) != 40)) { 65 | print_usage(argc, argv); 66 | return 0; 67 | } 68 | strcpy(uuid, argv[i]); 69 | 70 | ret = idevice_new(&phone, uuid); 71 | if (ret != IDEVICE_E_SUCCESS) { 72 | printf("No device found with uuid %s, is it plugged in?\n", uuid); 73 | return -1; 74 | } 75 | 76 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "ideviceenterrecovery")) { 77 | idevice_free(phone); 78 | return -1; 79 | } 80 | 81 | /* run query and output information */ 82 | printf("Telling device with uuid %s to enter recovery mode.\n", uuid); 83 | if(lockdownd_enter_recovery(client) != LOCKDOWN_E_SUCCESS) 84 | { 85 | printf("Failed to enter recovery mode.\n"); 86 | } 87 | printf("Device is successfully switching to recovery mode.\n"); 88 | 89 | lockdownd_client_free(client); 90 | idevice_free(phone); 91 | 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /libimobiledevice/tools/idevice_id.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define MODE_NONE 0 8 | #define MODE_SHOW_ID 1 9 | #define MODE_LIST_DEVICES 2 10 | 11 | static void print_usage(int argc, char **argv) 12 | { 13 | char *name = NULL; 14 | 15 | name = strrchr(argv[0], '/'); 16 | printf("Usage: %s [OPTIONS] [UUID]\n", (name ? name + 1: argv[0])); 17 | printf("Prints device name or a list of attached iPhone/iPod Touch devices.\n\n"); 18 | printf(" The UUID is a 40-digit hexadecimal number of the device\n"); 19 | printf(" for which the name should be retrieved.\n\n"); 20 | printf(" -l, --list\t\tlist UUID of all attached devices\n"); 21 | printf(" -d, --debug\t\tenable communication debugging\n"); 22 | printf(" -h, --help\t\tprints usage information\n"); 23 | printf("\n"); 24 | } 25 | 26 | int main(int argc, char **argv) 27 | { 28 | idevice_t phone = NULL; 29 | lockdownd_client_t client = NULL; 30 | char **dev_list = NULL; 31 | char *devname = NULL; 32 | int ret = 0; 33 | int i; 34 | int mode = MODE_SHOW_ID; 35 | char uuid[41]; 36 | uuid[0] = 0; 37 | 38 | /* parse cmdline args */ 39 | for (i = 1; i < argc; i++) { 40 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { 41 | idevice_set_debug_level(1); 42 | continue; 43 | } 44 | else if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "--list")) { 45 | mode = MODE_LIST_DEVICES; 46 | continue; 47 | } 48 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { 49 | print_usage(argc, argv); 50 | return 0; 51 | } 52 | } 53 | 54 | /* check if uuid was passed */ 55 | if (mode == MODE_SHOW_ID) { 56 | i--; 57 | if (!argv[i] || (strlen(argv[i]) != 40)) { 58 | print_usage(argc, argv); 59 | return 0; 60 | } 61 | strcpy(uuid, argv[i]); 62 | } 63 | 64 | switch (mode) { 65 | case MODE_SHOW_ID: 66 | idevice_new(&phone, uuid); 67 | if (!phone) { 68 | fprintf(stderr, "ERROR: No device with UUID=%s attached.\n", uuid); 69 | return -2; 70 | } 71 | 72 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "idevice_id")) { 73 | idevice_free(phone); 74 | fprintf(stderr, "ERROR: Connecting to device failed!\n"); 75 | return -2; 76 | } 77 | 78 | if ((LOCKDOWN_E_SUCCESS != lockdownd_get_device_name(client, &devname)) || !devname) { 79 | fprintf(stderr, "ERROR: Could not get device name!\n"); 80 | ret = -2; 81 | } 82 | 83 | lockdownd_client_free(client); 84 | idevice_free(phone); 85 | 86 | if (ret == 0) { 87 | printf("%s\n", devname); 88 | } 89 | 90 | if (devname) { 91 | free(devname); 92 | } 93 | 94 | return ret; 95 | case MODE_LIST_DEVICES: 96 | default: 97 | if (idevice_get_device_list(&dev_list, &i) < 0) { 98 | fprintf(stderr, "ERROR: Unable to retrieve device list!\n"); 99 | return -1; 100 | } 101 | for (i = 0; dev_list[i] != NULL; i++) { 102 | printf("%s\n", dev_list[i]); 103 | } 104 | idevice_device_list_free(dev_list); 105 | return 0; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /idevicerestore/src/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * common.c 3 | * Misc functions used in idevicerestore 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | 24 | #include "common.h" 25 | 26 | int idevicerestore_debug = 0; 27 | 28 | int write_file(const char* filename, const void* data, size_t size) { 29 | size_t bytes = 0; 30 | FILE* file = NULL; 31 | 32 | debug("Writing data to %s\n", filename); 33 | file = fopen(filename, "wb"); 34 | if (file == NULL) { 35 | error("read_file: Unable to open file %s\n", filename); 36 | return -1; 37 | } 38 | 39 | bytes = fwrite(data, 1, size, file); 40 | fclose(file); 41 | 42 | if (bytes != size) { 43 | error("ERROR: Unable to write entire file: %s: %d of %d\n", filename, bytes, size); 44 | return -1; 45 | } 46 | 47 | return size; 48 | } 49 | 50 | int read_file(const char* filename, void** data, size_t* size) { 51 | size_t bytes = 0; 52 | size_t length = 0; 53 | FILE* file = NULL; 54 | char* buffer = NULL; 55 | debug("Reading data from %s\n", filename); 56 | 57 | *size = 0; 58 | *data = NULL; 59 | 60 | file = fopen(filename, "rb"); 61 | if (file == NULL) { 62 | error("read_file: File %s not found\n", filename); 63 | return -1; 64 | } 65 | 66 | fseek(file, 0, SEEK_END); 67 | length = ftell(file); 68 | rewind(file); 69 | 70 | buffer = (char*) malloc(length); 71 | if (buffer == NULL) { 72 | error("ERROR: Out of memory\n"); 73 | fclose(file); 74 | return -1; 75 | } 76 | bytes = fread(buffer, 1, length, file); 77 | fclose(file); 78 | 79 | if (bytes != length) { 80 | error("ERROR: Unable to read entire file\n"); 81 | free(buffer); 82 | return -1; 83 | } 84 | 85 | *size = length; 86 | *data = buffer; 87 | return 0; 88 | } 89 | 90 | void debug_plist(plist_t plist) { 91 | int size = 0; 92 | char* data = NULL; 93 | plist_to_xml(plist, &data, &size); 94 | info("%s", data); 95 | free(data); 96 | } 97 | 98 | void print_progress_bar(double progress) { 99 | int i = 0; 100 | if(progress < 0) return; 101 | if(progress > 100) progress = 100; 102 | info("\r["); 103 | for(i = 0; i < 50; i++) { 104 | if(i < progress / 2) info("="); 105 | else info(" "); 106 | } 107 | info("] %3.1f%%", progress); 108 | if(progress == 100) info("\n"); 109 | fflush(stdout); 110 | } 111 | -------------------------------------------------------------------------------- /libimobiledevice/tools/ipa/README: -------------------------------------------------------------------------------- 1 | # ideviceinstaller 2 | -l -o list_all 3 | -i "Linux 1.2.ipa" 4 | -u com.evolonix.Linux-Reference-Guide 5 | 6 | -a com.evolonix.Linux-Reference-Guide 7 | -r com.evolonix.Linux-Reference-Guide 8 | -R com.evolonix.Linux-Reference-Guide 9 | 10 | Request\n\tStartService\n\tService\n\tcom.apple.mobile.installation_proxy\n\n\n" 11 | 12 | 13 | CommandBrowse" 14 | 15 | 16 | CurrentAmount10 17 | CurrentIndex0 18 | CurrentList 19 | 20 | ApplicationTypeSystem 21 | BuildMachineOSBuild10A433 22 | CFBundleDevelopmentRegionEnglish 23 | CFBundleExecutableDemoApp 24 | CFBundleIdentifiercom.apple.DemoApp 25 | CFBundleInfoDictionaryVersion6.0 26 | CFBundlePackageTypeAPPL 27 | CFBundleResourceSpecificationResourceRules.plist 28 | CFBundleShortVersionString1.0.0 29 | CFBundleSignature???? 30 | CFBundleSupportedPlatformsiPhoneOS 31 | CFBundleVersion1.0 32 | DTCompiler4.2 33 | DTPlatformBuild 34 | DTPlatformNameiphoneos 35 | DTPlatformVersion4.3 36 | DTSDKBuild8F177 37 | DTSDKNameiphoneos4.3.internal 38 | DTXcode0400 39 | DTXcodeBuild10M2515 40 | MinimumOSVersion4.3 41 | Path/Applications/DemoApp.app 42 | SBAppTagshidden 43 | UIApplicationExitsOnSuspend 44 | UIDeviceFamily12 45 | UIStatusBarHidden 46 | 47 | 48 | " 49 | 50 | 51 | 52 | ApplicationIdentifier 53 | com.evolonix.Linux-Reference-Guide 54 | Command 55 | Uninstall 56 | 57 | 58 | 59 | \n\n\tApplicationIdentifier\n\tcom.evolonix.Linux-Reference-Guide\n\tClientOptions\n\t\n\t\tSkipUninstall\n\t\t\n\t\n\tCommand\n\tArchive\n\n\n" 60 | 61 | \n\n\tApplicationIdentifier\n\tcom.evolonix.Linux-Reference-Guide\n\tCommand\n\tRestore\n\n\n" 62 | 63 | \n\n\tApplicationIdentifier\n\tcom.evolonix.Linux-Reference-Guide\n\tCommand\n\tRemoveArchive\n\n\n" 64 | 65 | -------------------------------------------------------------------------------- /ribusb/test/test_ribusb.rb: -------------------------------------------------------------------------------- 1 | require "test/unit" 2 | require "ribusb" 3 | 4 | class TestRibusb < Test::Unit::TestCase 5 | include RibUSB 6 | 7 | attr_accessor :usb 8 | 9 | def setup 10 | @usb = Context.new 11 | @usb.debug = 0 12 | end 13 | 14 | def test_find 15 | devlist = usb.find 16 | assert_kind_of Array, devlist, "Bus#find should return an Array" 17 | assert_kind_of Device, devlist.first, "Bus#find should return Devices" 18 | 19 | usb.find do |dev| 20 | assert_equal devlist.shift.device_address, dev.device_address, "Bus#find with block should give same devices" 21 | end 22 | end 23 | 24 | def test_descriptors 25 | usb.find do |dev| 26 | assert_match(/Device/, dev.inspect, "Device#inspect should work") 27 | dev.configurations.each do |config_desc| 28 | assert_match(/ConfigDescriptor/, config_desc.inspect, "ConfigDescriptor#inspect should work") 29 | assert dev.configurations.include?(config_desc), "Device#configurations should include this one" 30 | 31 | config_desc.interfaces.each do |interface| 32 | assert_match(/Interface/, interface.inspect, "Interface#inspect should work") 33 | 34 | assert dev.interfaces.include?(interface), "Device#interfaces should include this one" 35 | assert config_desc.interfaces.include?(interface), "ConfigDescriptor#interfaces should include this one" 36 | 37 | interface.alt_settings.each do |if_desc| 38 | assert_match(/InterfaceDescriptor/, if_desc.inspect, "InterfaceDescriptor#inspect should work") 39 | 40 | assert dev.interface_descriptors.include?(if_desc), "Device#interface_descriptors should include this one" 41 | assert config_desc.interface_descriptors.include?(if_desc), "ConfigDescriptor#interface_descriptors should include this one" 42 | assert interface.alt_settings.include?(if_desc), "Inteerface#alt_settings should include this one" 43 | 44 | if_desc.endpoints.each do |ep| 45 | assert_match(/EndpointDescriptor/, ep.inspect, "EndpointDescriptor#inspect should work") 46 | 47 | assert dev.endpoints.include?(ep), "Device#endpoints should include this one" 48 | assert config_desc.endpoints.include?(ep), "ConfigDescriptor#endpoints should include this one" 49 | assert interface.endpoints.include?(ep), "Inteerface#endpoints should include this one" 50 | assert if_desc.endpoints.include?(ep), "InterfaceDescriptor#endpoints should include this one" 51 | 52 | assert_equal if_desc, ep.interface_descriptor, "backref should be correct" 53 | assert_equal interface, ep.interface, "backref should be correct" 54 | assert_equal config_desc, ep.configuration, "backref should be correct" 55 | assert_equal dev, ep.device, "backref should be correct" 56 | 57 | assert_operator 0, :<, ep.wMaxPacketSize, "packet size should be > 0" 58 | end 59 | end 60 | end 61 | end 62 | end 63 | end 64 | 65 | def test_constants 66 | assert_equal 7, LIBUSB_CLASS_PRINTER, "Printer class id should be defined" 67 | assert_equal 48, LIBUSB_ISO_USAGE_TYPE_MASK, "iso usage type should be defined" 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /idevicerestore/src/img3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * img3.h 3 | * Functions for handling with Apple's IMG3 format 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef IDEVICERESTORE_IMG3_H 23 | #define IDEVICERESTORE_IMG3_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | typedef enum { 30 | kNorContainer = 0x696D6733, // img3 31 | kImg3Container = 0x496D6733, // Img3 32 | k8900Container = 0x30303938, // 8900 33 | kImg2Container = 0x494D4732 // IMG2 34 | } img3_container; 35 | 36 | typedef enum { 37 | kDataElement = 0x44415441, // DATA 38 | kTypeElement = 0x54595045, // TYPE 39 | kKbagElement = 0x4B424147, // KBAG 40 | kShshElement = 0x53485348, // SHSH 41 | kCertElement = 0x43455254, // CERT 42 | kChipElement = 0x43484950, // CHIP 43 | kProdElement = 0x50524F44, // PROD 44 | kSdomElement = 0x53444F4D, // SDOM 45 | kVersElement = 0x56455253, // VERS 46 | kBordElement = 0x424F5244, // BORD 47 | kSepoElement = 0x5345504F, // SEPO 48 | kEcidElement = 0x45434944, // ECID 49 | kUnknElement = 0x53414c54 // FIXME SALT 50 | } img3_element_type; 51 | 52 | typedef struct { 53 | unsigned int signature; 54 | unsigned int full_size; 55 | unsigned int data_size; 56 | unsigned int shsh_offset; 57 | unsigned int image_type; 58 | } img3_header; 59 | 60 | typedef struct { 61 | unsigned int signature; 62 | unsigned int full_size; 63 | unsigned int data_size; 64 | } img3_element_header; 65 | 66 | typedef struct { 67 | img3_element_header* header; 68 | img3_element_type type; 69 | unsigned char* data; 70 | } img3_element; 71 | 72 | typedef struct { 73 | char* data; 74 | img3_header* header; 75 | img3_element* type_element; 76 | img3_element* data_element; 77 | img3_element* vers_element; 78 | img3_element* sepo_element; 79 | img3_element* bord_element; 80 | img3_element* kbag1_element; 81 | img3_element* kbag2_element; 82 | img3_element* ecid_element; 83 | img3_element* shsh_element; 84 | img3_element* cert_element; 85 | img3_element* unkn_element; 86 | } img3_file; 87 | 88 | void img3_free(img3_file* image); 89 | img3_element* img3_parse_element(char* data); 90 | void img3_free_element(img3_element* element); 91 | img3_file* img3_parse_file(char* data, int size); 92 | int img3_get_data(img3_file* image, char** pdata, int* psize); 93 | int img3_replace_signature(img3_file* image, char* signature); 94 | 95 | 96 | #ifdef __cplusplus 97 | }s 98 | #endif 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /ideviceactivate/src/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * util.c 3 | * Just utility functions ;) 4 | * 5 | * Copyright (c) 2010 Joshua Hill and boxingsquirrel. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "util.h" 31 | 32 | int buffer_read_from_filename(const char *filename, char **buffer, uint32_t *length) { 33 | FILE *f; 34 | uint64_t size; 35 | 36 | f = fopen(filename, "rb"); 37 | if(f == NULL) { 38 | printf("Unable to open file %s\n", filename); 39 | return -1; 40 | } 41 | 42 | fseek(f, 0, SEEK_END); 43 | size = ftell(f); 44 | rewind(f); 45 | 46 | *buffer = (char*) malloc(sizeof(char) * size); 47 | if (fread(*buffer, sizeof(char), size, f) != size) { 48 | printf("Unable to read %llu bytes from '%s'.\n", size, filename); 49 | free(*buffer); 50 | *buffer = NULL; 51 | } 52 | fclose(f); 53 | 54 | *length = size; 55 | return 0; 56 | } 57 | 58 | int plist_read_from_filename(plist_t *plist, const char *filename) { 59 | char *buffer = NULL; 60 | uint32_t length; 61 | 62 | if (filename == NULL) { 63 | printf("No filename specified\n"); 64 | return -1; 65 | } 66 | 67 | if(buffer_read_from_filename(filename, &buffer, &length) < 0) { 68 | printf("Unable to read file\n"); 69 | return -1; 70 | } 71 | 72 | if (buffer == NULL) { 73 | printf("Buffer returned null\n"); 74 | return -1; 75 | } 76 | 77 | if (memcmp(buffer, "bplist00", 8) == 0) { 78 | plist_from_bin(buffer, length, plist); 79 | } else { 80 | plist_from_xml(buffer, length, plist); 81 | } 82 | 83 | free(buffer); 84 | 85 | return 0; 86 | } 87 | 88 | /* This one is a wrapper for p0sixninja's rather repetetive code... */ 89 | void lockdownd_get_string_value(lockdownd_client_t client, const char *what, char *val) 90 | { 91 | plist_t val_node=NULL; 92 | 93 | lockdownd_get_value(client, NULL, what, &val_node); 94 | if (!val_node || plist_get_node_type(val_node) != PLIST_STRING) { 95 | fprintf(stderr, "Unable to get %s from lockdownd\n", what); 96 | val=NULL; 97 | } 98 | plist_get_string_val(val_node, &val); 99 | plist_free(val_node); 100 | } 101 | 102 | /* This is really just a function to allow some hooking into Gtk stuff in iDeviceActivator... */ 103 | void info(const char *m) 104 | { 105 | printf("INFO: %s\n", m); 106 | } 107 | 108 | void error(const char *m) 109 | { 110 | fprintf(stderr, "%s\n", m); 111 | } 112 | 113 | void task(const char *m) 114 | { 115 | printf("%s\n", m); 116 | } 117 | -------------------------------------------------------------------------------- /libplist/src/Structure.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Structure.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace PList 25 | { 26 | 27 | Structure::Structure(Node* parent) : Node(parent) 28 | { 29 | } 30 | Structure::Structure(plist_type type, Node* parent) : Node(type, parent) 31 | { 32 | } 33 | 34 | Structure::~Structure() 35 | { 36 | } 37 | 38 | uint32_t Structure::GetSize() 39 | { 40 | uint32_t size = 0; 41 | plist_type type = plist_get_node_type(_node); 42 | if (type == PLIST_ARRAY) 43 | { 44 | size = plist_array_get_size(_node); 45 | } 46 | else if (type == PLIST_DICT) 47 | { 48 | size = plist_dict_get_size(_node); 49 | } 50 | return size; 51 | } 52 | 53 | std::string Structure::ToXml() 54 | { 55 | char* xml = NULL; 56 | uint32_t length = 0; 57 | plist_to_xml(_node, &xml, &length); 58 | std::string ret(xml, xml+length); 59 | free(xml); 60 | return ret; 61 | } 62 | 63 | std::vector Structure::ToBin() 64 | { 65 | char* bin = NULL; 66 | uint32_t length = 0; 67 | plist_to_bin(_node, &bin, &length); 68 | std::vector ret(bin, bin+length); 69 | free(bin); 70 | return ret; 71 | } 72 | 73 | void Structure::UpdateNodeParent(Node* node) 74 | { 75 | //Unlink node first 76 | if ( NULL != node->_parent ) 77 | { 78 | plist_type type = plist_get_node_type(node->_parent); 79 | if (PLIST_ARRAY ==type || PLIST_DICT == type ) 80 | { 81 | Structure* s = static_cast(node->_parent); 82 | s->Remove(node); 83 | } 84 | } 85 | node->_parent = this; 86 | } 87 | 88 | static Structure* ImportStruct(plist_t root) 89 | { 90 | Structure* ret = NULL; 91 | plist_type type = plist_get_node_type(root); 92 | 93 | if (PLIST_ARRAY == type || PLIST_DICT == type) 94 | { 95 | ret = static_cast(Node::FromPlist(root)); 96 | } 97 | else 98 | { 99 | plist_free(root); 100 | } 101 | 102 | return ret; 103 | } 104 | 105 | Structure* Structure::FromXml(const std::string& xml) 106 | { 107 | plist_t root = NULL; 108 | plist_from_xml(xml.c_str(), xml.size(), &root); 109 | 110 | return ImportStruct(root); 111 | } 112 | 113 | Structure* Structure::FromBin(const std::vector& bin) 114 | { 115 | plist_t root = NULL; 116 | plist_from_bin(&bin[0], bin.size(), &root); 117 | 118 | return ImportStruct(root); 119 | 120 | } 121 | 122 | }; 123 | 124 | -------------------------------------------------------------------------------- /ssl_cert.rb: -------------------------------------------------------------------------------- 1 | require 'openssl' 2 | require 'base64' 3 | require 'stringio' 4 | require 'plist' 5 | 6 | # % ruby -ropenssl -e 7 | # 'OpenSSL::PKey::RSA.new(1024).public_key.to_pem.display' 8 | # - -----BEGIN RSA PUBLIC KEY----- 9 | # MIGJAoGBAL8KLG/KSWzi48EMsa6cNlWwXKIrDUjn3dsoWv5fF31J/PUkg0ULw45I 10 | # kBapGw+9iUcfUIOegY80d+WDTO56F0OhLNA4+0huAPfcdVASDnbhyYTn8mQgv2Rf 11 | # qUEvL5+bnacbmN0NVhg9PhljZci2hEFsUDcJP2OX+pbcmXfvnVjbAgMBAAE= 12 | # - -----END RSA PUBLIC KEY----- 13 | 14 | root_private_key = OpenSSL::PKey::RSA.new(2048) 15 | host_private_key = OpenSSL::PKey::RSA.new(2048) 16 | 17 | b64_s =%Q{ 18 | LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JR0pBb0dCQUtuUUZPR2tBMXZB 19 | cG4rL0srK0ZuMUZWdHl1UGdXMkExU1lPNXBMZEoxcC9USzJ0TVQycXFuZmMKbjVTYjVm 20 | UkFoUi9tL00rYy9XSFd0cFpQSWJGN1VURCtYTFliakwrQ1grQkZzV2xnazNEQ0p6QTJr 21 | Y2ErWnlKeQpGR3VOUDNWN2ZONXdHQXVFMDRNcVMyQ2lFQzlwWHAvZHJhWXZENE1LelBy 22 | anlFSEJ0NlFMQWdNQkFBRT0KLS0tLS1FTkQgUlNBIFBVQkxJQyBLRVktLS0tLQo=" 23 | } 24 | 25 | pub_key = Base64.decode64(b64_s) 26 | 27 | p "pub_key:#{pub_key}" 28 | digest = OpenSSL::Digest::Digest.new("SHA1") 29 | 30 | root_ca_cert = OpenSSL::X509::Certificate.new 31 | root_ca_cert.serial = 0 32 | root_ca_cert.not_before = Time.now 33 | root_ca_cert.not_after = Time.now + 60 * 60 * 24 * 365 * 10 34 | root_ca_cert.public_key = root_private_key.public_key 35 | ef = OpenSSL::X509::ExtensionFactory.new 36 | root_ca_cert.extensions = [ 37 | ef.create_extension("basicConstraints","CA:TRUE", true), 38 | ] 39 | 40 | key = OpenSSL::PKey::RSA.new(pub_key) 41 | p "modulus:#{key.n}, exponent:#{key.e}" 42 | 43 | device_cert = OpenSSL::X509::Certificate.new 44 | device_cert.public_key = key.public_key 45 | device_cert.serial = 0 46 | device_cert.not_before = Time.now 47 | device_cert.not_after = Time.now + 60 * 60 * 24 * 365 * 10 48 | ef = OpenSSL::X509::ExtensionFactory.new 49 | device_cert.extensions = [ 50 | ef.create_extension("basicConstraints","CA:FALSE", true), 51 | ef.create_extension("keyUsage","Digital Signature, Key Encipherment", true), 52 | ] 53 | device_cert.sign(root_private_key, digest) 54 | 55 | host_cert = OpenSSL::X509::Certificate.new 56 | host_cert.public_key = host_private_key.public_key 57 | host_cert.serial = 0 58 | host_cert.not_before = Time.now 59 | host_cert.not_after = Time.now + 60 * 60 * 24 * 365 * 10 60 | ef = OpenSSL::X509::ExtensionFactory.new 61 | host_cert.extensions = [ 62 | ef.create_extension("basicConstraints","CA:FALSE", true), 63 | ef.create_extension("keyUsage","Digital Signature, Key Encipherment", true), 64 | ] 65 | 66 | # gnutls_x509_crt_set_key_usage(host_cert, GNUTLS_KEY_KEY_ENCIPHERMENT | GNUTLS_KEY_DIGITAL_SIGNATURE); 67 | host_cert.sign(root_private_key, digest) 68 | 69 | root_pem = root_ca_cert.to_pem 70 | device_pem = device_cert.to_pem 71 | host_pem = host_cert.to_pem 72 | 73 | root_certificate = StringIO.new(root_pem) 74 | host_certificate = StringIO.new << host_pem 75 | device_certificate = StringIO.new << device_pem 76 | 77 | def rand_hex_3(l) 78 | "%0#{l}x" % rand(1 << l*4) 79 | end 80 | 81 | def rand_digit(l) 82 | "%0#{l}d" % rand(10 ** l) 83 | end 84 | 85 | def gen_hostid 86 | # [8,4,4,4,12].map {|n| rand_hex_3(n)}.join('-') 87 | [8,18].map {|n| rand_digit(n)}.join('-') 88 | end 89 | 90 | host_id = gen_hostid 91 | p host_id 92 | 93 | certs = {"DeviceCertificate" => root_certificate, 94 | "HostCertificate" => device_certificate, 95 | "HostID" => host_id, 96 | "RootCertificate" => host_certificate} 97 | obj = {"PairRecord"=>certs, "Request" => "Pair" } 98 | p obj.to_plist -------------------------------------------------------------------------------- /libusbmuxd/src/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | usbmuxd - iPhone/iPod Touch USB multiplex server daemon 3 | 4 | Copyright (C) 2009 Hector Martin "marcan" 5 | Copyright (C) 2009 Nikias Bassen 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 2 or version 3. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | #include "utils.h" 30 | 31 | #ifdef USBMUXD_DAEMON 32 | # include "log.h" 33 | # define util_error(...) usbmuxd_log(LL_ERROR, __VA_ARGS__) 34 | #else 35 | # define util_error(...) fprintf(stderr, __VA_ARGS__) 36 | #endif 37 | 38 | #ifdef USBMUXD_DAEMON 39 | void fdlist_create(struct fdlist *list) 40 | { 41 | list->count = 0; 42 | list->capacity = 4; 43 | list->owners = malloc(sizeof(*list->owners) * list->capacity); 44 | list->fds = malloc(sizeof(*list->fds) * list->capacity); 45 | } 46 | void fdlist_add(struct fdlist *list, enum fdowner owner, int fd, short events) 47 | { 48 | if(list->count == list->capacity) { 49 | list->capacity *= 2; 50 | list->owners = realloc(list->owners, sizeof(*list->owners) * list->capacity); 51 | list->fds = realloc(list->fds, sizeof(*list->fds) * list->capacity); 52 | } 53 | list->owners[list->count] = owner; 54 | list->fds[list->count].fd = fd; 55 | list->fds[list->count].events = events; 56 | list->fds[list->count].revents = 0; 57 | list->count++; 58 | } 59 | 60 | void fdlist_free(struct fdlist *list) 61 | { 62 | list->count = 0; 63 | list->capacity = 0; 64 | free(list->owners); 65 | list->owners = NULL; 66 | free(list->fds); 67 | list->fds = NULL; 68 | } 69 | 70 | void fdlist_reset(struct fdlist *list) 71 | { 72 | list->count = 0; 73 | } 74 | #endif 75 | 76 | void collection_init(struct collection *col) 77 | { 78 | col->list = malloc(sizeof(void *)); 79 | memset(col->list, 0, sizeof(void *)); 80 | col->capacity = 1; 81 | } 82 | 83 | void collection_free(struct collection *col) 84 | { 85 | free(col->list); 86 | col->list = NULL; 87 | col->capacity = 0; 88 | } 89 | 90 | void collection_add(struct collection *col, void *element) 91 | { 92 | int i; 93 | for(i=0; icapacity; i++) { 94 | if(!col->list[i]) { 95 | col->list[i] = element; 96 | return; 97 | } 98 | } 99 | col->list = realloc(col->list, sizeof(void*) * col->capacity * 2); 100 | memset(&col->list[col->capacity], 0, sizeof(void *) * col->capacity); 101 | col->list[col->capacity] = element; 102 | col->capacity *= 2; 103 | } 104 | 105 | void collection_remove(struct collection *col, void *element) 106 | { 107 | int i; 108 | for(i=0; icapacity; i++) { 109 | if(col->list[i] == element) { 110 | col->list[i] = NULL; 111 | return; 112 | } 113 | } 114 | util_error("collection_remove: element %p not present in collection %p (cap %d)", element, col, col->capacity); 115 | } 116 | 117 | int collection_count(struct collection *col) 118 | { 119 | int i, cnt = 0; 120 | for(i=0; icapacity; i++) { 121 | if(col->list[i]) 122 | cnt++; 123 | } 124 | return cnt; 125 | } 126 | -------------------------------------------------------------------------------- /osx-plist/README.txt: -------------------------------------------------------------------------------- 1 | == osx-plist 2 | 3 | * http://github.com/kballard/osx-plist 4 | * by Kevin Ballard 5 | 6 | == DESCRIPTION: 7 | 8 | osx-plist is a Ruby library for manipulating Property Lists natively using the built-in support in OS X. 9 | 10 | == REQUIREMENTS: 11 | 12 | * CoreFoundation (i.e. Mac OS X) 13 | 14 | == INSTALL: 15 | 16 | $ gem sources -a http://gems.github.com/ (you only need to do this once) 17 | $ gem install kballard-osx-plist 18 | 19 | == SOURCE: 20 | 21 | osx-plist's git repo is available on GitHub, which can be browsed at: 22 | 23 | http://github.com/kballard/osx-plist 24 | 25 | and cloned from: 26 | 27 | git://github.com/kballard/osx-plist.git 28 | 29 | == USAGE: 30 | 31 | One new module is provided, named OSX::PropertyList. It has the following 4 methods: 32 | 33 | ==== OSX::PropertyList.load(input, format = false) 34 | 35 | Loads the property list from input, which is either an IO, StringIO, or a string. Format is an optional parameter - if false, the return value is the converted property list object. If true, the return value is a 2-element array, the first element being the returned value and the second being a symbol identifying the property list format. 36 | 37 | ==== OSX::PropertyList.dump(output, obj, format = :xml1) 38 | 39 | Dumps the property list object into output, which is either an IO or StringIO. Format determines the property list format to write out. The supported values are :xml1,, :binary1, and :openstep; however, OpenStep format appears to not be supported by the system for output anymore. 40 | 41 | The valid formats are :xml1, :binary1, and :openstep. When loading a property list, if the format is something else (not possible under any current OS, but perhaps if a future OS includes another type) then the format will be :unknown. 42 | 43 | ==== OSX::PropertyList.load_file(filepath, format = false) 44 | 45 | Calls OSX::PropertyList.load() on the file at the given path. 46 | 47 | ==== OSX::PropertyList.dump(filepath, obj, format = :xml1) 48 | 49 | Calls OSX::PropertyList.dump() on the file at the given path. 50 | 51 | This module also provides a method on Object: 52 | 53 | ==== Object#to_plist(format = :xml1) 54 | 55 | This is the same as PropertyList.dump except it outputs the property list as a string return value instead of writing it to a stream 56 | 57 | This module also provides 2 methods on String: 58 | 59 | ==== String#blob? 60 | 61 | Returns whether the string is a blob. 62 | 63 | ==== String#blob= 64 | 65 | Sets whether the string is a blob. 66 | 67 | A blob is a string that's been converted from a property list item. When dumping to a property list, any strings that are blobs are written as items rather than items. 68 | 69 | == LICENSE: 70 | 71 | (The MIT License) 72 | 73 | Copyright (c) 2008 Kevin Ballard 74 | 75 | Permission is hereby granted, free of charge, to any person obtaining 76 | a copy of this software and associated documentation files (the 77 | 'Software'), to deal in the Software without restriction, including 78 | without limitation the rights to use, copy, modify, merge, publish, 79 | distribute, sublicense, and/or sell copies of the Software, and to 80 | permit persons to whom the Software is furnished to do so, subject to 81 | the following conditions: 82 | 83 | The above copyright notice and this permission notice shall be 84 | included in all copies or substantial portions of the Software. 85 | 86 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 87 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 88 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 89 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 90 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 91 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 92 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 93 | -------------------------------------------------------------------------------- /libimobiledevice/src/afc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * afc.h 3 | * Defines and structs and the like for the built-in AFC client 4 | * 5 | * Copyright (c) 2008 Zach C. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "libimobiledevice/afc.h" 26 | 27 | #define AFC_MAGIC "CFA6LPAA" 28 | #define AFC_MAGIC_LEN (8) 29 | 30 | typedef struct { 31 | char magic[AFC_MAGIC_LEN]; 32 | uint64_t entire_length, this_length, packet_num, operation; 33 | } AFCPacket; 34 | 35 | #define AFCPacket_to_LE(x) \ 36 | (x)->entire_length = GUINT64_TO_LE((x)->entire_length); \ 37 | (x)->this_length = GUINT64_TO_LE((x)->this_length); \ 38 | (x)->packet_num = GUINT64_TO_LE((x)->packet_num); \ 39 | (x)->operation = GUINT64_TO_LE((x)->operation); 40 | 41 | #define AFCPacket_from_LE(x) \ 42 | (x)->entire_length = GUINT64_FROM_LE((x)->entire_length); \ 43 | (x)->this_length = GUINT64_FROM_LE((x)->this_length); \ 44 | (x)->packet_num = GUINT64_FROM_LE((x)->packet_num); \ 45 | (x)->operation = GUINT64_FROM_LE((x)->operation); 46 | 47 | typedef struct { 48 | uint64_t filehandle, size; 49 | } AFCFilePacket; 50 | 51 | struct afc_client_private { 52 | idevice_connection_t connection; 53 | AFCPacket *afc_packet; 54 | int file_handle; 55 | int lock; 56 | GMutex *mutex; 57 | int own_connection; 58 | }; 59 | 60 | /* AFC Operations */ 61 | enum { 62 | AFC_OP_STATUS = 0x00000001, /* Status */ 63 | AFC_OP_DATA = 0x00000002, /* Data */ 64 | AFC_OP_READ_DIR = 0x00000003, /* ReadDir */ 65 | AFC_OP_READ_FILE = 0x00000004, /* ReadFile */ 66 | AFC_OP_WRITE_FILE = 0x00000005, /* WriteFile */ 67 | AFC_OP_WRITE_PART = 0x00000006, /* WritePart */ 68 | AFC_OP_TRUNCATE = 0x00000007, /* TruncateFile */ 69 | AFC_OP_REMOVE_PATH = 0x00000008, /* RemovePath */ 70 | AFC_OP_MAKE_DIR = 0x00000009, /* MakeDir */ 71 | AFC_OP_GET_FILE_INFO = 0x0000000a, /* GetFileInfo */ 72 | AFC_OP_GET_DEVINFO = 0x0000000b, /* GetDeviceInfo */ 73 | AFC_OP_WRITE_FILE_ATOM = 0x0000000c, /* WriteFileAtomic (tmp file+rename) */ 74 | AFC_OP_FILE_OPEN = 0x0000000d, /* FileRefOpen */ 75 | AFC_OP_FILE_OPEN_RES = 0x0000000e, /* FileRefOpenResult */ 76 | AFC_OP_READ = 0x0000000f, /* FileRefRead */ 77 | AFC_OP_WRITE = 0x00000010, /* FileRefWrite */ 78 | AFC_OP_FILE_SEEK = 0x00000011, /* FileRefSeek */ 79 | AFC_OP_FILE_TELL = 0x00000012, /* FileRefTell */ 80 | AFC_OP_FILE_TELL_RES = 0x00000013, /* FileRefTellResult */ 81 | AFC_OP_FILE_CLOSE = 0x00000014, /* FileRefClose */ 82 | AFC_OP_FILE_SET_SIZE = 0x00000015, /* FileRefSetFileSize (ftruncate) */ 83 | AFC_OP_GET_CON_INFO = 0x00000016, /* GetConnectionInfo */ 84 | AFC_OP_SET_CON_OPTIONS = 0x00000017, /* SetConnectionOptions */ 85 | AFC_OP_RENAME_PATH = 0x00000018, /* RenamePath */ 86 | AFC_OP_SET_FS_BS = 0x00000019, /* SetFSBlockSize (0x800000) */ 87 | AFC_OP_SET_SOCKET_BS = 0x0000001A, /* SetSocketBlockSize (0x800000) */ 88 | AFC_OP_FILE_LOCK = 0x0000001B, /* FileRefLock */ 89 | AFC_OP_MAKE_LINK = 0x0000001C, /* MakeLink */ 90 | AFC_OP_SET_FILE_TIME = 0x0000001E /* set st_mtime */ 91 | }; 92 | 93 | -------------------------------------------------------------------------------- /libplist/src/Node.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Node.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace PList 34 | { 35 | 36 | Node::Node(Node* parent) : _parent(parent) 37 | { 38 | } 39 | 40 | Node::Node(plist_t node, Node* parent) : _node(node), _parent(parent) 41 | { 42 | } 43 | 44 | Node::Node(plist_type type, Node* parent) : _parent(parent) 45 | { 46 | _node = NULL; 47 | 48 | switch (type) 49 | { 50 | case PLIST_BOOLEAN: 51 | _node = plist_new_bool(0); 52 | break; 53 | case PLIST_UINT: 54 | _node = plist_new_uint(0); 55 | break; 56 | case PLIST_REAL: 57 | _node = plist_new_real(0.); 58 | break; 59 | case PLIST_STRING: 60 | _node = plist_new_string(""); 61 | break; 62 | case PLIST_DATA: 63 | _node = plist_new_data(NULL,0); 64 | break; 65 | case PLIST_DATE: 66 | _node = plist_new_date(0,0); 67 | break; 68 | case PLIST_ARRAY: 69 | _node = plist_new_array(); 70 | break; 71 | case PLIST_DICT: 72 | _node = plist_new_dict(); 73 | break; 74 | case PLIST_KEY: 75 | case PLIST_NONE: 76 | default: 77 | break; 78 | } 79 | } 80 | 81 | Node::~Node() 82 | { 83 | plist_free(_node); 84 | _node = NULL; 85 | _parent = NULL; 86 | } 87 | 88 | plist_type Node::GetType() 89 | { 90 | if (_node) 91 | { 92 | return plist_get_node_type(_node); 93 | } 94 | return PLIST_NONE; 95 | } 96 | 97 | plist_t Node::GetPlist() 98 | { 99 | return _node; 100 | } 101 | 102 | Node* Node::GetParent() 103 | { 104 | return _parent; 105 | } 106 | 107 | Node* Node::FromPlist(plist_t node, Node* parent) 108 | { 109 | Node* ret = NULL; 110 | if (node) 111 | { 112 | plist_type type = plist_get_node_type(node); 113 | switch (type) 114 | { 115 | case PLIST_DICT: 116 | ret = new Dictionary(node, parent); 117 | break; 118 | case PLIST_ARRAY: 119 | ret = new Array(node, parent); 120 | break; 121 | case PLIST_BOOLEAN: 122 | ret = new Boolean(node, parent); 123 | break; 124 | case PLIST_UINT: 125 | ret = new Integer(node, parent); 126 | break; 127 | case PLIST_REAL: 128 | ret = new Real(node, parent); 129 | break; 130 | case PLIST_STRING: 131 | ret = new String(node, parent); 132 | break; 133 | case PLIST_DATE: 134 | ret = new Date(node, parent); 135 | break; 136 | case PLIST_DATA: 137 | ret = new Data(node, parent); 138 | break; 139 | default: 140 | plist_free(node); 141 | break; 142 | } 143 | } 144 | return ret; 145 | } 146 | 147 | }; 148 | -------------------------------------------------------------------------------- /irecoverymode.rb: -------------------------------------------------------------------------------- 1 | require 'socket' 2 | require 'plist' 3 | 4 | class IDevice 5 | def write_plist(data) 6 | if data.kind_of?(Hash) || data.kind_of?(Array) 7 | data = data.to_plist 8 | end 9 | p "==write_plist==#{data}" 10 | @socket.write([data.length].pack("N") + data) 11 | end 12 | 13 | def read_plist 14 | buffer = @socket.read(4) 15 | if buffer 16 | size = buffer.unpack("N")[0] 17 | buffer = @socket.read(size) 18 | p "==read_plist==#{buffer}" 19 | Plist::parse_xml(buffer) 20 | end 21 | end 22 | 23 | def send_packet(socket, packet_type, data) 24 | packet = [data.length + 16, @version, packet_type, @tag].pack("V4") + data 25 | p "==send_packet==#{packet}" 26 | socket.write(packet) 27 | end 28 | 29 | def recv_packet(socket) 30 | header = socket.read(16) 31 | packet_length, unk, packet_type, tag = header.unpack("V4") 32 | data = socket.read(packet_length - 16) 33 | p "==recv_packet==#{data}" 34 | [packet_type, tag, data] 35 | end 36 | 37 | def initialize(port) 38 | @tag = 0 39 | @version = 1 40 | 41 | @socket = UNIXSocket.new("/var/run/usbmuxd") 42 | 43 | obj = {"MessageType" => "Listen"} 44 | data = obj.to_plist 45 | send_packet(@socket, 8, data) 46 | # send_packet(@socket, 3, "") 47 | recv_packet(@socket) 48 | # 49 | # DeviceID1 50 | # 51 | # ProductID4756 52 | # SerialNumber74f5014572b194c356c8157d6221bd9c84da104c 53 | # 54 | # 55 | p "Please unplug your device, then plug it back in" 56 | 57 | data = recv_packet(@socket)[2] 58 | result = Plist::parse_xml(data) 59 | @device_id = result['DeviceID'].to_i 60 | @product_id = result['Properties']['ProductID'] 61 | @serial_no = result['Properties']['SerialNumber'] 62 | 63 | p @device_id, @product_id, @serial_no 64 | 65 | @socket.close 66 | 67 | puts "Device ID: 0x#{@device_id.to_s(16)}" 68 | 69 | @use_ssl = false 70 | 71 | done = false 72 | @tag = 0 73 | @version = 1 74 | until done do 75 | @socket = UNIXSocket.new("/var/run/usbmuxd") 76 | puts "Retrying connection to port #{port}..." 77 | 78 | # DeviceID5 79 | # MessageTypeConnect 80 | # PortNumber32498 81 | # obj = {"BundleID"=>PLIST_BUNDLE_ID , "ClientVersionString"=>PLIST_CLIENT_VERSION_STRING, "ProgName"=> PLIST_PROGNAME, 82 | # "MessageType" => "Connect", "DeviceID" => @device_id, "PortNumber" => port } 83 | obj = {"MessageType" => "Connect", "DeviceID" => @device_id, "PortNumber" => port } 84 | data = obj.to_plist 85 | send_packet(@socket, 8, data) 86 | # send_packet(@socket, 2, [@device_id, port, 0].pack("Vnn")) 87 | data = recv_packet(@socket)[2] 88 | # MessageTypeResultNumber0/dict> 89 | result = Plist::parse_xml(data) 90 | 91 | done = result['Number'] == 0 92 | @socket.close unless done 93 | @tag += 1 94 | sleep(1) 95 | end 96 | puts "Connected to port #{port}" 97 | end 98 | 99 | def enter_recovery 100 | # obj = {"ProtocolVersion"=>"2", "Request" => "QueryType" } 101 | obj = {"Request" => "EnterRecovery" } 102 | write_plist(obj) 103 | p read_plist 104 | 105 | @socket.close 106 | end 107 | 108 | end 109 | 110 | if __FILE__ == $0 111 | PORT_RESTORE = 0x7ef2 112 | # PORT_RESTORE = 0xf27e 113 | d = IDevice.new(PORT_RESTORE) 114 | 115 | d.enter_recovery 116 | 117 | end 118 | 119 | # 120 | # irecovery -c "setenv auto-boot true" 121 | # irecovery -c "saveenv" 122 | # irecovery -c "reboot" 123 | # 124 | # idevice_id -l | awk -F= '{print "ideviceenterrecovery " $1}' |bash 125 | # # idevice_id -l 126 | # # ideviceenterrecovery -d 39150e1823d53b7c2a8e4ff543881e762392120a 127 | -------------------------------------------------------------------------------- /ideviceactivate/src/cache.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cache.c 3 | * Load data from/add data to the activation info cache. 4 | * 5 | * Copyright (c) 2010 boxingsquirrel. All Rights Reserved. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "cache.h" 27 | #include "util.h" 28 | 29 | int write_file(const char *filename, char data[BUFSIZE]) 30 | { 31 | FILE *f=fopen(filename, "w"); 32 | 33 | if (f==NULL) 34 | { 35 | printf("ERROR: Could not open %s for writing\n", filename); 36 | fclose(f); 37 | return -1; 38 | } 39 | 40 | else { 41 | fwrite(data, strlen(data), 1, f); 42 | fclose(f); 43 | 44 | return 0; 45 | } 46 | } 47 | 48 | int read_file(const char *filename, char data[BUFSIZE]) 49 | { 50 | FILE *f=fopen(filename, "r"); 51 | 52 | if (f==NULL) 53 | { 54 | printf("ERROR: Could not open %s for reading\n", filename); 55 | fclose(f); 56 | return -1; 57 | } 58 | 59 | else { 60 | uint32_t read=fread(data, 1, BUFSIZE, f); 61 | 62 | while (read>0) 63 | { 64 | read=fread(data, 1, BUFSIZE, f); 65 | printf("."); 66 | } 67 | 68 | printf("\nINFO: Read sucessfully from %s\n", filename); 69 | 70 | return 0; 71 | } 72 | } 73 | 74 | int cache(const char *fname, const char *what) 75 | { 76 | if (backup_to_cache==1) 77 | { 78 | char data[BUFSIZE]; 79 | snprintf(data, BUFSIZE, "%s", what); 80 | 81 | char f_name[512]; 82 | snprintf(f_name, BUFSIZE, "%s/%s", cachedir, fname); 83 | 84 | if (write_file((const char *)f_name, data)!=0) 85 | { 86 | return -1; 87 | } 88 | 89 | return 0; 90 | } 91 | 92 | else { 93 | return -1; 94 | } 95 | } 96 | 97 | int cache_plist(const char *fname, plist_t plist) 98 | { 99 | if (backup_to_cache==1) 100 | { 101 | uint32_t len=0; 102 | char *xml=NULL; 103 | 104 | plist_to_xml(plist, &xml, &len); 105 | 106 | return cache(fname, (const char *)xml); 107 | } 108 | 109 | else { 110 | return -1; 111 | } 112 | } 113 | 114 | char* get_from_cache(const char *what) 115 | { 116 | char fname[512]; 117 | snprintf(fname, 512, "%s/%s", cachedir, what); 118 | 119 | char d[BUFSIZE]; 120 | read_file((const char *)fname, d); 121 | 122 | return (char *)d; 123 | } 124 | 125 | /* Just prints a little notice about what caching actually does... */ 126 | void cache_warning() 127 | { 128 | printf("The process of creating a cache is simple: perform a legit activation, storing all the required data. That way, you can borrow (or, I guess, steal (don't do that, though)) a sim for the carrier your iPhone is locked to, and be able to reactivate without having to get that sim back.\n\nThis data is stored in a folder where you want it (hence the folder passed with -c/-r). It does not get sent to me (boxingsquirrel), p0sixninja, or anyone else. Plus, we really have better things to do than look at your activation data.\n\nThis really isn't needed for iPod Touches or Wi-Fi only iPads (and I don't know if 3G iPad users need this, but be safe and do it).\n\nPress any key to continue or CONTROL-C to abort...\n\n"); 129 | 130 | getchar(); 131 | } 132 | 133 | /* Validates the cache to make sure it really is the cache for the connected device... */ 134 | int check_cache(lockdownd_client_t c) 135 | { 136 | char* uuid_from_cache=get_from_cache("UUID"); 137 | char *uuid_from_device=NULL; 138 | 139 | lockdownd_get_string_value(c, "UniqueDeviceID", uuid_from_device); 140 | 141 | return strcmp(uuid_from_cache, uuid_from_device); 142 | } 143 | -------------------------------------------------------------------------------- /iactivate.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | $: << File.join(File.dirname(__FILE__), '.') 5 | $: << File.join(File.dirname(__FILE__), './osx-plist/lib') 6 | 7 | require 'optparse' 8 | require 'net/http' 9 | require 'rexml/document' 10 | require 'pp' 11 | require 'iservice' 12 | require 'osx/plist' 13 | 14 | options = {} 15 | 16 | optparse = OptionParser.new do |opts| 17 | opts.banner = "Usage: #{__FILE__} [options]" 18 | 19 | opts.on("-a", "--activate", "activate the target device") do |a| 20 | options[:activate] = a 21 | end 22 | opts.on("-h", "--help", "show usage") do |h| 23 | puts opts 24 | exit 25 | end 26 | end.parse! 27 | 28 | p options 29 | 30 | class DeviceActivateRelay < DeviceRelay 31 | def activate 32 | dev = get_value("DeviceClass") 33 | if (dev == "iPhone") 34 | uid = get_value("UniqueDeviceID") 35 | imei = get_value("InternationalMobileEquipmentIdentity") 36 | iccid = get_value("IntegratedCircuitCardIdentity") 37 | sn = get_value("SerialNumber") 38 | imsi = get_value("InternationalMobileSubscriberIdentity") 39 | activation_info = get_value("ActivationInfo") 40 | end 41 | 42 | p "uid:#{uid} imei:#{imei} iccid:#{iccid} sn:#{sn} imsi:#{imsi}" 43 | 44 | p "activation_info:#{activation_info}" 45 | 46 | p "fetching activation_record..." 47 | # url = URI("https://albert.apple.com/WebObjects/ALActivation.woa/wa/iPhoneRegistration") 48 | url = URI("https://albert.apple.com/WebObjects/ALUnbrick.woa/wa/deviceActivation") 49 | http = Net::HTTP.new(url.host, url.port) 50 | http.use_ssl = true 51 | http.start do |h| 52 | req = Net::HTTP::Post.new(url.path, "User-Agent" => "iTunes/9.1 (Macintosh; U; Intel Mac OS X 10.5.6)") 53 | req.form_data = { 54 | "AppleSerialNumber" => sn, 55 | "IMSI" => imsi, 56 | "InStoreActivation" => "false", 57 | "machineName" => "macos", 58 | "activation-info" => activation_info.to_plist, 59 | "ICCID" => iccid, 60 | "IMEI" => imei 61 | } 62 | #puts req.body 63 | result = h.request(req) 64 | puts result.body 65 | # 66 | # 67 | # 68 | # 69 | # 70 | # iphone-activation 71 | # 72 | # unbrick 73 | # 74 | # activation-record 75 | # 76 | # DeviceCertificate 77 | xmldoc = REXML::Document.new(result.body) 78 | buffer = REXML::XPath.first(xmldoc, "//plist").to_s 79 | # obj = Plist::parse_xml(StringIO.new(buffer)) 80 | obj = OSX::PropertyList.load(StringIO.new(buffer), :xml1)[0] 81 | # "iphone-activation"=>{"show-settings"=>true, "ack-received"=>true} 82 | tmp = obj["iphone-activation"] 83 | if tmp.include?("activation-record") 84 | activation_record = tmp["activation-record"] 85 | pp activation_record 86 | p "activating..." 87 | # ssl_enabled 88 | obj = {"Request" => "Activate", "ActivationRecord" => activation_record} 89 | write_plist(@ssl, obj) 90 | read_plist(@ssl) 91 | end 92 | end 93 | end 94 | 95 | def deactivate 96 | # ssl_enabled 97 | obj = {"Request" => "Deactivate"} 98 | write_plist(@ssl, obj) 99 | read_plist(@ssl) 100 | end 101 | end 102 | 103 | 104 | if __FILE__ == $0 105 | l = DeviceActivateRelay.new 106 | 107 | l.query_type 108 | 109 | # pub_key = l.get_value("DevicePublicKey").read 110 | pub_key = l.get_value("DevicePublicKey") 111 | p "pub_key:", pub_key 112 | # 113 | l.pair_device(pub_key) 114 | 115 | # l.validate_pair(pub_key) 116 | 117 | @session_id = l.start_session 118 | p "session_id:", @session_id 119 | 120 | # ssl_enable 121 | l.ssl_enable(true) 122 | if options[:activate] 123 | l.activate 124 | else 125 | l.deactivate 126 | end 127 | l.ssl_enable(false) 128 | # 129 | l.stop_session(@session_id) 130 | end 131 | 132 | 133 | -------------------------------------------------------------------------------- /libplist/src/Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Array.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | namespace PList 27 | { 28 | 29 | Array::Array(Node* parent) : Structure(PLIST_ARRAY, parent) 30 | { 31 | _array.clear(); 32 | } 33 | 34 | Array::Array(plist_t node, Node* parent) : Structure(parent) 35 | { 36 | _node = node; 37 | uint32_t size = plist_array_get_size(_node); 38 | 39 | for (uint32_t i = 0; i < size; i++) 40 | { 41 | plist_t subnode = plist_array_get_item(_node, i); 42 | _array.push_back( Node::FromPlist(subnode, this) ); 43 | } 44 | } 45 | 46 | Array::Array(PList::Array& a) : Structure() 47 | { 48 | _array.clear(); 49 | _node = plist_copy(a.GetPlist()); 50 | uint32_t size = plist_array_get_size(_node); 51 | 52 | for (uint32_t i = 0; i < size; i++) 53 | { 54 | plist_t subnode = plist_array_get_item(_node, i); 55 | _array.push_back( Node::FromPlist(subnode, this) ); 56 | } 57 | } 58 | 59 | Array& Array::operator=(PList::Array& a) 60 | { 61 | plist_free(_node); 62 | for (unsigned int it = 0; it < _array.size(); it++) 63 | { 64 | delete _array.at(it); 65 | } 66 | _array.clear(); 67 | 68 | _node = plist_copy(a.GetPlist()); 69 | uint32_t size = plist_array_get_size(_node); 70 | 71 | for (uint32_t i = 0; i < size; i++) 72 | { 73 | plist_t subnode = plist_array_get_item(_node, i); 74 | _array.push_back( Node::FromPlist(subnode, this) ); 75 | } 76 | return *this; 77 | } 78 | 79 | Array::~Array() 80 | { 81 | for (unsigned int it = 0; it < _array.size(); it++) 82 | { 83 | delete (_array.at(it)); 84 | } 85 | _array.clear(); 86 | } 87 | 88 | Node* Array::Clone() 89 | { 90 | return new Array(*this); 91 | } 92 | 93 | Node* Array::operator[](unsigned int index) 94 | { 95 | return _array.at(index); 96 | } 97 | 98 | void Array::Append(Node* node) 99 | { 100 | if (node) 101 | { 102 | Node* clone = node->Clone(); 103 | UpdateNodeParent(clone); 104 | plist_array_append_item(_node, clone->GetPlist()); 105 | _array.push_back(clone); 106 | } 107 | } 108 | 109 | void Array::Insert(Node* node, unsigned int pos) 110 | { 111 | if (node) 112 | { 113 | Node* clone = node->Clone(); 114 | UpdateNodeParent(clone); 115 | plist_array_insert_item(_node, clone->GetPlist(), pos); 116 | std::vector::iterator it = _array.begin(); 117 | it += pos; 118 | _array.insert(it, clone); 119 | } 120 | } 121 | 122 | void Array::Remove(Node* node) 123 | { 124 | if (node) 125 | { 126 | uint32_t pos = plist_array_get_item_index(node->GetPlist()); 127 | plist_array_remove_item(_node, pos); 128 | std::vector::iterator it = _array.begin(); 129 | it += pos; 130 | _array.erase(it); 131 | delete node; 132 | } 133 | } 134 | 135 | void Array::Remove(unsigned int pos) 136 | { 137 | plist_array_remove_item(_node, pos); 138 | std::vector::iterator it = _array.begin(); 139 | it += pos; 140 | delete _array.at(pos); 141 | _array.erase(it); 142 | } 143 | 144 | unsigned int Array::GetNodeIndex(Node* node) 145 | { 146 | std::vector::iterator it = std::find(_array.begin(), _array.end(), node); 147 | return std::distance (_array.begin(), it); 148 | } 149 | 150 | }; 151 | -------------------------------------------------------------------------------- /ribusb/test/test_ribusb_compat.rb: -------------------------------------------------------------------------------- 1 | require "test/unit" 2 | require "ribusb/compat" 3 | 4 | class TestRibusbCompat < Test::Unit::TestCase 5 | include USB 6 | 7 | attr_accessor :usb 8 | 9 | def test_find 10 | devlist = USB.devices 11 | assert_kind_of Array, devlist, "Bus#find should return an Array" 12 | assert_kind_of Device, devlist.first, "Bus#find should return Devices" 13 | devlist.each do |dev| 14 | assert_match( /Device/, dev.inspect, "Device#inspect should work") 15 | end 16 | end 17 | 18 | def test_constants 19 | assert_equal 7, USB_CLASS_PRINTER, "Printer class id should be defined" 20 | assert_equal 32, USB_TYPE_CLASS, "type class should be defined" 21 | end 22 | 23 | def test_descriptors 24 | USB.devices.each do |dev| 25 | assert_match(/Device/, dev.inspect, "Device#inspect should work") 26 | dev.configurations.each do |config_desc| 27 | assert_match(/ConfigDescriptor/, config_desc.inspect, "ConfigDescriptor#inspect should work") 28 | assert dev.configurations.include?(config_desc), "Device#configurations should include this one" 29 | 30 | config_desc.interfaces.each do |interface| 31 | assert_match(/Interface/, interface.inspect, "Interface#inspect should work") 32 | 33 | assert dev.interfaces.include?(interface), "Device#interfaces should include this one" 34 | assert config_desc.interfaces.include?(interface), "ConfigDescriptor#interfaces should include this one" 35 | 36 | interface.settings.each do |if_desc| 37 | assert_match(/InterfaceDescriptor/, if_desc.inspect, "InterfaceDescriptor#inspect should work") 38 | 39 | assert dev.settings.include?(if_desc), "Device#settings should include this one" 40 | assert config_desc.settings.include?(if_desc), "ConfigDescriptor#settings should include this one" 41 | assert interface.settings.include?(if_desc), "Inteerface#settings should include this one" 42 | 43 | if_desc.endpoints.each do |ep| 44 | assert_match(/EndpointDescriptor/, ep.inspect, "EndpointDescriptor#inspect should work") 45 | 46 | assert dev.endpoints.include?(ep), "Device#endpoints should include this one" 47 | assert config_desc.endpoints.include?(ep), "ConfigDescriptor#endpoints should include this one" 48 | assert interface.endpoints.include?(ep), "Inteerface#endpoints should include this one" 49 | assert if_desc.endpoints.include?(ep), "InterfaceDescriptor#endpoints should include this one" 50 | 51 | assert_equal if_desc, ep.setting, "backref should be correct" 52 | assert_equal interface, ep.interface, "backref should be correct" 53 | assert_equal config_desc, ep.configuration, "backref should be correct" 54 | assert_equal dev, ep.device, "backref should be correct" 55 | 56 | assert_operator 0, :<, ep.wMaxPacketSize, "packet size should be > 0" 57 | end 58 | end 59 | end 60 | end 61 | end 62 | end 63 | 64 | def test_open_mass_storage 65 | devs = [] 66 | USB.each_device_by_class(USB_CLASS_MASS_STORAGE, 0x01, 0x50){|dev| devs << dev } 67 | USB.each_device_by_class(USB_CLASS_MASS_STORAGE, 0x06, 0x50){|dev| devs << dev } 68 | 69 | dev = devs.last 70 | abort "no mass storage device found" unless dev 71 | devh = dev.open 72 | if RUBY_PLATFORM=~/linux/i 73 | data = " "*1000 74 | begin 75 | devh.usb_get_driver_np 0, data 76 | rescue Errno::ENODATA 77 | data = "nodata exception".ljust(1000, "\0") 78 | end 79 | assert_match(/\w+/, data, "There should be a driver or an exception") 80 | begin 81 | # second param is needed because of a bug in ruby-usb 82 | devh.usb_detach_kernel_driver_np 0, 123 83 | rescue RuntimeError => e 84 | assert_match(/entity not found/, e.to_s, "Raise proper exception, if no kernel driver is active") 85 | end 86 | end 87 | 88 | endpoint_in = dev.endpoints.find{|ep| ep.bEndpointAddress&USB_ENDPOINT_IN != 0 }.bEndpointAddress 89 | endpoint_out = dev.endpoints.find{|ep| ep.bEndpointAddress&USB_ENDPOINT_IN == 0 }.bEndpointAddress 90 | 91 | devh.set_configuration 1 92 | devh.claim_interface 0 93 | devh.clear_halt(endpoint_in) 94 | devh.clear_halt(endpoint_out) 95 | devh.release_interface 0 96 | devh.usb_close 97 | end 98 | end 99 | -------------------------------------------------------------------------------- /idevicerestore/src/dfu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dfu.c 3 | * Functions for handling idevices in DFU mode 4 | * 5 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "dfu.h" 27 | #include "recovery.h" 28 | #include "idevicerestore.h" 29 | 30 | int dfu_progress_callback(irecv_client_t client, const irecv_event_t* event) { 31 | if (event->type == IRECV_PROGRESS) { 32 | print_progress_bar(event->progress); 33 | } 34 | return 0; 35 | } 36 | 37 | int dfu_client_new(struct idevicerestore_client_t* client, uint32_t timeout) { 38 | struct dfu_client_t* dfu = NULL; 39 | if(client == NULL) { 40 | return -1; 41 | } 42 | 43 | if(client->dfu) { 44 | dfu_client_free(client); 45 | } 46 | 47 | dfu = (struct dfu_client_t*) malloc(sizeof(struct dfu_client_t)); 48 | if (dfu == NULL) { 49 | error("ERROR: Out of memory\n"); 50 | return -1; 51 | } 52 | 53 | if (dfu_open_with_timeout(dfu, timeout) < 0) { 54 | dfu_client_free(client); 55 | return -1; 56 | } 57 | 58 | if(dfu->client->mode != kDfuMode) { 59 | dfu_client_free(client); 60 | return -1; 61 | } 62 | 63 | client->dfu = dfu; 64 | return 0; 65 | } 66 | 67 | void dfu_client_free(struct idevicerestore_client_t* client) { 68 | struct dfu_client_t* dfu = NULL; 69 | if(client != NULL) { 70 | dfu = client->dfu; 71 | if (dfu != NULL) { 72 | if(dfu->client != NULL) { 73 | irecv_close(dfu->client); 74 | dfu->client = NULL; 75 | } 76 | free(dfu); 77 | } 78 | client->dfu = NULL; 79 | } 80 | } 81 | 82 | int dfu_open_with_timeout(struct idevicerestore_client_t* client, uint32_t timeout) { 83 | int i = 0; 84 | irecv_client_t recovery = NULL; 85 | irecv_error_t recovery_error = IRECV_E_UNKNOWN_ERROR; 86 | 87 | for (i = 1; i <= timeout; i++) { 88 | recovery_error = irecv_open(&recovery); 89 | if (recovery_error == IRECV_E_SUCCESS) { 90 | break; 91 | } 92 | 93 | if (i == timeout) { 94 | error("ERROR: Unable to connect to device in DFU mode\n"); 95 | return -1; 96 | } 97 | 98 | sleep(1); 99 | debug("Retrying connection...\n"); 100 | } 101 | 102 | irecv_event_subscribe(recovery, IRECV_PROGRESS, &dfu_progress_callback, NULL); 103 | client->dfu->client = recovery; 104 | return 0; 105 | } 106 | 107 | int dfu_check_mode() { 108 | return -1; 109 | } 110 | 111 | int dfu_enter_recovery(struct idevicerestore_client_t* client, plist_t build_identity) { 112 | irecv_client_t dfu = NULL; 113 | const char* component = "iBSS"; 114 | irecv_error_t dfu_error = IRECV_E_SUCCESS; 115 | 116 | if (recovery_open_with_timeout(client) < 0 || dfu->mode != kDfuMode) { 117 | error("ERROR: Unable to connect to DFU device\n"); 118 | if (dfu) 119 | irecv_close(dfu); 120 | return -1; 121 | } 122 | 123 | if (recovery_send_component(client, build_identity, component) < 0) { 124 | error("ERROR: Unable to send %s to device\n", component); 125 | irecv_close(dfu); 126 | return -1; 127 | } 128 | 129 | dfu_error = irecv_reset(client->dfu->client); 130 | if (dfu_error != IRECV_E_SUCCESS) { 131 | error("ERROR: Unable to reset device\n"); 132 | irecv_close(dfu); 133 | return -1; 134 | } 135 | irecv_close(client->dfu->client); 136 | client->dfu->client = NULL; 137 | 138 | // Reconnect to device, but this time make sure we're not still in DFU mode 139 | if (recovery_open_with_timeout(client) < 0 || client->mode->index != kDfuMode) { 140 | error("ERROR: Unable to connect to recovery device\n"); 141 | if (client->dfu->client) 142 | irecv_close(client->dfu->client); 143 | return -1; 144 | } 145 | 146 | client->mode = &idevicerestore_modes[MODE_RECOVERY]; 147 | irecv_close(client->dfu->client); 148 | client->dfu->client = NULL; 149 | return 0; 150 | } 151 | 152 | -------------------------------------------------------------------------------- /libimobiledevice/src/debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * debug.c 3 | * contains utilitary functions for debugging 4 | * 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. 6 | * Copyright (c) 2010 Martin S. All Rights Reserved. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifdef HAVE_CONFIG_H 24 | #include 25 | #endif 26 | #include 27 | #define _GNU_SOURCE 1 28 | #define __USE_GNU 1 29 | #include 30 | #include 31 | #include 32 | 33 | #include "debug.h" 34 | #include "libimobiledevice/libimobiledevice.h" 35 | 36 | int debug_level = 0; 37 | 38 | /** 39 | * Sets the level of debugging. Currently the only acceptable values are 0 and 40 | * 1. 41 | * 42 | * @param level Set to 0 for no debugging or 1 for debugging. 43 | */ 44 | void idevice_set_debug_level(int level) 45 | { 46 | debug_level = level; 47 | } 48 | 49 | #ifndef STRIP_DEBUG_CODE 50 | static void debug_print_line(const char *func, const char *file, int line, const char *buffer) 51 | { 52 | char *str_time = NULL; 53 | char *header = NULL; 54 | time_t the_time; 55 | 56 | time(&the_time); 57 | str_time = g_new0 (gchar, 255); 58 | strftime(str_time, 254, "%H:%M:%S", localtime (&the_time)); 59 | 60 | /* generate header text */ 61 | (void)asprintf(&header, "%s %s:%d %s()", str_time, file, line, func); 62 | free (str_time); 63 | 64 | /* trim ending newlines */ 65 | 66 | /* print header */ 67 | printf ("%s: ", header); 68 | 69 | /* print actual debug content */ 70 | printf ("%s\n", buffer); 71 | 72 | /* flush this output, as we need to debug */ 73 | fflush (stdout); 74 | 75 | free (header); 76 | } 77 | #endif 78 | 79 | inline void debug_info_real(const char *func, const char *file, int line, const char *format, ...) 80 | { 81 | #ifndef STRIP_DEBUG_CODE 82 | va_list args; 83 | char *buffer = NULL; 84 | 85 | if (!debug_level) 86 | return; 87 | 88 | /* run the real fprintf */ 89 | va_start(args, format); 90 | (void)vasprintf(&buffer, format, args); 91 | va_end(args); 92 | 93 | debug_print_line(func, file, line, buffer); 94 | 95 | free(buffer); 96 | #endif 97 | } 98 | 99 | inline void debug_buffer(const char *data, const int length) 100 | { 101 | #ifndef STRIP_DEBUG_CODE 102 | int i; 103 | int j; 104 | unsigned char c; 105 | 106 | if (debug_level) { 107 | for (i = 0; i < length; i += 16) { 108 | fprintf(stderr, "%04x: ", i); 109 | for (j = 0; j < 16; j++) { 110 | if (i + j >= length) { 111 | fprintf(stderr, " "); 112 | continue; 113 | } 114 | fprintf(stderr, "%02hhx ", *(data + i + j)); 115 | } 116 | fprintf(stderr, " | "); 117 | for (j = 0; j < 16; j++) { 118 | if (i + j >= length) 119 | break; 120 | c = *(data + i + j); 121 | if ((c < 32) || (c > 127)) { 122 | fprintf(stderr, "."); 123 | continue; 124 | } 125 | fprintf(stderr, "%c", c); 126 | } 127 | fprintf(stderr, "\n"); 128 | } 129 | fprintf(stderr, "\n"); 130 | } 131 | #endif 132 | } 133 | 134 | inline void debug_buffer_to_file(const char *file, const char *data, const int length) 135 | { 136 | #ifndef STRIP_DEBUG_CODE 137 | if (debug_level) { 138 | FILE *f = fopen(file, "w+"); 139 | fwrite(data, 1, length, f); 140 | fflush(f); 141 | fclose(f); 142 | } 143 | #endif 144 | } 145 | 146 | inline void debug_plist_real(const char *func, const char *file, int line, plist_t plist) 147 | { 148 | #ifndef STRIP_DEBUG_CODE 149 | if (!plist) 150 | return; 151 | 152 | char *buffer = NULL; 153 | uint32_t length = 0; 154 | plist_to_xml(plist, &buffer, &length); 155 | 156 | /* get rid of ending newline as one is already added in the debug line */ 157 | if (buffer[length-1] == '\n') 158 | buffer[length-1] = '\0'; 159 | 160 | debug_info_real(func, file, line, "printing %i bytes plist:\n%s", length, buffer); 161 | free(buffer); 162 | #endif 163 | } 164 | 165 | -------------------------------------------------------------------------------- /libusbmuxd/python-client/tcprelay.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # tcprelay.py - TCP connection relay for usbmuxd 5 | # 6 | # Copyright (C) 2009 Hector Martin "marcan" 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 or version 3. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | import usbmux 22 | import SocketServer 23 | import select 24 | from optparse import OptionParser 25 | import sys 26 | import threading 27 | 28 | class SocketRelay(object): 29 | def __init__(self, a, b, maxbuf=65535): 30 | self.a = a 31 | self.b = b 32 | self.atob = "" 33 | self.btoa = "" 34 | self.maxbuf = maxbuf 35 | def handle(self): 36 | while True: 37 | rlist = [] 38 | wlist = [] 39 | xlist = [self.a, self.b] 40 | if self.atob: 41 | wlist.append(self.b) 42 | if self.btoa: 43 | wlist.append(self.a) 44 | if len(self.atob) < self.maxbuf: 45 | rlist.append(self.a) 46 | if len(self.btoa) < self.maxbuf: 47 | rlist.append(self.b) 48 | rlo, wlo, xlo = select.select(rlist, wlist, xlist) 49 | if xlo: 50 | return 51 | if self.a in wlo: 52 | n = self.a.send(self.btoa) 53 | self.btoa = self.btoa[n:] 54 | if self.b in wlo: 55 | n = self.b.send(self.atob) 56 | self.atob = self.atob[n:] 57 | if self.a in rlo: 58 | s = self.a.recv(self.maxbuf - len(self.atob)) 59 | if not s: 60 | return 61 | self.atob += s 62 | if self.b in rlo: 63 | s = self.b.recv(self.maxbuf - len(self.btoa)) 64 | if not s: 65 | return 66 | self.btoa += s 67 | #print "Relay iter: %8d atob, %8d btoa, lists: %r %r %r"%(len(self.atob), len(self.btoa), rlo, wlo, xlo) 68 | 69 | class TCPRelay(SocketServer.BaseRequestHandler): 70 | def handle(self): 71 | print "Incoming connection to %d"%self.server.server_address[1] 72 | mux = usbmux.USBMux(options.sockpath) 73 | print "Waiting for devices..." 74 | if not mux.devices: 75 | mux.process(1.0) 76 | if not mux.devices: 77 | print "No device found" 78 | self.request.close() 79 | return 80 | dev = mux.devices[0] 81 | print "Connecting to device %s"%str(dev) 82 | dsock = mux.connect(dev, self.server.rport) 83 | lsock = self.request 84 | print "Connection established, relaying data" 85 | try: 86 | fwd = SocketRelay(dsock, lsock, self.server.bufsize * 1024) 87 | fwd.handle() 88 | finally: 89 | dsock.close() 90 | lsock.close() 91 | print "Connection closed" 92 | 93 | class TCPServer(SocketServer.TCPServer): 94 | allow_reuse_address = True 95 | 96 | class ThreadedTCPServer(SocketServer.ThreadingMixIn, TCPServer): 97 | pass 98 | 99 | HOST = "localhost" 100 | 101 | parser = OptionParser(usage="usage: %prog [OPTIONS] RemotePort[:LocalPort] [RemotePort[:LocalPort]]...") 102 | parser.add_option("-t", "--threaded", dest='threaded', action='store_true', default=False, help="use threading to handle multiple connections at once") 103 | parser.add_option("-b", "--bufsize", dest='bufsize', action='store', metavar='KILOBYTES', type='int', default=128, help="specify buffer size for socket forwarding") 104 | parser.add_option("-s", "--socket", dest='sockpath', action='store', metavar='PATH', type='str', default=None, help="specify the path of the usbmuxd socket") 105 | 106 | options, args = parser.parse_args() 107 | 108 | serverclass = TCPServer 109 | if options.threaded: 110 | serverclass = ThreadedTCPServer 111 | 112 | if len(args) == 0: 113 | parser.print_help() 114 | sys.exit(1) 115 | 116 | ports = [] 117 | 118 | for arg in args: 119 | try: 120 | if ':' in arg: 121 | rport, lport = arg.split(":") 122 | rport = int(rport) 123 | lport = int(lport) 124 | ports.append((rport, lport)) 125 | else: 126 | ports.append((int(arg), int(arg))) 127 | except: 128 | parser.print_help() 129 | sys.exit(1) 130 | 131 | servers=[] 132 | 133 | for rport, lport in ports: 134 | print "Forwarding local port %d to remote port %d"%(lport, rport) 135 | server = serverclass((HOST, lport), TCPRelay) 136 | server.rport = rport 137 | server.bufsize = options.bufsize 138 | servers.append(server) 139 | 140 | alive = True 141 | 142 | while alive: 143 | try: 144 | rl, wl, xl = select.select(servers, [], []) 145 | for server in rl: 146 | server.handle_request() 147 | except: 148 | alive = False 149 | -------------------------------------------------------------------------------- /tss_blob.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | $: << File.join(File.dirname(__FILE__), '.') 5 | $: << File.join(File.dirname(__FILE__), './osx-plist/lib') 6 | 7 | require 'rubygems' 8 | require 'pp' 9 | require 'base64' 10 | require 'osx/plist' 11 | require 'net/https' 12 | require 'uri' 13 | require 'img3file' 14 | require 'fileutils' 15 | require 'pathname' 16 | 17 | base_path = "/Users/dli/ipad/jailbreak" 18 | ipsw_fn = File.join(base_path, "iPhone2,1_4.3.3_8J2_Restore.ipsw") 19 | 20 | dmg_path = "/Users/dli/ipad/jailbreak/ipsw/dmg" 21 | manifest_fn = File.join(dmg_path, "BuildManifest.plist") 22 | 23 | ### unzip 24 | # system("mkdir -p #{dmg_path}") 25 | # system("unzip -d #{dmg_path} #{ipsw_fn}") 26 | 27 | ### gc-apple-dump_02 28 | # checkUnbrickHealth 29 | if false 30 | obj = { 31 | "ECID" => 86872710412, 32 | "ICCID" => "89860109158380264868", 33 | "IMEI" => "012037007915703", 34 | "IMSI" => "460018445986486", 35 | "SerialNumber" => "889437758M8" 36 | } 37 | payload = obj.to_plist(:xml1) 38 | 39 | uri_albert_serv = "https://albert.apple.com/WebObjects/ALUnbrick.woa/wa/ALActivationMonitor/checkUnbrickHealth" 40 | uri = URI.parse(uri_albert_serv) 41 | http = Net::HTTP.new(uri.host, uri.port) 42 | http.use_ssl = true 43 | http.verify_mode = OpenSSL::SSL::VERIFY_NONE 44 | request = Net::HTTP::Post.new(uri.request_uri) 45 | request["x-apple-store-front"] = "143465-2,12" 46 | request["x-apple-tz"] = "28800" 47 | request["User-Agent"] = "InetURL/1.0" 48 | request["Content-Length"] = payload.length 49 | request["Content-Type"] = "application/x-apple-plist" 50 | request.body = payload 51 | response = http.request(request) 52 | p response.body 53 | end 54 | 55 | ### tss request 56 | # gc-apple-dump_03 57 | # tssrqst_fn = "./amai/debug/tss-request.plist" 58 | # payload = File.open(tssrqst_fn).read 59 | buffer = File.open(manifest_fn).read 60 | obj = OSX::PropertyList.load(StringIO.new(buffer), :xml1)[0] 61 | # pp obj 62 | rqst_obj = { 63 | "@APTicket" => true, "@BBTicket" => true, "@HostIpAddress" => "172.16.191.1", 64 | "@HostPlatformInfo" => "mac", "@UUID" => "6D27AA8B-FE93-442D-B957-46BCC347D5FC", "@VersionInfo" => "libauthinstall-68.1", 65 | "ApECID" => 86872710412, "ApProductionMode" => true 66 | } 67 | 68 | tmp = obj["BuildIdentities"][0] 69 | manifest_info = {} 70 | 71 | tmp.each do |k, v| 72 | case k 73 | when "ApBoardID", "ApChipID", "ApSecurityDomain" 74 | rqst_obj[k] = v 75 | when "UniqueBuildID" 76 | v.blob = true 77 | rqst_obj[k] = v 78 | when "Manifest" 79 | hash = {} 80 | tmp["Manifest"].each do |mk, mv| 81 | #pp mk, mv 82 | unless mk =~ /Info/ 83 | hash[mk] ={} 84 | mv.each do |vk, vv| 85 | #pp vk, vv 86 | case vk 87 | when "Info" 88 | manifest_info = manifest_info.merge({mk => vv["Path"]}) 89 | when "PartialDigest", "Digest" 90 | vv.blob = true 91 | hash[mk] = hash[mk].merge({vk => vv}) 92 | else 93 | hash[mk] = hash[mk].merge({vk => vv}) 94 | end 95 | end 96 | end 97 | end 98 | rqst_obj = rqst_obj.merge(hash) 99 | end 100 | end 101 | 102 | # pp manifest_info 103 | 104 | # pp rqst_obj 105 | payload = rqst_obj.to_plist(:xml1) 106 | 107 | # http post 108 | uri_gs_serv = "http://gs.apple.com/TSS/controller?action=2" 109 | #uri_gs_serv = "http://cydia.saurik.com/TSS/controller?action=2" 110 | #uri_gs_serv = "http://127.0.0.1:8080/TSS/controller?action=2" 111 | uri = URI.parse(uri_gs_serv) 112 | http = Net::HTTP.new(uri.host, uri.port) 113 | request = Net::HTTP::Post.new(uri.request_uri) 114 | request["User-Agent"] = "InetURL/1.0" 115 | request["Content-Length"] = payload.length 116 | request["Content-Type"] = 'text/xml; charset="utf-8"' 117 | request.body = payload 118 | response = http.request(request) 119 | # STATUS=0&MESSAGE=SUCCESS&REQUEST_STRING= 120 | buffer = response.body.split("&REQUEST_STRING=")[1] 121 | # tssresp_fn = "./amai/debug/tss-response.plist" 122 | # buffer = File.open(tssresp_fn).read 123 | obj = OSX::PropertyList.load(StringIO.new(buffer), :xml1)[0] 124 | # pp obj 125 | 126 | ### patch img3 127 | dmg_new_path = "/Users/dli/ipad/jailbreak/ipsw/dmg_new" 128 | 129 | manifest_info.each do |k, v| 130 | if obj.include?(k) 131 | #pp k, v 132 | filename = File.join(dmg_path, v) 133 | img3 = Img3File.new 134 | data = File.open(filename,'r').read 135 | img3.parse(StringIO.new(data)) 136 | 137 | ### change the img3 file 138 | blob = obj[k]["Blob"] 139 | img3.update_elements(StringIO.new(blob), blob.length) 140 | 141 | tmp_filename = File.join(dmg_new_path, v) 142 | FileUtils.mkdir_p(Pathname.new(tmp_filename).dirname) 143 | f = File.open(tmp_filename, "wb") 144 | f.write(img3.to_s) 145 | f.close 146 | end 147 | end 148 | 149 | -------------------------------------------------------------------------------- /libimobiledevice/tools/idevicescreenshot.c: -------------------------------------------------------------------------------- 1 | /** 2 | * idevicescreenshot -- Gets a screenshot from a connected iPhone/iPod Touch 3 | * 4 | * Copyright (C) 2010 Nikias Bassen 5 | * 6 | * Licensed under the GNU General Public License Version 2 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more profile. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 21 | * USA 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | void print_usage(int argc, char **argv); 35 | 36 | int main(int argc, char **argv) 37 | { 38 | idevice_t device = NULL; 39 | lockdownd_client_t lckd = NULL; 40 | screenshotr_client_t shotr = NULL; 41 | uint16_t port = 0; 42 | int result = -1; 43 | int i; 44 | char *uuid = NULL; 45 | 46 | /* parse cmdline args */ 47 | for (i = 1; i < argc; i++) { 48 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { 49 | idevice_set_debug_level(1); 50 | continue; 51 | } 52 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { 53 | i++; 54 | if (!argv[i] || (strlen(argv[i]) != 40)) { 55 | print_usage(argc, argv); 56 | return 0; 57 | } 58 | uuid = strdup(argv[i]); 59 | continue; 60 | } 61 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { 62 | print_usage(argc, argv); 63 | return 0; 64 | } 65 | else { 66 | print_usage(argc, argv); 67 | return 0; 68 | } 69 | } 70 | 71 | if (IDEVICE_E_SUCCESS != idevice_new(&device, uuid)) { 72 | printf("No device found, is it plugged in?\n"); 73 | if (uuid) { 74 | free(uuid); 75 | } 76 | return -1; 77 | } 78 | if (uuid) { 79 | free(uuid); 80 | } 81 | 82 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lckd, NULL)) { 83 | idevice_free(device); 84 | printf("Exiting.\n"); 85 | return -1; 86 | } 87 | 88 | lockdownd_start_service(lckd, "com.apple.mobile.screenshotr", &port); 89 | lockdownd_client_free(lckd); 90 | if (port > 0) { 91 | if (screenshotr_client_new(device, port, &shotr) != SCREENSHOTR_E_SUCCESS) { 92 | printf("Could not connect to screenshotr!\n"); 93 | } else { 94 | char *imgdata = NULL; 95 | char filename[36]; 96 | uint64_t imgsize = 0; 97 | time_t now = time(NULL); 98 | strftime(filename, 36, "screenshot-%Y-%m-%d-%H-%M-%S.tiff", gmtime(&now)); 99 | if (screenshotr_take_screenshot(shotr, &imgdata, &imgsize) == SCREENSHOTR_E_SUCCESS) { 100 | FILE *f = fopen(filename, "w"); 101 | if (f) { 102 | if (fwrite(imgdata, 1, (size_t)imgsize, f) == (size_t)imgsize) { 103 | printf("Screenshot saved to %s\n", filename); 104 | result = 0; 105 | } else { 106 | printf("Could not save screenshot to file %s!\n", filename); 107 | } 108 | fclose(f); 109 | } else { 110 | printf("Could not open %s for writing: %s\n", filename, strerror(errno)); 111 | } 112 | } else { 113 | printf("Could not get screenshot!\n"); 114 | } 115 | screenshotr_client_free(shotr); 116 | } 117 | } else { 118 | printf("Could not start screenshotr service! Remember that you have to mount the Developer disk image on your device if you want to use the screenshotr service.\n"); 119 | } 120 | idevice_free(device); 121 | 122 | return result; 123 | } 124 | 125 | void print_usage(int argc, char **argv) 126 | { 127 | char *name = NULL; 128 | 129 | name = strrchr(argv[0], '/'); 130 | printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); 131 | printf("Gets a screenshot from the connected iPhone/iPod Touch.\n"); 132 | printf("The screenshot is saved as a TIFF image in the current directory.\n"); 133 | printf("NOTE: A mounted developer disk image is required on the device, otherwise\n"); 134 | printf("the screenshotr service is not available.\n\n"); 135 | printf(" -d, --debug\t\tenable communication debugging\n"); 136 | printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); 137 | printf(" -h, --help\t\tprints usage information\n"); 138 | printf("\n"); 139 | } 140 | -------------------------------------------------------------------------------- /libimobiledevice/tools/idevicesyslog.c: -------------------------------------------------------------------------------- 1 | /* 2 | * idevicesyslog.c 3 | * Relay the syslog of a device to stdout 4 | * 5 | * Copyright (c) 2009 Martin Szulecki All Rights Reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | static int quit_flag = 0; 33 | 34 | void print_usage(int argc, char **argv); 35 | 36 | /** 37 | * signal handler function for cleaning up properly 38 | */ 39 | static void clean_exit(int sig) 40 | { 41 | fprintf(stderr, "Exiting...\n"); 42 | quit_flag++; 43 | } 44 | 45 | int main(int argc, char *argv[]) 46 | { 47 | lockdownd_client_t client = NULL; 48 | idevice_t phone = NULL; 49 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; 50 | int i; 51 | char uuid[41]; 52 | uint16_t port = 0; 53 | uuid[0] = 0; 54 | 55 | signal(SIGINT, clean_exit); 56 | signal(SIGQUIT, clean_exit); 57 | signal(SIGTERM, clean_exit); 58 | signal(SIGPIPE, SIG_IGN); 59 | 60 | /* parse cmdline args */ 61 | for (i = 1; i < argc; i++) { 62 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { 63 | idevice_set_debug_level(1); 64 | continue; 65 | } 66 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { 67 | i++; 68 | if (!argv[i] || (strlen(argv[i]) != 40)) { 69 | print_usage(argc, argv); 70 | return 0; 71 | } 72 | strcpy(uuid, argv[i]); 73 | continue; 74 | } 75 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { 76 | print_usage(argc, argv); 77 | return 0; 78 | } 79 | else { 80 | print_usage(argc, argv); 81 | return 0; 82 | } 83 | } 84 | 85 | if (uuid[0] != 0) { 86 | ret = idevice_new(&phone, uuid); 87 | if (ret != IDEVICE_E_SUCCESS) { 88 | printf("No device found with uuid %s, is it plugged in?\n", uuid); 89 | return -1; 90 | } 91 | } 92 | else 93 | { 94 | ret = idevice_new(&phone, NULL); 95 | if (ret != IDEVICE_E_SUCCESS) { 96 | printf("No device found, is it plugged in?\n"); 97 | return -1; 98 | } 99 | } 100 | 101 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "idevicesyslog")) { 102 | idevice_free(phone); 103 | return -1; 104 | } 105 | 106 | /* start syslog_relay service and retrieve port */ 107 | ret = lockdownd_start_service(client, "com.apple.syslog_relay", &port); 108 | if ((ret == LOCKDOWN_E_SUCCESS) && port) { 109 | lockdownd_client_free(client); 110 | 111 | /* connect to socket relay messages */ 112 | idevice_connection_t conn = NULL; 113 | if ((idevice_connect(phone, port, &conn) != IDEVICE_E_SUCCESS) || !conn) { 114 | printf("ERROR: Could not open usbmux connection.\n"); 115 | } else { 116 | while (!quit_flag) { 117 | char *receive = NULL; 118 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; 119 | 120 | ret = idevice_connection_receive(conn, (char *) &datalen, sizeof(datalen), &bytes); 121 | if (ret < 0) { 122 | fprintf(stderr, "Error receiving data. Exiting...\n"); 123 | break; 124 | } 125 | 126 | datalen = GUINT32_FROM_BE(datalen); 127 | 128 | if (datalen == 0) 129 | continue; 130 | 131 | recv_bytes += bytes; 132 | receive = (char *) malloc(sizeof(char) * datalen); 133 | 134 | while (!quit_flag && (recv_bytes <= datalen)) { 135 | ret = idevice_connection_receive(conn, receive, datalen, &bytes); 136 | 137 | if (bytes == 0) 138 | break; 139 | 140 | recv_bytes += bytes; 141 | 142 | fwrite(receive, sizeof(char), bytes, stdout); 143 | } 144 | 145 | free(receive); 146 | } 147 | } 148 | idevice_disconnect(conn); 149 | } else { 150 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); 151 | } 152 | 153 | idevice_free(phone); 154 | 155 | return 0; 156 | } 157 | 158 | void print_usage(int argc, char **argv) 159 | { 160 | char *name = NULL; 161 | 162 | name = strrchr(argv[0], '/'); 163 | printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); 164 | printf("Relay syslog of a connected iPhone/iPod Touch.\n\n"); 165 | printf(" -d, --debug\t\tenable communication debugging\n"); 166 | printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); 167 | printf(" -h, --help\t\tprints usage information\n"); 168 | printf("\n"); 169 | } 170 | 171 | -------------------------------------------------------------------------------- /libplist/src/Dictionary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Dictionary.cpp 3 | * 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace PList 25 | { 26 | 27 | Dictionary::Dictionary(Node* parent) : Structure(PLIST_DICT, parent) 28 | { 29 | } 30 | 31 | Dictionary::Dictionary(plist_t node, Node* parent) : Structure(parent) 32 | { 33 | _node = node; 34 | plist_dict_iter it = NULL; 35 | 36 | char* key = NULL; 37 | plist_t subnode = NULL; 38 | plist_dict_new_iter(_node, &it); 39 | plist_dict_next_item(_node, it, &key, &subnode); 40 | while (subnode) 41 | { 42 | _map[std::string(key)] = Node::FromPlist(subnode, this); 43 | 44 | subnode = NULL; 45 | free(key); 46 | key = NULL; 47 | plist_dict_next_item(_node, it, &key, &subnode); 48 | } 49 | free(it); 50 | } 51 | 52 | Dictionary::Dictionary(PList::Dictionary& d) : Structure() 53 | { 54 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) 55 | { 56 | plist_free(it->second->GetPlist()); 57 | delete it->second; 58 | } 59 | _map.clear(); 60 | 61 | _node = plist_copy(d.GetPlist()); 62 | plist_dict_iter it = NULL; 63 | 64 | char* key = NULL; 65 | plist_t subnode = NULL; 66 | plist_dict_new_iter(_node, &it); 67 | plist_dict_next_item(_node, it, &key, &subnode); 68 | while (subnode) 69 | { 70 | _map[std::string(key)] = Node::FromPlist(subnode, this); 71 | 72 | subnode = NULL; 73 | free(key); 74 | key = NULL; 75 | plist_dict_next_item(_node, it, NULL, &subnode); 76 | } 77 | free(it); 78 | } 79 | 80 | Dictionary& Dictionary::operator=(PList::Dictionary& d) 81 | { 82 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) 83 | { 84 | plist_free(it->second->GetPlist()); 85 | delete it->second; 86 | } 87 | _map.clear(); 88 | 89 | _node = plist_copy(d.GetPlist()); 90 | plist_dict_iter it = NULL; 91 | 92 | char* key = NULL; 93 | plist_t subnode = NULL; 94 | plist_dict_new_iter(_node, &it); 95 | plist_dict_next_item(_node, it, &key, &subnode); 96 | while (subnode) 97 | { 98 | _map[std::string(key)] = Node::FromPlist(subnode, this); 99 | 100 | subnode = NULL; 101 | free(key); 102 | key = NULL; 103 | plist_dict_next_item(_node, it, NULL, &subnode); 104 | } 105 | free(it); 106 | return *this; 107 | } 108 | 109 | Dictionary::~Dictionary() 110 | { 111 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) 112 | { 113 | delete it->second; 114 | } 115 | _map.clear(); 116 | } 117 | 118 | Node* Dictionary::Clone() 119 | { 120 | return new Dictionary(*this); 121 | } 122 | 123 | Node* Dictionary::operator[](const std::string& key) 124 | { 125 | return _map[key]; 126 | } 127 | 128 | Dictionary::iterator Dictionary::Begin() 129 | { 130 | return _map.begin(); 131 | } 132 | 133 | Dictionary::iterator Dictionary::End() 134 | { 135 | return _map.end(); 136 | } 137 | 138 | Dictionary::iterator Dictionary::Find(const std::string& key) 139 | { 140 | return _map.find(key); 141 | } 142 | 143 | Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) 144 | { 145 | if (node) 146 | { 147 | Node* clone = node->Clone(); 148 | UpdateNodeParent(clone); 149 | plist_dict_insert_item(_node, key.c_str(), clone->GetPlist()); 150 | delete _map[key]; 151 | _map[key] = clone; 152 | return _map.find(key); 153 | } 154 | return iterator(NULL); 155 | } 156 | 157 | void Dictionary::Remove(Node* node) 158 | { 159 | if (node) 160 | { 161 | char* key = NULL; 162 | plist_dict_get_item_key(node->GetPlist(), &key); 163 | plist_dict_remove_item(_node, key); 164 | std::string skey = key; 165 | free(key); 166 | _map.erase(skey); 167 | delete node; 168 | } 169 | } 170 | 171 | void Dictionary::Remove(const std::string& key) 172 | { 173 | plist_dict_remove_item(_node, key.c_str()); 174 | delete _map[key]; 175 | _map.erase(key); 176 | } 177 | 178 | std::string Dictionary::GetNodeKey(Node* node) 179 | { 180 | for (iterator it = _map.begin(); it != _map.end(); ++it) 181 | { 182 | if (it->second == node) 183 | return it->first; 184 | } 185 | return ""; 186 | } 187 | 188 | }; 189 | -------------------------------------------------------------------------------- /ribusb/README.rdoc: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | = Access USB devices from Ruby via libusb. 4 | 5 | * hosted on RubyForge: http://rubyforge.org/projects/ribusb 6 | * development at Github: http://github.com/larskanis/ribusb 7 | * API documentation: http://ribusb.rubyforge.org/ribusb 8 | 9 | == DESCRIPTION: 10 | 11 | RibUSB is a Ruby extension that gives a Ruby programmer access to all functionality of libusb, version 1.0. 12 | 13 | * libusb is a library that gives full access to devices connected via the USB bus. No kernel driver is thus necessary for accessing USB devices. Linux and OSX support is ready, Windows support is under development, ports to other systems are bound to appear with time. 14 | * This Ruby extension supports the API version 1.0 of libusb. Note that the old "legacy" version 0.1.x of libusb uses a completely different API and is thus not supported. 15 | * The API is currently work-in-progress. Do not rely on it being stable just yet. 16 | 17 | This project is being developed by András G. Major and Lars Kanis, is hosted on RubyForge[http://rubyforge.org/projects/ribusb] and Github[http://github.com/larskanis/ribusb]. 18 | 19 | RibUSB is covered by the GNU Public License version 2. 20 | 21 | == FEATURES: 22 | * Access to descriptors of devices, configurations, interfaces, settings and endpoints 23 | * Synchronous and asynchronous communication for bulk, control and interrupt transfers 24 | * Compatibility layer for ruby-usb[http://www.a-k-r.org/ruby-usb/] (API based on libusb-0.1) 25 | * Download as source or precompiled win32 gems 26 | 27 | == SYNOPSIS: 28 | 29 | require "ribusb" 30 | 31 | usb = RibUSB::Context.new 32 | device = usb.find(:idVendor => 0x04b4, :idProduct => 0x8613).first 33 | device.claim_interface(0) 34 | device.control_transfer(:bmRequestType => 0x40, :bRequest => 0xa0, :wValue => 0xe600, :wIndex => 0x0000, :dataOut => 1.chr) 35 | device.release_interface(0) 36 | 37 | RibUSB::Context#find is used to get all or only particular devices. A RibUSB::Device can be used to communicate with the USB device 38 | by RibUSB::Device#control_transfer, RibUSB::Device#bulk_transfer or RibUSB::Device#interrupt_transfer. 39 | 40 | RibUSB is compatible to ruby-usb[http://www.a-k-r.org/ruby-usb/]. See ::USB for description of ruby-usb compatibility layer. 41 | 42 | == REQUIREMENTS: 43 | 44 | * libusb version 1.0 or greater 45 | * Ruby MRI 1.8, 1.9 or Rubinius 46 | * Linux, MacOSX or Windows system 47 | 48 | == INSTALL: 49 | 50 | In order to install RibUSB from source code, you need a working Ruby installation, including its 51 | header files and build utilities (on Debian and Ubuntu systems, part the ruby-dev package). Also, 52 | you need a C compiler (usually gcc), and make. The libusb-1.0 library along with its header files 53 | must naturally be present (on Debian and Ubuntu system, install the libusb-1.0-0-dev package). 54 | 55 | To install from gem, execute this command to download RibUSB and to build it. On Windows 56 | a binary gem is installed automatically: 57 | 58 | gem install ribusb 59 | 60 | To install from source, execute this command to configure RibUSB and to build it: 61 | 62 | git clone git://github.com/larskanis/ribusb.git 63 | rake install_gem 64 | 65 | From now on, you can use the RibUSB extension from any instance of Ruby on that computer by 66 | "requiring" it from within your Ruby program: 67 | 68 | require "ribusb" 69 | 70 | Please browse the documentation on the website for example uses of RibUSB. Have fun. 71 | 72 | 73 | == Usage on Windows 74 | 75 | In contrast to Linux, any access to an USB device by RibUSB on Windows requires a proper driver 76 | installed in the system. Fortunately creating such a driver is quite easy with 77 | Zadig[http://sourceforge.net/apps/mediawiki/libwdi/index.php?title=Main_Page]. Select the interesting USB device 78 | and press "Install Driver". That's it. You may take the generated output directory 79 | with it's INI-file and use it for driver installation on other 32 or 64 bit Windows 80 | systems. 81 | 82 | RibUSB can be used as precompiled Windows gem, so there should be no need for a compiler. 83 | 84 | 85 | == Cross compiling for mswin32 86 | 87 | Using rake-compiler a cross compiled ribusb-gem can be build on a linux or darwin host for 88 | the win32 platform. Libusb is downloaded from source git repo and cross compiled. 89 | The generated gem is statically linked against libusb-1.0. 90 | There are no runtime dependencies to any but the standard Windows DLLs. 91 | 92 | Install mingw32. On a debian based system this should work: 93 | 94 | apt-get install mingw32 95 | 96 | On MacOS X, if you have MacPorts installed: 97 | 98 | port install i386-mingw32-gcc 99 | 100 | Install the rake-compiler: 101 | 102 | gem install rake-compiler 103 | 104 | Download and cross compile ruby 1.8 and 1.9 for win32: 105 | 106 | rake-compiler cross-ruby VERSION=1.8.6-p398 107 | rake-compiler cross-ruby VERSION=1.9.2-p180 108 | 109 | Download and cross compile ribusb for win32: 110 | 111 | rake cross native gem 112 | or with custom versions: 113 | rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.2 LIBUSB_VERSION=295c9d1 114 | 115 | If everything works, there should be ribusb-VERSION-x86-mswin32.gem in the pkg 116 | directory. 117 | 118 | == Todo 119 | 120 | * add proper handling for polling and timing: http://libusb.sourceforge.net/api-1.0/group__poll.html 121 | --------------------------------------------------------------------------------