0

I want to prevent a user to fake the GPS coordinate, there is an app that can be run to fake the GPS if the iPhone is jailbroken. so to prevent this issue I want to check if the user is jailbroken or not, if the user uses the jailbroken iPhone, I will force close the app.

how to do that in Swift ? I can't find it in stackoverflow so far

Alexa289
  • 8,089
  • 10
  • 74
  • 178
  • Did you check https://stackoverflow.com/questions/413242/how-do-i-detect-that-an-ios-app-is-running-on-a-jailbroken-phone ? – Martin R Apr 06 '18 at 07:41
  • Look at https://stackoverflow.com/questions/6530364/how-to-detect-that-the-app-is-running-on-a-jailbroken-device – Ankit Jayaswal Apr 06 '18 at 07:41
  • Just a question because i found that interesting, isn't the ""jailbroke-detection system"" hardware related ? In my opinion it would be pretty insecure, to say the least, if it was soft oriented. – N.K Apr 06 '18 at 07:42

1 Answers1

-2

This Jailbreak medium article provided a very good rundown

if TARGET_IPHONE_SIMULATOR != 1

{

// Check 1 : existence of files that are common for jailbroken devices

if FileManager.default.fileExists(atPath: “/Applications/Cydia.app”)

|| FileManager.default.fileExists(atPath: “/Library/MobileSubstrate/MobileSubstrate.dylib”)

|| FileManager.default.fileExists(atPath: “/bin/bash”)

|| FileManager.default.fileExists(atPath: “/usr/sbin/sshd”)

|| FileManager.default.fileExists(atPath: “/etc/apt”)

|| FileManager.default.fileExists(atPath: “/private/var/lib/apt/”)

|| UIApplication.shared.canOpenURL(URL(string:”cydia://package/com.example.package”)!)

{

return true

}

// Check 2 : Reading and writing in system directories (sandbox violation)

let stringToWrite = “Jailbreak Test”

do

{

try stringToWrite.write(toFile:”/private/JailbreakTest.txt”, atomically:true, encoding:String.Encoding.utf8)

//Device is jailbroken

return true

}catch

{

return false

}

}else

{

return false

}
Happiehappie
  • 1,084
  • 2
  • 13
  • 26