There is a private API SBDataReset in SpringboardServices private framework. It wipes all data.
You can check the following code for example how to use it.
An application which uses this API should have "com.apple.springboard.wipedevice" entitlement to work.
BTW. One more alternative is to use MDM protocol. It has a wipe command. However, it requires way more machinery (MDM server, enroll a user).
Update 1
It looks like sample code in the link is out date. I looked into Preferences and couple of other pieces of iOS software which uses SBDataReset and it looks like new argument was introduced to SBDataReset.
Try following code (sorry, I don't have jailbroken iOS device right now, so I can't try it on my own)
#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>
#include <dlfcn.h>
#include <stdio.h>
// Framework Paths
#define SBSERVPATH "/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices"
#define UIKITPATH "/System/Library/Framework/UIKit.framework/UIKit"
#define WIPE_MODE_NORMAL 4
int main(int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Fetch the SpringBoard server port
mach_port_t *p;
void *uikit = dlopen(UIKITPATH, RTLD_LAZY);
int (*SBSSpringBoardServerPort)() =
dlsym(uikit, "SBSSpringBoardServerPort");
p = SBSSpringBoardServerPort();
dlclose(uikit);
// Getting DataReset proc
void *sbserv = dlopen(SBSERVPATH, RTLD_LAZY);
int (*dataReset)(mach_port_t* port, int wipeMode) = dlsym(sbserv, "SBDataReset");
dataReset(p, WIPE_MODE_NORMAL);
dlclose(sbserv);
[pool release];
}
Please notice, that there is second parameter for SBDataReset function.
It looks like 4 is normal wipe mode and 6 is brick wipe mode.
DISCLAIMER This code is provided AS IS. I have no idea what will happen if device will be wiped in brick mode.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…