Is it possible, and how do I add a key-value pair into the new entitlements file when repacking an iOS application with frida gadget? - ios

I am trying to repack an iOS Application; IPA file with the frida gadget dynamic library according to the following link. However, i am running into a console log error when launching the application:
<Warning>: Unable to obtain a task name port right for pid 610: (os/kern) failure (5)
Thus, googling a bit, I found that a possible fix(second link to related fix) might be to add a task_for_pid-allow key-value pair to the entitlements file.
Editing the entitlements file by adding the key using a text-editor before re-sigining the application with the following code snippet:
codesign --force --sign "iPhone Developer: m*****************" --entitlements entitlements.plist Payload/Plain\ Notes.app/Plain\ Notes
Resulted in a verification error when running ios-deploy as shown below:
Error 0xe800003a: The application could not be verified. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0)
Is there a specific way to add key-value pairs to the entitlements file when repacking applications on iOS which would solve the verification error that I am getting?

I found out how to add values to the entitlements file, use PlistBuddy.
In my case, the below snippet should add the task_for_pid-allow key into my entitlements:
/usr/libexec/PlistBuddy -c "Add :Entitlements:task_for_pid-allow bool True" profile.plist
To check that it has been successfully added:
/usr/libexec/PlistBuddy -c "Print :Entitlements" profile.plist

Related

Mapped file has no Team ID and is not a platform binary

Note: this question looks similar, but is different. The error here is about a file having no Team ID, whereas the linked answer is about adhoc-signing a file that is not signed at all. The answer there (explaining how to adhoc-sign) does not solve the problem here.
Trying to run an executable linking to a dynamic library, I get the following error:
Library not loaded:
[...]
Reason: tried:
<lib> not valid for use in process: mapped file has no Team ID and is not a
platform binary (signed with custom identity or adhoc?))
How can I check the signature and fix it?
Check the signature of your file with:
% codesign -d -v ./mavsdk
It may show, for instance (note in particular the Signature=adhoc):
Executable=<path/to/lib>
Identifier=some.package.name
Format=bundle with Mach-O thin (x86_64)
CodeDirectory v=20400 size=253962 flags=0x2(adhoc) hashes=7930+3 location=embedded
Signature=adhoc
Info.plist entries=11
TeamIdentifier=not set
Sealed Resources version=2 rules=13 files=13
Internal requirements count=0 size=12
In order to sign the library, first list your identities:
% security find-identity -v -p codesigning
It may show something like this:
1) D3F12EDB89FF03FEBA39D1A45F8BD300BAC1C3F0 "Apple Development: Your Name (234MBK19TS)"
2) CA4F82BC3C4BABE180CC8BC52A48CBF4DE0E2CAA "lldb_codesign"
3) EB4AD59AE2BBD1C8A0F43C9B2AAA7FBDA1B0D3EE "gdb-cert"
3 valid identities found
In which case you can sign the library with:
% codesign -s "Apple Development: Your Name (234MBK19TS)" <lib>
Had the same problem. When tried to sign the library, library was already signed...
<lib>: is already signed
Forcing the signature solved the issue :
% codesign -s "Apple Development: Your Name (234MBK19TS)" -f <lib>

I'm not able to validate my ipa from command line but it work from xcode?

