Skip to content

Instantly share code, notes, and snippets.

View jeffniblack's full-sized avatar

Jeff Niblack jeffniblack

  • Minneapolis, MN
View GitHub Profile
@jeffniblack
jeffniblack / gist:3743902
Created September 18, 2012 15:57
fork check for jailbroken iOS devices
static inline int
fork_check(void)
__attribute__((always_inline));
int fork_check(void) {
int result = fork();
if (!result) {
exit(0);
}
@jeffniblack
jeffniblack / gist:3743906
Created September 18, 2012 15:59
fstab check for jailbroken iOS devices
#include <sys/stat.h>
static inline int
fstab_check(void)
__attribute__((always_inline));
int fstab_check(void) {
struct stat sb;
int result = 1;
@jeffniblack
jeffniblack / gist:3743914
Created September 18, 2012 16:00
files check for jailbroken iOS devices
static inline int
files_check(void)
__attribute__((always_inline));
int files_check(void) {
struct stat sb;
int result = 0;
if (stat("/bin/bash", &sb) == 0) {
@jeffniblack
jeffniblack / gist:3743917
Created September 18, 2012 16:00
symbolic link check for jailbroken iOS devices
static inline int
symbolic_link_check(void)
__attribute__((always_inline));
int symbolic_link_check(void) {
struct stat sb;
int result = 0;
if (lstat("/Applications", &sb) == 0) {
@jeffniblack
jeffniblack / gist:3743918
Created September 18, 2012 16:01
main for iOS jailbreak detection
int main(int argc, char *argv[])
{
bool lifeIsGood = YES; //assume things will be good
//do checks here...finding something bad sets lifeIsGood to NO
if ((fork_check())
|| (files_check())
|| (fstab_check())
|| (symbolic_link_check())) {
lifeIsGood = NO;
@jeffniblack
jeffniblack / NSDate+DateUtils.h
Created September 18, 2012 16:05
NSDate+DateUtils
@interface NSDate (DateUtils)
- (NSDate *)toLocalTime;
- (NSString *)toLocalShortTime;
- (NSString *)toLocalShortDate;
- (NSString *)toLocalShortDate2;
- (NSString *)toLocalHeaderDate;
- (NSString *)toLocalArticleDetailDate;
@end