APP已获得ROOT权限,但依旧打不开keychain-2.db数据库

最近在做一个项目,需要清除APP的keychains,也就是需要清理/var/Keychains/keychain-2.db里的相应数据,但前提得能打开keychain-2.db这个文件。

首先我根据论坛的这个教程成功获取Root权限,并也已确定能进行一些Root 权限的操作。[在iOS上以root身份运行守护进程]

然后使用管理员分享的越狱iOS清痕核心代码里面的:

    sqlite3 *database;
    int openResult = sqlite3_open("/var/Keychains/keychain-2.db", &database);
    if (openResult == SQLITE_OK)
    {
            int execResult = sqlite3_exec(database, "DELETE FROM genp WHERE agrp<>'apple'", NULL, NULL, NULL);
            if (execResult != SQLITE_OK) NSLog(@"iOSRE: Failed to exec DELETE FROM genp WHERE agrp<>'apple', error %d", execResult);
            execResult = sqlite3_exec(database, "DELETE FROM cert WHERE agrp<>'lockdown-identities'", NULL, NULL, NULL);
            if (execResult != SQLITE_OK) NSLog(@"iOSRE: Failed to exec DELETE FROM cert WHERE agrp<>'lockdown-identities', error %d", execResult);
            execResult = sqlite3_exec(database, "DELETE FROM keys WHERE agrp<>'lockdown-identities'", NULL, NULL, NULL);
            if (execResult != SQLITE_OK) NSLog(@"iOSRE: Failed to exec DELETE FROM keys WHERE agrp<>'lockdown-identities'', error %d", execResult);
            execResult = sqlite3_exec(database, "DELETE FROM inet", NULL, NULL, NULL);
            if (execResult != SQLITE_OK) NSLog(@"iOSRE: Failed to exec DELETE FROM inet, error %d", execResult);
            execResult = sqlite3_exec(database, "DELETE FROM sqlite_sequence", NULL, NULL, NULL);
            if (execResult != SQLITE_OK) NSLog(@"iOSRE: Failed to exec DELETE FROM sqlite_sequence, error %d", execResult);
            sqlite3_close(database);
    }
    else NSLog(@"iOSRE: Failed to open /var/Keychains/keychain-2.db, error %d", openResult);

结果打开keychain-2.db依然失败,openResult返回值是14。

然后我手动用iFile将/var/Keychains/keychain-2.db 的Keychains文件夹所有权设为Root并打开应用到所有层级,这时才能打开keychain-2.db这个数据库:

但是我的目的是像改机软件那样,实现一键点击就可以清理keychains。求问大神们怎么解决,我应该还要怎样做?

@snakeninny ban吗

1 个赞

算了,他问的都是技术细节,帖子封掉,人就别ban了

1 个赞