如何使用命令卸载插件

  • (void)cellBtnClicked {

    // 拼接需要执行的命令
    NSString *command = @“killall -9 SpringBoard”;

    // 使用 NSTask 执行命令
    NSTask *task = [[NSTask alloc] init];
    [task setLaunchPath:@“/bin/bash”];
    [task setArguments:@[@“-c”, command]];

    NSPipe *pipe = [NSPipe pipe];
    [task setStandardOutput:pipe];
    [task setStandardError:pipe];

    [task launch];

    NSFileHandle *file = [pipe fileHandleForReading];
    NSData *data = [file readDataToEndOfFile];
    NSString *output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    NSLog(@“Output: %@”, output);

}

  • (void)uninstallPackage {

    // 拼接需要执行的命令
    NSString *command = @“dpkg -r com.uncj.test”;

    // 使用 NSTask 执行命令
    NSTask *task = [[NSTask alloc] init];
    [task setLaunchPath:@“/bin/bash”];
    [task setArguments:@[@“-c”, command]];

    NSPipe *pipe = [NSPipe pipe];
    [task setStandardOutput:pipe];
    [task setStandardError:pipe];

    [task launch];

    NSFileHandle *file = [pipe fileHandleForReading];
    NSData *data = [file readDataToEndOfFile];
    NSString *output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    NSLog(@“Output: %@”, output);

}

上面两个方法分别是 使用task 注销桌面跟卸载命令。注销桌面是正常没问题的,但是使用dpkg 卸载命令打印是没有权限,于是我使用task 执行本地 sh文件,手机会直接安全模式,使用rm命令也会安全模式,我手机牛磺酸越狱,也装了dkpg的插件。不想使用越狱商店去手动卸载插件,想在插件内写一个卸载,想问一下还有什么使用代码的方法可以实现卸载插件。

安全模式应该是插件报错导致的,这个是注入SpringBoard的插件?

对的

