Incident Response Part 2.2 : Analysis

Alican Kiraz
12 min readFeb 14, 2022

Yazı Serimin bu bölümünde; Preparation ve Detection Sistemleri tamamladığımızdan şimdi Analiz aşamasına odaklanacağız. Kurduğumuz HIDS, NIDS ve SIEM sistemlerinde ayrıca Sysmon ve WinEventLog yapılarından faydalanarak analiz aşamalarını işleyeceğiz.

Analiz adımlarımızda Lockheed M.’nin Cyber Kill Chain adımlarını harmanlayıp tüm noktalara dokunmaya çalışacağız.

https://cybotsai.com/

Kill Chain Detection & Logs

Kill Chain adımlarının Faliyetlerinde tespit için loglara odaklanalım. Aktif ve Pasif Enumeration, Olası C2 Heartbeat’lerini, Delivery faaliyetlerini, Exploitation ve Installation adımlarındaki hareketleri belirlememiz için ilgili loglara ihtiyacımız olacak;

  • Application Logs : Bir uygulamanın audit log’ları sayesinde uygulama üzerinde yapılan enumeration aktivitelerini tespit edebiliriz. Uygulama üzerinde kullanıcı, parametre, uygulamanın makineler ve topolojiler arası erişim yetkinlikleri, servis hesapları, uygulama versiyon kontrolleri gibi bir çok konuda saldırgan enumeration faaliyetleri yapacaktır. Ardından olası Exploitation ve Installation faliyetlerinde uygulama logları yine işimize yarayacaktır.
  • Network based Software or Hardware : Network temelli Flow analiz cihaz ve yazılımlarının logları, özellikle FW logları, IDS veya NDR logları. Birçok ağ temelli enumeration aktivitesinde iç ve dış host ve topolojilerin enumerate edilmesine karsı yine tespit sağlamada yardımcı olacaktır. Ayrıca Delivery ve C2 adımlarının tespitinde yine elimizi güçlendirecektir.
  • Security based Software or Hardware : Güvenlik temelli cihazların logları olay öncesi ve sonrası elimizi güçlendirecektir. Ve aynı şekilde bu cihazlardan alınan detection logları ile çeşitli korelasyonlar ile Kill Chain’nin tüm adımlarında daha gelişmiş alarmler dizayn edebileceğiz.
  • Hosts and VM Management logs: Host’lardan ve Sanal hostların yönetildiği sistemlerden alınan loglar ile çeşitli korelasyonlar ile Kill Chain’nin tüm adımlarında daha gelişmiş alarmler dizayn edebileceğiz.

Analizlerimizde Wireshark ve Splunk’ı baz alacağız.

Öncesinde bir saldırganın oluşturacağı Şüpheli Hesap EventID’lerine göz atalım.

Hesap oturum açma olaylarına özel Event ID’ler;

•4624 (successful logon)
• 4625 (failed logon)
• 4634 (successful logoff)
• 4647 (user-initiated logoff)
• 4648 (logon using explicit credentials)
• 4672 (special privileges assigned)
• 4768 (Kerberos ticket (TGT) requested)
• 4769 (Kerberos service ticket requested)
• 4771 (Kerberos pre-auth failed)
• 4776 (attempted to validate credentials)
• 4778 (session reconnected)
• 4779 (session disconnected)

Hesap yönetimine özel Event ID’ler;

• 4720 (account created)
• 4722 (account enabled)
• 4724 (attempt to reset password)
• 4728 (user added to global group)
• 4732 (user added to local group)
• 4756 (user added to universal group)

Hesaplara özel Etkinlik Kimlikleriyle ilgili dikkat edilmesi gereken bir diğer bilgi de Oturum Açma Kimliğidir.

https://techtalk.gfi.com/monitoring-logons-in-windows-environments/

Windows Processes Analysis

Windows core processes’leri söz konusu olduğunda ve bunların sahte core processes’ler olup olmadığını tespit etmeye çalışırken şu temel faktörlere bakabiliriz:

  • Beklenen bir parent process’in mi onu yarattığına bakmalıyız.
  • Beklenen bir path’den oluşan process olduğuna bakmalıyız. Örneğin yetki ve değiştirebilirliği az olan System32'den mi yoksa Downloads klasöründen mi çalışıp çalışmadığına bakmalıyız.
  • Uygun SID‘ler altında çalışıp çalışmadığına bakmalıyız.
  • Microsoft tarafından imzalanıp imzalanmadığına bakmalıyız.
