Day to Day

Renamed Command Line Programs
event_platform=win event_simpleName=ProcessRollup2 ImageSubsystem_decimal=3 
| rename FileName as runningExe
| lookup local=true appinfo.csv SHA256HashData OUTPUT FileName FileDescription
| eval runningExe=lower(runningExe)
| eval FileName=lower(FileName)
| where runningExe!=FileName
| search FileName=cmd.exe
| stats dc(aid) as "System Count" count(aid) as "Execution Count" values(runningExe) as "File On Disk" values(FileName) as "Cloud File Name" values(FileDescription) as "File Description" by SHA256HashData
Mining Windows Command History for Artifacts

Video : Click Here Note : Open the Link in Personal Laotop Only

index=main sourcetype=CommandHistory* event_platform=win event_simpleName=CommandHistory
| rex field=CommandHistory ".*(?<passedURL>http(|s)\:\/\/.*\.(net|com|org|io)).*"
| where isnotnull(passedURL)
| fillnull ApplicationName value="powershell.exe"
| eval timestamp=timestamp/1000
| table timestamp ComputerName ApplicationName TargetProcessId_decimal passedURL CommandHistory 
| search ComputerName!=DESKTOP-ICAKMS8 AND passedURL!="*.crowdstrike.*" AND passedURL!="*.microsoft.*"
| convert ctime(timestamp)
| rename timestamp as Time, ComputerName as Endpoint, ApplicationName as "Responsible Application", TargetProcessId_decimal as "Falcon PID", passedURL as "URL Fragment", CommandHistory as "Complete Command Context"
Scheduled Searches, Failed User Logons, and Thresholds
index=main sourcetype=UserLogonFailed* event_platform=win event_simpleName=UserLogonFailed2 
| search LogonType_decimal IN (2, 7, 10, 13)
| where ComputerName=LogonDomain
| eval LogonType=case(LogonType_decimal="2", "Interactive", LogonType_dgecimal="7", "Unlock", LogonType_decimal="10", "RDP", LogonType_decimal="13", "Unlock Workstation")
| eval SubStatus_decimal=tostring(SubStatus_decimal,"hex")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000064", "User name does not exist")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC000006A", "User name is correct but the password is wrong")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000234", "User is currently locked out")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000072", "Account is currently disabled")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC000006F", "User tried to logon outside his day of week or time of day restrictions")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000070", "Workstation restriction, or Authentication Policy Silo violation (look for event ID 4820 on domain controller)")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000193", "Account expiration")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000071", "Expired password")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000133", "Clocks between DC and other computer too far out of sync")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000224", "User is required to change password at next logon")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC0000225", "Evidently a bug in Windows and not a risk")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xc000015b", "The user has not been granted the requested logon type (aka logon right) at this machine")
| eval SubStatus_decimal=replace(SubStatus_decimal,"0xC000006E", "Unknown user name or bad password")
| stats values(ComputerName) as computerName, values(LocalAddressIP4) as localIPAddresses, count(aid) as failedLogonAttempts, dc(UserName) as credentialsUsed, values(UserName) as userNames, earliest(ContextTimeStamp_decimal) as firstFailedAttmpt, latest(ContextTimeStamp_decimal) as lastFailedAttempt, values(RemoteAddressIP4) as remoteIPAddresses, values(LogonType) as logonTypes, values(SubStatus_decimal) as failedLogonReasons by aid
| eval failedLoginsDeltaMinutes=round((lastFailedAttempt-firstFailedAttmpt)/60,0)
| eval failedLoginsDeltaSeconds=round((lastFailedAttempt-firstFailedAttmpt),2)
| where failedLogonAttempts>=5
| convert ctime(firstFailedAttmpt) ctime(lastFailedAttempt)
| sort -failedLogonAttempts
Mining EndOfProcess and Profiling Programs
(index=main sourcetype=EndOfProcess* event_platform=win event_simpleName=EndOfProcess ImageSubsystem_decimal=3) OR (index=main sourcetype=ProcessRollup2* event_platform=win event_simpleName=ProcessRollup2 ImageSubsystem_decimal=3)
| lookup local=true appinfo.csv SHA256HashData OUTPUT FileName as cloudFileName
| eval cloudFileName=lower(cloudFileName) 
| search cloudFileName=powershell.exe
| search event_simpleName=ProcessRollup2 OR (event_simpleName=EndOfProcess AND ScreenshotsTakenCount_decimal>0 OR (NewExecutableWrittenCount_decimal>=2 AND NewExecutableWrittenCount_decimal!=27 AND NewExecutableWrittenCount_decimal!=28))
| stats dc(event_simpleName) as eventCount, earliest(ProcessStartTime_decimal) as procStartTime, values(ComputerName) as computerName, values(UserName) as userName, values(UserSid_readable) as userSid, values(FileName) as fileName, values(cloudFileName) as cloudFileName, values(CommandLine) as cmdLine, values(ScreenshotsTakenCount_decimal) as screenShotsTaken, values(NewExecutableWrittenCount_decimal) as ExesWritten by aid, TargetProcessId_decimal
| where eventCount>1
| table aid, computerName, userSid, userName, TargetProcessId_decimal, fileName, cloudFileName, ExesWritten, screenShotsTaken, cmdLine
| rename TargetProcessId_decimal as falconPID
Auditing SSH connections being made to Linux Systems.
event_platform=lin event_simpleName=CriticalEnvironmentVariableChanged, EnvironmentVariableName IN (SSH_CONNECTION, USER) 
| eventstats list(EnvironmentVariableName) as EnvironmentVariableName,list(EnvironmentVariableValue) as EnvironmentVariableValue by aid, ContextProcessId_decimal
| eval tempData=mvzip(EnvironmentVariableName,EnvironmentVariableValue,":")
| rex field=tempData "SSH_CONNECTION\:((?<clientIP>\d+\.\d+\.\d+\.\d+)\s+(?<rPort>\d+)\s+(?<serverIP>\d+\.\d+\.\d+\.\d+)\s+(?<lPort>\d+))"
| rex field=tempData "USER\:(?<userName>.*)"
| where isnotnull(clientIP)
| iplocation clientIP
| lookup local=true aid_master aid OUTPUT Version as osVersion, Country as sshServerCountry
| fillnull City, Country, Region value="-"
| table _time aid ComputerName sshServerCountry osVersion serverIP lPort userName clientIP rPort City Region Country
| where isnotnull(userName)
| sort +ComputerName, +_time
Users accounts being added to groups on Windows hosts.
(index=main sourcetype=UserAccountAddedToGroup* event_platform=win event_simpleName=UserAccountAddedToGroup) OR (index=main sourcetype=ProcessRollup2* event_platform=win event_simpleName=ProcessRollup2)
| eval falconPID=coalesce(TargetProcessId_decimal, RpcClientProcessId_decimal)
| rename UserName as responsibleUserName
| rename UserSid_readable as responsibleUserSID
| eval GroupRid_dec=tonumber(ltrim(tostring(GroupRid), "0"), 16)
| eval UserRid_dec=tonumber(ltrim(tostring(UserRid), "0"), 16)
| eval UserSid_readable=DomainSid. "-" .UserRid_dec
| lookup local=true userinfo.csv UserSid_readable OUTPUT UserName
| lookup local=true grouprid_wingroup.csv GroupRid_dec OUTPUT WinGroup
| fillnull value="-" UserName responsibleUserName
| stats dc(event_simpleName) as eventCount, values(ProcessStartTime_decimal) as processStartTime, values(FileName) as responsibleFile, values(CommandLine) as responsibleCmdLine, values(responsibleUserSID) as responsibleUserSID, values(responsibleUserName) as responsibleUserName, values(WinGroup) as windowsGroupName, values(GroupRid_dec) as windowsGroupRID, values(UserName) as addedUserName, values(UserSid_readable) as addedUserSID by aid, falconPID
| where eventCount>1 
| eval ProcExplorer=case(falconPID!="","https://falcon.us-2.crowdstrike.com/investigate/process-explorer/" .aid. "/" . falconPID)
| convert ctime(processStartTime)
| table processStartTime, aid, responsibleUserSID, responsibleUserName, responsibleFile, responsibleCmdLine, addedUserSID, addedUserName, windowsGroupRID, windowsGroupName, ProcExplorer 
Hunting modification (ASEP modifications) of the Windows registry
Hunting Cluster Events by Process Lineage
Encrypted command line strings emanating from PowerShell.
Linux UserLogon and FailedUserLogon Event Updates

Transforms Cheetsheat | convert ctime(LogonTime_decimal) as LogonTime, ctime(PasswordLastSet_decimal) as PasswordLastSet | eval LogonType=case(LogonType_decimal=2, "Interactive", LogonType_decimal=10, "Remote Interactive/SSH") | eval UserIsAdmin=case(UserIsAdmin_decimal=1, "Admin", UserIsAdmin_decimal=0, "Non-Admin")

Microsoft Teams Credentials in the Clear

===================================================================================

Hunting modification (ASEP modifications) of the Windows registry The value 999 is associated with the SYSTEM user. Other common local user ID values (LUID) are below:

  • INVALID_LUID (0)

  • NETWORK_SERVICE (996)

  • LOCAL_SERVICE (997)

  • SYSTEM (999)

Last updated

Was this helpful?