Question: Write a script that analyzes the events in your windows System Security Log. To make the lab easier export your security log entries to a

Write a script that analyzes the events in your windows System Security Log. To make the lab easier export your security log entries to a CSV file which will be used by the script to perform the analysis. The script should count the number of success and failure audits logged, provide the count associated with each, and the most common event ID.

I have never written in python before so where am i going wrong? This is what i have so far:

import pandas as pd

import os

path = "/usr/tmp"

retval = os.getcwd()

os.chdir(r"C:\Users\DakotaDavila\Desktop")

df = pd.read_csv("SystemSecurityLogs.csv")

df_success = df[df['Keywords'] == 'Audit Success']

df_failure = df[df['Keywords'] == 'Audit Failure']

total = len(df_success.index) + len(df_failure.index)

err_ID_failure = str(st.mode(df_failure['Event ID'].tolist()))

err_ID_success = str(st.mode(df_success['Event ID'].tolist()))

print("Number of Audit Failures: " +str(len(df_failure.index))

+ " failures of " + str(total) + " entries \t"

+ "Most common Event ID: " + err_ID_failure

+ " Number of Audit Successes: " + str(len(df_success.index))

+ " successes of " + str(total) + " entries \t"

+ "Most common Event ID: " + err_ID_success)

And here is the first part of the csv file:

Keywords Date and Time Source Event ID Task Category
Audit Success 11/12/2018 9:55 Microsoft-Windows-Security-Auditing 4672 Special Logon Special privileges assigned to new logon. Subject: Security ID: SYSTEM Account Name: SYSTEM Account Domain: NT AUTHORITY Logon ID: 0x3E7 Privileges: SeAssignPrimaryTokenPrivilege SeTcbPrivilege SeSecurityPrivilege SeTakeOwnershipPrivilege SeLoadDriverPrivilege SeBackupPrivilege SeRestorePrivilege SeDebugPrivilege SeAuditPrivilege SeSystemEnvironmentPrivilege SeImpersonatePrivilege SeDelegateSessionUserImpersonatePrivilege
Audit Success 11/12/2018 9:55 Microsoft-Windows-Security-Auditing 4624 Logon An account was successfully logged on. Subject: Security ID: SYSTEM Account Name: DAKOTAS-LAPTOP$ Account Domain: WORKGROUP Logon ID: 0x3E7 Logon Information: Logon Type: 5 Restricted Admin Mode: - Virtual Account: No Elevated Token: Yes Impersonation Level: Impersonation New Logon: Security ID: SYSTEM Account Name: SYSTEM Account Domain: NT AUTHORITY Logon ID: 0x3E7 Linked Logon ID: 0x0 Network Account Name: - Network Account Domain: - Logon GUID: {00000000-0000-0000-0000-000000000000} Process Information: Process ID: 0x350 Process Name: C:\Windows\System32\services.exe Network Information: Workstation Name: - Source Network Address: - Source Port: - Detailed Authentication Information: Logon Process: Advapi Authentication Package: Negotiate Transited Services: - Package Name (NTLM only): - Key Length: 0 This event is generated when a logon session is created. It is generated on the computer that was accessed. The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe. The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network). The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on. The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases. The impersonation level field indicates the extent to which a process in the logon session can impersonate. The authentication information fields provide detailed information about this specific logon request. - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event. - Transited services indicate which intermediate services have participated in this logon request. - Package name indicates which sub-protocol was used among the NTLM protocols. - Key length indicates the length of the generated session key. This will be 0 if no session key was requested.
Audit Success 11/12/2018 9:51 Microsoft-Windows-Security-Auditing 4672 Special Logon Special privileges assigned to new logon. Subject: Security ID: SYSTEM Account Name: SYSTEM Account Domain: NT AUTHORITY Logon ID: 0x3E7 Privileges: SeAssignPrimaryTokenPrivilege SeTcbPrivilege SeSecurityPrivilege SeTakeOwnershipPrivilege SeLoadDriverPrivilege SeBackupPrivilege SeRestorePrivilege SeDebugPrivilege SeAuditPrivilege SeSystemEnvironmentPrivilege SeImpersonatePrivilege SeDelegateSessionUserImpersonatePrivilege
Audit Success 11/12/2018 9:51 Microsoft-Windows-Security-Auditing 4624 Logon An account was successfully logged on. Subject: Security ID: SYSTEM Account Name: DAKOTAS-LAPTOP$ Account Domain: WORKGROUP Logon ID: 0x3E7 Logon Information: Logon Type: 5 Restricted Admin Mode: - Virtual Account: No Elevated Token: Yes Impersonation Level: Impersonation New Logon: Security ID: SYSTEM Account Name: SYSTEM Account Domain: NT AUTHORITY Logon ID: 0x3E7 Linked Logon ID: 0x0 Network Account Name: - Network Account Domain: - Logon GUID: {00000000-0000-0000-0000-000000000000} Process Information: Process ID: 0x350 Process Name: C:\Windows\System32\services.exe Network Information: Workstation Name: - Source Network Address: - Source Port: - Detailed Authentication Information: Logon Process: Advapi Authentication Package: Negotiate Transited Services: - Package Name (NTLM only): - Key Length: 0 This event is generated when a logon session is created. It is generated on the computer that was accessed. The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe. The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network). The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on. The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases. The impersonation level field indicates the extent to which a process in the logon session can impersonate. The authentication information fields provide detailed information about this specific logon request. - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event. - Transited services indicate which intermediate services have participated in this logon request. - Package name indicates which sub-protocol was used among the NTLM protocols. - Key length indicates the length of the generated session key. This will be 0 if no session key was requested.
Audit Success 11/12/2018 9:48 Microsoft-Windows-Security-Auditing 5379 User Account Management Credential Manager credentials were read. Subject: Security ID: DAKOTAS-LAPTOP\Dakota_Davila Account Name: Dakota_Davila Account Domain: DAKOTAS-LAPTOP Logon ID: 0x3E493CA Read Operation: Enumerate Credentials This event occurs when a user performs a read operation on stored credentials in Credential Manager.
Audit Success 11/12/2018 9:46 Microsoft-Windows-Security-Auditing 4672 Special Logon Special privileges assigned to new logon. Subject: Security ID: SYSTEM Account Name: SYSTEM Account Domain: NT AUTHORITY Logon ID: 0x3E7 Privileges: SeAssignPrimaryTokenPrivilege SeTcbPrivilege SeSecurityPrivilege SeTakeOwnershipPrivilege SeLoadDriverPrivilege SeBackupPrivilege SeRestorePrivilege SeDebugPrivilege SeAuditPrivilege SeSystemEnvironmentPrivilege SeImpersonatePrivilege SeDelegateSessionUserImpersonatePrivilege
Audit Success 11/12/2018 9:46 Microsoft-Windows-Security-Auditing 4624 Logon An account was successfully logged on. Subject: Security ID: SYSTEM Account Name: DAKOTAS-LAPTOP$ Account Domain: WORKGROUP Logon ID: 0x3E7 Logon Information: Logon Type: 5 Restricted Admin Mode: - Virtual Account: No Elevated Token: Yes Impersonation Level: Impersonation New Logon: Security ID: SYSTEM Account Name: SYSTEM Account Domain: NT AUTHORITY Logon ID: 0x3E7 Linked Logon ID: 0x0 Network Account Name: - Network Account Domain: - Logon GUID: {00000000-0000-0000-0000-000000000000} Process Information: Process ID: 0x350 Process Name: C:\Windows\System32\services.exe Network Information: Workstation Name: - Source Network Address: - Source Port: - Detailed Authentication Information: Logon Process: Advapi Authentication Package: Negotiate Transited Services: - Package Name (NTLM only): - Key Length: 0 This event is generated when a logon session is created. It is generated on the computer that was accessed. The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe. The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network). The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on. The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases. The impersonation level field indicates the extent to which a process in the logon session can impersonate. The authentication information fields provide detailed information about this specific logon request. - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event. - Transited services indicate which intermediate services have participated in this logon request. - Package name indicates which sub-protocol was used among the NTLM protocols. - Key length indicates the length of the generated session key. This will be 0 if no session key was requested.
Audit Success 11/12/2018 9:41 Microsoft-Windows-Security-Auditing 4798 User Account Management A user's local group membership was enumerated. Subject: Security ID: SYSTEM Account Name: DAKOTAS-LAPTOP$ Account Domain: WORKGROUP Logon ID: 0x3E7 User: Security ID: DAKOTAS-LAPTOP\Dakota_Davila Account Name: Dakota_Davila Account Domain: Dakotas-Laptop Process Information: Process ID: 0x700 Process Name: C:\Windows\System32\svchost.exe
Audit Success 11/12/2018 9:41 Microsoft-Windows-Security-Auditing 4798 User Account Management A user's local group membership was enumerated. Subject: Security ID: SYSTEM Account Name: DAKOTAS-LAPTOP$ Account Domain: WORKGROUP Logon ID: 0x3E7 User: Security ID: Dakotas-Laptop\Administrator Account Name: Administrator Account Domain: Dakotas-Laptop Process Information: Process ID: 0x700 Process Name: C:\Windows\System32\svchost.exe

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!