那应该是你代码报错了,可以连接控制台看下报错信息.
你可以自己写个bin签上权限来执行
附上ent.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>allow-obliterate-device</key>
        <true/>
        <key>application-identifier</key>
        <string>com.test</string>
        <key>aps-connection-initiate</key>
        <true/>
        <key>backupd-connection-initiate</key>
        <true/>
        <key>checklessPersistentURLTranslation</key>
        <true/>
        <key>com.apple.BTServer.allowRestrictedServices</key>
        <true/>
        <key>com.apple.BTServer.programmaticPairing</key>
        <true/>
        <key>com.apple.CallHistory.sync.allow</key>
        <true/>
        <key>com.apple.CommCenter.fine-grained</key>
        <array>
            <string>spi</string>
            <string>preferences-reset</string>
            <string>voice</string>
            <string>identity</string>
            <string>phone</string>
            <string>carrier-settings</string>
        </array>
        <key>com.apple.Contacts.database-allow</key>
        <true/>
        <key>com.apple.CoreRoutine.LocationOfInterest</key>
        <true/>
        <key>com.apple.MobileInternetSharing.allow</key>
        <true/>
        <key>com.apple.QuartzCore.displayable-context</key>
        <true/>
        <key>com.apple.QuartzCore.global-capture</key>
        <true/>
        <key>com.apple.QuartzCore.secure-capture</key>
        <true/>
        <key>com.apple.QuartzCore.secure-mode</key>
        <true/>
        <key>com.apple.SystemConfiguration.SCDynamicStore-write-access</key>
        <true/>
        <key>com.apple.SystemConfiguration.SCPreferences-write-access</key>
        <array>
            <string>com.apple.AutoWake.xml</string>
            <string>preferences.plist</string>
            <string>com.apple.radios.plist</string>
        </array>
        <key>com.apple.accounts.appleaccount.fullaccess</key>
        <true/>
        <key>com.apple.assistant.client</key>
        <true/>
        <key>com.apple.authkit.writer.internal</key>
        <true/>
        <key>com.apple.avfoundation.allow-still-image-capture-shutter-sound-manipulation</key>
        <true/>
        <key>com.apple.avfoundation.allow-system-wide-context</key>
        <true/>
        <key>com.apple.avfoundation.allows-set-output-device</key>
        <true/>
        <key>com.apple.backboard.client</key>
        <true/>
        <key>com.apple.backboard.displaybrightness</key>
        <true/>
        <key>com.apple.backboardd.cancelsTouchesInHostedContent</key>
        <true/>
        <key>com.apple.backboardd.hostCanRequireTouchesFromHostedContent</key>
        <true/>
        <key>com.apple.backboardd.lastUserEventTime</key>
        <true/>
        <key>com.apple.backboardd.launchapplications</key>
        <true/>
        <key>com.apple.backboardd.touchDeliveryObservation</key>
        <true/>
        <key>com.apple.bulletinboard</key>
        <true/>
        <key>com.apple.bulletinboard.dataprovider</key>
        <true/>
        <key>com.apple.bulletinboard.observer</key>
        <true/>
        <key>com.apple.bulletinboard.serverconduit</key>
        <true/>
        <key>com.apple.bulletinboard.settings</key>
        <true/>
        <key>com.apple.bulletinboard.systemstate</key>
        <true/>
        <key>com.apple.bulletinboard.utilities</key>
        <true/>
        <key>com.apple.cards.all-access</key>
        <true/>
        <key>com.apple.coreaudio.allow-amr-decode</key>
        <true/>
        <key>com.apple.coreaudio.allow-speex-codec</key>
        <true/>
        <key>com.apple.coreduetd.allow</key>
        <true/>
        <key>com.apple.coreduetd.batterysaver.allow</key>
        <true/>
        <key>com.apple.coremedia.allow-pre-wiring-pixel-buffers</key>
        <true/>
        <key>com.apple.coremedia.allow-protected-content-playback</key>
        <true/>
        <key>com.apple.coremedia.virtualdisplaysession</key>
        <true/>
        <key>com.apple.developer.extension-host.widget-extension</key>
        <true/>
        <key>com.apple.developer.homekit</key>
        <true/>
        <key>com.apple.developer.ubiquity-kvstore-identifier</key>
        <string>com.apple.springboard</string>
        <key>com.apple.duet.activityscheduler.allow</key>
        <true/>
        <key>com.apple.duet.expertcenter.consumer</key>
        <true/>
        <key>com.apple.fileprovider.enumerate</key>
        <true/>
        <key>com.apple.fileprovider.fetch-url</key>
        <true/>
        <key>com.apple.frontboard.app-badge-value-access</key>
        <true/>
        <key>com.apple.frontboard.launchapplications</key>
        <true/>
        <key>com.apple.frontboard.shutdown</key>
        <true/>
        <key>com.apple.geoservices.navigation_info</key>
        <true/>
        <key>com.apple.homekit.private-spi-access</key>
        <true/>
        <key>com.apple.iapd.accessibility</key>
        <true/>
        <key>com.apple.icloud.findmydeviced.access</key>
        <true/>
        <key>com.apple.icloud.fmfd.access</key>
        <true/>
        <key>com.apple.imagent</key>
        <true/>
        <key>com.apple.imagent.av</key>
        <true/>
        <key>com.apple.imagent.chat</key>
        <true/>
        <key>com.apple.intents.extension.discovery</key>
        <true/>
        <key>com.apple.itunesstored.private</key>
        <true/>
        <key>com.apple.keystore.device</key>
        <true/>
        <key>com.apple.keystore.lockassertion</key>
        <true/>
        <key>com.apple.keystore.stash.access</key>
        <true/>
        <key>com.apple.launchservices.clearadvertisingid</key>
        <true/>
        <key>com.apple.locationd.activity</key>
        <true/>
        <key>com.apple.locationd.authorizeapplications</key>
        <true/>
        <key>com.apple.locationd.effective_bundle</key>
        <true/>
        <key>com.apple.locationd.prompt_behavior</key>
        <true/>
        <key>com.apple.locationd.region_proxy_service</key>
        <true/>
        <key>com.apple.locationd.status</key>
        <true/>
        <key>com.apple.locationd.usage_oracle</key>
        <true/>
        <key>com.apple.locationd.vehicle_data</key>
        <true/>
        <key>com.apple.lsapplicationproxy.deviceidentifierforvendor</key>
        <true/>
        <key>com.apple.managedconfiguration.mdmd-access</key>
        <true/>
        <key>com.apple.managedconfiguration.profiled-access</key>
        <true/>
        <key>com.apple.mediastream.mstreamd-access</key>
        <true/>
        <key>com.apple.messages.composeclient</key>
        <true/>
        <key>com.apple.mkb.usersession.info</key>
        <true/>
        <key>com.apple.mkb.usersession.loginwindow</key>
        <true/>
        <key>com.apple.mobile.deleted.AllowFreeSpace</key>
        <true/>
        <key>com.apple.mobile.keybagd.UserManager.logoutcritical</key>
        <true/>
        <key>com.apple.mobilemail.mailservices</key>
        <true/>
        <key>com.apple.multitasking.systemappassertions</key>
        <true/>
        <key>com.apple.multitasking.termination</key>
        <true/>
        <key>com.apple.nfcd.hwmanager</key>
        <true/>
        <key>com.apple.nfcd.seshat</key>
        <true/>
        <key>com.apple.notificationcenter.widgetcontrollerhascontent</key>
        <true/>
        <key>com.apple.payment.configuration</key>
        <true/>
        <key>com.apple.payment.presentation</key>
        <true/>
        <key>com.apple.private.CallHistory.read</key>
        <true/>
        <key>com.apple.private.CoreAuthentication.SPI</key>
        <true/>
        <key>com.apple.private.InstallCoordination.allowed</key>
        <true/>
        <key>com.apple.private.MobileContainerManager.otherIdLookup</key>
        <true/>
        <key>com.apple.private.MobileGestalt.AllowedProtectedKeys</key>
        <array>
            <string>InverseDeviceID</string>
        </array>
        <key>com.apple.private.accounts.allaccounts</key>
        <true/>
        <key>com.apple.private.appleaccount.app-hidden-from-icloud-settings</key>
        <true/>
        <key>com.apple.private.attentionawareness</key>
        <true/>
        <key>com.apple.private.attentionawareness.poll</key>
        <true/>
        <key>com.apple.private.bmk.allow</key>
        <true/>
        <key>com.apple.private.canGetAppLinkInfo</key>
        <true/>
        <key>com.apple.private.canModifyAppLinkPermissions</key>
        <true/>
        <key>com.apple.private.carkit</key>
        <true/>
        <key>com.apple.private.carkit.app</key>
        <true/>
        <key>com.apple.private.carkit.dnd</key>
        <true/>
        <key>com.apple.private.clouddocs.can-grant-access-to-document</key>
        <true/>
        <key>com.apple.private.contactsui</key>
        <true/>
        <key>com.apple.private.corerecents</key>
        <true/>
        <key>com.apple.private.coreservices.canopenactivity</key>
        <true/>
        <key>com.apple.private.coreservices.lsuseractivityd.bestappsuggestion</key>
        <true/>
        <key>com.apple.private.corespotlight.search.internal</key>
        <true/>
        <key>com.apple.private.externalaccessory.showallaccessories</key>
        <true/>
        <key>com.apple.private.game-center</key>
        <array>
            <string>Account</string>
            <string>Games</string>
        </array>
        <key>com.apple.private.game-center.bypass-authentication</key>
        <true/>
        <key>com.apple.private.healthkit</key>
        <true/>
        <key>com.apple.private.healthkit.read_authorization_override</key>
        <array>
            <string>HKCategoryTypeIdentifierSleepAnalysis</string>
        </array>
        <key>com.apple.private.healthkit.source_override</key>
        <string>com.apple.mobiletimer</string>
        <key>com.apple.private.healthkit.write_authorization_override</key>
        <array>
            <string>HKCategoryTypeIdentifierSleepAnalysis</string>
        </array>
        <key>com.apple.private.hid.client.event-dispatch</key>
        <true/>
        <key>com.apple.private.hid.client.service-protected</key>
        <true/>
        <key>com.apple.private.hid.manager.client</key>
        <true/>
        <key>com.apple.private.icfcallserver</key>
        <true/>
        <key>com.apple.private.ids.idsquery</key>
        <true/>
        <key>com.apple.private.ids.messaging</key>
        <array>
            <string>com.apple.private.alloy.bulletinboard</string>
            <string>com.apple.madrid</string>
            <string>com.apple.private.alloy.siri.phrasespotter</string>
        </array>
        <key>com.apple.private.ids.messaging.urgent-priority</key>
        <array>
            <string>com.apple.private.alloy.bulletinboard</string>
            <string>com.apple.private.alloy.siri.phrasespotter</string>
        </array>
        <key>com.apple.private.ids.registration-reset</key>
        <true/>
        <key>com.apple.private.imavcore.imavagent</key>
        <true/>
        <key>com.apple.private.imcore.imdpersistence.database-access</key>
        <true/>
        <key>com.apple.private.imcore.spi.database-access</key>
        <true/>
        <key>com.apple.private.in-app-payments</key>
        <true/>
        <key>com.apple.private.kernel.darkboot</key>
        <true/>
        <key>com.apple.private.kernel.jetsam</key>
        <true/>
        <key>com.apple.private.librarian.can-get-application-info</key>
        <true/>
        <key>com.apple.private.lockdown.finegrained-get</key>
        <array>
            <string>NULL/ActivationState</string>
            <string>NULL/BrickState</string>
            <string>NULL/SBLockdownEverRegisteredKey</string>
            <string>com.apple.xcode.developerdomain/DeveloperStatus</string>
            <string>NULL/BuildExpireTime</string>
        </array>
        <key>com.apple.private.lockdown.finegrained-remove</key>
        <array>
            <string>com.apple.mobile.iTunes.store/AppleID</string>
            <string>com.apple.mobile.data_sync/Contacts</string>
            <string>com.apple.mobile.data_sync/Calendars</string>
            <string>com.apple.mobile.data_sync/Bookmarks</string>
            <string>com.apple.mobile.data_sync/Mail Accounts</string>
        </array>
        <key>com.apple.private.mis.online_auth_agent</key>
        <true/>
        <key>com.apple.private.mobilesafari.searchengine</key>
        <true/>
        <key>com.apple.private.network.socket-delegate</key>
        <true/>
        <key>com.apple.private.networkextension.configuration</key>
        <true/>
        <key>com.apple.private.persona.read</key>
        <true/>
        <key>com.apple.private.replay-kit</key>
        <true/>
        <key>com.apple.private.security.container-manager</key>
        <true/>
        <key>com.apple.private.suggestions.contacts</key>
        <true/>
        <key>com.apple.private.suggestions.events</key>
        <true/>
        <key>com.apple.private.system-keychain</key>
        <true/>
        <key>com.apple.private.tcc.allow</key>
        <array>
            <string>kTCCServiceAddressBook</string>
            <string>kTCCServiceCalendar</string>
            <string>kTCCServiceReminders</string>
            <string>kTCCServicePhotos</string>
            <string>kTCCServicePhotosAdd</string>
            <string>kTCCServiceMediaLibrary</string>
            <string>kTCCServiceMicrophone</string>
            <string>kTCCServiceCamera</string>
            <string>kTCCServiceWillow</string>
            <string>kTCCServiceFaceID</string>
        </array>
        <key>com.apple.private.tcc.manager</key>
        <true/>
        <key>com.apple.private.tty.settings</key>
        <true/>
        <key>com.apple.private.ubiquity-kvstore-access</key>
        <array>
            <string>com.apple.weather</string>
            <string>com.apple.stocks</string>
            <string>com.apple.backboardd</string>
            <string>com.apple.Accessibility</string>
            <string>com.apple.Accessibility.SwitchControl</string>
            <string>com.apple.Accessibility.TouchAccommodations</string>
            <string>com.apple.AssistiveTouch</string>
            <string>com.apple.HearingAids</string>
            <string>com.apple.SpeakSelection</string>
            <string>com.apple.VoiceOverTouch</string>
            <string>com.apple.ZoomTouch</string>
        </array>
        <key>com.apple.purplebuddy.budd.access</key>
        <true/>
        <key>com.apple.remotenotification.access</key>
        <true/>
        <key>com.apple.remotenotification.preferences</key>
        <true/>
        <key>com.apple.securebackupd.access</key>
        <true/>
        <key>com.apple.security.application-groups</key>
        <array>
            <string>group.com.apple.weather</string>
            <string>group.com.apple.stocks</string>
        </array>
        <key>com.apple.security.system-container</key>
        <true/>
        <key>com.apple.security.system-groups</key>
        <array>
            <string>systemgroup.com.apple.sharedpclogging</string>
            <string>systemgroup.com.apple.regulatory_images</string>
            <string>systemgroup.com.apple.lsd</string>
        </array>
        <key>com.apple.sharing.Client</key>
        <true/>
        <key>com.apple.sharing.CoordinatedAlerts</key>
        <true/>
        <key>com.apple.siri.client_lite</key>
        <true/>
        <key>com.apple.sos.trigger</key>
        <true/>
        <key>com.apple.springboard-ui.client</key>
        <true/>
        <key>com.apple.springboard.activateRemoteAlert</key>
        <true/>
        <key>com.apple.springboard.activateawayviewplugins</key>
        <true/>
        <key>com.apple.springboard.allowallcallurls</key>
        <true/>
        <key>com.apple.springboard.application-removability.proxy</key>
        <true/>
        <key>com.apple.springboard.opensensitiveurl</key>
        <true/>
        <key>com.apple.springboard.openurlswhenlocked</key>
        <true/>
        <key>com.apple.springboard.secureAppAssertion</key>
        <true/>
        <key>com.apple.springboard.setbadgestring</key>
        <true/>
        <key>com.apple.springboard.shortcutitems.fullaccess</key>
        <true/>
        <key>com.apple.springboard.statusbarstyleoverrides</key>
        <true/>
        <key>com.apple.symptom_analytics.query</key>
        <true/>
        <key>com.apple.symptom_analytics.refresh</key>
        <true/>
        <key>com.apple.symptoms.NetworkOfInterest</key>
        <true/>
        <key>com.apple.telephonyutilities.callservicesd</key>
        <array>
            <string>access-calls</string>
            <string>modify-calls</string>
            <string>access-call-providers</string>
            <string>access-moments</string>
        </array>
        <key>com.apple.timed</key>
        <true/>
        <key>com.apple.tzlink.allow</key>
        <true/>
        <key>com.apple.ui-services-discovery</key>
        <true/>
        <key>com.apple.usernotification.notificationschedulerproxy</key>
        <true/>
        <key>com.apple.videoconference.allow-conferencing</key>
        <true/>
        <key>com.apple.visualvoicemail.client</key>
        <true/>
        <key>com.apple.voiceservices.tts.customvoice</key>
        <true/>
        <key>com.apple.voicetrigger.voicetriggerservice</key>
        <true/>
        <key>com.apple.watchlist.private</key>
        <true/>
        <key>com.apple.wifi.manager-access</key>
        <true/>
        <key>com.apple.private.security.no-container</key>
        <true/>
        <key>platform-application</key>
        <true/>
        <key>com.apple.private.security.no-sandbox</key>
        <true/>

    </dict>
