Skip to content

Commit

Permalink
VPN detection added
Browse files Browse the repository at this point in the history
  • Loading branch information
r3ggi committed May 20, 2024
1 parent cf0f36d commit 2304290
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions IOSSecuritySuite/ProxyChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,39 @@
import Foundation

internal class ProxyChecker {
static func amIProxied() -> Bool {
guard let unmanagedSettings = CFNetworkCopySystemProxySettings() else {
return false
static func amIProxied(considerVPNConnectionAsProxy: Bool = false) -> Bool {
guard let unmanagedSettings = CFNetworkCopySystemProxySettings() else {
return false
}

let settingsOptional = unmanagedSettings.takeRetainedValue() as? [String: Any]

guard let settings = settingsOptional else {
return false
}

if(considerVPNConnectionAsProxy) {
if let scoped = settings["__SCOPED__"] as? [String: Any] {
for interface in scoped.keys {

let names = [
"tap",
"tun",
"ppp",
"ipsec",
"utun"
]

for name in names {
if(interface.contains(name)) {
print("detected: \(interface)")
return true
}
}
}
}
}

return (settings.keys.contains("HTTPProxy") || settings.keys.contains("HTTPSProxy"))
}

let settingsOptional = unmanagedSettings.takeRetainedValue() as? [String: Any]

guard let settings = settingsOptional else {
return false
}

return (settings.keys.contains("HTTPProxy") || settings.keys.contains("HTTPSProxy"))
}
}

0 comments on commit 2304290

Please sign in to comment.