越狱iOS 6.x打开命令行

TBI*_*_RO 3 command jailbreak ios

在iOS 6.x之前,我曾经open package_id在iOS设备上从命令行打开一个应用程序.在iOS 6.x上如果我使用此命令SpringBoard崩溃.Open可以从BigBoss获得,作者是Conrad Kramer.

是否有替代或修复openBigBoss 的命令?

Nat*_*ate 7

更新:

看起来原版/usr/bin/open已经在Cydia上针对iOS 6进行了更新,所以我建议你先尝试一下.


原答案:

我也想念open!但是,在iOS 6更新之前,您可以构建自己的非图形应用程序(只是一个main程序,而不是一个程序UIApplicationMain())并自己做同样的事情.

我将跳过解析命令行参数int main(int argc, char *argv[],但是一旦你知道要打开的应用程序的Bundle Id(CFBundleIdentifier),打开SpringBoardServices私有框架,并使用它来启动应用程序:

#include <dlfcn.h>
#define SBSERVPATH "/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices"

-(void) openApp: (NSString*) bundleId {

    // the SpringboardServices.framework private framework can launch apps,
    //  so we open it dynamically and find SBSLaunchApplicationWithIdentifier()
    void* sbServices = dlopen(SBSERVPATH, RTLD_LAZY);
    int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
    int result = SBSLaunchApplicationWithIdentifier((__bridge CFStringRef)bundleId, false);
    dlclose(sbServices);
}
Run Code Online (Sandbox Code Playgroud)

此代码要求com.apple.springboard.launchapplications命令行程序的权利以mobile用户身份成功使用它. 请参阅此处以添加权利.您需要可执行文件的entitlements.xml文件,如下所示:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>com.apple.springboard.launchapplications</key>
        <true/>
    </dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

然后用它签名

ldid -Sentitlements.xml MyCommandLineTool
Run Code Online (Sandbox Code Playgroud)

注意:我没有对此进行测试,但是这个答案指出使用权利的替代方法是以root身份运行命令.