-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
username updates and cleanup #17
Changes from 5 commits
d1f4212
a2c9c23
26787ca
b68a43e
7b86f47
30c6947
ede03e2
b7a6ba5
4aac700
e4a5ed2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,24 +26,29 @@ class BashProfiles: ArtifactsModule { | |
let globalFiles = ["/etc/profile", "/etc/zshenv", "/etc/zprofile", "/etc/zshrc", "/etc/zlogin", "/etc/zlogout"] | ||
|
||
// for each user, copy the shell historys and profiles | ||
if let users = self.users { | ||
for user in users { | ||
for filename in userFiles { | ||
let path = URL(fileURLWithPath: "\(user.homedir)/\(filename)") | ||
for user in getUsersOnSystem() { | ||
for filename in userFiles { | ||
let path = URL(fileURLWithPath: "\(user.homedir)/\(filename)") | ||
if (filemanager.fileExists(atPath: path.path)) { | ||
let newFileName = "\(user.username)_\(filename)" | ||
self.copyFileToCase(fileToCopy: path, toLocation: self.profilesDir, newFileName: newFileName) | ||
} | ||
} else { continue } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these continue's performing any additional function that I don't know about? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they break that current iteration of the |
||
|
||
} | ||
} | ||
|
||
|
||
// Copy all the global files | ||
for file in globalFiles { | ||
let fileUrl = URL(fileURLWithPath: file) | ||
let filename = fileUrl.lastPathComponent | ||
let newFileName = "etc_\(filename)" | ||
self.copyFileToCase(fileToCopy: fileUrl, toLocation: self.profilesDir, newFileName: newFileName) | ||
if (filemanager.fileExists(atPath: fileUrl.path)) { | ||
let filename = fileUrl.lastPathComponent | ||
let newFileName = "etc_\(filename)" | ||
self.copyFileToCase(fileToCopy: fileUrl, toLocation: self.profilesDir, newFileName: newFileName) | ||
} else { continue } | ||
} | ||
|
||
|
||
self.log("Finished collecting shell history and profile information...") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,65 +16,78 @@ class TCC: ArtifactsModule { | |
} | ||
|
||
func getTCC() { | ||
let fileURL = try! filemanager.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathComponent("com.apple.TCC/TCC.db") | ||
self.copyFileToCase(fileToCopy: fileURL, toLocation: tccDir) | ||
|
||
let capturedTCC = self.createNewCaseFile(dirUrl: self.moduleDirRoot, filename: "tccItems.txt") | ||
var db : OpaquePointer? | ||
|
||
if sqlite3_open(fileURL.path, &db) == SQLITE_OK { | ||
var queryStatement: OpaquePointer? = nil | ||
let queryString = "select client, auth_value, auth_reason, service from access" | ||
for user in getBasicUsersOnSystem() { | ||
|
||
var fileURL: URL | ||
if filemanager.fileExists(atPath: "\(user.homedir)/Library/Application Support/com.apple.TCC/TCC.db") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To keep this cleaner
|
||
fileURL = URL(fileURLWithPath: "\(user.homedir)/Library/Application Support/com.apple.TCC/TCC.db") | ||
} else { continue } | ||
|
||
|
||
self.copyFileToCase(fileToCopy: fileURL, toLocation: tccDir, newFileName: "tcc_\(user.username)") | ||
|
||
if sqlite3_prepare_v2(db, queryString, -1, &queryStatement, nil) == SQLITE_OK { | ||
var client: String = "" | ||
var authValue: String = "" | ||
var authReason: String = "" | ||
var service: String = "" | ||
|
||
var db : OpaquePointer? | ||
|
||
if sqlite3_open(fileURL.path, &db) == SQLITE_OK { | ||
var queryStatement: OpaquePointer? = nil | ||
let queryString = "select client, auth_value, auth_reason, service from access" | ||
|
||
while sqlite3_step(queryStatement) == SQLITE_ROW { | ||
let col1 = sqlite3_column_text(queryStatement, 0) | ||
if col1 != nil{ | ||
client = String(cString: col1!) | ||
} | ||
if sqlite3_prepare_v2(db, queryString, -1, &queryStatement, nil) == SQLITE_OK { | ||
var client: String = "" | ||
var authValue: String = "" | ||
var authReason: String = "" | ||
var service: String = "" | ||
|
||
let col2 = sqlite3_column_text(queryStatement, 1) | ||
if col2 != nil { | ||
authValue = String(cString: col2!) | ||
for item in TCCAuthValue.allCases { | ||
if authValue == String(item.rawValue) { | ||
authValue = String(describing: item) | ||
while sqlite3_step(queryStatement) == SQLITE_ROW { | ||
let col1 = sqlite3_column_text(queryStatement, 0) | ||
if col1 != nil{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can clean all of these up by using
This is the more standard way to do it in swift that way you're not force unwrapping with If you would prefer to do all of this in a separate PR that's fine. I know you have a lot of sql statements |
||
client = String(cString: col1!) | ||
} | ||
|
||
let col2 = sqlite3_column_text(queryStatement, 1) | ||
if col2 != nil { | ||
authValue = String(cString: col2!) | ||
for item in TCCAuthValue.allCases { | ||
if authValue == String(item.rawValue) { | ||
authValue = String(describing: item) | ||
} | ||
} | ||
} | ||
} | ||
|
||
let col3 = sqlite3_column_text(queryStatement, 2) | ||
if col3 != nil { | ||
authReason = String(cString: col3!) | ||
for item in TCCAuthReason.allCases { | ||
if authReason == String(item.rawValue) { | ||
authReason = String(describing: item) | ||
let col3 = sqlite3_column_text(queryStatement, 2) | ||
if col3 != nil { | ||
authReason = String(cString: col3!) | ||
for item in TCCAuthReason.allCases { | ||
if authReason == String(item.rawValue) { | ||
authReason = String(describing: item) | ||
} | ||
} | ||
} | ||
} | ||
|
||
let col4 = sqlite3_column_text(queryStatement, 3) | ||
if col4 != nil { | ||
service = String(cString: col4!) | ||
for item in TCCService.allCases { | ||
if service == String(item.rawValue) { | ||
service = String(describing: item) | ||
let col4 = sqlite3_column_text(queryStatement, 3) | ||
if col4 != nil { | ||
service = String(cString: col4!) | ||
for item in TCCService.allCases { | ||
if service == String(item.rawValue) { | ||
service = String(describing: item) | ||
} | ||
} | ||
} | ||
|
||
self.addTextToFile(atUrl: capturedTCC, text: "TCC Data for \(user.username)") | ||
self.addTextToFile(atUrl: capturedTCC, text: "Name: \(client)\nRequested Service: \(service)\nAuth Value: \(authValue)\nAuth Reason: \(authReason)\n") | ||
} | ||
|
||
self.addTextToFile(atUrl: capturedTCC, text: "Name: \(client)\nRequested Service: \(service)\nAuth Value: \(authValue)\nAuth Reason: \(authReason)\n") | ||
} | ||
self.log("Finished capturing TCC data for \(user.username)") | ||
} else { | ||
self.log("An error occurred when attempting to query the TCC database for user \(user.username)...") | ||
} | ||
self.log("Finished capturing TCC data") | ||
} else { | ||
self.log("An error occurred when attempting to query the TCC database...") | ||
} | ||
self.log("Finished querying TCC") | ||
} | ||
|
||
override func run() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed?