12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191 |
- //
- // SecurityShield.swift
- // StreamShield
- //
- // Created by Qindi on 31/10/24.
- //
- import Foundation
- import UIKit
- import nuSDKService
- import AVFoundation
- import AVKit
- import CoreTelephony
- import CryptoKit
- import MachO
- import CommonCrypto
- import SystemConfiguration.CaptiveNetwork
- import CoreLocation
- import Network
- public class SecurityShield: NSObject {
-
- static var dispatch: DispatchGroup?
-
- public static func check(appName: String, apiKey: String) {
- Preference.setAppId(value: appName)
- Preference.setAccount(value: apiKey)
- DispatchQueue.global().async {
- do {
- var id = Preference.getConnectionID()
- if id.isEmpty {
- let sDID = UIDevice.current.identifierForVendor?.uuidString ?? "UNK-DEVICE"
- id = String(sDID[sDID.index(sDID.endIndex, offsetBy: -5)...])
- Preference.setConnectionID(value: id)
- }
- if !API.bnuSDKServiceReady() || API.nGetCLXConnState() == 0 {
- let address = getAddressNew(apiKey:Preference.getAccount())
- if address.isEmpty {
- return
- }
- let addressConn = address.components(separatedBy: ":")[0]
- let port = Int(address.components(separatedBy: ":")[1]) ?? 0
- try API.initConnection(sAPIK: apiKey, cbiI: CallBackSS(), sTCPAddr: addressConn, nTCPPort: port, sUserID: id, sStartWH: "09:00")
- while (!API.bnuSDKServiceReady() || API.nGetCLXConnState() == 0) {
- Thread.sleep(forTimeInterval: 1)
- }
- }
- pull()
- } catch {
-
- }
- }
- }
-
- private static func getAddressNew(apiKey: String) -> String {
- var result = ""
- let url = URL(string: "\(Preference.getDomainOpr())dipp/NuN1v3rs3/Qm3r4i0/get_ip_domain?account=\(apiKey)")!
- let urlConfig = URLSessionConfiguration.default
- let sessionDelegate = SelfSignedURLSessionDelegate()
- urlConfig.requestCachePolicy = .returnCacheDataElseLoad
- urlConfig.timeoutIntervalForRequest = 10.0
- urlConfig.timeoutIntervalForResource = 10.0
- let semaphore = DispatchSemaphore(value: 0)
- let task = URLSession(configuration: urlConfig, delegate: sessionDelegate, delegateQueue: nil).dataTask(with: url) {(data, response, error) in
- guard let data = data,
- let url = response?.url,
- let httpResponse = response as? HTTPURLResponse,
- let fields = httpResponse.allHeaderFields as? [String: String] else {
- semaphore.signal()
- return
- }
- let dataEncode = String(data: data, encoding: .utf8)!
- if !dataEncode.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
- let dataDecodeBase64 = String(data: Data(base64Encoded: dataEncode)!, encoding: .utf8)!
- let dataRealDecode = UtilsSS.decrypt(str: dataDecodeBase64)
- do {
- if let jsonData = dataRealDecode.data(using: .utf8), let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any] {
- var newDomain = jsonObject["domain"] as! String
- let jsonAddress = jsonObject["address"] as! [[String: Any]]
- let newIp = jsonAddress[0]["ip"] as! String
- let newPort = jsonAddress[0]["portI"] as! String
- if newDomain.substring(from: newDomain.count-1, to: nil) != "/" {
- newDomain += "/"
- }
- if (newIp+":"+newPort) != Preference.getIpOpr() || newDomain != Preference.getDomainOpr() {
- //check new domain
- if checkNewDomain(newDomain) {
- Preference.setDomainOpr(value: newDomain)
- Preference.setIpPortOpr(value: (newIp+":"+newPort))
- }
- }
- }
- } catch {
-
- }
- }
- semaphore.signal()
- }
- task.resume()
- _ = semaphore.wait(timeout: .distantFuture)
- result = Preference.getIpOpr()
- return result
- }
-
- private static func checkNewDomain(_ newDomain: String) -> Bool {
- var result = false
- let url = URL(string: "\(newDomain)dipp/NuN1v3rs3/Qm3r4i0/get_ip_domain?account=\(Preference.getAccount())")!
- let urlConfig = URLSessionConfiguration.default
- let sessionDelegate = SelfSignedURLSessionDelegate()
- urlConfig.requestCachePolicy = .returnCacheDataElseLoad
- urlConfig.timeoutIntervalForRequest = 10.0
- urlConfig.timeoutIntervalForResource = 10.0
- let semaphore = DispatchSemaphore(value: 0)
- let task = URLSession(configuration: urlConfig, delegate: sessionDelegate, delegateQueue: nil).dataTask(with: url) {(data, response, error) in
- if let httpResponse = response as? HTTPURLResponse {
- if httpResponse.statusCode == 200 {
- guard let url = response?.url,
- let fields = httpResponse.allHeaderFields as? [String: String] else {
- semaphore.signal()
- return
- }
- result = true
- }
- }
- semaphore.signal()
- }
- task.resume()
- _ = semaphore.wait(timeout: .distantFuture)
- return result
- }
-
- private static func pull() {
- let me: String! = SecureUserDefaultsSS.shared.value(forKey: "me") ?? Preference.getConnectionID()
- let tmessage = TMessageSS()
- tmessage.mCode = "SS01"
- tmessage.mStatus = CoreMessage_TMessageUtil.getTID()
- tmessage.mPIN = me
- tmessage.mBodies["Api"] = Preference.getAccount()
- tmessage.mBodies["AAN"] = Preference.getAppId()
- tmessage.mBodies["type"] = "0"
- DispatchQueue.global().async{
- postDataWithCookiesAndUserAgent(from: URL(string: Preference.getDomainOpr() + "get_feature_access_new")!) { data, response, error in
- let response = response as? HTTPURLResponse
- if response?.statusCode != 200 || error != nil {
- return
- }
- if let data = data, let responseString = String(data: data, encoding: .utf8) {
- Process.check(dataSS: responseString)
- } else {
- Process.check(dataSS: "")
- }
- }
- // if let response = Service.writeSync(message: tmessage) {
- // if response.isOk() {
- // let dataResp = response.getBody(key: "A112")
- // Process.check(dataSS: dataResp)
- // } else {
- // Process.check(dataSS: "")
- // }
- // } else {
- // Process.check(dataSS: "")
- // }
- }
- }
-
- static func postDataWithCookiesAndUserAgent(from url: URL, parameter: [String: Any] = [:], parameters: [[String: Any]] = [], isFormData: Bool = false, completion: @escaping (Data?, URLResponse?, Error?) -> ()) {
- let apiKey: String = Preference.getAccount()
- let me: String? = SecureUserDefaultsSS.shared.value(forKey: "me")
- var defaultParameter: [String : Any] = [
- "app_id": Preference.getAppId(),
- "apikey": apiKey,
- ]
- if me != nil {
- defaultParameter["f_pin"] = me
- }
- var jsonArray: [[String: Any]] = []
- if parameters.count == 0 {
- jsonArray.append(defaultParameter)
- } else {
- jsonArray = parameters
- }
- var jsonData: Data!
- if !isFormData {
- jsonData = try? JSONSerialization.data(withJSONObject: parameter.count == 0 ? jsonArray : parameter, options: [])
- } else {
- let formData = parameter.map { "\($0.key)=\($0.value)" }.joined(separator: "&")
- jsonData = formData.data(using: .utf8)
- }
- var request = URLRequest(url: url)
- request.httpMethod = "POST"
- // request.setValue(Utils.getUserAgent(), forHTTPHeaderField: "User-Agent")
- // request.setValue(Utils.getCookiesMobile(), forHTTPHeaderField: "Cookie")
- if isFormData {
- request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
- } else {
- request.setValue("application/json;charset=UTF-8", forHTTPHeaderField: "Content-Type")
- request.setValue("application/json", forHTTPHeaderField: "Accept")
- }
- request.httpBody = jsonData
- let urlConfig = URLSessionConfiguration.default
- urlConfig.timeoutIntervalForRequest = 30.0
- urlConfig.timeoutIntervalForResource = 60.0
- let sessionDelegate = SelfSignedURLSessionDelegate()
- let session = URLSession(configuration: urlConfig, delegate: sessionDelegate, delegateQueue: nil)
- let task = session.dataTask(with: request, completionHandler: completion)
- task.resume()
- }
-
- private static func showToast(message : String, font: UIFont = UIFont.systemFont(ofSize: 12, weight: .medium), controller: UIViewController) {
-
- let toastContainer = UIView(frame: CGRect())
- toastContainer.backgroundColor = controller.traitCollection.userInterfaceStyle == .dark ? .white.withAlphaComponent(0.6) : UIColor.mainColorSS.withAlphaComponent(0.6)
- toastContainer.alpha = 0.0
- toastContainer.layer.cornerRadius = 25;
- toastContainer.clipsToBounds = true
-
- let toastLabel = UILabel(frame: CGRect())
- toastLabel.textColor = controller.traitCollection.userInterfaceStyle == .dark ? .blackDarkModeSS : UIColor.white
- toastLabel.textAlignment = .center;
- toastLabel.font = font
- toastLabel.text = message
- toastLabel.clipsToBounds = true
- toastLabel.numberOfLines = 0
-
- toastContainer.addSubview(toastLabel)
- controller.view.addSubview(toastContainer)
- controller.view.bringSubviewToFront(toastContainer)
-
- toastLabel.translatesAutoresizingMaskIntoConstraints = false
- toastContainer.translatesAutoresizingMaskIntoConstraints = false
-
- let a1 = NSLayoutConstraint(item: toastLabel, attribute: .leading, relatedBy: .equal, toItem: toastContainer, attribute: .leading, multiplier: 1, constant: 15)
- let a2 = NSLayoutConstraint(item: toastLabel, attribute: .trailing, relatedBy: .equal, toItem: toastContainer, attribute: .trailing, multiplier: 1, constant: -15)
- let a3 = NSLayoutConstraint(item: toastLabel, attribute: .bottom, relatedBy: .equal, toItem: toastContainer, attribute: .bottom, multiplier: 1, constant: -15)
- let a4 = NSLayoutConstraint(item: toastLabel, attribute: .top, relatedBy: .equal, toItem: toastContainer, attribute: .top, multiplier: 1, constant: 15)
- toastContainer.addConstraints([a1, a2, a3, a4])
-
- let c1 = NSLayoutConstraint(item: toastContainer, attribute: .leading, relatedBy: .equal, toItem: controller.view, attribute: .leading, multiplier: 1, constant: 65)
- let c2 = NSLayoutConstraint(item: toastContainer, attribute: .trailing, relatedBy: .equal, toItem: controller.view, attribute: .trailing, multiplier: 1, constant: -65)
- let c3 = NSLayoutConstraint(item: toastContainer, attribute: .bottom, relatedBy: .equal, toItem: controller.view, attribute: .bottom, multiplier: 1, constant: -75)
- controller.view.addConstraints([c1, c2, c3])
-
- UIView.animate(withDuration: 0.5, delay: 0.0, options: .curveEaseIn, animations: {
- toastContainer.alpha = 1.0
- }, completion: { _ in
- UIView.animate(withDuration: 0.5, delay: 1.5, options: .curveEaseOut, animations: {
- toastContainer.alpha = 0.0
- }, completion: {_ in
- toastContainer.removeFromSuperview()
- })
- })
- }
- }
- private class Process: NSObject, CLLocationManagerDelegate {
- static func check(dataSS : String) {
- if !dataSS.isEmpty {
- if let jsonArray = try? JSONSerialization.jsonObject(with: dataSS.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
- do {
- for jsonData in jsonArray {
- if jsonData["check_keylogger"]! != nil {
- Preference.setPreventKeylogger(value: jsonData["check_keylogger"]! as! String == "1")
- Preference.setPreventKeyloggerAction(value: jsonData["action"]! as! String)
- Preference.setKeyloggerAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setKeyloggerAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_screen_capture"]! != nil {
- Preference.setPreventScreenCapture(value: jsonData["check_screen_capture"]! as! String == "1")
- Preference.setPreventScreenCaptureAction(value: jsonData["action"]! as! String)
- Preference.setCheckScreenCaptureAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setScreenCaptureAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_emulator"]! != nil {
- Preference.setCheckEmulator(value: jsonData["check_emulator"]! as! String == "1")
- Preference.setCheckEmulatorAction(value: jsonData["action"]! as! String)
- Preference.setCheckEmulatorAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckEmulatorAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_rooted_device"]! != nil {
- Preference.setCheckRooted(value: jsonData["check_rooted_device"]! as! String == "1")
- Preference.setCheckRootedAction(value: jsonData["action"]! as! String)
- Preference.setCheckRootedAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckRootedAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_outdated_os"]! != nil {
- Preference.setCheckOutdatedOs(value: jsonData["check_outdated_os"]! as! String == "1")
- Preference.setCheckOutdatedOsAction(value: jsonData["action"]! as! String)
- Preference.setCheckOutdatedOsAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckOutdatedOsAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["minimum_ios_version"]! != nil {
- Preference.setMinimumOsVersion(value: jsonData["minimum_ios_version"]! as! String)
- }
- if jsonData["check_sum"]! != nil {
- Preference.setCheckTempering(value: jsonData["check_sum"]! as! String == "1")
- Preference.setCheckTemperingAction(value: jsonData["action"]! as! String)
- Preference.setCheckTemperingAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckTemperingAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_hook"]! != nil {
- Preference.setCheckHooked(value: jsonData["check_hook"]! as! String == "1")
- Preference.setCheckHookedAction(value: jsonData["action"]! as! String)
- Preference.setCheckHookedAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckHookedAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_usb_debugging"]! != nil {
- Preference.setCheckDebugging(value: jsonData["check_usb_debugging"]! as! String == "1")
- Preference.setCheckDebuggingAction(value: jsonData["action"]! as! String)
- Preference.setCheckDebuggingAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckDebuggingAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_screen_casting"]! != nil {
- Preference.setCheckScreenCasting(value: jsonData["check_screen_casting"]! as! String == "1")
- Preference.setCheckScreenCastingAction(value: jsonData["action"]! as! String)
- Preference.setCheckScreenCastingAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckScreenCastingAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_screen_overlay"]! != nil {
- Preference.setCheckScreenOverlay(value: jsonData["check_screen_overlay"]! as! String == "1")
- Preference.setCheckScreenOverlayAction(value: jsonData["action"]! as! String)
- Preference.setCheckScreenOverlayAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckScreenOverlayAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_call_forwarding"]! != nil {
- Preference.setCheckCallForward(value: jsonData["check_call_forwarding"]! as! String == "1")
- Preference.setCheckCallForwardAction(value: jsonData["action"]! as! String)
- Preference.setCheckCallForwardAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckCallForwardAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["multiple_login"]! != nil {
- Preference.setCheckMultipleLogin(value: jsonData["multiple_login"]! as! String == "1")
- Preference.setCheckMultipleLoginAction(value: jsonData["action"]! as! String)
- Preference.setCheckMultipleLoginAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckMultipleLoginAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_sim_swap"]! != nil {
- Preference.setCheckSimSwap(value: jsonData["check_sim_swap"]! as! String == "1")
- Preference.setCheckSimSwapAction(value: jsonData["action"]! as! String)
- Preference.setCheckSimSwapAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckSimSwapAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["check_geovelocity"]! != nil {
- Preference.setCheckGeoVelocity(value: jsonData["check_geovelocity"]! as! String == "1")
- Preference.setCheckGeoVelocityAction(value: jsonData["action"]! as! String)
- Preference.setCheckGeoVelocityAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckGeoVelocityAlertMessage(value: jsonData["alert_message"]! as! String)
- }
- if jsonData["behavioral_analysis"]! != nil {
- Preference.setCheckBehaviourAnalysis(value: jsonData["behavioral_analysis"]! as! String == "1")
- Preference.setCheckBehaviourAnalysisAction(value: jsonData["action"]! as! String)
- Preference.setCheckBehaviourAnalysisAlertTitle(value: jsonData["alert_title"]! as! String)
- Preference.setCheckBehaviourAnalysisAlertMessage(value: jsonData["alert_message"]! as! String)
- }
-
- }
- if Preference.getPreventKeylogger() || Preference.getPreventScreenCapture() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getPreventKeylogger() ? Preference.getKeyloggerAlertTitle() : Preference.getCheckScreenCaptureAlertTitle(), message: Preference.getPreventKeylogger() ? Preference.getKeyloggerAlertMessage() : Preference.getScreenCaptureAlertMessage(), preferredStyle: .alert)
- if Preference.getPreventKeyloggerAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE || Preference.getPreventScreenCaptureAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- NotificationCenter.default.addObserver(self, selector: #selector(preventScreenRecording), name: UIScreen.capturedDidChangeNotification, object: nil)
- DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
- if let window = UIApplication.shared.windows.first {
- makeSecure(window: window)
- }
- })
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-101)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- } else {
- if screen != nil {
- screen?.removeFromSuperview()
- }
- }
- subCheck(1)
- } catch {
-
- }
- }
- } else {
- subCheck(1)
- }
- }
-
- private static var screen: UIView!
- @objc static func preventScreenRecording() {
- let isCaptured = UIScreen.main.isCaptured
- if isCaptured {
- blurScreen()
- }
- else {
- removeBlurScreen()
- }
- }
- private static func blurScreen(style: UIBlurEffect.Style = UIBlurEffect.Style.regular) {
- screen = UIScreen.main.snapshotView(afterScreenUpdates: false)
- let blurEffect = UIBlurEffect(style: style)
- let blurBackground = UIVisualEffectView(effect: blurEffect)
- screen.addSubview(blurBackground)
- blurBackground.frame = (screen.frame)
- if let window = UIApplication.shared.windows.first {
- window.addSubview(screen)
- } else {
- }
- }
- private static func removeBlurScreen() {
- screen?.removeFromSuperview()
- }
-
- private static func makeSecure(window: UIWindow) {
- let field = UITextField()
- let view = UIView(frame: CGRect(x: 0, y: 0, width: field.frame.self.width, height: field.frame.self.height))
- let image = UIImageView(image: UIImage.imageWithColorSS(color: .black, size: CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)))
- image.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
- field.isSecureTextEntry = true
- window.addSubview(field)
- view.addSubview(image)
- window.layer.superlayer?.addSublayer(field.layer)
- field.layer.sublayers?.last!.addSublayer(window.layer)
- field.leftView = view
- field.leftViewMode = .always
- }
-
- /*
- * 1: Login from new device / multiple login detected
- * 2: Call redirection
- * 3: Sim change/swap
- * 4: Rooted device
- * 5: Emulator detected
- * 6: Developer mode/debugger (USB/WiFi) detected
- * 7: Screen recording/sharing/capture; keylogger
- * 8: Malware & suspicious apps
- * 9: App cloning
- * 10: Remote wipe
- * 11: Secure Folder
- * 12: Outdated OS
- * 13: Application Backup Detected
- * 14: Checksum / Tempering
- * 15: Screen Overlay
- * 16: Sideload app
- * 17: Behavioral Anomaly Detected
- * 18: Magisk Detected
- * 19: Rooted device by RootBeer
- * 20: Google Play Integrity
- * 21: Geovelocity
- * 22: Hook/Anti Frida Detected
- */
-
- static func subCheck(_ typeSecurity : Int) {
- if typeSecurity == 1 {
- if checkEmulator() {
- sendShieldErrorLog(code: 5)
- return
- }
- subCheck(2)
- } else if typeSecurity == 2 {
- if checkRootedDevice() {
- sendShieldErrorLog(code: 4)
- return
- }
- subCheck(3)
- } else if typeSecurity == 3 {
- if checkOutdatedOS() {
- sendShieldErrorLog(code: 12)
- return
- }
- subCheck(4)
- } else if typeSecurity == 4 {
- if checkTempering() {
- sendShieldErrorLog(code: 14)
- return
- }
- subCheck(5)
- } else if typeSecurity == 5 {
- if checkHooked() {
- sendShieldErrorLog(code: 22)
- return
- }
- subCheck(6)
- } else if typeSecurity == 6 {
- if checkDebugging() {
- sendShieldErrorLog(code: 6)
- return
- }
- subCheck(7)
- } else if typeSecurity == 7 {
- NotificationCenter.default.addObserver(self, selector: #selector(screenDidConnect), name: UIScreen.didConnectNotification, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(screenDidDisconnect), name: UIScreen.didDisconnectNotification, object: nil)
- if checkScreenCasting() {
- sendShieldErrorLog(code: 7)
- return
- }
- subCheck(8)
- } else if typeSecurity == 8 {
- if checkScreenOverlay() {
- sendShieldErrorLog(code: 15)
- return
- }
- subCheck(9)
- } else if typeSecurity == 9 {
- if checkCallForward() {
- sendShieldErrorLog(code: 2)
- return
- }
- subCheck(10)
- } else if typeSecurity == 10 {
- if checkMultipleLogin() {
- sendShieldErrorLog(code: 1)
- return
- }
- subCheck(11)
- } else if typeSecurity == 11 {
- if checkSimSwap() {
- sendShieldErrorLog(code: 3)
- return
- }
- subCheck(12)
- } else if typeSecurity == 12 {
- if checkGeovelocity() {
- sendShieldErrorLog(code: 21)
- return
- }
- subCheck(13)
- } else if typeSecurity == 13 {
- if checkBehaviourAnalysis() {
- sendShieldErrorLog(code: 17)
- return
- }
- }
- }
-
- static func checkEmulator() -> Bool {
- if Preference.getCheckEmulator() && isEmulator() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckEmulatorAlertTitle(), message: Preference.getCheckEmulatorAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckEmulatorAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(2)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-101)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkRootedDevice() -> Bool {
- if Preference.getCheckRooted() && isRooted() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckRootedAlertTitle(), message: Preference.getCheckRootedAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckRootedAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(3)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkOutdatedOS() -> Bool {
- if Preference.getCheckOutdatedOs() {
- let requiredVersion = Preference.getMinimumOsVersion()
- let systemVersion = UIDevice.current.systemVersion
- let versionComponents = systemVersion.split(separator: ".").prefix(2)
- let versionString = versionComponents.joined(separator: ".")
- if let currentVersion = Double(versionString),
- let requiredVersionDouble = Double(requiredVersion) {
- if currentVersion < requiredVersionDouble {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckRootedAlertTitle(), message: Preference.getCheckRootedAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckOutdatedOsAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(4)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-103)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- } else {
- }
- }
- return false
- }
-
- static func checkTempering() -> Bool {
- if Preference.getCheckTempering() && isTempering() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckTemperingAlertTitle(), message: Preference.getCheckTemperingAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckTemperingAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(5)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkHooked() -> Bool {
- if Preference.getCheckHooked() && isHooked() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckHookedAlertTitle(), message: Preference.getCheckHookedAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckHookedAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(6)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkDebugging() -> Bool {
- if Preference.getCheckDebugging() && isDebugging() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckDebuggingAlertTitle(), message: Preference.getCheckDebuggingAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckDebuggingAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(7)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkScreenCasting() -> Bool {
- if Preference.getCheckScreenCasting() && isScreenCasting() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckScreenCastingAlertTitle(), message: Preference.getCheckScreenCastingAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckScreenCastingAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(8)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkScreenOverlay() -> Bool {
- if Preference.getCheckScreenOverlay() && isScreenOverlay() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckScreenOverlayAlertTitle(), message: Preference.getCheckScreenOverlayAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckScreenOverlayAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(9)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkCallForward() -> Bool {
- if Preference.getCheckCallForward() && isCallForwarded() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckCallForwardAlertTitle(), message: Preference.getCheckCallForwardAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckCallForwardAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(10)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkMultipleLogin() -> Bool {
- if Preference.getCheckMultipleLogin() && isMultipleLogin() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckMultipleLoginAlertTitle(), message: Preference.getCheckMultipleLoginAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckMultipleLoginAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(11)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkSimSwap() -> Bool {
- if Preference.getCheckSimSwap() && isSimSwap() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckSimSwapAlertTitle(), message: Preference.getCheckSimSwapAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckSimSwapAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(12)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkGeovelocity() -> Bool {
- if Preference.getCheckGeoVelocity() && isGeovelocityDetected() {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckGeoVelocityAlertTitle(), message: Preference.getCheckGeoVelocityAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckGeoVelocityAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(13)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- return true
- }
- return false
- }
-
- static func checkBehaviourAnalysis() -> Bool {
- if Preference.getCheckBehaviourAnalysis() {
- isSuspiciousBehavior()
- return true
- }
- return false
- }
-
-
- private static func isEmulator() -> Bool {
- let deviceName = UIDevice.current.name
- if deviceName.contains("Simulator") {
- return true
- }
- let deviceModel = UIDevice.current.model
- if deviceModel.hasPrefix("Simulator") {
- return true
- }
- let systemName = UIDevice.current.systemName
- if systemName == "Simulator" {
- return true
- }
- #if targetEnvironment(simulator)
- return true
- #else
- #endif
- return false
- }
-
- private static func isRooted() -> Bool {
- let fileManager = FileManager.default
- if fileManager.fileExists(atPath: "/Applications/Cydia.app") ||
- fileManager.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
- fileManager.fileExists(atPath: "/bin/bash") ||
- fileManager.fileExists(atPath: "/usr/sbin/sshd") ||
- fileManager.fileExists(atPath: "/etc/apt") ||
- fileManager.fileExists(atPath: "/private/var/lib/apt/") ||
- fileManager.fileExists(atPath: "/Applications/FakeApp.app") {
- return true
- }
-
- let testPath = "/private/" + UUID().uuidString
- do {
- try "test".write(toFile: testPath, atomically: true, encoding: .utf8)
- try FileManager.default.removeItem(atPath: testPath)
- return true
- } catch {
- // Could not write outside sandbox
- }
-
- return false
- }
-
- private static func isTempering() -> Bool {
- return false
- }
-
- private static func isDebugging() -> Bool {
- var name: [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
- var info = kinfo_proc()
- var size = MemoryLayout<kinfo_proc>.size
- let result = sysctl(&name, UInt32(name.count), &info, &size, nil, 0)
-
- if result == 0 {
- return (info.kp_proc.p_flag & P_TRACED) != 0
- } else {
- return false
- }
- }
-
- private static func isHooked() -> Bool {
- let suspiciousLibraries = [
- "FridaGadget",
- "libsubstrate.dylib",
- "libcycript.dylib",
- "cyinject.dylib",
- "MobileSubstrate.dylib",
- "SSLKillSwitch.dylib",
- "CydiaSubstrate",
- "TweakInject",
- "0Shadow",
- "shadow.dylib"
- ]
-
- for i in 0..<_dyld_image_count() {
- if let imageName = _dyld_get_image_name(i) {
- let name = String(cString: imageName)
- for library in suspiciousLibraries {
- if name.lowercased().contains(library.lowercased()) {
- return true
- }
- }
- }
- }
- return false
- }
-
- private static func isScreenCasting() -> Bool {
- return checkForExternalScreen()
- }
-
- @objc static func screenDidConnect(notification: Notification) {
- _ = checkScreenCasting()
- }
-
- // Called when a screen is disconnected
- @objc static func screenDidDisconnect(notification: Notification) {
- _ = checkScreenCasting()
- }
-
- private static func checkForExternalScreen() -> Bool {
- let screens = UIScreen.screens
- if screens.count > 1 {
- return true
- } else {
- return false
- }
- }
-
- private static func isScreenOverlay() -> Bool {
- return false
- }
-
- private static func isCallForwarded() -> Bool {
- return false
- }
-
- private static func isMultipleLogin() -> Bool {
- return false
- }
-
- private static func isSimSwap() -> Bool {
- guard let savedSimInfo: [String: [String: String]]? = SecureUserDefaultsSS.shared.value(forKey: "SavedSIMInfo") else {
- let simInfo = getSIMInfo()
- SecureUserDefaultsSS.shared.set(simInfo, forKey: "SavedSIMInfo")
- return false
- }
- let currentSimInfo = getSIMInfo()
- return savedSimInfo != currentSimInfo
- }
-
- private static func getSIMInfo() -> [String: [String: String]] {
- let networkInfo = CTTelephonyNetworkInfo()
- var simData: [String: [String: String]] = [:]
-
- if let carriers = networkInfo.serviceSubscriberCellularProviders {
- for (key, carrier) in carriers {
- let carrierName = carrier.carrierName ?? "Unknown"
- let mobileCountryCode = carrier.mobileCountryCode ?? "Unknown"
- let mobileNetworkCode = carrier.mobileNetworkCode ?? "Unknown"
- let isoCountryCode = carrier.isoCountryCode ?? "Unknown"
-
- simData[key] = [
- "carrierName": carrierName,
- "mobileCountryCode": mobileCountryCode,
- "mobileNetworkCode": mobileNetworkCode,
- "isoCountryCode": isoCountryCode
- ]
- }
- }
- return simData
- }
-
- private static func isGeovelocityDetected() -> Bool {
- return false
- }
-
- private static func isSuspiciousBehavior() {
- let data = collectDeviceAttributes()
- // print("DATA COLLECT: \(data)")
- DispatchQueue.global().async{
- SecurityShield.postDataWithCookiesAndUserAgent(from: URL(string: Preference.getDomainOpr() + "data_capture")!, parameter: data) { data, response, error in
- let response = response as? HTTPURLResponse
- if response?.statusCode != 200 || error != nil {
- return
- }
- if let data = data, let responseString = String(data: data, encoding: .utf8) {
- if !responseString.isEmpty {
- // print("RESPON ANOMALI : \(responseString)")
- if responseString == "ANOMALY_DETECTED" {
- DispatchQueue.main.async(execute: {
- let alert = SSLibAlertController(title: Preference.getCheckBehaviourAnalysisAlertTitle(), message: Preference.getCheckBehaviourAnalysisAlertMessage(), preferredStyle: .alert)
- if Preference.getCheckBehaviourAnalysisAction() == PreferencesKey.SECURITY_SHIELD_ALERT_CONTINUE {
- alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {_ in
- subCheck(14)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- } else {
- alert.addAction(UIAlertAction(title: "Exit", style: UIAlertAction.Style.default, handler: {_ in
- exit(-141)
- }))
- if UIApplication.shared.visibleViewController?.navigationController != nil {
- UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
- } else {
- UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
- }
- }
- })
- }
- }
- }
- }
- }
- }
-
- private static func sendShieldErrorLog(code: Int) {
- var data = collectDeviceAttributes()
- data["security_shield"] = "\(code)"
- if let jsonData = try? JSONSerialization.data(withJSONObject: data, options: .prettyPrinted),
- let jsonString = String(data: jsonData, encoding: .utf8) {
- let me: String! = SecureUserDefaultsSS.shared.value(forKey: "me") ?? ""
- let tmessage = TMessageSS()
- tmessage.mCode = "SSG"
- tmessage.mStatus = CoreMessage_TMessageUtil.getTID()
- tmessage.mPIN = me
- tmessage.mBodies["A112"] = jsonString
- _ = Service.write(message: tmessage)
- }
- }
-
- private static let vers = "5.0.52"
- private var currentLocation: CLLocation?
- private static func collectDeviceAttributes() -> [String: Any] {
- var params: [String: Any] = [:]
- // User and session
- let me: String? = SecureUserDefaultsSS.shared.value(forKey: "me")
- let sesId: String? = Preference.getConnectionID()
- params["f_pin"] = me
- params["session_id"] = sesId
- // App info (replace with your preferences retrieval)
- params["api"] = Preference.getAccount()
- params["app_id"] = Preference.getAppId()
- params["lib_version"] = vers
- params["app_version"] = vers
- // Network Info
- let (netType, netTypeName) = getNetworkType()
- let (operatorCode, operatorName) = getCarrierInfo()
- let (wifiStatus, wifiIp, wifiSsid, wifiBssid) = getWifiInfo()
- params["network_type"] = netType
- params["network_type_name"] = netTypeName
- params["network_operator"] = operatorCode
- params["network_operator_name"] = operatorName
- params["wifi_ssid"] = wifiSsid
- params["wifi_bssid"] = wifiBssid
- params["wifi_adapter"] = wifiStatus
- params["wifi_ip"] = wifiIp
-
- // IP Address
- params["ip_addressv4"] = getIPAddress(useIPv4: true)
- params["ip_address"] = getIPAddress(useIPv4: false)
- // GPS / location
- let semaphore = DispatchSemaphore(value: 0)
-
- DispatchQueue.main.async {
- LocationFetcher.shared.getCurrentLocation { coordinate in
- var long = "0"
- var lat = "0"
- if let coord = coordinate {
- long = "\(coord.longitude)"
- lat = "\(coord.latitude)"
- }
- // print("Latitude: \(lat), Longitude: \(long)")
- params["latitude"] = lat
- params["longitude"] = long
- semaphore.signal()
- }
- }
-
- _ = semaphore.wait(timeout: .now() + 10.0)
- // iOS doesn't have an Android ID; use identifierForVendor
- params["ios_identifier"] = UIDevice.current.identifierForVendor?.uuidString ?? ""
- // Device attributes
- let device = UIDevice.current
- params["device_NAME"] = device.name
- params["device_MODEL"] = device.model
- params["device_SYSTEM_NAME"] = device.systemName
- params["device_SYSTEM_VERSION"] = device.systemVersion
- params["device_IDENTIFIER_FOR_VENDOR"] = device.identifierForVendor?.uuidString ?? ""
- return getSimData(params: params)
- }
-
- private static func getSimData(params: [String: Any] = [:]) -> [String: Any] {
- var params = params
- var simArray: [[String: Any]] = []
- let networkInfo = CTTelephonyNetworkInfo()
- if #available(iOS 12.0, *) {
- if let carriers = networkInfo.serviceSubscriberCellularProviders {
- for (key, carrier) in carriers {
- var simInfo: [String: Any] = [:]
- simInfo["carrier_name"] = carrier.carrierName ?? ""
- simInfo["mcc"] = carrier.mobileCountryCode ?? ""
- simInfo["mnc"] = carrier.mobileNetworkCode ?? ""
- simInfo["sim_slot"] = key // This is not a true "slot", but the key used internally
- simArray.append(simInfo)
- }
- }
- } else {
- if let carrier = networkInfo.subscriberCellularProvider {
- var simInfo: [String: Any] = [:]
- simInfo["carrier_name"] = carrier.carrierName ?? ""
- simInfo["mcc"] = carrier.mobileCountryCode ?? ""
- simInfo["mnc"] = carrier.mobileNetworkCode ?? ""
- simInfo["sim_slot"] = "default"
- simArray.append(simInfo)
- }
- }
- params["sim_data"] = simArray
- return params
- }
-
- private static func getNetworkType() -> (type: String, name: String) {
- let monitor = NWPathMonitor()
- var networkType = ""
- var networkTypeName = ""
-
- let semaphore = DispatchSemaphore(value: 0)
- monitor.pathUpdateHandler = { path in
- if path.usesInterfaceType(.wifi) {
- networkType = "1" // Corresponds to TYPE_WIFI in Android
- networkTypeName = "WIFI"
- } else if path.usesInterfaceType(.cellular) {
- networkType = "0" // Corresponds to TYPE_MOBILE
- networkTypeName = "MOBILE"
- } else {
- networkType = "-1"
- networkTypeName = "UNKNOWN"
- }
- semaphore.signal()
- monitor.cancel()
- }
- let queue = DispatchQueue(label: "NetworkMonitor")
- monitor.start(queue: queue)
- semaphore.wait()
-
- return (networkType, networkTypeName)
- }
-
- private static func getCarrierInfo() -> (operatorCode: String, operatorName: String) {
- let networkInfo = CTTelephonyNetworkInfo()
-
- var carrierCode = ""
- var carrierName = ""
-
- if #available(iOS 12.0, *) {
- if let carriers = networkInfo.serviceSubscriberCellularProviders {
- for (_, carrier) in carriers {
- carrierCode = (carrier.mobileCountryCode ?? "") + (carrier.mobileNetworkCode ?? "")
- carrierName = carrier.carrierName ?? ""
- break // Just use the first one
- }
- }
- } else {
- if let carrier = networkInfo.subscriberCellularProvider {
- carrierCode = (carrier.mobileCountryCode ?? "") + (carrier.mobileNetworkCode ?? "")
- carrierName = carrier.carrierName ?? ""
- }
- }
-
- return (carrierCode, carrierName)
- }
-
- private static func getWifiInfo() -> (adapter: String, ip: String, ssid: String, bssid: String) {
- var adapterStatus = "Off"
- var ipAddress = ""
- var ssid = ""
- var bssid = ""
-
- // Get IP Address
- if let interfaces = CNCopySupportedInterfaces() as NSArray? {
- for interfaceName in interfaces {
- if let unsafeInterfaceData = CNCopyCurrentNetworkInfo(interfaceName as! CFString) as NSDictionary? {
- ssid = unsafeInterfaceData["SSID"] as? String ?? ""
- bssid = unsafeInterfaceData["BSSID"] as? String ?? ""
- adapterStatus = "Connected"
- break
- }
- }
- }
-
- if ssid.isEmpty {
- adapterStatus = "Not Connected"
- }
- ipAddress = getWiFiIPAddress() ?? ""
- return (adapterStatus, ipAddress, ssid, bssid)
- }
- private static func getWiFiIPAddress() -> String? {
- var address: String?
- var ifaddr: UnsafeMutablePointer<ifaddrs>?
- guard getifaddrs(&ifaddr) == 0, let firstAddr = ifaddr else { return nil }
- for ptr in sequence(first: firstAddr, next: { $0.pointee.ifa_next }) {
- let interface = ptr.pointee
- let addrFamily = interface.ifa_addr.pointee.sa_family
- if addrFamily == UInt8(AF_INET) || addrFamily == UInt8(AF_INET6) {
- let name = String(cString: interface.ifa_name)
- if name == "en0" { // en0 is Wi-Fi
- var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
- getnameinfo(interface.ifa_addr, socklen_t(interface.ifa_addr.pointee.sa_len),
- &hostname, socklen_t(hostname.count),
- nil, socklen_t(0), NI_NUMERICHOST)
- address = String(cString: hostname)
- break
- }
- }
- }
- freeifaddrs(ifaddr)
- return address
- }
-
- private static func getIPAddress(useIPv4: Bool) -> String {
- var address: String = ""
- var ifaddr: UnsafeMutablePointer<ifaddrs>? = nil
- if getifaddrs(&ifaddr) == 0, let firstAddr = ifaddr {
- for ptr in sequence(first: firstAddr, next: { $0.pointee.ifa_next }) {
- let interface = ptr.pointee
- let addrFamily = interface.ifa_addr.pointee.sa_family
- if addrFamily == UInt8(AF_INET) || addrFamily == UInt8(AF_INET6) {
- let name = String(cString: interface.ifa_name)
- if name == "en0" || name == "pdp_ip0" {
- var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
- let result = getnameinfo(
- interface.ifa_addr,
- socklen_t(interface.ifa_addr.pointee.sa_len),
- &hostname,
- socklen_t(hostname.count),
- nil,
- socklen_t(0),
- NI_NUMERICHOST
- )
- if result == 0 {
- let ip = String(cString: hostname)
- let isIPv4 = ip.contains(":") == false
- if useIPv4 && isIPv4 {
- address = ip
- break
- } else if !useIPv4 && !isIPv4 {
- // Remove IPv6 scope if present
- let cleanIPv6 = ip.split(separator: "%").first.map(String.init) ?? ip
- address = cleanIPv6.uppercased()
- break
- }
- }
- }
- }
- }
- freeifaddrs(ifaddr)
- }
- return address
- }
- }
- private class LocationFetcher: NSObject, CLLocationManagerDelegate {
- static var shared = LocationFetcher()
- private var manager: CLLocationManager?
- private var completion: ((CLLocationCoordinate2D?) -> Void)?
-
- func getCurrentLocation(completion: @escaping (CLLocationCoordinate2D?) -> Void) {
- self.completion = completion
- self.manager = CLLocationManager()
- self.manager?.delegate = self
- self.manager?.desiredAccuracy = kCLLocationAccuracyBest
- self.manager?.requestWhenInUseAuthorization()
-
- if CLLocationManager.locationServicesEnabled() {
- self.manager?.requestLocation()
- } else {
- completion(nil)
- }
- }
-
- // MARK: - CLLocationManagerDelegate
- func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
- completion?(locations.last?.coordinate)
- cleanup()
- }
- func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
- print("Error: \(error.localizedDescription)")
- completion?(nil)
- cleanup()
- }
-
- private func cleanup() {
- manager?.stopUpdatingLocation()
- manager?.delegate = nil
- manager = nil
- completion = nil
- }
- }
- private class Service {
- static func writeSync(message: TMessageSS, timeout: Int = 15 * 1000) -> TMessageSS? {
- if !API.bInetConnAvailable() || API.nGetCLXConnState() == 0 {
- return nil
- }
- do {
- if let data = try API.sGetResponse(sRequest: message.pack(), lTimeout: timeout, bKeepTOResp: true) {
- let response = TMessageSS(data: data)
- return response
- }
- } catch {
- print(error)
- }
- return nil
- }
-
- static func write(message: TMessageSS, timeout: Int = 15 * 1000) -> String? {
- do {
- if !API.bInetConnAvailable() || API.nGetCLXConnState() == 0 {
- return nil
- }
- //print(">> SENDING MESSAGE >> ", message.toLogString())
- if message.getMedia().count == 0 {
- if let data = try API.sSend(sData: message.pack(), nPriority: 1, lTimeout: timeout) {
- //print("<< RESPONSE MESSAGE << ", data)
- return data
- }
- }
- // media
- if let data = try API.sSend(abData: message.toBytes(), nPriority: 2, lTimeout: timeout) {
- //print("<< RESPONSE MESSAGE << ", data)
- return data
- }
- } catch {
- //print(error)
- }
- return nil
- }
- }
- private class Preference {
- static func setConnectionID(value: String) {
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CONNECTION_ID)
- }
- static func getConnectionID() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CONNECTION_ID) {
- return value
- }
- return ""
- }
- static func getAppId() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_USER_APP_ID) {
- return value
- }
- return ""
- }
-
- static func setAppId(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_USER_APP_ID)
- }
-
- static func getAccount() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_USER_ACCOUNT) {
- return value
- }
- return ""
- }
-
- static func setAccount(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_USER_ACCOUNT)
- }
-
- static func setDomainOpr(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_DOMAIN_OPR)
- }
-
- static func getDomainOpr() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_DOMAIN_OPR) {
- return value
- }
- return "https://nexilis.io/"
- }
-
- static func setIpPortOpr(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_IP_PORT_OPR)
- }
-
- static func getIpOpr() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_IP_PORT_OPR) {
- return value
- }
- return "34.101.172.194:42823"
- }
-
- /**
- * Keylogger
- */
- static func setPreventKeylogger(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_KEYLOGGER)
- }
-
- static func getPreventKeylogger() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_KEYLOGGER) {
- return value
- }
- return false
- }
- static func setPreventKeyloggerAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_KEYLOGGER_ACTION)
- }
-
- static func getPreventKeyloggerAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_KEYLOGGER_ACTION) {
- return value
- }
- return "0"
- }
- static func setKeyloggerAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_KEYLOGGER_ALERT_TITLE)
- }
-
- static func getKeyloggerAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_KEYLOGGER_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_screenshare_title
- }
- return value
- }
- return PreferencesKey.ss_screenshare_title
- }
- static func setKeyloggerAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_KEYLOGGER_ALERT_MESSAGE)
- }
-
- static func getKeyloggerAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_KEYLOGGER_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_screenshare_warning
- }
- return value
- }
- return PreferencesKey.ss_screenshare_warning
- }
- /**
- * Screen Capture
- */
- static func setPreventScreenCapture(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_CAPTURE)
- }
-
- static func getPreventScreenCapture() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_CAPTURE) {
- return value
- }
- return false
- }
- static func setPreventScreenCaptureAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_CAPTURE_ACTION)
- }
-
- static func getPreventScreenCaptureAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_CAPTURE_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckScreenCaptureAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_CAPTURE_ALERT_TITLE)
- }
-
- static func getCheckScreenCaptureAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_CAPTURE_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_screenshare_title
- }
- return value
- }
- return PreferencesKey.ss_screenshare_title
- }
- static func setScreenCaptureAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_CAPTURE_ALERT_MESSAGE)
- }
-
- static func getScreenCaptureAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_CAPTURE_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_screenshare_warning
- }
- return value
- }
- return PreferencesKey.ss_screenshare_warning
- }
- /**
- * Emulator
- */
- static func setCheckEmulator(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_EMULATOR)
- }
-
- static func getCheckEmulator() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_EMULATOR) {
- return value
- }
- return false
- }
- static func setCheckEmulatorAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_EMULATOR_ACTION)
- }
-
- static func getCheckEmulatorAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_EMULATOR_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckEmulatorAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_EMULATOR_ALERT_TITLE)
- }
-
- static func getCheckEmulatorAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_EMULATOR_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_emulator_title
- }
- return value
- }
- return PreferencesKey.ss_emulator_title
- }
- static func setCheckEmulatorAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_EMULATOR_ALERT_MESSAGE)
- }
-
- static func getCheckEmulatorAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_EMULATOR_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_emulator_continue
- }
- return value
- }
- return PreferencesKey.ss_emulator_continue
- }
-
- /**
- * Root/Jailbreak Detection
- */
- static func setCheckRooted(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_ROOTED)
- }
-
- static func getCheckRooted() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_ROOTED) {
- return value
- }
- return false
- }
- static func setCheckRootedAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_ROOTED_ACTION)
- }
-
- static func getCheckRootedAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_ROOTED_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckRootedAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_ROOTED_ALERT_TITLE)
- }
-
- static func getCheckRootedAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_ROOTED_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_rooted_title
- }
- return value
- }
- return PreferencesKey.ss_rooted_title
- }
- static func setCheckRootedAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_ROOTED_ALERT_MESSAGE)
- }
-
- static func getCheckRootedAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_ROOTED_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_rooted_warning
- }
- return value
- }
- return PreferencesKey.ss_rooted_warning
- }
-
- /**
- * Outdated OS Detection
- */
- static func setCheckOutdatedOs(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_OUTDATED_OS)
- }
-
- static func getCheckOutdatedOs() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_OUTDATED_OS) {
- return value
- }
- return false
- }
- static func setCheckOutdatedOsAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_ROOTED_ACTION)
- }
-
- static func getCheckOutdatedOsAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_ROOTED_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckOutdatedOsAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_OUTDATED_OS_ALERT_TITLE)
- }
-
- static func getCheckOutdatedOsAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_OUTDATED_OS_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_os_not_supported_title
- }
- return value
- }
- return PreferencesKey.ss_os_not_supported_title
- }
- static func setCheckOutdatedOsAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_OUTDATED_OS_ALERT_MESSAGE)
- }
-
- static func getCheckOutdatedOsAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_OUTDATED_OS_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_os_not_supported_continue
- }
- return value
- }
- return PreferencesKey.ss_os_not_supported_continue
- }
- static func setMinimumOsVersion(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_MINIMUM_OS_VERSION)
- }
-
- static func getMinimumOsVersion() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_MINIMUM_OS_VERSION) {
- return value
- }
- return "14"
- }
-
- /**
- * Tempering Detection
- */
- static func setCheckTempering(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_TEMPERING)
- }
-
- static func getCheckTempering() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_TEMPERING) {
- return value
- }
- return false
- }
- static func setCheckTemperingAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_TEMPERING_ACTION)
- }
-
- static func getCheckTemperingAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_TEMPERING_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckTemperingAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_TEMPERING_ALERT_TITLE)
- }
-
- static func getCheckTemperingAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_TEMPERING_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_tempering_title
- }
- return value
- }
- return PreferencesKey.ss_tempering_title
- }
- static func setCheckTemperingAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_TEMPERING_ALERT_MESSAGE)
- }
-
- static func getCheckTemperingAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_TEMPERING_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_tempering_warning
- }
- return value
- }
- return PreferencesKey.ss_tempering_warning
- }
-
- /**
- * Debugging Detection
- */
- static func setCheckDebugging(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_DEBUGGING)
- }
-
- static func getCheckDebugging() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_DEBUGGING) {
- return value
- }
- return false
- }
- static func setCheckDebuggingAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_DEBUGGING_ACTION)
- }
-
- static func getCheckDebuggingAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_DEBUGGING_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckDebuggingAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_DEBUGGING_ALERT_TITLE)
- }
-
- static func getCheckDebuggingAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_DEBUGGING_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_debugging_title
- }
- return value
- }
- return PreferencesKey.ss_debugging_title
- }
- static func setCheckDebuggingAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_DEBUGGING_ALERT_MESSAGE)
- }
-
- static func getCheckDebuggingAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_DEBUGGING_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_debugging_warning
- }
- return value
- }
- return PreferencesKey.ss_debugging_warning
- }
-
- /**
- * Screen Casting
- */
- static func setCheckScreenCasting(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_CASTING)
- }
-
- static func getCheckScreenCasting() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_CASTING) {
- return value
- }
- return false
- }
- static func setCheckScreenCastingAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_CASTING_ACTION)
- }
-
- static func getCheckScreenCastingAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_CASTING_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckScreenCastingAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_CASTING_ALERT_TITLE)
- }
-
- static func getCheckScreenCastingAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_CASTING_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_debugging_title
- }
- return value
- }
- return PreferencesKey.ss_debugging_title
- }
- static func setCheckScreenCastingAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_CASTING_ALERT_MESSAGE)
- }
-
- static func getCheckScreenCastingAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_CASTING_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_debugging_warning
- }
- return value
- }
- return PreferencesKey.ss_debugging_warning
- }
-
- /**
- * Screen Overlay
- */
- static func setCheckScreenOverlay(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_OVERLAY)
- }
-
- static func getCheckScreenOverlay() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_OVERLAY) {
- return value
- }
- return false
- }
- static func setCheckScreenOverlayAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_OVERLAY_ACTION)
- }
-
- static func getCheckScreenOverlayAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_OVERLAY_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckScreenOverlayAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_OVERLAY_ALERT_TITLE)
- }
-
- static func getCheckScreenOverlayAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_OVERLAY_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_screenoverlay_title
- }
- return value
- }
- return PreferencesKey.ss_screenoverlay_title
- }
- static func setCheckScreenOverlayAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SCREEN_OVERLAY_ALERT_MESSAGE)
- }
-
- static func getCheckScreenOverlayAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SCREEN_OVERLAY_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_screenoverlay_continue
- }
- return value
- }
- return PreferencesKey.ss_screenoverlay_continue
- }
-
- /**
- * Call Redirection Detection
- */
- static func setCheckCallForward(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_CALL_FORWARD)
- }
-
- static func getCheckCallForward() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_CALL_FORWARD) {
- return value
- }
- return false
- }
- static func setCheckCallForwardAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_CALL_FORWARD_ACTION)
- }
-
- static func getCheckCallForwardAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_CALL_FORWARD_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckCallForwardAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_CALL_FORWARD_ALERT_TITLE)
- }
-
- static func getCheckCallForwardAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_CALL_FORWARD_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_callforward_title
- }
- return value
- }
- return PreferencesKey.ss_callforward_title
- }
- static func setCheckCallForwardAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_CALL_FORWARD_ALERT_MESSAGE)
- }
-
- static func getCheckCallForwardAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_CALL_FORWARD_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_callforward_continue
- }
- return value
- }
- return PreferencesKey.ss_callforward_continue
- }
-
- /**
- * Multiple Login Detection
- */
- static func setCheckMultipleLogin(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_MULTIPLE_LOGIN)
- }
-
- static func getCheckMultipleLogin() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_MULTIPLE_LOGIN) {
- return value
- }
- return false
- }
- static func setCheckMultipleLoginAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_MULTIPLE_LOGIN_ACTION)
- }
-
- static func getCheckMultipleLoginAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_MULTIPLE_LOGIN_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckMultipleLoginAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_MULTIPLE_LOGIN_ALERT_TITLE)
- }
-
- static func getCheckMultipleLoginAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_MULTIPLE_LOGIN_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_multiple_login_title
- }
- return value
- }
- return PreferencesKey.ss_multiple_login_title
- }
- static func setCheckMultipleLoginAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_MULTIPLE_LOGIN_ALERT_MESSAGE)
- }
-
- static func getCheckMultipleLoginAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_MULTIPLE_LOGIN_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_multiple_login_warning
- }
- return value
- }
- return PreferencesKey.ss_multiple_login_warning
- }
-
- /**
- * SIM Swap Detection
- */
- static func setCheckSimSwap(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SIM_SWAP)
- }
-
- static func getCheckSimSwap() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SIM_SWAP) {
- return value
- }
- return false
- }
- static func setCheckSimSwapAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SIM_SWAP_ACTION)
- }
-
- static func getCheckSimSwapAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SIM_SWAP_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckSimSwapAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SIM_SWAP_ALERT_TITLE)
- }
-
- static func getCheckSimSwapAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SIM_SWAP_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_simswap_title
- }
- return value
- }
- return PreferencesKey.ss_simswap_title
- }
- static func setCheckSimSwapAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_SIM_SWAP_ALERT_MESSAGE)
- }
-
- static func getCheckSimSwapAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_SIM_SWAP_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_simswap_warning
- }
- return value
- }
- return PreferencesKey.ss_simswap_warning
- }
-
- /**
- * Geo-Velocity Checks
- */
- static func setCheckGeoVelocity(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_GEO_VELOCITY)
- }
-
- static func getCheckGeoVelocity() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_GEO_VELOCITY) {
- return value
- }
- return false
- }
- static func setCheckGeoVelocityAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_GEO_VELOCITY_ACTION)
- }
-
- static func getCheckGeoVelocityAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_GEO_VELOCITY_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckGeoVelocityAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_GEO_VELOCITY_ALERT_TITLE)
- }
-
- static func getCheckGeoVelocityAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_GEO_VELOCITY_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_geo_velocity_title
- }
- return value
- }
- return PreferencesKey.ss_geo_velocity_title
- }
- static func setCheckGeoVelocityAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_GEO_VELOCITY_ALERT_MESSAGE)
- }
-
- static func getCheckGeoVelocityAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_GEO_VELOCITY_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_geo_velocity_warning
- }
- return value
- }
- return PreferencesKey.ss_geo_velocity_warning
- }
-
- /**
- * Behavioral Anomaly Detection
- */
- static func setCheckBehaviourAnalysis(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_BEHAVIOUR_ANALYSIS)
- }
-
- static func getCheckBehaviourAnalysis() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_BEHAVIOUR_ANALYSIS) {
- return value
- }
- return false
- }
- static func setCheckBehaviourAnalysisAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_BEHAVIOUR_ANALYSIS_ACTION)
- }
-
- static func getCheckBehaviourAnalysisAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_BEHAVIOUR_ANALYSIS_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckBehaviourAnalysisAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_BEHAVIOUR_ANALYSIS_ALERT_TITLE)
- }
-
- static func getCheckBehaviourAnalysisAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_BEHAVIOUR_ANALYSIS_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_behaviour_anomaly_title
- }
- return value
- }
- return PreferencesKey.ss_behaviour_anomaly_title
- }
- static func setCheckBehaviourAnalysisAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_BEHAVIOUR_ANALYSIS_ALERT_MESSAGE)
- }
-
- static func getCheckBehaviourAnalysisAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_BEHAVIOUR_ANALYSIS_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_behaviour_anomaly_warning
- }
- return value
- }
- return PreferencesKey.ss_behaviour_anomaly_warning
- }
-
- /**
- * Hooked Detection
- */
- static func setCheckHooked(value: Bool){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_HOOKED)
- }
-
- static func getCheckHooked() -> Bool {
- if let value: Bool = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_HOOKED) {
- return value
- }
- return false
- }
- static func setCheckHookedAction(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_HOOKED_ACTION)
- }
-
- static func getCheckHookedAction() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_HOOKED_ACTION) {
- return value
- }
- return "0"
- }
- static func setCheckHookedAlertTitle(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_HOOKED_ALERT_TITLE)
- }
-
- static func getCheckHookedAlertTitle() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_HOOKED_ALERT_TITLE) {
- if value.isEmpty {
- return PreferencesKey.ss_hooked_title
- }
- return value
- }
- return PreferencesKey.ss_hooked_title
- }
- static func setCheckHookedAlertMessage(value: String){
- SecureUserDefaultsSS.shared.set(value, forKey: PreferencesKey.SS_CHECK_HOOKED_ALERT_MESSAGE)
- }
-
- static func getCheckHookedAlertMessage() -> String {
- if let value: String = SecureUserDefaultsSS.shared.value(forKey: PreferencesKey.SS_CHECK_HOOKED_ALERT_MESSAGE) {
- if value.isEmpty {
- return PreferencesKey.ss_hooked_warning
- }
- return value
- }
- return PreferencesKey.ss_hooked_warning
- }
- }
- private class PreferencesKey {
- static let SECURITY_SHIELD_ALERT_EXIT = "0"
- static let SECURITY_SHIELD_ALERT_CONTINUE = "1"
-
- static let ERR121 = "121:Emulator detected"
- static let ERR122 = "122:Malware detected"
- static let ERR123 = "123:USB/WiFi debugging detected"
- static let ERR124 = "124:Cloned app detected"
- static let ERR125 = "125:Call forwarding detected"
- static let ERR126 = "126:Screen sharing detected"
- static let ERR127 = "127:OS Version not supported"
- static let ERR128 = "128:Application backup detected"
- static let ERR129 = "129:Failed security reasons"
- static let ERR130 = "130:Tampering detected"
- static let ERR131 = "131:SIM Swap detected"
- static let ERR132 = "132:Behavioral Anomaly detected"
-
- static let SS_CONNECTION_ID = "ss_connection_id"
-
- static let SS_USER_APP_ID = "ss_user_app_id"
- static let SS_USER_ACCOUNT = "ss_user_account"
- static let SS_DOMAIN_OPR = "domain_opr"
- static let SS_IP_PORT_OPR = "ip_opr"
-
- static let SS_CHECK_KEYLOGGER = "ss_check_keylogger"
- static let SS_CHECK_KEYLOGGER_ACTION = "ss_check_keylogger_action"
- static let SS_CHECK_KEYLOGGER_ALERT_TITLE = "ss_check_keylogger_alert_title"
- static let SS_CHECK_KEYLOGGER_ALERT_MESSAGE = "ss_check_keylogger_alert_message"
- static let SS_CHECK_SCREEN_CAPTURE = "ss_check_screen_capture"
- static let SS_CHECK_SCREEN_CAPTURE_ACTION = "ss_check_screen_capture_action"
- static let SS_CHECK_SCREEN_CAPTURE_ALERT_TITLE = "ss_check_screen_capture_alert_title"
- static let SS_CHECK_SCREEN_CAPTURE_ALERT_MESSAGE = "ss_check_screen_capture_alert_message"
- static let ss_screenshare_title = "Screen Sharing Detected!"
- static let ss_screenshare_warning = "We are sorry for the inconvenience. For security reasons this app is not allowed to cast/share screen display. The application will automatically stop.<br><br>To try again, please stop the screen casting/sharing."
-
-
- static let SS_CHECK_EMULATOR = "ss_check_emulator"
- static let SS_CHECK_EMULATOR_ACTION = "ss_check_emulator_action"
- static let SS_CHECK_EMULATOR_ALERT_TITLE = "ss_check_emulator_alert_title"
- static let SS_CHECK_EMULATOR_ALERT_MESSAGE = "ss_check_emulator_alert_message"
- static let ss_emulator_title = "Emulator Detected!"
- static let ss_emulator_continue = "We are sorry for the inconvenience. For security reasons this app is not allowed to run on an emulator."
-
- static let SS_CHECK_ROOTED = "ss_check_rooted"
- static let SS_CHECK_ROOTED_ACTION = "ss_check_rooted_action"
- static let SS_CHECK_ROOTED_ALERT_TITLE = "ss_check_rooted_alert_title"
- static let SS_CHECK_ROOTED_ALERT_MESSAGE = "ss_check_rooted_alert_message"
- static let ss_rooted_title = "Root or Jailbreak Detected!"
- static let ss_rooted_warning = "The operating system on your device has been modified unauthorizedly(the root). The modification might compromise secure access to organizational resources such as email and documents.<br><br> %app_name% will not work on your device. Please reset/unroot your device or contact %app_name% customer center for further information. We apologize for the inconvenient."
-
- static let SS_CHECK_OUTDATED_OS = "ss_check_outdated_os"
- static let SS_CHECK_OUTDATED_OS_ACTION = "ss_check_outdated_os_action"
- static let SS_CHECK_OUTDATED_OS_ALERT_TITLE = "ss_check_outdated_os_alert_title"
- static let SS_CHECK_OUTDATED_OS_ALERT_MESSAGE = "ss_check_outdated_os_alert_message"
- static let SS_CHECK_MINIMUM_OS_VERSION = "ss_minimum_os_version"
- static let ss_os_not_supported_title = "Android Version Not Secure!"
- static let ss_os_not_supported_continue = "We are sorry for the inconvenience. This device's Android version has been deemed as no longer secure."
-
- static let SS_CHECK_TEMPERING = "ss_check_tempering"
- static let SS_CHECK_TEMPERING_ACTION = "ss_check_tempering_action"
- static let SS_CHECK_TEMPERING_ALERT_TITLE = "ss_check_tempering_alert_title"
- static let SS_CHECK_TEMPERING_ALERT_MESSAGE = "ss_check_tempering_alert_message"
- static let ss_tempering_title = "Tempering Detected!"
- static let ss_tempering_warning = "Our security shield has detected changes in the application that may indicate tempering, which could potentially lead to malware infection, data manipulation, and other risks. Please remove this apps and download from official Google Play Store."
-
- static let SS_CHECK_DEBUGGING = "ss_check_debugging"
- static let SS_CHECK_DEBUGGING_ACTION = "ss_check_debugging_action"
- static let SS_CHECK_DEBUGGING_ALERT_TITLE = "ss_check_debugging_alert_title"
- static let SS_CHECK_DEBUGGING_ALERT_MESSAGE = "ss_check_debugging_alert_message"
- static let ss_debugging_title = "Debugging Mode Detected!"
- static let ss_debugging_warning = "Your device running on debugging mode. Please disable it."
-
- static let SS_CHECK_SCREEN_CASTING = "ss_check_screen_casting"
- static let SS_CHECK_SCREEN_CASTING_ACTION = "ss_check_screen_casting_action"
- static let SS_CHECK_SCREEN_CASTING_ALERT_TITLE = "ss_check_screen_casting_alert_title"
- static let SS_CHECK_SCREEN_CASTING_ALERT_MESSAGE = "ss_check_screen_casting_alert_message"
-
- static let SS_CHECK_SCREEN_OVERLAY = "ss_check_screen_overlay"
- static let SS_CHECK_SCREEN_OVERLAY_ACTION = "ss_check_screen_overlay_action"
- static let SS_CHECK_SCREEN_OVERLAY_ALERT_TITLE = "ss_check_screen_overlay_alert_title"
- static let SS_CHECK_SCREEN_OVERLAY_ALERT_MESSAGE = "ss_check_screen_overlay_alert_message"
- static let ss_screenoverlay_title = "Screen Overlay Detected!"
- static let ss_screenoverlay_continue = "We are sorry for the inconvenience. For security reasons this app is not allowed to share screen overlay. Please stop the screen overlay in app setting."
-
- static let SS_CHECK_CALL_FORWARD = "ss_check_call_forward"
- static let SS_CHECK_CALL_FORWARD_ACTION = "ss_check_call_forward_action"
- static let SS_CHECK_CALL_FORWARD_ALERT_TITLE = "ss_check_call_forward_alert_title"
- static let SS_CHECK_CALL_FORWARD_ALERT_MESSAGE = "ss_check_call_forward_alert_message"
- static let ss_callforward_title = "Call Forwarding Detected!";
- static let ss_callforward_continue = "We are sorry for the inconvenience. For security reasons this app does not recommend allowing call forwarding to be active.";
-
- static let SS_CHECK_MULTIPLE_LOGIN = "ss_check_multiple_login"
- static let SS_CHECK_MULTIPLE_LOGIN_ACTION = "ss_check_multiple_login_action"
- static let SS_CHECK_MULTIPLE_LOGIN_ALERT_TITLE = "ss_check_multiple_login_alert_title"
- static let SS_CHECK_MULTIPLE_LOGIN_ALERT_MESSAGE = "ss_check_multiple_login_alert_message"
- static let ss_multiple_login_title = "Multiple Login Detected!"
- static let ss_multiple_login_warning = "We have detected multiple login attempts to your account from different devices or locations within a short period. This alert is designed to protect your account and ensure your security.<br><br> If you initiated these logins, no further action is required. However, if you did not authorize this activity, it is crucial to take immediate steps to safeguard your account. Unauthorized access may put your personal information at risk."
-
- static let SS_CHECK_SIM_SWAP = "ss_check_sim_swap"
- static let SS_CHECK_SIM_SWAP_ACTION = "ss_check_sim_swap_action"
- static let SS_CHECK_SIM_SWAP_ALERT_TITLE = "ss_check_sim_swap_alert_title"
- static let SS_CHECK_SIM_SWAP_ALERT_MESSAGE = "ss_check_sim_swap_alert_message"
- static let ss_simswap_title = "Sim Swap Detected!"
- static let ss_simswap_warning = "We noticed some unusual app behaviors and activities, including SimCard Swap on your device. If these actions were not initiated by you or you are unsure about any apps, please change your true number imediately."
-
- static let SS_CHECK_GEO_VELOCITY = "ss_check_geo_velocity"
- static let SS_CHECK_GEO_VELOCITY_ACTION = "ss_check_geo_velocity_action"
- static let SS_CHECK_GEO_VELOCITY_ALERT_TITLE = "ss_check_geo_velocity_alert_title"
- static let SS_CHECK_GEO_VELOCITY_ALERT_MESSAGE = "ss_check_geo_velocity_alert_message"
- static let ss_geo_velocity_title = "Geo Velocity Anomaly Detected!"
- static let ss_geo_velocity_warning = "Anomalies have been identified in the location check associated with your account. This warning is issued to inform you of significant irregularities in the expected location data. Immediate attention is required to address these anomalies, as they may impact your account's functionality, security, and overall user experience."
- static let SS_CHECK_BEHAVIOUR_ANALYSIS = "ss_check_behaviour_analysis"
- static let SS_CHECK_BEHAVIOUR_ANALYSIS_ACTION = "ss_check_behaviour_analysis_action"
- static let SS_CHECK_BEHAVIOUR_ANALYSIS_ALERT_TITLE = "ss_check_behaviour_analysis_alert_title"
- static let SS_CHECK_BEHAVIOUR_ANALYSIS_ALERT_MESSAGE = "ss_check_behaviour_analysis_alert_message"
- static let ss_behaviour_anomaly_title = "Behaviour Anomaly Detected!"
- static let ss_behaviour_anomaly_warning = "We have identified a significant anomaly in the behavior of your device. This notification serves as a precautionary measure, as unusual patterns can indicate potential security threats, unauthorized access, or software malfunctions that could compromise your data and overall device performance."
-
- static let SS_CHECK_HOOKED = "ss_check_hooked"
- static let SS_CHECK_HOOKED_ACTION = "ss_check_hooked_action"
- static let SS_CHECK_HOOKED_ALERT_TITLE = "ss_check_hooked_alert_title"
- static let SS_CHECK_HOOKED_ALERT_MESSAGE = "ss_check_hooked_alert_message"
- static let ss_hooked_title = "Hooked Detected!"
- static let ss_hooked_warning = "Our security shield has detected changes in the application that may indicate Hook or Anti Frida, which could potentially lead to malware infection, data manipulation, and other risks. Please remove this apps and download from official App Store."
- }
- private class SelfSignedURLSessionDelegate: NSObject, URLSessionTaskDelegate, URLSessionDataDelegate {
- func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
- if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
- if let serverTrust = challenge.protectionSpace.serverTrust {
- let credential = URLCredential(trust: serverTrust)
- completionHandler(.useCredential, credential)
- }
- }
- }
- }
- private class UtilsSS {
- private static let I_BB = 48 // 0
- private static let I_BBT_1 = 57 // 9
- private static let I_BAT_1 = 65 // A
- private static let I_BBT_2 = 90 // Z
- private static let I_BAT_2 = 97 // a
- private static let I_BA = 122 // z
- private static let IC_BB = 33 // !
- private static let IC_BBT_1 = 47 // /
- private static let IC_BAT_1 = 58 // :
- private static let IC_BBT_2 = 64 // @
- private static let IC_BAT_2 = 91 // [
- private static let IC_BBT_3 = 96 // @
- private static let IC_BAT_3 = 123 // [
- private static let IC_BA = 126 // `
- private static var icIGNORE = Set<Int>()
- private static func initIcIgnore() {
- icIGNORE.insert(10)// \r
- icIGNORE.insert(13)// \n
- icIGNORE.insert(32)// <space>
- }
-
- public static func decrypt(str: String) -> String {
- var arr: [Character]
- var iRandom = 0
- var sDecrypt: String
- iRandom = Int(str.substring(from: 0, to: 0)) ?? 0
- sDecrypt = getPalindrom(str: str.substring(from: 1, to: nil))
- arr = Array(sDecrypt)
- for i in 0..<arr.count {
- if (isSpecialChar(ch: arr[i])) {
- arr[i] = getBeforecChar(ch: arr[i], inc: iRandom)
- } else {
- arr[i] = getBeforeChar(ch: arr[i], inc: iRandom)
- }
- }
- return String(arr)
- }
-
- private static func isSpecialChar(ch: Character) -> Bool {
- let ch = Int(ch.asciiValue ?? 0)
- return (ch >= IC_BB && ch <= IC_BBT_1) || (ch >= IC_BAT_1 && ch <= IC_BBT_2) || (ch >= IC_BAT_2 && ch <= IC_BBT_3) || (ch >= IC_BAT_3 && ch <= IC_BA)
- }
-
- private static func getPalindrom(str: String) -> String {
- let arr: [Character] = Array(str)
- var arr2: [Character] = Array(arr)
- for i in 0..<arr.count {
- arr2[i] = arr[arr.count - (i + 1)]
- }
- return String(arr2)
- }
-
- private static func getBeforeChar(ch: Character, inc: Int) -> Character {
- if icIGNORE.isEmpty {
- initIcIgnore()
- }
- var iAscii = ch
- let iAsciiBefore = iAscii
- if (icIGNORE.contains(Int(iAscii.asciiValue ?? 0))) {
- return iAscii;
- }
- if Int(iAscii.asciiValue ?? 0) > I_BA || Int(iAscii.asciiValue ?? 0) < I_BB {
- } else {
- if !icIGNORE.contains(Int(iAscii.asciiValue ?? 0)) {
- iAscii = Character(UnicodeScalar(Int(iAscii.asciiValue ?? 0) - inc)!)
- if (I_BAT_1 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= I_BAT_1) {
- iAscii = Character(UnicodeScalar((I_BBT_1 + 1) - (I_BAT_1 - Int(iAscii.asciiValue ?? 0)))!)
- }
- if (I_BAT_2 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= I_BAT_2) {
- iAscii = Character(UnicodeScalar((I_BBT_2 + 1) - (I_BAT_2 - Int(iAscii.asciiValue ?? 0)))!)
- }
- if (Int(iAscii.asciiValue ?? 0) < I_BB) {
- iAscii = Character(UnicodeScalar((I_BA + 1) + (Int(iAscii.asciiValue ?? 0) - I_BB))!)
- }
- }
- }
- return iAscii
- }
-
- private static func getBeforecChar(ch: Character, inc: Int) -> Character {
- var iAscii = ch
- let iAsciiBefore = iAscii
- if (Int(iAscii.asciiValue ?? 0) > IC_BA || Int(iAscii.asciiValue ?? 0) < IC_BB) {
- } else {
- iAscii = Character(UnicodeScalar(Int(iAscii.asciiValue ?? 0) - inc)!)
- if (Int(iAscii.asciiValue ?? 0) < IC_BB) {
- iAscii = Character(UnicodeScalar((IC_BA + 1) + (Int(iAscii.asciiValue ?? 0) - IC_BB))!)
- if (Int(iAscii.asciiValue ?? 0) < IC_BAT_3 && Int(iAscii.asciiValue ?? 0) > IC_BBT_3) {
- iAscii = Character(UnicodeScalar((IC_BBT_3 + 1) - (IC_BAT_3 - Int(iAscii.asciiValue ?? 0)))!)
- }
- }
- if (IC_BAT_3 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= IC_BAT_3) {
- iAscii = Character(UnicodeScalar((IC_BBT_3 + 1) - (IC_BAT_3 - Int(iAscii.asciiValue ?? 0)))!)
- }
- if (IC_BAT_2 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= IC_BAT_2) {
- iAscii = Character(UnicodeScalar((IC_BBT_2 + 1) - (IC_BAT_2 - Int(iAscii.asciiValue ?? 0)))!)
- }
- if (IC_BAT_1 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= IC_BAT_1) {
- iAscii = Character(UnicodeScalar((IC_BBT_1 + 1) - (IC_BAT_1 - Int(iAscii.asciiValue ?? 0)))!)
- }
- }
- return iAscii
- }
- }
- extension String {
- func substring(from: Int?, to: Int?) -> String {
- if let start = from {
- guard start < self.count else {
- return ""
- }
- }
-
- if let end = to {
- guard end >= 0 else {
- return ""
- }
- }
-
- if let start = from, let end = to {
- guard end - start >= 0 else {
- return ""
- }
- }
-
- let startIndex: String.Index
- if let start = from, start >= 0 {
- startIndex = self.index(self.startIndex, offsetBy: start)
- } else {
- startIndex = self.startIndex
- }
-
- let endIndex: String.Index
- if let end = to, end >= 0, end < self.count {
- endIndex = self.index(self.startIndex, offsetBy: end + 1)
- } else {
- endIndex = self.endIndex
- }
-
- return String(self[startIndex ..< endIndex])
- }
- }
- extension UIColor {
- static var mainColorSS: UIColor {
- return renderColor(hex: "#046cfc")
- }
-
- static var blackDarkModeSS: UIColor {
- return renderColor(hex: "#262626")
- }
-
- private class func renderColor(hex: String) -> UIColor {
- var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
- if (cString.hasPrefix("#")) {
- cString.remove(at: cString.startIndex)
- }
- if ((cString.count) != 6) {
- return UIColor.gray
- }
- var rgbValue:UInt64 = 0
- Scanner(string: cString).scanHexInt64(&rgbValue)
- return UIColor(
- red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
- green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
- blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
- alpha: CGFloat(1.0)
- )
- }
- }
- extension UIApplication {
- static var appVersion: String? {
- return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
- }
-
- var rootViewController: UIViewController? {
- return UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController
- }
-
- var visibleViewController: UIViewController? {
- let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
- if var topController = keyWindow?.rootViewController {
- while let presentedViewController = topController.presentedViewController {
- topController = presentedViewController
- }
- return topController
- }
- return nil
- }
- }
- extension UIImage {
- static func imageWithColorSS(color: UIColor, size: CGSize) -> UIImage? {
- let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
- UIGraphicsBeginImageContextWithOptions(size, false, 0)
- color.setFill()
- UIRectFill(rect)
- guard let image: UIImage = UIGraphicsGetImageFromCurrentImageContext() else {
- return nil
- }
- UIGraphicsEndImageContext()
- return image
- }
- }
- private class TMessageSS {
- var mType: String = ""
- var mVersion: String = ""
- var mCode: String = ""
- var mStatus: String = ""
- var mPIN: String = ""
- var mL_PIN: String = ""
- var mBodies: [String: String] = [String: String]()
- private var mMedia:[UInt8] = [UInt8]()
-
- let C_HEADER:UnicodeScalar = UnicodeScalar(0x01)
- let C_ENTRY:UnicodeScalar = UnicodeScalar(0x02)
- let C_KEYVAL:UnicodeScalar = UnicodeScalar(0x03)
- let C_ARRAY:UnicodeScalar = UnicodeScalar(0x04)
-
- var S_HEADER: String = ""
- var S_ENTRY: String = ""
- var S_KEYVAL: String = ""
- var S_ARRAY: String = ""
-
-
- static let TYPE_SQLITE_ONLY = "1"
- static let TYPE_ALL = "2"
- static let TYPE_NEED_ACK = "3"
-
- let ERRCOD = "A97"
- let MEDIA_LENGTH = "ML"
- let FILE_SIZE = "A53C"
- let IMEI = "Bb"
- let VERCOD = "Bd"
-
- func getCLMUserId() -> String {
- guard let me: String = SecureUserDefaultsSS.shared.value(forKey: "me") else {
- return ""
- }
- return me
- }
-
- init() {
- mVersion = "1.0.116"
- mBodies[IMEI] = getCLMUserId()
- mBodies[VERCOD] = "2.2.177"
- }
-
- init(data : String) {
- _ = unpack(data: data)
- }
-
- init(type: String, version: String, code: String,status: String, pin: String, l_pin: String, bodies:[String: String], media: [UInt8]) {
- mType = type
- mVersion = version
- mCode = code
- mStatus = status
- mPIN = pin
- mL_PIN = l_pin
- mBodies = bodies
- mMedia = media
- mBodies[IMEI] = getCLMUserId()
- mBodies[VERCOD] = "2.2.177"
- }
-
- func clone(p_tmessage:TMessageSS) -> TMessageSS {
- return TMessageSS(
- type: p_tmessage.mType,
- version: p_tmessage.mVersion,
- code: p_tmessage.mCode,
- status: p_tmessage.mStatus,
- pin: p_tmessage.mPIN,
- l_pin: p_tmessage.mL_PIN,
- bodies: p_tmessage.mBodies,
- media: p_tmessage.mMedia
- )
- }
-
- func setMedia(media: [UInt8]) {
- mMedia = media
- mBodies[MEDIA_LENGTH] = String(media.count)
- }
-
- func getCode() -> String {
- return mCode
- }
- func getStatus() -> String {
- return mStatus
- }
- func getPIN() -> String {
- return mPIN
- }
- func getType() -> String {
- return mType
- }
- func getL_PIN() -> String {
- return mL_PIN
- }
- func getMedia() -> [UInt8] {
- return mMedia
- }
- func getBody(key : String) -> String {
- if let data = mBodies[key] {
- return data
- }
- else {
- return ""
- }
- }
- func getBody(key : String, default_value: String) -> String {
- if ((mBodies[key] == nil)) {
- return default_value
- } else if mBodies[key] == "null" {
- return default_value
- } else {
- return mBodies[key]!
- }
- }
-
- func getBodyAsInteger(key : String, default_value: Int) -> Int {
- if ((mBodies[key] == nil)) {
- return default_value
- } else if mBodies[key] == "null" {
- return default_value
- } else {
- return Int(mBodies[key]!)!
- }
- }
- func getBodyAsLong(key : String, default_value: CLong) -> CLong {
- if let body = mBodies[key] {
- if (body == "null") {
- return default_value
- }
- if (body == "nil") {
- return default_value
- }
- return (body as NSString).integerValue
-
- }
- else {
- return default_value
- }
- }
-
- func pack() -> String {
- if (S_HEADER.isEmpty) { S_HEADER.append(Character(C_HEADER)) }
-
- var data = ""
- data.append(mType)
- data.append(Character(C_HEADER))
- data.append(mVersion)
- data.append(Character(C_HEADER))
- data.append(mCode)
- data.append(Character(C_HEADER))
- data.append(mStatus)
- data.append(Character(C_HEADER))
- data.append(mPIN)
- data.append(Character(C_HEADER))
- data.append(mL_PIN)
- data.append(Character(C_HEADER))
- data.append(toString(body: mBodies))
- data.append(Character(C_HEADER))
- if let media = String(data: Data(getMedia()), encoding: .windowsCP1250) {
- data.append(media)
- }
- return data
-
- }
-
-
- func toBytes() -> [UInt8] {
- let data:String = pack()
- var result: [UInt8] = Array(data.utf8)
- if (!getMedia().isEmpty) {
- for index in 0...getMedia().count - 1 {
- result.append(getMedia()[index])
- }
- }
- return result
-
- }
-
- private func toString(body : [String: String]) -> String {
- if (S_ENTRY.isEmpty) { S_ENTRY.append(Character(C_ENTRY)) }
- if (S_KEYVAL.isEmpty) { S_KEYVAL.append(Character(C_KEYVAL)) }
-
- var result = ""
- for (key, value) in body {
- result += key + S_KEYVAL + value + S_ENTRY
- }
- if (!result.isEmpty) {
- result = String(result.prefix(result.count - 1))
- }
- return result
- }
-
- private func toMediaBytes(image: String) -> [UInt8] {
- if (image == "null") {
- return [UInt8]()
- }
- if let data = NSData(base64Encoded: image, options: .ignoreUnknownCharacters) {
- var buffer = [UInt8](repeating: 0, count: data.length)
- data.getBytes(&buffer, length: data.length)
- return buffer
- }
- return [UInt8]()
- }
-
- func unpack(data: String) -> Bool {
- var result = false
- if (S_HEADER.isEmpty) { S_HEADER.append(Character(C_HEADER)) }
- let headers = data.split(separator: Character(C_HEADER), maxSplits: 8, omittingEmptySubsequences: false)
- if (headers.count == 8) {
- mType = String(headers[0])
- mVersion = String(headers[1])
- mCode = String(headers[2])
- mStatus = String(headers[3])
- mPIN = String(headers[4])
- mL_PIN = String(headers[5])
- mBodies = toBodies(data: String(headers[6]))
- mMedia = toMediaBytes(image: String(headers[7]))
- result = true
- }
- return result
- }
-
- func unpack(bytes_data: [UInt8]) -> Bool {
- var result = false
- let data = getData(bytes_data: bytes_data)
- let headers = data.split(separator: Character(C_HEADER), maxSplits: 8, omittingEmptySubsequences: false)
- if (headers.count >= 8) {
- mType = String(headers[0])
- mVersion = String(headers[1])
- mCode = String(headers[2])
- mStatus = String(headers[3])
- mPIN = String(headers[4])
- mL_PIN = String(headers[5])
- mBodies = toBodies(data: String(headers[6]))
- mMedia = getMedia(bytes_data: bytes_data)
- result = true
- }
- else {
- }
- return result
- }
-
- private func toBodies(data: String) -> [String: String] {
- var cvalues = [String: String]()
-
- if (data.isEmpty || data == "") {
- return cvalues
- }
- if (S_ENTRY.isEmpty) { S_ENTRY.append(Character(C_ENTRY)) }
- if (S_KEYVAL.isEmpty) { S_KEYVAL.append(Character(C_KEYVAL)) }
-
- let elements = data.split(separator: Character(C_ENTRY), omittingEmptySubsequences: false)
-
- for element in elements {
- let keyval = element.split(separator: Character(C_KEYVAL), omittingEmptySubsequences: false)
- cvalues[String(keyval[0])] = String(keyval[1])
- }
- return cvalues
- }
-
- private func getData(bytes_data : [UInt8]) -> String {
- var result = ""
- if (S_HEADER.isEmpty) { S_HEADER.append(Character(C_HEADER)) }
-
- var iLength = 0
- for bData in bytes_data {
- let chr = Character(UnicodeScalar(bData))
-
- if (chr == Character(C_HEADER)) {
- iLength = iLength + 1
- if (iLength == 8) {
- break
- }
- }
- result.append(chr)
- }
- return result
- }
-
- private func getMedia(bytes_data: [UInt8]) -> [UInt8] {
- var result:[UInt8] = [UInt8]()
- if bytes_data.count > 0 {
- var ml = getBodyAsInteger(key: MEDIA_LENGTH, default_value: 0)
- if ml == 0 {
- ml = getBodyAsInteger(key: FILE_SIZE, default_value: 0)
- }
- if ml > 0 {
- let start = bytes_data.count - ml
- for index in start...bytes_data.count - 1 {
- result.append(bytes_data[index])
- }
- }
- }
- return result
- }
-
- func toLogString() -> String {
- var result = ""
- result += ("[" + mType + "]")
- result += ("[" + mVersion + "]")
- result += ("[" + mCode + "]")
- result += ("[" + mStatus + "]")
- result += ("[" + mPIN + "]")
- result += ("[" + mL_PIN + "]")
- result += ("[" + toBodyLogString() + "]")
- result += ("[" + String(mMedia.count) + "]")
- return result
- }
-
- private func toBodyLogString() -> String {
- if (S_ENTRY.isEmpty) { S_ENTRY.append(Character(C_ENTRY)) }
- if (S_KEYVAL.isEmpty) { S_KEYVAL.append(Character(C_KEYVAL)) }
-
- var result = ""
- for (key, value) in mBodies {
- result += "{" + key + "=" + value + "}"
- }
- return result
- }
-
- func isOk() -> Bool {
- return getBody(key: ERRCOD, default_value: "99") == "00"
- }
- }
- private class CoreMessage_TMessageUtil {
-
- private static var mTID = NSDate().timeIntervalSince1970 * 1000
-
- static func getTID() -> String {
- mTID = Double(Int(mTID) + Int(1))
- return String(Int(mTID))
- }
-
- static func getString(json: Any, key: String) -> String {
- return getString(json: json, key: key, def: "")
- }
-
- static func getString(json: Any, key: String, def: String) -> String {
- if let dict = json as? [String: Any], let value = dict[key] as? String {
- if !value.isEmpty {
- return value
- }
- }
- return def
- }
-
- static func getInt(json: Any, key: String, def: Int) -> Int {
- if let dict = json as? [String: Any], let value = dict[key] as? Int {
- return value
- }
- return def
- }
-
- static func getIntAsString(json: Any, key: String, def: Int) -> String {
- return String(getInt(json: json, key: key, def: def))
- }
-
- static func getLong(json: Any, key: String, def: CLong) -> CLong {
- if let dict = json as? [String: Any], let value = dict[key] as? CLong {
- return value
- }
- return def
- }
-
- }
- private class SSLibAlertController: UIAlertController {
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
-
- // Customize the title's font
- let titleFont = UIFont.boldSystemFont(ofSize: 16)
- let titleAttributes = [NSAttributedString.Key.font: titleFont]
- setValue(NSAttributedString(string: self.title ?? "", attributes: titleAttributes), forKey: "attributedTitle")
-
- // Change the font for the message
- let messageFont = UIFont.systemFont(ofSize: 14)
- let messageAttributes = [NSAttributedString.Key.font: messageFont]
- setValue(NSAttributedString(string: self.message ?? "", attributes: messageAttributes), forKey: "attributedMessage")
-
- for i in self.actions {
- let attributedText = NSAttributedString(string: i.title ?? "", attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)])
- guard let label = (i.value(forKey: "__representer") as AnyObject).value(forKey: "label") as? UILabel else { return }
- label.attributedText = attributedText
- }
- }
- }
- private class SecureUserDefaultsSS {
- static let shared = SecureUserDefaultsSS()
- private let defaults: UserDefaults
- private let prefsKeyAlias = "_iosx_security_master_key_easysoft_"
- // Initialization with a SymmetricKey
- init(defaults: UserDefaults = .standard) {
- self.defaults = defaults
- do {
- try generateAndStorePrefsKey()
- } catch {
-
- }
- }
-
- func generateAndStorePrefsKey() throws {
- if try isKeyExists(keyAliasCode: prefsKeyAlias) {
- return
- }
- let key = SymmetricKey(size: .bits256)
- let keyData = key.withUnsafeBytes { Data($0) }
-
- let query: [String: Any] = [
- kSecClass as String: kSecClassKey,
- kSecAttrApplicationTag as String: prefsKeyAlias,
- kSecValueData as String: keyData,
- kSecAttrAccessible as String: kSecAttrAccessibleAfterFirstUnlock
- ]
-
- SecItemDelete(query as CFDictionary) // Remove if it exists
- let status = SecItemAdd(query as CFDictionary, nil)
- guard status == errSecSuccess else {
- throw NSError(domain: "KeychainError", code: Int(status), userInfo: nil)
- }
- }
-
- func isKeyExists(keyAliasCode: String) throws -> Bool {
- let query: [String: Any] = [
- kSecClass as String: kSecClassKey,
- kSecAttrApplicationTag as String: keyAliasCode,
- kSecReturnData as String: false // We only check existence, not retrieve data
- ]
- let status = SecItemCopyMatching(query as CFDictionary, nil)
- if status == errSecItemNotFound {
- return false
- } else if status == errSecSuccess {
- return true
- } else {
- throw NSError(domain: "KeychainError", code: Int(status), userInfo: nil)
- }
- }
-
- func getPrefsKey() throws -> SymmetricKey {
- let query: [String: Any] = [
- kSecClass as String: kSecClassKey,
- kSecAttrApplicationTag as String: prefsKeyAlias,
- kSecReturnData as String: true
- ]
-
- var item: CFTypeRef?
- let status = SecItemCopyMatching(query as CFDictionary, &item)
- guard status == errSecSuccess else {
- throw NSError(domain: "KeychainError", code: Int(status), userInfo: nil)
- }
-
- guard let keyData = item as? Data else {
- throw NSError(domain: "KeyRetrievalError", code: -1, userInfo: nil)
- }
-
- return SymmetricKey(data: keyData)
- }
- func encrypt(data: Data) throws -> Data {
- let key = try getPrefsKey()
- let sealedBox = try AES.GCM.seal(data, using: key)
- return sealedBox.combined!
- }
-
- func decrypt(data: Data) throws -> Data {
- let key = try getPrefsKey()
- let sealedBox = try AES.GCM.SealedBox(combined: data)
- return try AES.GCM.open(sealedBox, using: key)
- }
- func set<T: Codable>(_ value: T, forKey key: String) {
- let encoder = JSONEncoder()
- guard let encodedData = try? encoder.encode(value),
- let encryptedData = try? encrypt(data: encodedData) else {
- return
- }
- defaults.set(encryptedData, forKey: key)
- }
- // Retrieve a value
- func value<T: Codable>(forKey key: String) -> T? {
- guard let encryptedData = defaults.data(forKey: key),
- let decryptedData = try? decrypt(data: encryptedData) else {
- return nil
- }
- let decoder = JSONDecoder()
- return try? decoder.decode(T.self, from: decryptedData)
- }
- // Remove a value
- func removeValue(forKey key: String) {
- defaults.removeObject(forKey: key)
- }
-
- func sync() {
- defaults.synchronize()
- }
- }
- class CallBackSS : CallBack {
- var sID: String = ""
-
- func connectionStateChanged(sUserID: String!, sDeviceID: String!, bConState: Bool!, nConType: Int!, nConSubType: Int!, nCLMConStat: UInt8!) {
-
- }
-
- func gpsStateChanged(nState: Int!) {
-
- }
-
- func sleepStateChanged(bState: Bool!) {
-
- }
-
- func callStateChanged(nState: Int!, sMessage: String!) -> Int {
- return 1
- }
-
- func bcastStateChanged(nState: Int!, sMessage: String!) -> Int {
- return 1
- }
-
- func sshareStateChanged(nState: Int!, sMessage: String!) -> Int {
- return 1
- }
-
- func incomingData(sPacketID: String!, oData: AnyObject!) throws {
-
- }
-
- func lateResponse(sPacketID: String!, sResponse: String!) throws {
-
- }
-
- func asycnACKReceived(sPacketID: String!) throws {
-
- }
-
- func locationUpdated(lTime: Int64!, sLocationInfo: String!) {
-
- }
-
- func resetDB() {
-
- }
-
-
- }
|