https://support.kaspersky.com/common/windows/6325

Buradaki core process’leri ve amaçlarını inceleyelim;

smss.exe

Oturum Yöneticisi olarak bilinir. Sorumluluğu yeni oturumlar oluşturmaktır.

  • Session 0, csrss.exe ve wininit.exe’yi başlatır. (işletim sistemi hizmetleri)
  • Session 1, csrss.exe ve winlogon.exe’yi başlatır. (Kullanıcı oturumu)
  • İşlem ağacında 1 örnek (Oturum 0) göreceksiniz. Diğer oturumları oluşturmak için kullanılan smss.exe’nin alt örnekleri, kendisini bu yeni oturuma kopyalayarak kendi kendine sona erecektir.

Ek oturumlar, RDP oturumları, Fast User Switching ile oluşturulabilir. Bu, durum genelde şüphelidir. Bu nedenle ek oturumlar mutlaka kontrol edilmeli!

Executable Path: %SystemRoot%\System32\smss.exe

Parent Process: System

Username: NT AUTHORITY\SYSTEM (S-1–5–18)

Base Priority: 11

Time of Execution: For Session 0, within seconds of boot time

csrss.exe

Client/Server Çalıştırma Alt Sistemi Process’idir. Windows API’yi diğer işlemler için kullanılabilir hale getirmenin yanı sıra, process’leri ve thread’leri yönetmekten sorumludur. Ayrıca sürücü harflerini(drive letters) eşlemekten, geçici dosyalar oluşturmaktan(creating temp files) ve kapatma işlemini yönetmekten de sorumludur. Session 0 ve 1 içinde çalışır.

Executable Path: %SystemRoot%\System32\csrss.exe

Parent Process: -

Username: NT AUTHORITY\SYSTEM (S-1–5–18)

Base Priority: 13

Time of Execution: For Sessions 0 & 1, within seconds of boot time

lsass.exe

Local Security Authority Subsystem’idir. Kullanıcı kimlik doğrulamasından ve user ve user session’ında ortaya çıkan işlemler için güvenlik ilkeleri ve/veya kısıtlamalar belirleyen erişim belirteçleri oluşturmaktan sorumludur. Çoğu kez kötüye kullanılır; Parola hash’lerini boşaltmayı hedefler ve genellikle görünürde gizlemek için kullanılır. Bu işlem için farklı yazım varyasyonları (lass.exe veya lsasss.exe) görebilir.

Executable Path: %SystemRoot%\System32\lsass.exe

Parent Process: wininit.exe

Username: NT AUTHORITY\SYSTEM (S-1–5–18)

Base Priority: 9

Winlogon.exe

Windows Oturum Açma İşlemidir. Kullanıcı oturum açma/kapatma işlemlerinden sorumludur. Kullanıcı adı ve parola için LogonUI.exe’yi başlatır ve kimlik bilgilerini AD veya yerel SAM aracılığıyla doğrulanan LSASS.exe’ye iletir. Userinit.exe’yi Software\…\Winlogon aracılığıyla yükler. Kötü amaçlı yazılımlar bazen SHELL registry değerini kötüye kullanır. Bu değer explorer.exe ve Userinit’dir.

Executable Path: %SystemRoot%\System32\winlogon.exe

Parent Process: -

Username: NT AUTHORITY\SYSTEM (S-1–5–18)

Base Priority: 13

wininit.exe

Windows Initialization Process’idir. Services.exe, lsass.exe ve lsm.exe’nin Session 0'da başlatılmasından sorumludur.

Executable Path: %SystemRoot%\System32\wininit.exe

Parent Process: -

Username: NT AUTHORITY\SYSTEM (S-1–5–18)

Base Priority: 13

lsm.exe

Yeni kullanıcı oturumları oluşturmak, yok etmek veya değiştirmek(create, destroy, or manipulate) için smss.exe ile çalışmaktan sorumludur. Win7'den sonra yoktur artık lsm.dll adlı bir hizmettir.

Executable Path: %SystemRoot%\System32\lsm.exe

Parent Process: wininit.exe

