Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
isJailBroken/IsJailBroken/Extension/UIDevice+JailBroken.swift
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
96 lines (87 sloc)
3.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIDevice+JailBroken.swift | |
// IsJailBroken | |
// | |
// Created by Vineet Choudhary on 07/02/20. | |
// Copyright © 2020 Developer Insider. All rights reserved. | |
// | |
import Foundation | |
import UIKit | |
extension UIDevice { | |
var isSimulator: Bool { | |
return TARGET_OS_SIMULATOR != 0 | |
} | |
var isJailBroken: Bool { | |
get { | |
if UIDevice.current.isSimulator { return false } | |
if JailBrokenHelper.hasCydiaInstalled() { return true } | |
if JailBrokenHelper.isContainsSuspiciousApps() { return true } | |
if JailBrokenHelper.isSuspiciousSystemPathsExists() { return true } | |
return JailBrokenHelper.canEditSystemFiles() | |
} | |
} | |
} | |
private struct JailBrokenHelper { | |
static func hasCydiaInstalled() -> Bool { | |
return UIApplication.shared.canOpenURL(URL(string: "cydia://")!) | |
} | |
static func isContainsSuspiciousApps() -> Bool { | |
for path in suspiciousAppsPathToCheck { | |
if FileManager.default.fileExists(atPath: path) { | |
return true | |
} | |
} | |
return false | |
} | |
static func isSuspiciousSystemPathsExists() -> Bool { | |
for path in suspiciousSystemPathsToCheck { | |
if FileManager.default.fileExists(atPath: path) { | |
return true | |
} | |
} | |
return false | |
} | |
static func canEditSystemFiles() -> Bool { | |
let jailBreakText = "Developer Insider" | |
do { | |
try jailBreakText.write(toFile: jailBreakText, atomically: true, encoding: .utf8) | |
return true | |
} catch { | |
return false | |
} | |
} | |
/** | |
Add more paths here to check for jail break | |
*/ | |
static var suspiciousAppsPathToCheck: [String] { | |
return ["/Applications/Cydia.app", | |
"/Applications/blackra1n.app", | |
"/Applications/FakeCarrier.app", | |
"/Applications/Icy.app", | |
"/Applications/IntelliScreen.app", | |
"/Applications/MxTube.app", | |
"/Applications/RockApp.app", | |
"/Applications/SBSettings.app", | |
"/Applications/WinterBoard.app" | |
] | |
} | |
static var suspiciousSystemPathsToCheck: [String] { | |
return ["/Library/MobileSubstrate/DynamicLibraries/LiveClock.plist", | |
"/Library/MobileSubstrate/DynamicLibraries/Veency.plist", | |
"/private/var/lib/apt", | |
"/private/var/lib/apt/", | |
"/private/var/lib/cydia", | |
"/private/var/mobile/Library/SBSettings/Themes", | |
"/private/var/stash", | |
"/private/var/tmp/cydia.log", | |
"/System/Library/LaunchDaemons/com.ikey.bbot.plist", | |
"/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist", | |
"/usr/bin/sshd", | |
"/usr/libexec/sftp-server", | |
"/usr/sbin/sshd", | |
"/etc/apt", | |
"/bin/bash", | |
"/Library/MobileSubstrate/MobileSubstrate.dylib" | |
] | |
} | |
} |