Skip to content

Commit

Permalink
Version 3.7.6
Browse files Browse the repository at this point in the history
- Added `SIP.SIPStatus.resultsFullyDisabled` to detect if SIP is actually fully disabled
- Improved some comments and descriptions
- Updated the demo playground
  • Loading branch information
ITzTravelInTime committed Jul 29, 2021
1 parent c1057e8 commit afab6b8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Playgrounds/Demo.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ print("Is this program running on a macOS Recovery/Installer OS? \((Recovery.sta

print("SIP raw status: 0x\(String(SIP.status, radix: 16) )")

print("Is SIP fully disabled? \(SIP.status.resultsFullyDisabled ? "Yes" : "No")")

if let status = SIP.status.resultsEnabled {
print("Is SIP activated? \(status ? "Yes" : "No")")
}else{
Expand Down
17 changes: 15 additions & 2 deletions Sources/TINURecovery/SIP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ open class SIP: SimulatableDetectable{
return ret
}

///A mask integer wth all the flags expected to be set for SIP to be on or off
///A mask integer wth all the flags expected to be set for SIP by csrutil when sip is enabled or disabled using the system recovery
public static var CSR_DISABLE_FLAGS: SIPIntegerFormat{

return CSR_ALLOW_UNTRUSTED_KEXTS.rawValue | CSR_ALLOW_UNRESTRICTED_FS.rawValue | CSR_ALLOW_TASK_FOR_PID.rawValue | CSR_ALLOW_KERNEL_DEBUGGER.rawValue | CSR_ALLOW_APPLE_INTERNAL.rawValue | CSR_ALLOW_UNRESTRICTED_DTRACE.rawValue | CSR_ALLOW_UNRESTRICTED_NVRAM.rawValue
Expand Down Expand Up @@ -180,7 +180,7 @@ public extension SIP.SIPStatus{
return (self & (~SIP.SIPBits.CSR_VALID_FLAGS)) != 0
}

///Indicates if SIP is fully enabled, fully disabled or uses an undeterminated configuration
///Indicates if SIP has enabled all the valus that csrutil will change when it sets the SIP enabled, or disabled or uses a mixed configuration
var resultsEnabled: Bool!{
let ref = (SIP.SIPBits.CSR_DISABLE_FLAGS & (~SIP.SIPBits.CSR_ALLOW_APPLE_INTERNAL.rawValue) )
switch (self & ref) {
Expand All @@ -193,6 +193,19 @@ public extension SIP.SIPStatus{
}
}

///Indicates if SIP has all the valus supported by the current OS all enabled
var resultsFullyDisabled: Bool{
let ref = SIP.SIPBits.CSR_VALID_FLAGS & (~SIP.SIPBits.CSR_ALLOW_APPLE_INTERNAL.rawValue)

switch self & ref {
case ref:
return true
default:
return false
}

}

///Returns the SIP configuration as an integer
var detailedConfigurationInteger: SIP.SIPStatus{
return self
Expand Down
4 changes: 3 additions & 1 deletion Sources/TINURecovery/SIPUserDescriptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ public extension SIP.SIPStatus{
func statusStrig() -> String{
var ret = ""

let fully = self.resultsFullyDisabled

if let stat = self.resultsEnabled{
ret += "SIP is \(stat ? "enabled" : "disabled")"
ret += "SIP is \(fully ? "fully " : "")\(stat ? "enabled" : "disabled")"
}else{
ret += "SIP status unknown"
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TINURecovery/Sandbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
#if os(macOS)
///This class manages program sandbox detection code
public final class Sandbox{

///Detects is the current program is running as sandboxed
public static var isEnabled: Bool {
//Uses a static value to avoid repeting the detection code for each call of the variable
Expand Down

0 comments on commit afab6b8

Please sign in to comment.