Username: NT AUTHORITY\SYSTEM (S-1–5–18)

Base Priority: 8

service.exe

Service Control Manager’dir. Servisleri (otomatik başlatma) ve aygıt sürücülerini belleğe yüklemekten sorumludur. svchost.exe, dllhost.exe, taskhost.exe, spoolsv.exe vb.’nin parent’ıdır. Yalnızca 1 adet çalışır.

Executable Path: %SystemRoot%\System32\services.exe

Parent Process: wininit.exe

Username: NT AUTHORITY\SYSTEM (S-1–5–18)

Base Priority: 9

Svchost.exe

Generic Service Host Process’idir. Birden çok hizmet DLL’ini genel bir paylaşılan hizmet sürecinde barındırmaktan sorumludur. Her svchost.exe işlemi benzersiz bir –k <ad> ile çalışacaktır. Çok fazla suistimal edilen bir process ‘dir. Service’ler söz konusu olduğunda, svchost.exe tarafından yüklenen service/DLL’nin meşru olup olmadığını belirlemek için ekstra adımlar uygulamak gerekir.

taskhost.exe

EXE’ler yerine DLL’lerden çalışan işlemler için bir host görevi gören genel bir host işlemidir. Başlangıçta, TASKHOST, yüklemesi gereken DLL tabanlı hizmetlerin bir listesini oluşturmak için registry’nin service bölümünü kontrol eder ve ardından bunları yükler. Windows 10'da bu işlem, taskhostw.exe’dir.

Executable Path: %SystemRoot%\System32\taskhost.exe

Parent Process: services.exe

Username: Varies

Base Priority: 8

explorer.exe

Windows Gezgini’dir. Explorer.exe, kullanıcının masaüstünden ve dosyalara erişim (dosya tarayıcısı) ve dosya uzantıları aracılığıyla dosyaları başlatma dahil olmak üzere onunla birlikte gelen her şeyden sorumludur. Birden çok Windows Gezgini penceresi açılsa bile, oturum açmış her kullanıcı için yalnızca 1 işlem oluşturulacaktır. Çok fazla suistimal edilen bir process ‘dir.Explorer’ın CMD’yi kapattığı veya bir ağ bağlantı noktasında dinlediği/bağlandığı durumları aramak gerekir.

Executable Path: %SystemRoot%\explorer.exe

Parent Process: -

Username: As logged-on users

Base Priority: 8

Simdi Use Case’ler ile ilerleyebiliriz.

Recon, C2 & Delivery — Detection Use Cases

TOR Traffic Detection

Tor kaynaklı trafiğin engellenmesi her zaman gereklidir. Engellemenin bir şekilde bypass durumu kontrol edilip alarmlaştırılmalıdır.

index=network sourcetype=firewall_data app=tor src_ip=* action=allowed| table _time src_ip src_port dest_ip dest_port bytes app

Port Scan

Ağ içerisinde bir makineden diğer bir makinenin portuna doğru oluşan trafik belirli bir zaman içersinde X_tane'den fazla ise bize gösterecektir.

| from datamodel:”Network_Traffic”.”All_Traffic”

| stats dc(dest_port) as dc_dest_port by src, dest

| where dc_dest_port > X_Tane

Detect Outbound SMB Traffic

Outbound SMB trafiği oluşmuşsa bize gösterecektir.

| tstats `security_content_summariesonly` count earliest(_time) as earliest latest(_time) as latest values(All_Traffic.action) from datamodel=Network_Traffic where (All_Traffic.action!=blocked AND All_Traffic.action!=dropped) All_Traffic.dest_category !=internal (All_Traffic.dest_port=139 OR All_Traffic.dest_port=445 OR All_Traffic.app=smb) by All_Traffic.src_ip All_Traffic.dest_ip | `drop_dm_object_name(“All_Traffic”)` | search ( dest_ip!=10.0.0.0/8 AND dest_ip!=172.16.0.0/12 AND dest_ip!=192.168.0.0/16) | `security_content_ctime(earliest)`| `security_content_ctime(latest)` | `detect_outbound_smb_traffic_filter`

Excessive DNS Failures

Peşi sıra alınan DNS Sorgu Hata’larının incelenmesi yine C&C trafiğine bağlı heartbeat’leri tespit etme gibi adımlarda yardımcı olacaktır.

| tstats `security_content_summariesonly` count values(“DNS.query”) as queries from datamodel=Network_Resolution where nodename=DNS “DNS.reply_code”!=”No Error” “DNS.reply_code”!=”NoError” DNS.reply_code!=”unknown” NOT “DNS.query”=”*.arpa” “DNS.query”=”*.*” by “DNS.src”,”DNS.query”| `drop_dm_object_name(“DNS”)`| lookup cim_corporate_web_domain_lookup domain as query OUTPUT domain| where isnull(domain)| lookup update=true alexa_lookup_by_str domain as query OUTPUT rank| where isnull(rank)| stats sum(count) as count mode(queries) as queries by src| `get_asset(src)`| where count>50 | `excessive_dns_failures_filter`

WINRM Enumeration Detection

| tstats dc(All_Traffic.dest) as dest_count from datamodel=Network_Traffic.All_Traffic where All_Traffic.dest_port IN (5985 5986) by All_Traffic.src All_Traffic.user All_Traffic.action | where dest_count > 3 | rename All_Traffic.src as src All_Traffic.user as user All_Traffic.action as action

Internal Port Scan Activity

| tstats dc(All_Traffic.dest_port) as taranan_port from datamodel=Network_Traffic.All_Traffic where All_Traffic.src IN (10.0.0.0/8 172.16.0.0/12 192.168.0.0/12) by All_Traffic.src All_Traffic.dest All_Traffic.user | where taranan_port > 200 | rename All_Traffic.src as src All_Traffic.dest as dest All_Traffic.user as user

Anomalous New Listening Port

| from inputlookup:”listeningports_tracker” | eval earliestQual=case(match(“-24h@h”, “^\d”), tostring(“-24h@h”), match(“-24h@h”, “^([@\+-]){1}”), relative_time(time(), “-24h@h”), true(), time()) | eval latestQual=case(match(“+0s”, “^\d”), tostring(“+0s”), match(“+0s”, “^([@\+-]){1}”), relative_time(time(), “+0s”), true(), time()) | where (‘firstTime’>=earliestQual AND ‘firstTime’<=latestQual) | fields — earliestQual, latestQual | stats dc(dest) as “dest_count” by “transport”,”dest_port” | where ‘dest_count’>10

Connection established over port SMB or SSH ports

| tstats `summariesonly` count from datamodel=Network_Traffic.All_Traffic where (All_Traffic.dest_port=445 OR All_Traffic.dest_port=22 ) AND (All_Traffic.src!=10.0.0.0/8 All_Traffic.src!=172.16.0.0/12 All_Traffic.src!=192.168.0.0/16) All_Traffic.action=allowed by All_Traffic.src All_Traffic.dest All_Traffic.dest_port

External Port Scan Activity

|tstats `summariesonly` dc(All_Traffic.dest_port) as taranan_port from datamodel=Network_Traffic.All_Traffic where All_Traffic.src!=10.0.0.0/8 All_Traffic.src!=172.16.0.0/16 All_Traffic.src!=192.168.0.0/16 by All_Traffic.src All_Traffic.dest | where taranan_port > 499

Recon, C2 & Delivery — IDS — Use Cases

NMAP -sA

alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:”NMAP -sA “; fragbits:!D; dsize:0; flags:A,12; window:1024; threshold: type both, track by_dst, count 1, seconds 60;)

Potential SSH Scan

alert tcp $EXTERNAL_NET any -> $HOME_NET 22 (msg:”Potential SSH Scan”; flow:to_server; flags:S,12; threshold: type both, track by_src, count 5, seconds 120;)

Behavioral Unusual Port 445 traffic Potential Scan or Infection

alert tcp $HOME_NET any -> any 445 (msg:”Behavioral Unusual Port 445 traffic Potential Scan or Infection”; flow:to_server; flags: S,12; threshold: type both, track by_src, count 70 , seconds 60; metadata: former_category SCAN;)

Behavioral Unusual Port 139 traffic Potential Scan or Infection

alert tcp $HOME_NET any -> any 139 (msg:”Behavioral Unusual Port 139 traffic Potential Scan or Infection”; flow:to_server; flags: S,12; threshold: type both, track by_src, count 70 , seconds 60; metadata: former_category SCAN;)

Behavioral Unusual Port 137 traffic Potential Scan or Infection

alert tcp $HOME_NET any -> any 137 (msg:”Behavioral Unusual Port 137 traffic Potential Scan or Infection”; flow:to_server; flags: S,12; threshold: type both, track by_src, count 70 , seconds 60; metadata: former_category SCAN;)

Behavioral Unusual Port 135 traffic Potential Scan or Infection

alert tcp $HOME_NET any -> any 135 (msg:”Behavioral Unusual Port 135 traffic Potential Scan or Infection”; flow:to_server; flags: S,12; threshold: type both, track by_src, count 70 , seconds 60; metadata: former_category SCAN;)

alert tcp $HOME_NET any -> any 1434 (msg:”Behavioral Unusual Port 1434 traffic Potential Scan or Infection”; flow:to_server; flags: S,12; threshold: type both, track by_src, count 40 , seconds 60; metadata: former_category SCAN;)

Behavioral Unusual Port 1433 traffic Potential Scan or Infection

alert tcp $HOME_NET any -> any 1433 (msg:”Behavioral Unusual Port 1433 traffic Potential Scan or Infection”; flow:to_server; flags: S,12; threshold: type both, track by_src, count 40 , seconds 60; metadata: former_category SCAN;)

Potential FTP Brute-Force attempt response

alert tcp $HOME_NET 21 -> $EXTERNAL_NET any (msg:”Potential FTP Brute-Force attempt response”; flow:from_server,established; dsize:<100; content:”530 “; depth:4; pcre:”/530\s+(Login|User|Failed|Not)/smi”; threshold: type threshold, track by_dst, count 5, seconds 300;)

Nessus User Agent

alert http $EXTERNAL_NET any -> $HOME_NET any (msg:”Nessus User Agent”; flow: established,to_server; content:”Nessus”; nocase; depth:40; http_user_agent; threshold: type limit, track by_src,count 1, seconds 60;)

Nikto Web App Scan in Progress

