idevice 1.1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/NOTICE +202 -0
  5. data/README.md +74 -0
  6. data/Rakefile +37 -0
  7. data/examples/idevimgmount +58 -0
  8. data/examples/idumplockdownvalues +64 -0
  9. data/examples/ifetchcrashreports +54 -0
  10. data/examples/ilistapps +38 -0
  11. data/examples/ilistudids +26 -0
  12. data/examples/ilog +35 -0
  13. data/examples/installipa +51 -0
  14. data/examples/iremoveapp +42 -0
  15. data/examples/irestart +26 -0
  16. data/examples/iscreenshotr +39 -0
  17. data/idevice.gemspec +33 -0
  18. data/lib/idevice.rb +69 -0
  19. data/lib/idevice/afc.rb +518 -0
  20. data/lib/idevice/c.rb +129 -0
  21. data/lib/idevice/diagnostics_relay.rb +185 -0
  22. data/lib/idevice/file_relay.rb +83 -0
  23. data/lib/idevice/heartbeat.rb +99 -0
  24. data/lib/idevice/house_arrest.rb +138 -0
  25. data/lib/idevice/idevice.rb +208 -0
  26. data/lib/idevice/image_mounter.rb +117 -0
  27. data/lib/idevice/installation_proxy.rb +193 -0
  28. data/lib/idevice/lockdown.rb +350 -0
  29. data/lib/idevice/misagent.rb +112 -0
  30. data/lib/idevice/mobilebackup.rb +183 -0
  31. data/lib/idevice/mobilebackup2.rb +174 -0
  32. data/lib/idevice/mobilesync.rb +306 -0
  33. data/lib/idevice/notification_proxy.rb +168 -0
  34. data/lib/idevice/plist.rb +366 -0
  35. data/lib/idevice/restore.rb +176 -0
  36. data/lib/idevice/sbservices.rb +152 -0
  37. data/lib/idevice/screenshotr.rb +88 -0
  38. data/lib/idevice/version.rb +3 -0
  39. data/lib/idevice/webinspector.rb +96 -0
  40. data/spec/afc_devicespec.rb +409 -0
  41. data/spec/diagnostics_relay_devicespec.rb +125 -0
  42. data/spec/file_relay_devicespec.rb +45 -0
  43. data/spec/heartbeat_devicespec.rb +39 -0
  44. data/spec/idevice_devicespec.rb +93 -0
  45. data/spec/idevice_spec.rb +29 -0
  46. data/spec/image_mounter_devicespec.rb +65 -0
  47. data/spec/installation_proxy_devicespec.rb +54 -0
  48. data/spec/lockdown_devicespec.rb +106 -0
  49. data/spec/misagent_devicespec.rb +43 -0
  50. data/spec/mobilebackup2_devicespec.rb +58 -0
  51. data/spec/mobilebackup_devicespec.rb +41 -0
  52. data/spec/mobilesync_devicespec.rb +62 -0
  53. data/spec/notification_proxy_devicespec.rb +45 -0
  54. data/spec/plist_spec.rb +176 -0
  55. data/spec/restore_devicespec.rb +72 -0
  56. data/spec/samples/plist.bin +0 -0
  57. data/spec/samples/plist.xml +10 -0
  58. data/spec/sbservices_devicespec.rb +64 -0
  59. data/spec/screenshotr_devicespec.rb +39 -0
  60. data/spec/spec_helper.rb +73 -0
  61. data/spec/webinspector_devicespec.rb +36 -0
  62. metadata +233 -0
