Module: Macos::Artifacts

Defined in:
lib/macos/artifacts.rb,
lib/macos/artifacts/apps.rb,
lib/macos/artifacts/help.rb,
lib/macos/artifacts/files.rb,
lib/macos/artifacts/state.rb,
lib/macos/artifacts/version.rb

Defined Under Namespace

Modules: Apps, Files, Help, State

Constant Summary collapse

VERSION =
"0.6.4"

Class Method Summary collapse

Class Method Details

.airDropObject



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/macos/artifacts.rb', line 147

def self.airDrop
  airdropUsage = `log show --style json --last 7d --predicate 'subsystem == "com.apple.sharing" AND category == "AirDrop" AND eventMessage == "Sending Ask response with code OK (200)"'`.strip
  data = JSON.parse(airdropUsage)

  puts "Airdrop Activty last 7 Days:"
  data.each do |item|
      # puts item
      puts "  UserID: #{item["userID"]}"
      puts "  Subsystem: #{item["subsystem"]}"
      puts "  Category: #{item["category"]}"
      puts "  Time: #{item["timestamp"]}"
      puts "  Message: #{item["eventMessage"]}"
      puts ""
  end
end

.architectureObject



56
57
58
59
# File 'lib/macos/artifacts.rb', line 56

def self.architecture
  arch = `uname -m`.strip
  puts "Architecture: #{arch}"
end

.buildObject



31
32
33
34
# File 'lib/macos/artifacts.rb', line 31

def self.build
  osBuild = `sw_vers -BuildVersion`.strip
  puts "Build: #{osBuild}"
end

.chipObject



51
52
53
54
# File 'lib/macos/artifacts.rb', line 51

def self.chip
  chipArch = `system_profiler SPHardwareDataType | grep "Chip" | cut -d ":" -f2 | xargs`.strip
  puts "Chip: #{chipArch}"
end

.computerNameObject



16
17
18
19
# File 'lib/macos/artifacts.rb', line 16

def self.computerName
  computerName = `scutil --get ComputerName`.strip
  puts "Host Name: #{computerName}"
end

.filevaultStatusObject



86
87
88
89
# File 'lib/macos/artifacts.rb', line 86

def self.filevaultStatus
  command = `fdesetup status | awk '{print $3}' | head -c2 | xargs`.strip
  puts "FireVault Status: #{command}"
end

.firewallStatusObject



91
92
93
94
95
96
97
98
99
# File 'lib/macos/artifacts.rb', line 91

def self.firewallStatus
  command =  `defaults read /Library/Preferences/com.apple.alf globalstate`.strip

  if command == "0"
    puts "Firewall Status: Off"
  else
    puts "Firewall Status: On"
  end
end

.hardwareUIDObject



66
67
68
69
# File 'lib/macos/artifacts.rb', line 66

def self.hardwareUID
  uuid = `system_profiler SPHardwareDataType | grep "Hardware" | cut -d ":" -f2 | xargs`.strip
  puts "Hardware UID: #{uuid}"
end

.kernelObject



36
37
38
39
# File 'lib/macos/artifacts.rb', line 36

def self.kernel
  arch = `uname -r`.strip
  puts "Kernel: #{arch}"
end

.lockStatusObject



101
102
103
104
# File 'lib/macos/artifacts.rb', line 101

def self.lockStatus
  status = `system_profiler SPHardwareDataType | grep "Activation Lock Status" | cut -d ":" -f2 | xargs`.strip
  puts "Activation Lock Status: #{status}"
end

.memoryObject



61
62
63
64
# File 'lib/macos/artifacts.rb', line 61

def self.memory
  memory = `system_profiler SPHardwareDataType | grep "Memory" | cut -d ":" -f2 | xargs`.strip
  puts "Memory: #{memory}"
end

.modelIDObject



46
47
48
49
# File 'lib/macos/artifacts.rb', line 46

def self.modelID
  modelID =  `system_profiler SPHardwareDataType | grep "Model Identifier" | cut -d ":" -f2 | xargs`.strip
  puts "Model ID: #{modelID}"
