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,106 @@
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::LockdownClient do
24
+ it "should attach without arguments" do
25
+ client = Idevice::LockdownClient.attach
26
+ client.should be_a Idevice::LockdownClient
27
+ client.device_udid.should == client.get_value(nil, "UniqueDeviceID")
28
+ end
29
+
30
+ it "should attach with an instantiated idevice" do
31
+ client = Idevice::LockdownClient.attach(idevice: Idevice::Idevice.attach)
32
+ client.should be_a Idevice::LockdownClient
33
+ client.device_udid.should == client.get_value(nil, "UniqueDeviceID")
34
+ end
35
+
36
+ context "an attached client" do
37
+ before :each do
38
+ @lockdown = Idevice::LockdownClient.attach(idevice: shared_idevice)
39
+ end
40
+
41
+ after :each do
42
+ @lockdown.goodbye
43
+ end
44
+
45
+ it "should attach" do
46
+ @lockdown.should be_a Idevice::LockdownClient
47
+ end
48
+
49
+ it "should list sync data classes" do
50
+ result = @lockdown.sync_data_classes
51
+ result.should be_a Array
52
+ result.count.should > 1
53
+ end
54
+
55
+ it "should query type" do
56
+ @lockdown.query_type.should == "com.apple.mobile.lockdown"
57
+ end
58
+
59
+ it "should have a device_udid" do
60
+ result = @lockdown.device_udid
61
+ result.should be_a String
62
+ result.should =~ /^[a-f0-9]{40}$/i
63
+ result.should == @lockdown.get_value(nil, "UniqueDeviceID")
64
+ end
65
+
66
+ it "should have a device_name" do
67
+ result = @lockdown.device_name
68
+ result.should be_a String
69
+ result.should == @lockdown.get_value(nil, "DeviceName")
70
+ end
71
+
72
+ it "should get a value for nil:UniqueDeviceID" do
73
+ result = @lockdown.get_value(nil, "UniqueDeviceID")
74
+ result.should be_a String
75
+ result.should =~ /^[a-f0-9]{40}$/i
76
+ result.should == @lockdown.device_udid
77
+ end
78
+
79
+ it "should not get a value for nil:BogusKey" do
80
+ result = @lockdown.get_value(nil, "BogusKey")
81
+ result.should be_nil
82
+ end
83
+
84
+ it "should get an empty hash for BogusDomain" do
85
+ result = @lockdown.get_value("BogusDomain", nil)
86
+ result.should == {}
87
+ end
88
+
89
+ it "should not get a value for BogusDomain:UniqueDeviceID" do
90
+ result = @lockdown.get_value("BogusDomain", "UniqueDeviceID")
91
+ result.should be_nil
92
+ end
93
+
94
+ it "should start an 'afc' lockdown service" do
95
+ ldsvc = @lockdown.start_service("com.apple.afc")
96
+ ldsvc.should_not be_nil
97
+ ldsvc[:port].should > 1024
98
+ [0,1].include?(ldsvc[:ssl_enabled]).should be_true
99
+ end
100
+
101
+ it "should raise an error starting a nonexistent lockdown service" do
102
+ lambda{ @lockdown.start_service("nonexistent.service.garbage") }.should raise_error Idevice::IdeviceLibError
103
+ end
104
+
105
+ end
106
+ end
@@ -0,0 +1,43 @@
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::MisAgentClient do
24
+ before :each do
25
+ @mis = Idevice::MisAgentClient.attach(idevice:shared_idevice)
26
+ end
27
+
28
+ it "should attach" do
29
+ @mis.should be_a Idevice::MisAgentClient
30
+ end
31
+
32
+ it "should list installed profiles" do
33
+ profiles = @mis.profiles
34
+ profiles.should be_a Array
35
+ profiles.each do |profile|
36
+ profile.should be_a StringIO
37
+ end
38
+ end
39
+
40
+ it "should install a profile"
41
+
42
+ it "should remove an installed profile"
43
+ end
@@ -0,0 +1,58 @@
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::MobileBackup2Client do
24
+ before :each do
25
+ @mb2 = Idevice::MobileBackup2Client.attach(idevice:shared_idevice)
26
+ end
27
+
28
+ after :each do
29
+ end
30
+
31
+ it "should attach" do
32
+ @mb2.should be_a Idevice::MobileBackup2Client
33
+ end
34
+
35
+ it "should exchange versions" do
36
+ versions = [1.0, 1.1, 1.2, 1.3, 2.0, 2.1, 2.2, 2.3]
37
+ versions.should include(@mb2.version_exchange(versions))
38
+ end
39
+
40
+ it "should raise an exception attempting to negotiate an invalid version" do
41
+ lambda{ @mb2.version_exchange([999.99]) }.should raise_error Idevice::MobileBackup2Error
42
+ end
43
+
44
+ it "should send a message"
45
+
46
+ it "should receive a message"
47
+
48
+ it "should send a raw message"
49
+
50
+ it "should receive a raw message"
51
+
52
+ it "should send a request"
53
+
54
+ it "should send a status response"
55
+
56
+ end
57
+
58
+
@@ -0,0 +1,41 @@
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
+ if ENV["TEST_MOBILEBACKUP1"]
24
+
25
+ describe Idevice::MobileBackupClient do
26
+ before :each do
27
+ @mb = Idevice::MobileBackupClient.attach(idevice:shared_idevice)
28
+ end
29
+
30
+ after :each do
31
+ end
32
+
33
+ it "should attach" do
34
+ @mb.should be_a Idevice::MobileBackupClient
35
+ end
36
+
37
+ it "needs functional tests" do
38
+ pending "writing more specs for MobileBackupClient"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,62 @@
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::MobileSyncClient do
24
+ before :each do
25
+ @sync = Idevice::MobileSyncClient.attach(idevice:shared_idevice)
26
+ end
27
+
28
+ after :each do
29
+ end
30
+
31
+ it "should attach" do
32
+ @sync.should be_a Idevice::MobileSyncClient
33
+ end
34
+
35
+ it "should send a plist"
36
+
37
+ it "should receive a plist"
38
+
39
+ it "should start synchronizing a data class with the device"
40
+
41
+ it "should cancel"
42
+
43
+ it "should finish"
44
+
45
+ it "should get all records from a device"
46
+
47
+ it "should get changes from a device"
48
+
49
+ it "should clear all records on a device"
50
+
51
+ it "should receive changes from a device"
52
+
53
+ it "should acknowledge changes from a device"
54
+
55
+ it "should signal it is ready to send changes from the computer"
56
+
57
+ it "should send changes"
58
+
59
+ it "should remap identifiers"
60
+
61
+
62
+ 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_relative 'spec_helper'
22
+
23
+ describe Idevice::NotificationProxyClient do
24
+ before :each do
25
+ @sync = Idevice::NPClient.attach(idevice:shared_idevice)
26
+ end
27
+
28
+ after :each do
29
+ end
30
+
31
+ it "should attach" do
32
+ @sync.should be_a Idevice::NotificationProxyClient
33
+ end
34
+
35
+ it "should post a notification"
36
+
37
+ it "should observe a notification"
38
+
39
+ it "should observe notifications (in the plural)"
40
+
41
+ it "should set a notification callback"
42
+
43
+ it "should receive notifications via a callback"
44
+
45
+ end
@@ -0,0 +1,176 @@
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 Plist do
24
+ it "should parse a xml plist to a hash" do
25
+ hash = Plist.parse_xml(sample_file("plist.xml").read)
26
+ hash.should be_a Hash
27
+ hash.should == {"Label" => "idevspecs", "Request" => "QueryType"}
28
+ end
29
+
30
+ it "should parse a binary plist to a hash" do
31
+ hash = Plist.parse_binary(sample_file("plist.bin").read)
32
+ hash.should be_a Hash
33
+ hash.should == {"Label" => "idevspecs", "Request" => "QueryType"}
34
+ end
35
+
36
+ it "should parse a xml plist to plist pointer" do
37
+ ptr = Plist.xml_to_pointer(sample_file("plist.xml").read)
38
+ ptr.should be_a FFI::Pointer
39
+ end
40
+
41
+ it "should parse a binary plist to plist pointer" do
42
+ ptr = Plist.binary_to_pointer(sample_file("plist.bin").read)
43
+ ptr.should be_a FFI::Pointer
44
+ end
45
+
46
+ it "should convert a plist pointer from and to a hash" do
47
+ ptr = Idevice::Plist_t.new_dict
48
+ ptr.should be_a FFI::Pointer
49
+ ptr.should_not be_null
50
+ hash = ptr.to_ruby
51
+ hash.should == {}
52
+ end
53
+
54
+ it "should create a plist pointer from and to an array" do
55
+ ptr = Idevice::Plist_t.new_array
56
+ ptr.should be_a FFI::Pointer
57
+ ptr.should_not be_null
58
+ ary = ptr.to_ruby
59
+ ary.should == []
60
+ end
61
+
62
+ it "should convert a plist pointer from and to a string" do
63
+ ptr = Idevice::Plist_t.new_string("foobadoo")
64
+ ptr.should be_a FFI::Pointer
65
+ ptr.should_not be_null
66
+ str = ptr.to_ruby
67
+ str.should == "foobadoo"
68
+ end
69
+
70
+ it "should convert a plist pointer from and to a string using from_ruby" do
71
+ ptr = Idevice::Plist_t.from_ruby("foobadoo")
72
+ ptr.should be_a FFI::Pointer
73
+ ptr.should_not be_null
74
+ str = ptr.to_ruby
75
+ str.should == "foobadoo"
76
+ end
77
+
78
+ it "should convert a plist pointer from and to bool" do
79
+ ptr = Idevice::Plist_t.new_bool(false)
80
+ ptr.should be_a FFI::Pointer
81
+ ptr.should_not be_null
82
+ bool = ptr.to_ruby
83
+ bool.should == false
84
+
85
+ ptr = Idevice::Plist_t.new_bool(true)
86
+ ptr.should be_a FFI::Pointer
87
+ ptr.should_not be_null
88
+ bool = ptr.to_ruby
89
+ bool.should == true
90
+ end
91
+
92
+ it "should convert a plist pointer from and to bool using from_ruby" do
93
+ ptr = Idevice::Plist_t.from_ruby(false)
94
+ ptr.should be_a FFI::Pointer
95
+ ptr.should_not be_null
96
+ bool = ptr.to_ruby
97
+ bool.should == false
98
+
99
+ ptr = Idevice::Plist_t.from_ruby(true)
100
+ ptr.should be_a FFI::Pointer
101
+ ptr.should_not be_null
102
+ bool = ptr.to_ruby
103
+ bool.should == true
104
+ end
105
+
106
+
107
+ it "should convert a plist pointer from and to an unsigned int" do
108
+ ptr = Idevice::Plist_t.new_uint(0xdeadbeef)
109
+ ptr.should be_a FFI::Pointer
110
+ ptr.should_not be_null
111
+ val = ptr.to_ruby
112
+ val.should == 0xdeadbeef
113
+ end
114
+
115
+ it "should convert a negative number to an unsigned 64-bit int" do
116
+ ptr = Idevice::Plist_t.from_ruby(-2)
117
+ ptr.should be_a FFI::Pointer
118
+ ptr.should_not be_null
119
+ val = ptr.to_ruby
120
+ val.should == 0xfffffffffffffffe
121
+ end
122
+
123
+ it "should convert a plist pointer from and to an unsigned int using from_ruby" do
124
+ ptr = Idevice::Plist_t.from_ruby(0xdeadbeef)
125
+ ptr.should be_a FFI::Pointer
126
+ ptr.should_not be_null
127
+ val = ptr.to_ruby
128
+ val.should == 0xdeadbeef
129
+ end
130
+
131
+ it "should convert a plist pointer from and to a real number" do
132
+ ptr = Idevice::Plist_t.new_real(1234.567)
133
+ ptr.should be_a FFI::Pointer
134
+ ptr.should_not be_null
135
+ val = ptr.to_ruby
136
+ val.should == 1234.567
137
+ end
138
+
139
+ it "should convert a plist pointer from and to a real number from an integer" do
140
+ ptr = Idevice::Plist_t.new_real(1234)
141
+ ptr.should be_a FFI::Pointer
142
+ ptr.should_not be_null
143
+ val = ptr.to_ruby
144
+ val.should == 1234.0
145
+ end
146
+
147
+
148
+ it "should convert a plist pointer from and to a real number using from_ruby" do
149
+ ptr = Idevice::Plist_t.from_ruby(1234.567)
150
+ ptr.should be_a FFI::Pointer
151
+ ptr.should_not be_null
152
+ val = ptr.to_ruby
153
+ val.should == 1234.567
154
+ end
155
+
156
+ it "should convert a plist pointer from and to raw data" do
157
+ ptr = Idevice::Plist_t.new_data("some data here")
158
+ ptr.should be_a FFI::Pointer
159
+ val = ptr.to_ruby
160
+ val.should be_a StringIO
161
+ val.string.should == "some data here"
162
+ end
163
+
164
+ it "should convert a plist pointer from and to raw data using from_ruby" do
165
+ ptr = Idevice::Plist_t.from_ruby(StringIO.new("some data here"))
166
+ ptr.should be_a FFI::Pointer
167
+ val = ptr.to_ruby
168
+ val.should be_a StringIO
169
+ val.string.should == "some data here"
170
+ end
171
+
172
+ it "should convert a plist date pointer from and to a ruby"
173
+
174
+ it "should convert a plist date pointer from and to a ruby using from_ruby"
175
+
176
+ end