alert http $EXTERNAL_NET any -> $HOME_NET any (msg:”Nikto Web App Scan in Progress”; flow:to_server,established; content:”(Nikto”; http_user_agent; threshold: type both, count 5, seconds 60, track by_src;)

Suspicious User-Agent inbound (bot)

alert http $EXTERNAL_NET any -> $HOME_NET any (msg:”Suspicious User-Agent inbound (bot)”; flow:to_server,established; content:”bot/”; nocase; http_user_agent; depth:4; threshold: type limit, count 3, seconds 300, track by_src; metadata: former_category HUNTING;)

Tomcat Auth Brute Force attempt (admin)

alert http $EXTERNAL_NET any -> $HTTP_SERVERS any (msg:”Tomcat Auth Brute Force attempt (admin)”; flow:to_server,established; content:”Authorization|3a| Basic YWRtaW46"; fast_pattern:15,14; http_header; threshold: type threshold, track by_src, count 5, seconds 30;)

Tomcat Auth Brute Force attempt (tomcat)

alert http $EXTERNAL_NET any -> $HTTP_SERVERS any (msg:”Tomcat Auth Brute Force attempt (tomcat)”; flow:to_server,established; content:”Authorization|3a| Basic dG9tY2F0"; fast_pattern:15,14; http_header; threshold: type threshold, track by_src, count 5, seconds 30;)

Weaponise, Exploitation & Installation— Detection Use Cases

Bu kısımda daha çok log inceleme ve process kontrolü yapacağız.

Weaponise, Exploitation & Installation — Detection Use Cases

Anomalous New Listening Port

| from inputlookup:”listeningports_tracker” | eval earliestQual=case(match(“-24h@h”, “^\d”), tostring(“-24h@h”), match(“-24h@h”, “^([@\+-]){1}”), relative_time(time(), “-24h@h”), true(), time()) | eval latestQual=case(match(“+0s”, “^\d”), tostring(“+0s”), match(“+0s”, “^([@\+-]){1}”), relative_time(time(), “+0s”), true(), time()) | where (‘firstTime’>=earliestQual AND ‘firstTime’<=latestQual) | fields — earliestQual, latestQual | stats dc(dest) as “dest_count” by “transport”,”dest_port” | where ‘dest_count’>10

Suspicious PowerShell Commands

index=windows source=”WinEventLog:Microsoft-Windows-PowerShell/Operational” EventCode=4104 AND ((ScriptBlockText=*-noni* *iex* *New-Object*) OR (ScriptBlockText=*-ep* *bypass* *-Enc*) OR (ScriptBlockText=*powershell* *reg* *add* *HKCU\\software\\microsoft\\windows\\currentversion\\run*) OR (ScriptBlockText=*bypass* *- noprofile* *-windowstyle* *hidden* *new-object* *system.net.webclient* *.download*) OR (ScriptBlockText=*iex* *New-Object* *Net.WebClient* *.Download*)) | table Computer, ScriptBlockText, UserID

Unusual Child Process for Spoolsv.Exe or Connhost.Exe

index=sysmon_index EventCode=1 (Image=C:\\Windows\\System32\\spoolsv.exe* OR Image=C:\\Windows\\System32\\conhost.exe) ParentImage = “C:\\Windows\\System32\\cmd.exe”

Malicious PowerShell Activity

index=* EventID=4688 (BaseFileName=powershell.exe OR BaseFileName=powershell_ise.exe OR BaseFileName=cmd.exe) (Copy-Item OR .CopyHere OR New-Object OR WebClient OR DownloadFile OR downloadstring OR WebRequest OR restmethod) (CommandLine=”*Copy-Item*” OR CommandLine=”*CopyHere*” OR CommandLine=”*New- Object*” OR CommandLine=”*WebClient*” OR CommandLine=”*DownloadFile*” OR CommandLine=”*downloadstring*” OR CommandLine=”*WebRequest*” OR CommandLine=”*restmethod*” OR CommandLine=”*iex*” OR CommandLine=”*comobject*InternetExplorer*” OR CommandLine=”*Msxml2.XMLHTTP*” OR CommandLine=”*WinHttp*” OR CommandLine=”*bitstransfer*” | table _time, Computer, SubjectDomainName, SubjectUserName, BaseFileName, CommandLine, CreatorProcessName, NewProcessName, FileDescription, FileVersion, MD5

WMI Persistence

index=* (event_id:(“19” OR “20” OR “21”) AND source_name:*Sysmon) OR (event_id:”5858" AND user_data.Operation:(*Ev entConsumer* *EventFilter* *FilterToConsumerBinding *) AND — user_data.Operation:”*TargetInstance ISA*”)

Attempt To Stop Security Service

| tstats `security_content_summariesonly` values(Processes.process) as process min(_time) as firstTime max(_time) as lastTime from datamodel=Endpoint.Processes where `process_net` OR Processes.process_name = sc.exe Processes.process=”* stop *” by Processes.dest Processes.user Processes.parent_process Processes.process_name Processes.original_file_name Processes.process Processes.process_id Processes.parent_process_id | `drop_dm_object_name(Processes)` | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)` |lookup security_services_lookup service as process OUTPUTNEW category, description | search category=security | `attempt_to_stop_security_service_filter`

Child Processes of Spoolsv exe

| tstats `security_content_summariesonly` count values(Processes.process_name) as process_name values(Processes.process) as process min(_time) as firstTime max(_time) as lastTime from datamodel=Endpoint.Processes where Processes.parent_process_name=spoolsv.exe AND Processes.process_name!=regsvr32.exe by Processes.dest Processes.parent_process Processes.user | `drop_dm_object_name(Processes)` | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)` | `child_processes_of_spoolsv_exe_filter`

Common Ransomware Extensions

| tstats `security_content_summariesonly` count min(_time) as firstTime max(_time) as lastTime values(Filesystem.user) as user values(Filesystem.dest) as dest values(Filesystem.file_path) as file_path from datamodel=Endpoint.Filesystem by Filesystem.file_name | `drop_dm_object_name(Filesystem)` | `security_content_ctime(lastTime)` | `security_content_ctime(firstTime)`| rex field=file_name “(?<file_extension>\.[^\.]+)$” | `ransomware_extensions` | `common_ransomware_extensions_filter`

Create local admin accounts using net exe

| tstats `security_content_summariesonly` count values(Processes.user) as user values(Processes.parent_process) as parent_process min(_time) as firstTime max(_time) as lastTime from datamodel=Endpoint.Processes where (Processes.process_name=net.exe OR Processes.process_name=net1.exe) AND Processes.process=*/add* AND (Processes.process=*administrators* OR Processes.process=*administratoren* OR Processes.process=*administrateurs* OR Processes.process=*administrador* OR Processes.process=*amministratori* OR Processes.process=*administratorer*) by Processes.process Processes.process_name Processes.dest | `drop_dm_object_name(Processes)` | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)` | `create_local_admin_accounts_using_net_exe_filter`

Detect Prohibited Applications Spawning cmd exe

| tstats `security_content_summariesonly` count values(Processes.process) as process min(_time) as firstTime max(_time) as lastTime from datamodel=Endpoint.Processes where `process_cmd` by Processes.parent_process_name Processes.process_name Processes.original_file_name Processes.dest Processes.user| `drop_dm_object_name(Processes)` | `security_content_ctime(firstTime)`| `security_content_ctime(lastTime)` |search [`prohibited_apps_launching_cmd`] | `detect_prohibited_applications_spawning_cmd_exe_filter`

New scheduled task created

index=win* EventCode=4698 Task_Name!=”\\Microsoft\\Windows\\Backup\\Microsoft-Windows-WindowsBackup” | table user Task_Name host

Inactive Account Activity Detected

| `inactive_account_usage(“90”,”2")` | `ctime(lastTime)` | fields + user,tag,inactiveDays,lastTime | search user!=*-*

Weaponise, Exploitation & Installation — IDS — Use Cases

alert http $EXTERNAL_NET any -> $HTTP_SERVERS any (msg:”Suspicious User-Agent Containing SQL Injection Likely SQL Injection Scanner”; flow:established,to_server; content:”SQL”; nocase; depth:200; http_user_agent; content:”Inject”; nocase; distance:0; http_user_agent; metadata: former_category HUNTING;)

alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:”Metasploit Meterpreter Reverse HTTPS certificate”; flow:from_server,established; content:”|A3 0D 30 0B 30 09 06 03 55 1D 13 04 02 30 00|”; fast_pattern; content:”|16 03 03|”; pcre:”/^..\x0B.{9}\x30\x82..\x30\x82..\xA0\x03\x02\x01\x02\x02(?:\x09.{9}|\x08.{8})/Rs”; content:”|30 0D 06 09 2A 86 48 86 F7 0D 01 01 0B 05 00 30|”; within:16; pcre:”/^.\x31.\x30.\x06\x03\x55\x04\x03\x0C.([a-z]{2,9})\x30.\x17\x0D[0–9]{12}Z\x17\x0D[0–9]{12}Z\x30.\x31.\x30.\x06\x03\x55\x04\x03\x0C.\g{1}\x30\x82../Rs”; content:”|30 0D 06 09 2A 86 48 86 F7 0D 01 01 01 05 00 03 82|”; within:17; pcre:”/^…\x30\x82..\x02\x82…{256,257}/Rs”; content:”|02 03 01 00 01 A3 0D 30 0B 30 09 06 03 55 1D 13 04 02 30 00 30 0D 06 09 2A 86 48 86 F7 0D 01 01 0B 05 00|”; within:36; content:!”|06|ubuntu”; content:!”|04|mint”; content:!”|a9 d5 73 d2 a0 a5 a1 69|”; )

alert http any any -> $HOME_NET any (msg:”Windows SCM DLL Hijack Command (UTF-16) Inbound via HTTP M1"; flow:established,from_server; content:”200"; http_stat_code; file_data; content:”|00|s|00|t|00|o|00|p|00 20 00|I|00|K|00|E|00|E|00|X|00|T|00|”; content:”|00|c|00|o|00|p|00|y|00 20 00|w|00|l|00|b|00|s|00|c|00|t|00|r|00|l|00|.|00|d|00|l|00|l|00|”; content:”|00 5c 00|W|00|i|00|n|00|d|00|o|00|w|00|s|00 5c 00|S|00|y|00|s|00|t|00|e|00|m|00|3|00|2|00 5c 00|w|00|l|00|b|00|s|00|c|00|t|00|r|00|l|00|.|00|d|00|l|00|l|00|”; distance:0; fast_pattern; metadata: former_category ATTACK_RESPONSE; )

alert tcp $HOME_NET any -> $EXTERNAL_NET any (msg:”Outbound PHP Connection”; flow: established,to_server; content:”From|3a| anon@anon.com”; nocase; offset: 0; depth: 19; content:”User-Agent|3a| PHP”; nocase;)

alert http $HOME_NET any -> $EXTERNAL_NET any (msg:”Possible /etc/passwd via HTTP (linux style)”; flow:established,from_server; file_data; content:”root|3a|x|3a|0|3a|0|3a|root|3a|/root|3a|/”; nocase; )

alert http $HOME_NET any -> $EXTERNAL_NET any (msg:” Possible /etc/passwd via HTTP (BSD style)”; flow:established,from_server; file_data; content:”root|3a|*|3a|0|3a|0|3a|”; nocase; content:”|3a|/root|3a|/bin”; nocase;)

alert tcp $HOME_NET any -> any any (msg:”Possible MS CMD Shell opened on local system 2"; dsize:<200; content:”Microsoft Windows “; depth:40; content:”[Version”; distance:0; within:10; content:”Copyright © 2009"; distance:0; content:”Microsoft Corp”; distance:0; )

alert tcp $HOME_NET any -> $EXTERNAL_NET 25 (msg:”Possible /etc/passwd via SMTP (linux style)”; flow:established,to_server; content:”root|3a|x|3a|0|3a|0|3a|root|3a|/root|3a|/”; nocase;)

alert tcp $HOME_NET any -> $EXTERNAL_NET 25 (msg:”Possible /etc/passwd via SMTP (BSD style)”; flow:established,to_server; content:”root|3a|*|3a|0|3a|0|3a|”; nocase; content:”|3a|/root|3a|/bin”; nocase;)

#alert http $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”r57 phpshell source being uploaded”; flow:established,to_server; content:”/* ©oded by 1dt.w0lf”; content:”/* RST/GHC http”; distance:0;)

alert http $EXTERNAL_NET any -> $HOME_NET any (msg:”Windows LMHosts File Download — Likely DNSChanger Infection”; flow:established,to_client; content:”#|0d 0a|#|20|This|20|is|20|a|20|sample|20|HOSTS|20|file|20|used|20|by|20|Microsoft|20|TCP/IP|20|for|20|Windows.|0d 0a|#|0d 0a|#|20|This|20|file|20|contains|20|the|20|mappings|20|of|20|IP|20|addresses|20|to|20|host|20|names.”;)

alert tcp $HOME_NET any -> any any (msg:”Possible MS CMD Shell opened on local system”; flow:established; dsize:<110; content:”Microsoft Windows “; depth:20; content:”Copyright 1985–20"; distance:0; content:”Microsoft Corp”; distance:0; content:”|0a 0a|”; distance:0;)

alert http $HTTP_SERVERS $HTTP_PORTS -> $EXTERNAL_NET any (msg:”Frequent HTTP 401 Unauthorized — Possible Brute Force Attack”; flow:from_server,established; content:”401"; http_stat_code; threshold:type both, track by_dst, count 30, seconds 60;)

alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:”Metasploit Meterpreter File Download Detected”; flow:to_client,established; content:”stdapi_fs_stat”; depth:54;)

alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:”Metasploit Meterpreter Process List (ps) Command Detected”; flow:to_client,established; content:”stdapi_sys_process_get_processes”; depth:65;)

alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:”Metasploit Meterpreter Process Migration Detected”; flow:to_client,established; content:”core_migrate”; depth:60;)

alert tcp $SQL_SERVERS 3306 -> $EXTERNAL_NET any (msg:”MySQL User Account Enumeration”; flow:from_server,established; content:”|02|”; offset:3; depth:4; content:”|15 04|Access denied for user”; fast_pattern; threshold:type both,track by_dst,count 10,seconds 1;)

Umarım bu Use Case’ler işinize yarar ve Hunting kabiliyetlerinizi geliştirmenize yardımcı olur. Okuduğunuz için teşekkür ederim.

https://tenor.com/view/keanu-reeves-thank-you-gif-18255532

--

--

Alican Kiraz

Head of Cyber Defense Center | CSIE | CSAE | CCISO | CASP+ | OSCP | eCIR | CPENT | eWPTXv2 | eCDFP | eCTHPv2 | OSWP | CEH Master | Pentest+ | CySA+ and more...