end

.modelNameObject



41
42
43
44
# File 'lib/macos/artifacts.rb', line 41

def self.modelName
  modelName = `system_profiler SPHardwareDataType | grep "Model Name" | cut -d ":" -f2 | xargs`.strip
  puts "Model Name: #{modelName}"
end

.privateIPObject



76
77
78
79
# File 'lib/macos/artifacts.rb', line 76

def self.privateIP
  ip = `ipconfig getifaddr en0`.strip
  puts "Private IP: #{ip}"
end

.publicIPObject



71
72
73
74
# File 'lib/macos/artifacts.rb', line 71

def self.publicIP
  ip = `dig -4 TXT +short o-o.myaddr.l.google.com ns1.google.com | tr -d '"'`.strip
  puts "Public IP: #{ip}"
end

.screenlockStatusObject



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/macos/artifacts.rb', line 106

def self.screenlockStatus
  screensaverPlist = "/Library/Managed Preferences/com.apple.screensaver.plist"

  if File.exists?("#{screensaverPlist}")
    screenSaverTime = `defaults read '#{screensaverPlist}' askForPasswordDelay`.strip
    puts "found"
  else
    $askForPasswordStatus = `sysadminctl -screenLock status 2>&1 >/dev/null`.split("]")
    puts "Screen Lock Status: #{$askForPasswordStatus[1].strip}"
  end
end

.serialObject



21
22
23
24
# File 'lib/macos/artifacts.rb', line 21

def self.serial
  serialNumber = `system_profiler SPHardwareDataType | grep Serial | cut -d ":" -f2 | xargs`.strip
  puts "Serial: #{serialNumber}"
end

.sipStatusObject



81
82
83
84
# File 'lib/macos/artifacts.rb', line 81

def self.sipStatus
  command = `csrutil status | cut -d ":" -f2 | xargs | head -c7 | xargs`.strip
  puts "SIP Status: #{command}"
end

.softwareUpdatesObject



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/macos/artifacts.rb', line 118

def self.softwareUpdates
  managedUpdates = "/Library/Managed Preferences/com.apple.SoftwareUpdate.plist"

  puts "Software Updates:"
  if File.exists?("#{managedUpdates}")
    autoCheck = `defaults read "#{managedUpdates}" AutomaticCheckEnabled`.strip
    automaticDownload = `defaults read "#{managedUpdates}" AutomaticDownload`.strip
    automaticallyInstallMacOSUpdates = `defaults read "#{managedUpdates}" AutomaticallyInstallMacOSUpdates`.strip
    configDataInstall = `defaults read "#{managedUpdates}" ConfigDataInstall`.strip
    criticalUpdateInstall = `defaults read "#{managedUpdates}" CriticalUpdateInstall`.strip
    puts "  Auto Updates: #{autoCheck}"
    puts "  Auto Download: #{automaticDownload}"
    puts "  Auto Install: #{automaticallyInstallMacOSUpdates}"
    puts "  Install Config Data: #{configDataInstall}"
    puts "  Install Critical Updates: #{criticalUpdateInstall}"
  else
    autoCheck = `defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled`.strip
    automaticDownload = `defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload`.strip
    automaticallyInstallMacOSUpdates = `defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticallyInstallMacOSUpdates`.strip
    configDataInstall = `defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall`.strip
    criticalUpdateInstall = `defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall`.strip
    puts "  Auto Updates: #{autoCheck}"
    puts "  Auto Download: #{automaticDownload}"
    puts "  Auto Install: #{automaticallyInstallMacOSUpdates}"
    puts "  Install Config Data: #{configDataInstall}"
    puts "  Install Critical Updates: #{criticalUpdateInstall}"
  end
end

.versionObject



26
27
28
29
# File 'lib/macos/artifacts.rb', line 26

def self.version
  osVersion = `sw_vers -ProductVersion`.strip
  puts "Version: #{osVersion}"
end