I'm trying to validate my app by command line using this :
xcrun altool --validate-app -f myapp.ipa -t ios -u "id" -p
But I'm getting this error :
altool[1043:29194] *** Error: Unable to validate archive 'myapp.ipa':
( "Error Domain=ITunesSoftwareServiceErrorDomain Code=-21017 "Could
not find the main bundle or the Info.plist is missing a
CFBundleIdentifier in 'myapp.ipa'."
UserInfo={NSLocalizedDescription=Could not find the main bundle or the
Info.plist is missing a CFBundleIdentifier in 'myapp.ipa'.,
NSLocalizedFailureReason=Unable to validate your application.}" )
I exported an IPA from Xcode, directly in Xcode I can validate and upload it but I don't understand this error when I'm trying to do it from the command line

I'm not able to validate my ipa from command line but it work from xcode

I'm trying to validate my app by command line using this :
xcrun altool --validate-app -f myapp.ipa -t ios -u "id" -p
But I'm getting this error :
altool[1043:29194] *** Error: Unable to validate archive 'myapp.ipa': (
"Error Domain=ITunesSoftwareServiceErrorDomain Code=-21017 "Could not find the main bundle or the Info.plist is missing a CFBundleIdentifier in 'myapp.ipa'." UserInfo={NSLocalizedDescription=Could not find the main bundle or the Info.plist is missing a CFBundleIdentifier in 'myapp.ipa'., NSLocalizedFailureReason=Unable to validate your application.}"
)
I exported an IPA from Xcode, directly in Xcode I can validate and upload it but I don't understand this error when I'm trying to do it from the command line

Error no mobile provisioning profile found

While using the build system instruction from https://webrtc.org/native-code/ios/ all went fine except following error
Error: no mobile provisioning profile found for
When i do xcrun security find-identity -v -p codesigning i do see my certificates, Is there anyway to fix it?
$ gn gen out/ios_64 --args='target_os="ios" target_cpu="arm64"'
Done. Made 719 targets from 110 files in 2444ms
$ ninja -C out/ios_64 AppRTCMobile
ninja: Entering directory `out/ios_64'
[2086/2100] CODE SIGNING //webrtc/sdk:r...(//build/toolchain/mac:ios_clang_arm64)
FAILED: WebRTC.framework/WebRTC WebRTC.framework/_CodeSignature/CodeResources WebRTC.framework/embedded.mobileprovision
python ../../build/config/ios/codesign.py code-sign-bundle -t=iphoneos -i=3F06B010E7BE32A3D212219D02DF440B0F20D6A3 -e=../../build/config/ios/entitlements.plist -b=obj/webrtc/sdk/WebRTC WebRTC.framework
Error: no mobile provisioning profile found for "org.webrtc.WebRTC".
ninja: build stopped: subcommand failed.
Let me tell the steps that works for me
Edit the file src/examples/objc/AppRTCMobile/ios/Info.plist and change the value com.google.AppRTCMobile with your own bundle identifier.
Edit the file src/sdk/objc/Framework/Info.plist and change the value org.webrtc.WebRTC with your own bundle identifier
I have created bundle identifiers on Xcode and after that build is successful

Xcode - Sharing app - PackageApplication failed with exit code 1

I've created an ad hoc distribution build for my iPhone app using Xcode 4.1. The target successfully builds and produces an archive file that I can see in Organizer. I then click 'Share' which allows me to select .ipa and my distribution profile. However, after i hit 'Next' the Organizer crashes with the error below. The error log appears to suggest that the error is related to the 'ResourceRules.plist'? I'm using CorePlot for graphing, might it be related to that?
For info, I have a valid distribution certificate and imported a distribution provisioning profile. Entitlements file is not needed anymore for ad hoc distribution apparently so I don't have one in the project. All of my other apps don't crash at the 'sharing' stage, so it doesn't appear to be a problem with Xcode, just this particular app.
Any help much appreciated.
Grant.
PackageApplication failed with exit code 1.
Packaging application: '/Users/gabt/Library/Developer/Xcode/Archives/2011-08-20/myApp 20-08-2011 14.11.xcarchive/Products/Applications/myApp.app'
Arguments: embed=/Users/gabt/Library/MobileDevice/Provisioning Profiles/FA16C6A9-603C-46A6-8B98-F367A6B056CD.mobileprovision verbose=1 output=/var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/670E174E-0BCA-4F18-AB8D-5ACF3D7E569A-8458-000005FCA81C6AE5/app.ipa sign=iPhone Distribution: Grant Abt
Environment variables:
HOME = /Users/gabt
LOGNAME = gabt
__CF_USER_TEXT_ENCODING = 0x1F5:0:0
DISPLAY = /tmp/launch-WoNf6c/org.x:0
COMMAND_MODE = unix2003
VERSIONER_PERL_PREFER_32_BIT = no
PATH = /Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
SHELL = /bin/bash
SSH_AUTH_SOCK = /tmp/launch-hHkBrJ/Listeners
Apple_PubSub_Socket_Render = /tmp/launch-P0dtgN/Render
TMPDIR = /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/
USER = gabt
VERSIONER_PERL_VERSION = 5.12
Output directory: '/var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/670E174E-0BCA-4F18-AB8D-5ACF3D7E569A-8458-000005FCA81C6AE5/app.ipa'
Temporary Directory: '/var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS' (will NOT be deleted on exit when verbose set)
+ /bin/cp -Rp /Users/gabt/Library/Developer/Xcode/Archives/2011-08-20/myApp 20-08-2011 14.11.xcarchive/Products/Applications/myApp.app /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/Payload
Program /bin/cp returned 0 : []
### Checking original app
+ /usr/bin/codesign --verify -vvvv /Users/gabt/Library/Developer/Xcode/Archives/2011-08-20/myApp 20-08-2011 14.11.xcarchive/Products/Applications/myApp.app
Program /usr/bin/codesign returned 0 : [/Users/gabt/Library/Developer/Xcode/Archives/2011-08-20/myApp 20-08-2011 14.11.xcarchive/Products/Applications/myApp.app: valid on disk
/Users/gabt/Library/Developer/Xcode/Archives/2011-08-20/myApp 20-08-2011 14.11.xcarchive/Products/Applications/myApp.app: satisfies its Designated Requirement
]
Done checking the original app
### Embedding '/Users/gabt/Library/MobileDevice/Provisioning Profiles/FA16C6A9-603C-46A6-8B98-F367A6B056CD.mobileprovision'
+ /bin/rm -rf /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/Payload/myApp.app/embedded.mobileprovision
Program /bin/rm returned 0 : []
+ /bin/cp -rp /Users/gabt/Library/MobileDevice/Provisioning Profiles/FA16C6A9-603C-46A6-8B98-F367A6B056CD.mobileprovision /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/Payload/myApp.app/embedded.mobileprovision
Program /bin/cp returned 0 : []
+ /usr/bin/codesign -d --entitlements /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/entitlements_rawMkZVbU5I /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/Payload/myApp.app
Program /usr/bin/codesign returned 0 : [Executable=/private/var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/Payload/myApp.app/myApp
]
+ /usr/libexec/PlistBuddy -c Set :get-task-allow NO /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/entitlements_plistt2Evi2T_
Program /usr/libexec/PlistBuddy returned 0 : []
+ /usr/bin/plutil -lint /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/entitlements_plistt2Evi2T_
Program /usr/bin/plutil returned 0 : [/var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/entitlements_plistt2Evi2T_: OK
]
### Codesigning '/Users/gabt/Library/MobileDevice/Provisioning Profiles/FA16C6A9-603C-46A6-8B98-F367A6B056CD.mobileprovision' with 'iPhone Distribution: Grant Abt'
+ /usr/bin/codesign --force --preserve-metadata --sign iPhone Distribution: Grant Abt --resource-rules=/var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/Payload/myApp.app/ResourceRules.plist --entitlements /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/entitlements_plistt2Evi2T_ /var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/Payload/myApp.app
Program /usr/bin/codesign returned 1 : [/var/folders/jw/s5ky0r1n34322jt4pw3047m00000gn/T/y30BrfbtxS/Payload/myApp.app/ResourceRules.plist: cannot read resources
]
error: codesign failed with error 1
Had the same problem today..
The "Code Signing Resource Rules Path" was missing in the PROJECT - Build Settings
...
Opened the "Build Settings" tab of your project.
Searched "Code Signing Resource Rules Path", it was empty for me
and added
$(SDKROOT)/ResourceRules.plist
credits goes to Adams Blair who described this problem with SDK2.2
yeah, i think it's xcode6.1 problem (or bug?)
you can
1.add $(SDKROOT)/ResourceRules.plist to "Code Signing Resource Rules Path"
or
2.use xcode-select back to 6.01 build
or
3.sign argument without "sign=iPhone Distribution: Grant Abt"
to work
Check your code signing profiles again. Your developer profile should be set to the debug and for the release you must set your distribution profile. Make sure you select any iOS SDK under each category and set the respective profiles for them as well.
Encounter this issue when testing with Xcode 6.1 beta version. Back to Xcode 6.0.1 works.

Resources