@@ -0,0 +1,125 @@
1
+ #
2
+ # Copyright (c) 2013 Eric Monti - Bluebox Security
3
+ #
4
+ # Licensed to the Apache Software Foundation (ASF) under one
5
+ # or more contributor license agreements. See the NOTICE file
6
+ # distributed with this work for additional information
7
+ # regarding copyright ownership. The ASF licenses this file
8
+ # to you under the Apache License, Version 2.0 (the
9
+ # "License"); you may not use this file except in compliance
10
+ # with the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing,
15
+ # software distributed under the License is distributed on an
16
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ # KIND, either express or implied. See the License for the
18
+ # specific language governing permissions and limitations
19
+ # under the License.
20
+
21
+ require_relative 'spec_helper'
22
+
23
+ describe Idevice::DiagnosticsRelayClient do
24
+ before :all do
25
+ @idevice = shared_idevice
26
+ end
27
+
28
+ before :each do
29
+ @drc = Idevice::DiagnosticsRelayClient.attach(idevice:@idevice)
30
+ end
31
+
32
+ after :each do
33
+ @drc.goodbye rescue nil
34
+ end
35
+
36
+ it "should attach" do
37
+ @drc.should be_a Idevice::DiagnosticsRelayClient
38
+ end
39
+
40
+ it "should request diagnostics" do
41
+ result = @drc.diagnostics("All")
42
+ result.should be_a Hash
43
+ result.should have_key "WiFi"
44
+ result.should have_key "GasGauge"
45
+ result["WiFi"].keys.sort.should == ["Active", "Status"]
46
+ result["GasGauge"].keys.sort.should == ["CycleCount", "DesignCapacity", "FullChargeCapacity", "Status"]
47
+ end
48
+
49
+ it "should request All diagnostics by default" do
50
+ result = @drc.diagnostics()
51
+ result.should be_a Hash
52
+ result.should have_key "WiFi"
53
+ result.should have_key "GasGauge"
54
+ result["WiFi"].keys.sort.should == ["Active", "Status"]
55
+ result["GasGauge"].keys.sort.should == ["CycleCount", "DesignCapacity", "FullChargeCapacity", "Status"]
56
+ end
57
+
58
+ it "should request WiFi diagnostics" do
59
+ result = @drc.diagnostics("WiFi")
60
+ result.should be_a Hash
61
+ result.keys.should == ["WiFi"]
62
+ result["WiFi"].keys.sort.should == ["Active", "Status"]
63
+ end
64
+
65
+ it "should request GasGauge diagnostics" do
66
+ result = @drc.diagnostics("GasGauge")
67
+ result.should be_a Hash
68
+ result.keys.should == ["GasGauge"]
69
+ result["GasGauge"].keys.sort.should == ["CycleCount", "DesignCapacity", "FullChargeCapacity", "Status"]
70
+ end
71
+
72
+ it "should raise an error for invalid diagnostic types " do
73
+ lambda{ @drc.diagnostics("SomeBogusType") }.should raise_error(Idevice::DiagnosticsRelayError)
74
+ end
75
+
76
+ it "should query mobilegestalt" do
77
+ result = @drc.mobilegestalt("UniqueDeviceID")
78
+ result.should be_a Hash
79
+ result.keys.should == ["MobileGestalt"]
80
+ result["MobileGestalt"].keys.sort.should == ["Status", "UniqueDeviceID"]
81
+ result["MobileGestalt"]["Status"].should == "Success"
82
+ result["MobileGestalt"]["UniqueDeviceID"].should =~ /^[a-f0-9]{40}$/i
83
+ end
84
+
85
+ it "should query ioregistry entries"
86
+
87
+ it "should query the Root ioregistry plane" do
88
+ result = @drc.ioregistry_plane("Root")
89
+ result.should be_a Hash
90
+ result.keys.should == ["IORegistry"]
91
+ result["IORegistry"].should be_a Hash
92
+ result["IORegistry"]["name"].should == "Root"
93
+ result["IORegistry"]["children"].should be_empty
94
+ end
95
+
96
+ it "should query the IOPower ioregistry plane" do
97
+ result = @drc.ioregistry_plane("IOPower")
98
+ result.should be_a Hash
99
+ result.keys.should == ["IORegistry"]
100
+ result["IORegistry"].should be_a Hash
101
+ result["IORegistry"]["name"].should == "Root"
102
+ result["IORegistry"]["children"].should_not be_empty
103
+ end
104
+
105
+ it "should say goodbye to disconnect from the service" do
106
+ @drc.goodbye.should be_true
107
+ lambda{ @drc.diagnostics }.should raise_error(Idevice::DiagnosticsRelayError)
108
+ end
109
+
110
+ it "should put a device to sleep" do
111
+ pending "don't actually put the device to sleep"
112
+ @drc.sleep
113
+ end
114
+
115
+ it "should restart a device" do
116
+ pending "don't actually reboot the device"
117
+ @drc.restart(0) #(with optional flags arg)
118
+ end
119
+
120
+ it "should shutdown a device" do
121
+ pending "don't actually shutdown the device"
122
+ @drc.shutdown(0) #(with optional flags arg)
123
+ end
124
+
125
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright (c) 2013 Eric Monti - Bluebox Security
3
+ #
4
+ # Licensed to the Apache Software Foundation (ASF) under one
5
+ # or more contributor license agreements. See the NOTICE file
6
+ # distributed with this work for additional information
7
+ # regarding copyright ownership. The ASF licenses this file
8
+ # to you under the Apache License, Version 2.0 (the
9
+ # "License"); you may not use this file except in compliance
10
+ # with the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing,
15
+ # software distributed under the License is distributed on an
16
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ # KIND, either express or implied. See the License for the
18
+ # specific language governing permissions and limitations
19
+ # under the License.
20
+
21
+ require 'spec_helper'
22
+
23
+ describe Idevice::FileRelayClient do
24
+ before :each do
25
+ @frc = Idevice::FileRelayClient.attach(idevice:shared_idevice)
26
+ end
27
+
28
+ it "should attach" do
29
+ @frc.should be_a Idevice::FileRelayClient
30
+ end
31
+
32
+ it "should return an error when requesting invalid sources" do
33
+ lambda{ @frc.request_sources("this source is lies") }.should raise_error(Idevice::FileRelayError)
34
+ end
35
+
36
+ it "should request and receive CrashReporter logs" do
37
+ crashdata = @frc.request_sources("CrashReporter")
38
+ crashdata.should be_a String
39
+
40
+ # the returned data is actually a gzip-compressed cpio
41
+ shell_pipe(crashdata[0..256], "file -").should =~ /gzip compressed data, from Unix\n$/
42
+ shell_pipe(crashdata, "cpio -t").should =~ /^\.\/var\/mobile\/Library/
43
+ end
44
+ end
45
+
@@ -0,0 +1,39 @@
1
+ #
2
+ # Copyright (c) 2013 Eric Monti - Bluebox Security
3
+ #
4
+ # Licensed to the Apache Software Foundation (ASF) under one
5
+ # or more contributor license agreements. See the NOTICE file
6
+ # distributed with this work for additional information
7
+ # regarding copyright ownership. The ASF licenses this file
8
+ # to you under the Apache License, Version 2.0 (the
9
+ # "License"); you may not use this file except in compliance
10
+ # with the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing,
15
+ # software distributed under the License is distributed on an
16
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ # KIND, either express or implied. See the License for the
18
+ # specific language governing permissions and limitations
19
+ # under the License.
20
+
21
+ require_relative 'spec_helper'
22
+
23
+ describe Idevice::HeartbeatClient do
24
+ before :all do
25
+ @hb = Idevice::HeartbeatClient.attach(idevice:shared_idevice)
26
+ end
27
+
28
+ it "should attach" do
29
+ @hb.should be_a Idevice::HeartbeatClient
30
+ end
31
+
32
+ it "should send and receive a heartbeat" do
33
+ pending "Heartbeat is not working on my test device"
34
+ marco = @hb.receive_plist
35
+ marco.should be_a Hash
36
+ @hb.send_plist("Command" => "Polo").should be_true
37
+ end
38
+ end
39
+
@@ -0,0 +1,93 @@
1
+ #
2
+ # Copyright (c) 2013 Eric Monti - Bluebox Security
3
+ #
4
+ # Licensed to the Apache Software Foundation (ASF) under one
5
+ # or more contributor license agreements. See the NOTICE file
6
+ # distributed with this work for additional information
7
+ # regarding copyright ownership. The ASF licenses this file
8
+ # to you under the Apache License, Version 2.0 (the
9
+ # "License"); you may not use this file except in compliance
10
+ # with the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing,
15
+ # software distributed under the License is distributed on an
16
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ # KIND, either express or implied. See the License for the
18
+ # specific language governing permissions and limitations
19
+ # under the License.
20
+
21
+ require_relative 'spec_helper'
22
+
23
+ describe Idevice do
24
+ it "should list attached devices" do
25
+ devlist = Idevice.device_list
26
+ devlist.count.should > 0
27
+ devlist.each do |dev|
28
+ dev.should =~ /^[a-f0-9]{40}$/i
29
+ end
30
+ end
31
+ end
32
+
33
+ describe Idevice::Idevice do
34
+
35
+ context "with an attached device" do
36
+ before :all do
37
+ @idevice = Idevice::Idevice.attach()
38
+ end
39
+
40
+ it "should attach" do
41
+ @idevice.should be_a Idevice::Idevice
42
+ end
43
+
44
+ it "should have a udid" do
45
+ @idevice.udid.should_not be_nil
46
+ @idevice.udid.should =~ /^[a-f0-9]{40}$/i
47
+ end
48
+
49
+ it "should have a handle" do
50
+ @idevice.handle.should_not be_nil
51
+ @idevice.handle.should be_a Numeric
52
+ end
53
+
54
+ it "should fail to connect to the telnet port" do
55
+ lambda{ @idevice.connect(23).should be_false }.should raise_error
56
+ end
57
+
58
+ context "connecting to lockdown" do
59
+ it "should connect to the lockdownd port" do
60
+ begin
61
+ connection = @idevice.connect(62078)
62
+ connection.should be_a Idevice::IdeviceConnection
63
+ connection.should be_connected
64
+ connection.should_not be_disconnected
65
+ ensure
66
+ connection.disconnect if connection
67
+ end
68
+ end
69
+
70
+ it "should query lockdownd" do
71
+ begin
72
+ connection = @idevice.connect(62078)
73
+ connection.should be_a Idevice::IdeviceConnection
74
+ connection.should be_connected
75
+ connection.should_not be_disconnected
76
+
77
+ connection.send_data("\000\000\001\032<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>Label</key>\n\t<string>idevspecs</string>\n\t<key>Request</key>\n\t<string>QueryType</string>\n</dict>\n</plist>\n")
78
+ blen = connection.receive_data(4)
79
+ blen.size.should == 4
80
+ len = blen.unpack("N").first
81
+ dat = connection.receive_data(len)
82
+ dat.size.should == len
83
+ dat.should =~ /^<\?xml /
84
+
85
+ ensure
86
+ connection.disconnect if connection
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ end
93
+
@@ -0,0 +1,29 @@
1
+ #
2
+ # Copyright (c) 2013 Eric Monti - Bluebox Security
3
+ #
4
+ # Licensed to the Apache Software Foundation (ASF) under one
5
+ # or more contributor license agreements. See the NOTICE file
6
+ # distributed with this work for additional information
7
+ # regarding copyright ownership. The ASF licenses this file
8
+ # to you under the Apache License, Version 2.0 (the
9
+ # "License"); you may not use this file except in compliance
10
+ # with the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing,
15
+ # software distributed under the License is distributed on an
16
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ # KIND, either express or implied. See the License for the
18
+ # specific language governing permissions and limitations
19
+ # under the License.
20
+
21
+ require_relative 'spec_helper'
22
+
23
+ describe Idevice do
24
+ it "should have a version" do
25
+ Idevice::VERSION.should be_a String
26
+ Idevice::VERSION.should =~ /^(\d+\.)+\d+$/
27
+ end
28
+ end
29
+
@@ -0,0 +1,65 @@
1
+ #
2
+ # Copyright (c) 2013 Eric Monti - Bluebox Security
3
+ #
4
+ # Licensed to the Apache Software Foundation (ASF) under one
5
+ # or more contributor license agreements. See the NOTICE file
6
+ # distributed with this work for additional information
7
+ # regarding copyright ownership. The ASF licenses this file
8
+ # to you under the Apache License, Version 2.0 (the
9
+ # "License"); you may not use this file except in compliance
10
+ # with the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing,
15
+ # software distributed under the License is distributed on an
16
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ # KIND, either express or implied. See the License for the
18
+ # specific language governing permissions and limitations
19
+ # under the License.
20
+
21
+ require_relative 'spec_helper'
22
+
23
+ describe Idevice::ImageMounterClient do
24
+ before :each do
25
+ @imgmounter = Idevice::ImageMounterClient.attach(idevice:shared_idevice)
26
+ end
27
+
28
+ after :each do
29
+ @imgmounter.hangup rescue nil
30
+ end
31
+
32
+ it "should attach" do
33
+ @imgmounter.should be_a Idevice::ImageMounterClient
34
+ end
35
+
36
+ it "should look up whether the Developer image is mounted" do
37
+ res=@imgmounter.lookup_image("Developer")
38
+ res["Status"].should == "Complete"
39
+ res.should have_key "ImagePresent"
40
+ end
41
+
42
+ it "should look up whether the Developer image is mounted (by default)" do
43
+ res=@imgmounter.lookup_image
44
+ res["Status"].should == "Complete"
45
+ res.should have_key "ImagePresent"
46
+ end
47
+
48
+ it "should look up whether the Debug image is mounted" do
49
+ res=@imgmounter.lookup_image("Debug")
50
+ res["Status"].should == "Complete"
51
+ res.should have_key "ImagePresent"
52
+ end
53
+
54
+ it "should look up whether an arbitrary image is mounted" do
55
+ @imgmounter.lookup_image("SomebogusImageName").should == {"ImagePresent"=>false, "Status"=>"Complete"}
56
+ end
57
+
58
+ it "should hangup" do
59
+ @imgmounter.hangup.should be_true
60
+ lambda{ @imgmounter.lookup_image }.should raise_error(Idevice::ImageMounterError)
61
+ end
62
+
63
+ it "should mount an image"
64
+ end
65
+
@@ -0,0 +1,54 @@
1
+ #
2
+ # Copyright (c) 2013 Eric Monti - Bluebox Security
3
+ #
4
+ # Licensed to the Apache Software Foundation (ASF) under one
5
+ # or more contributor license agreements. See the NOTICE file
6
+ # distributed with this work for additional information
7
+ # regarding copyright ownership. The ASF licenses this file
8
+ # to you under the Apache License, Version 2.0 (the
9
+ # "License"); you may not use this file except in compliance
10
+ # with the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing,
15
+ # software distributed under the License is distributed on an
16
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ # KIND, either express or implied. See the License for the
18
+ # specific language governing permissions and limitations
19
+ # under the License.
20
+
21
+ require_relative 'spec_helper'
22
+
23
+ describe Idevice::InstProxyClient do
24
+ before :each do
25
+ @instproxy = Idevice::InstProxyClient.attach(idevice:shared_idevice)
26
+ end
27
+
28
+ it "should attach" do
29
+ @instproxy.should be_a Idevice::InstProxyClient
30
+ end
31
+
32
+ it "should browse installed apps" do
33
+ browsedata = @instproxy.browse()
34
+ browsedata.should be_a Array
35
+ browsedata.map{|x| x.class }.uniq.should == [Hash]
36
+ browsedata.map{|x| x["ApplicationType"]}.should include "System"
37
+ end
38
+
39
+ it "should install an application"
40
+
41
+ it "should upgrade an application"
42
+
43
+ it "should uninstall an application"
44
+
45
+ it "should lookup archives"
46
+
47
+ it "should archive an application"
48
+
49
+ it "should restore an archived application"
50
+
51
+ it "should remove an archive"
52
+
53
+ end
54
+