</plist>

我是直接注入 dylib的 没有用ipa呢

注入backboardd试试呢

我执行 killall -9 SpringBoard 就没问题也不会安全模式,还有什么办法可以卸载插件吗

我觉得是NSTask不好使,用posix_spawn试试

pid_t pid;
char *argv[] = {"dpkg", "-r", "com.main.test", NULL};
int status;

status = posix_spawn(&pid, "/usr/bin/dpkg", NULL, NULL, argv, NULL);
if (status == 0) {
    if (waitpid(pid, &status, 0) != -1) {
        printf("Child process exited with status %d\n", status);
    } else {
        perror("waitpid");
    }
} else {
    fprintf(stderr, "posix_spawn: %s\n", strerror(status));
}

我使用这个方法来卸载 没有安全模式,但是也没有卸载成功,是我使用的方式不对么?打印
Child process exited with status 512 这个内容,我查了这是错误退出的意思

  • (int)runCmd:(NSString *)cmd{

    if (getuid()!=0) {
    NSLog(@“app不具备执行能力”);
    return -1;
    }

    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored “-Wc++11-compat-deprecated-writable-strings”
    char *env[] = {
    “PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games”,
    "PS1=\h:\w \u\$ ",
    NULL
    };

    pid_t pid;
    char *rawCmd = StringToChar(cmd);
    char argv[] = {“sh”, “-c”, (char)rawCmd, NULL};
    int status;
    status = posix_spawn(&pid, “/bin/sh”, NULL, NULL, argv, (char **)&env);
    if (status == 0) {
    if (waitpid(pid, &status, 0) == -1) {
    perror(“waitpid”);
    }
    } else {
    NSLog(@“执行命令失败:%@”,[NSString stringWithUTF8String:strerror(status)]);
    }
    free(rawCmd);
    return status;
    #pragma GCC diagnostic pop
    }

执行了 提示 :App 不具备执行能力

我是直接把dylib注入到桌面的 没有ipa应用 是不是就用不了

和应用没关系,我记得sb权限特殊,但是它没有没有root权限

那还有别的方法可以实现卸载么