<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Just Moi on Medium]]></title>
        <description><![CDATA[Stories by Just Moi on Medium]]></description>
        <link>https://medium.com/@justmoii?source=rss-46011f015c2c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oPIK71qwkxbwvUZmbFpfIQ.jpeg</url>
            <title>Stories by Just Moi on Medium</title>
            <link>https://medium.com/@justmoii?source=rss-46011f015c2c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 23:03:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@justmoii/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create Your Own Up-to-Date Threat Intelligence]]></title>
            <link>https://detect.fyi/create-your-own-up-to-date-threat-intelligence-9bc7cd8c7085?source=rss-46011f015c2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bc7cd8c7085</guid>
            <category><![CDATA[threat-intelligence]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[soc]]></category>
            <dc:creator><![CDATA[Just Moi]]></dc:creator>
            <pubDate>Sun, 25 Jan 2026 19:18:52 GMT</pubDate>
            <atom:updated>2026-01-27T15:50:24.975Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Does This Script Do?</h3><ul><li>Fetches IP addresses with a <strong>high confidence score (≥ 80)</strong> from the AbuseIPDB blacklist endpoint.</li><li>Applies <strong>time-based filtering</strong>, focusing on IPs reported within the <strong>last 24 hours</strong>.</li><li>Retrieves <strong>detailed reports</strong> for each IP using the “/check” endpoint.</li><li>Supports both <strong>Global Mode</strong> and <strong>country-based analysis</strong> for IP evaluation.</li><li>Produces <strong>analyst-ready output</strong> in <strong>JSON and CSV formats</strong>, including interpretable fields such as: Mapped abuse categories, Recent report comments, Reporter count</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*tHcozWzVsOCLwqVf4u747g.png" /></figure><p><strong>Example of the Generated CSV Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sj0AmXp6sDkDFGsz-eSxRQ.png" /></figure><p><strong>The configuration file is separate and can be easily modified to fit specific needs.</strong></p><pre># Filtering Configuration<br>MIN_CONFIDENCE_SCORE = 80<br>HOURS_BACK = 24  # Reported within the last 24 hours<br>TEST_LIMIT = 995  # Maximum number of IPs to fetch<br><br># Reporter Country Filter<br>REPORTER_COUNTRY = None  # Country code (e.g., &quot;DE&quot;, &quot;US&quot;, &quot;FR&quot;) or None for global<br>MIN_REPORTERS_COUNTRY = 2  # Minimum reporters from the specified country<br>REPORTS_TO_CHECK = 10  # Most recent 10 reports<br>MAX_COMMENTS = 5  # Get last 5 comments</pre><p>(Since the AbuseIPDB free tier allows up to 1,000 IP checks per day, the test_limit is set to 995.)</p><p>As the data is continuously refreshed, the output <strong>is not a static blacklist</strong> <strong>but a living threat intelligence</strong> set that can be directly operationalized within security workflows.</p><p>The script includes example configurations, and it can be scheduled to run daily using tools such as crontab (Linux) or Windows Task Scheduler to automatically collect the generated outputs.</p><h3><strong>Threat Hunting</strong></h3><p>It can be leveraged as a seed list for threat hunting queries, especially when analyzing:</p><ul><li>“Firewall Logs”</li><li>“Network Traffic”</li><li>“Authentication Logs”</li></ul><h4>Detection Rules (SIEM / XDR)</h4><ul><li>When used as an external intelligence lookup in SIEM correlation rules, abuse confidence scores and reporter counts allow for smarter threshold tuning and meaningful noise reduction.</li></ul><h3>Risk-Based Alerting (RBA)</h3><p>IPs can be scored based on:</p><ul><li>Abuse confidence score</li><li>Reporter count</li><li>Recency of activity</li></ul><p><strong>Alert severity can be increased dynamically</strong> based on the aggregated risk score. <em>Example logic:</em></p><ul><li>+15 → High confidence score</li><li>+10 → Multiple reporters from same country</li><li>+5 → Recent activity</li></ul><h3>Direct Blacklisting</h3><p>IPs with high confidence scores and strong reporter signals can be automatically added to:</p><ul><li>Firewall blocklists</li><li>Proxy blocklists</li><li>EDR / NDR blocklists</li></ul><p>This is particularly effective against:</p><ul><li>Short-lived attack infrastructure</li><li>Active scanning and brute-force sources</li></ul><h3>📌 <strong>Source Code</strong></h3><p>The full script and configuration files are available on <a href="https://github.com/SayMoi/AbuseIPDB-Project-Global"><strong><em>GitHub</em></strong></a>.</p><p><strong>In case you missed it, here’s the link:</strong> [<a href="https://github.com/SayMoi/AbuseIPDB-Project-Global">Link</a>]</p><h3>Thanks for reading.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bc7cd8c7085" width="1" height="1" alt=""><hr><p><a href="https://detect.fyi/create-your-own-up-to-date-threat-intelligence-9bc7cd8c7085">Create Your Own Up-to-Date Threat Intelligence</a> was originally published in <a href="https://detect.fyi/">Detect FYI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Detection Rules]]></title>
            <link>https://justmoii.medium.com/testing-detection-rules-35cea16b5f91?source=rss-46011f015c2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/35cea16b5f91</guid>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[detection-rules]]></category>
            <dc:creator><![CDATA[Just Moi]]></dc:creator>
            <pubDate>Sun, 30 Nov 2025 19:21:47 GMT</pubDate>
            <atom:updated>2025-11-30T19:23:18.048Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tespit Kurallarının Testi</h3><h3>SIEM Tespit Kurallarının Test Edilmesi Neden Bu Kadar Önemli?</h3><p>Günlük SOC merkezlerinde milyonlarca log, yüzlerce alarm ve onlarca farklı kaynaktan akan veriyle çalışır. Bu yoğun akış içinde <strong>asıl farkı yaratan</strong>, SIEM üzerinde çalışan <strong>tespit kurallarıdır</strong>.</p><p>Bu kurallar doğru çalıştığında, kritik bir saldırı dakikalar içinde görünür olur. Peki iyi yazılmış bir kural neden zamanla bozulabilir? Ve bu bozulmayı nasıl fark edebiliriz?</p><p>Bu yazıda, <strong>tespit </strong>kurallarının neden düzenli olarak test edilmesi gerektiğini, nasıl test edilebileceğini ve optimum ne şekilde olabileceğini anlatmaya çalışıyor olacağım.</p><h3><strong>Tespit </strong>Kuralları Neden Test Edilmeli?</h3><p>Bir tespit kuralını yazıp bırakmak büyük bir hata olabilir. Çünkü kural ne kadar test edilip yazılmış olsa da kontrol ettiği loglar değiştiğinde işlevini kaybedebilir.</p><ul><li>Bir log kaynağından gelen log formatı değişebilir.</li><li>Yeni bir ajan güncellemesi ile fieldlar farklılaşabilir.</li><li>Bazı field’lar boş gönderilmeye başlanabilir.</li><li>Yeni cihazlar eklenir, eski cihazlar devre dışı kalabilir.</li><li>Log yönlendirme kuralında yanlış düzenleme yapılabilir.</li><li>Kural üstünde sonradan yapılan düzenlemede hata yapılmış olabilir.</li></ul><p>Bu değişiklikler sonucunda kural:</p><ul><li>Tetiklenmez, sessizce bozulmuş olur.</li><li>Gereksiz alarm üretir. (Aynı şekilde kural üzerinde tuning de çalışmayabilir.)</li><li>Yanlış alanlara bakmış olur.</li><li>Eskimiş mantıkla çalışır.</li></ul><p>Dolayısıyla tespit kurallarının gerçekten işlevsel olabilmesi için <strong>kural testinin bir defalık değil</strong>, <strong>düzenli </strong>bir süreç olması gerekir.</p><h3>Tespit Kuralları Nasıl Test Edilebilir?</h3><p>Tespit kurallarının doğrulaması tamamen manuel olarak da yapılabilir; belirli komutların çalıştırılması, logların izlenmesi ve tetik durumlarının elle kontrol edilmesi mümkündür. Ancak bu süreç hem zaman alıcıdır hem de tekrarlanabilirliği düşüktür. Günümüzde aynı işlemler; lisanslı BAS ürünleri, açık kaynak saldırı simülasyon araçları ve otomasyon destekli test platformlarıyla çok daha hızlı, güvenilir ve ölçülebilir bir şekilde gerçekleştirilebilir. Bu tarz ürünler yalnızca test sürecini hızlandırmakla kalmaz; detaylı raporlama, MITRE ATT&amp;CK eşleşmeleri, coverage analizleri, tetiklenme oranlarını ve nedenlerini gösterebilen gelişmiş çıktılar sunarak ekiplerin kural verimliliğini çok daha net izlemesini sağlar. Böylece manuel bir sürecin hata şansını büyük ölçüde azaltmış oluruz ve onun yerine, daha oturmuş, sistematik ve sürekli iyileştirmeye açık bir test yaklaşımı benimsenmiş olur. Aşağıda bu ürünlere ve yöntemlere birkaç örnek verdim;</p><p><strong>Lisanslı bas ürünleri</strong>;<br>-<a href="https://www.picussecurity.com/">Picus</a><br>-<a href="https://cymulate.com/">Cymulate</a><br>-<a href="https://www.attackiq.com/">AttackIQ </a>vb.</p><p><strong>Açık kaynak araçlar;</strong><br>-<a href="https://github.com/redcanaryco/atomic-red-team">Atomic Red Team</a> (Atomic atakları oluşturmak için <a href="https://atomicgen.io/">atomicgen.io</a> kullanabilirsiniz ekip arkadaşım Burak Karaduman’ın projesidir.)<br>-<a href="https://github.com/mitre/caldera">Caldera</a> vb.</p><p><strong>Log Replaying; </strong><br>Log replaying nedir? Gerçek bir saldırıdan veya gerçekçi bir testten alınan logların SIEM test ortamına zaman damgası değiştirilerek tekrar gönderilmesidir. Böylece eskiden oluşmuş bir incident’ın yeniden simüle edilmesi sağlanır.</p><p><strong>Purple Team çalışmaları;</strong><br>Purple Team testleri, otomatik araçlarla veya tek adımlık atomik tekniklerle doğrulanamayan, daha karmaşık ve çok aşamalı saldırı davranışlarını hedefler. Genellikle purple team çalışmalarında davranış bazlı kuralları, lateral movement kurallarını (daha çok adımlı daha çok kullanıcı ile etkileşimde) test etmede daha uygundur.</p><h3>Tespit Kurallarını Ne Sıklıkta Test Etmeliyiz?</h3><p>Tespit kurallarının test periyodu her kural için aynı olamaz; çünkü her kuralın risk seviyesi, bozulma olasılığı ve tetiklenmesi gereken davranışın karmaşıklığı farklıdır. Örneğin, komut çalıştırma (PowerShell, CMD, WMI) gibi execution tabanlı kurallar, kolayca otomotize edilerek haftalık veya en az iki haftada bir test edilebilir. Buna karşılık, domain controller ele geçirme, Golden Ticket saldırısı, privilege escalation zincirleri veya lateral movement kampanyaları gibi daha karmaşık ve çok aşamalı saldırılar ki bunlar genellikle Purple Team çalışmalarına daha uygundur. günlük operasyonlarda doğal olarak tetiklenmez. Bu nedenle bu tür “yüksek etkili ama düşük frekanslı” saldırı senaryolarının test edilme sıklığı 6 ayda 1 veya yılda 1 defa olarak belirlenebilir. Böylece hem operasyonel riski artırmadan gerçekçi bir saldırı zinciri test edilmiş olur, hem de bu tür kuralların hala doğru tetiklediğinden emin olunur. Sonuç olarak, sık değişen, kolay bozulabilen kurallar daha sık; çok aşamalı karmaşık saldırı tespitleri ise daha seyrek fakat senaryolu testlerle doğrulanmalıdır.</p><p><strong>Bonus: </strong>Tüm kuralları test düzenine oturtana kadar tetiklenme sıklıklarını izleyebilir, anomali durumlar için kurallar yazabilirsiniz.</p><h3>Testing Detection Rules</h3><h3>Why Is Testing SIEM Detection Rules So Important?</h3><p>Modern SOC environments operate with millions of logs, hundreds of alerts, and data flowing in from dozens of different sources. Amid this overwhelming volume, what truly makes the difference is the detection rules running on the SIEM.</p><p>When these rules function properly, a critical attack becomes visible within minutes. But why can a well-written rule break over time? And how can we identify this misbehavior?</p><p>In this article, I will discuss why detection rules must be tested regularly, how they can be tested, and what the optimal testing approach looks like.</p><h3>Why Should Detection Rules Be Tested?</h3><p>Writing a detection rule and leaving it untouched afterward can be a major mistake. No matter how thoroughly a rule is written and tested initially, it may lose effectiveness when the logs it depends on change.</p><p>Several things can cause a rule to break:</p><ul><li>The log format from a source may change.</li><li>A new agent update may alter field names.</li><li>Some fields may start arriving as empty.</li><li>New devices may be added; old ones may be decommissioned.</li><li>A misconfiguration in log forwarding may occur.</li><li>Later modifications to the rule may introduce errors.</li></ul><p>As a result, a rule may:</p><ul><li>Stop triggering entirely (silently breaking).</li><li>Generate unnecessary alerts (and tuning efforts may fail as well).</li><li>Look at the wrong fields.</li><li>Operate with outdated logic.</li></ul><p>Therefore, for detection rules to remain functional, testing must not be a one-time effort — it must be a <strong>continuous cycle.</strong></p><h3>How Can Detection Rules Be Tested?</h3><p>Detection validation can be performed manually by running commands, observing logs, and checking triggers one by one. However, this approach is time-consuming and lacks repeatability.</p><p>Today, the same tasks can be performed much faster and more reliably using licensed BAS products, open-source attack simulation tools, and automation-driven testing platforms. These solutions not only accelerate the testing process but also provide advanced outputs such as detailed reports, MITRE ATT&amp;CK mappings, coverage analysis, trigger rates, and the root causes behind failures. This greatly reduces the risk of human error and establishes a more systematic, repeatable, and continuously improving testing approach.</p><p>Below are some examples of tools and techniques:</p><p><strong>Licensed BAS Products;</strong><br>-<a href="https://www.picussecurity.com/">Picus</a><br>-<a href="https://cymulate.com/">Cymulate</a><br>-<a href="https://www.attackiq.com/">AttackIQ </a>etc.</p><p><strong>Open-Source Tools;</strong><br>-<a href="https://github.com/redcanaryco/atomic-red-team">Atomic Red Team</a> (You can use <a href="https://atomicgen.io/">atomicgen.io</a> generate atomic tests, a project by my teammate Burak Karaduman.)<br>-<a href="https://github.com/mitre/caldera">Caldera</a> vb.</p><p><strong>Log Replaying; </strong><br>What is log replaying? It is the process of taking logs from a real attack or a realistic simulation, modifying the timestamps, and sending them into the SIEM’s test environment. This allows you to recreate and validate past incidents end-to-end.</p><p><strong>Purple Team Exercises;</strong><br>Purple Team tests target complex and multi-step attack behaviors that cannot be validated easily with automated tools or one-off atomic techniques. These exercises are particularly suitable for validating behavior-based rules and lateral movement detections that involve multiple steps and user interactions.</p><h3>How Often Should Detection Rules Be Tested?</h3><p>Not all rules should be tested at the same frequency. Each rule has a different risk level, likelihood of breaking, and behavioral complexity.</p><p>For example:</p><ul><li><strong>Execution-based rules</strong> (PowerShell, CMD, WMI) can be automated and tested weekly, or at least biweekly.</li><li><strong>High-impact, low-frequency attack chains</strong>, such as domain controller compromise, Golden Ticket attacks, privilege escalation chains, and lateral movement campaigns, are more suited for Purple Team testing. These scenarios rarely occur naturally in daily operations.</li></ul><p>Therefore, these more complex multi-stage detections can be tested <strong>once every 6 months or once a year</strong>, ensuring the rule still triggers correctly without creating unnecessary operational risk.</p><p>In summary:</p><ul><li>Rules that change frequently or break easily should be tested more often.</li><li>Multi-stage, complex detections should be tested less frequently but through fully scripted scenarios and Purple Team exercises.</li></ul><p><strong>Bonus:</strong> Until you establish a proper testing schedule, you can monitor rule trigger frequencies and write anomaly-based rules to detect unexpected changes in behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3M-c40tyJlcG7JDI5Zm5ZQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35cea16b5f91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Overlooked Risk in Logging: The Importance of Registry Monitoring]]></title>
            <link>https://justmoii.medium.com/loglamada-g%C3%B6zden-ka%C3%A7an-risk-registry-i%CC%87zlemenin-%C3%B6nemi-920ad8fca30a?source=rss-46011f015c2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/920ad8fca30a</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[splunk]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[registry]]></category>
            <dc:creator><![CDATA[Just Moi]]></dc:creator>
            <pubDate>Tue, 01 Jul 2025 20:12:18 GMT</pubDate>
            <atom:updated>2026-01-27T15:54:53.102Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Kayıt defteri (Registry) nedir?</strong> Windows’un çalışması sırasında sürekli olarak başvurduğu bilgileri içerir. Bu bilgiler arasında her kullanıcıya ait profiller, bilgisayarda yüklü olan uygulamalar ve bu uygulamaların oluşturabileceği belge türleri, klasörler ve uygulama simgeleri için özellik ayarları, sistemde bulunan donanımlar ve kullanılan portlar yer alır.</p><p>Windows kayıt defteri, beş temel ana bölümden (hive) oluşur.</p><p><strong><em>HKEY_LOCAL_MACHINE (HKLM): </em></strong><em>Bilgisayara ait genel ayarları içerir. Tüm kullanıcılar için geçerlidir. Donanım bilgileri, sürücüler, hizmetler ve yazılım konfigürasyonları burada yer alır. Sunucu tarafında en kritik kayıtlar genelde buradadır.</em></p><p><strong><em>HKEY_CURRENT_USER (HKCU): </em></strong><em>Oturum açmış olan kullanıcıya özel ayarları içerir. Masaüstü düzeni, uygulama tercihleri ve kullanıcı bazlı kalıcılık teknikleri burada uygulanabilir. Özellikle client cihazlarda güvenlik açısından dikkat edilmelidir.</em></p><p><strong><em>HKEY_CLASSES_ROOT (HKCR): </em></strong><em>Dosya uzantıları ve uygulama ilişkilendirmeleri gibi bilgiler burada tutulur. Zararlı yazılımlar dosya tiplerini manipüle ederek kendilerini buradan tetikleyebilir.</em></p><p><strong><em>HKEY_USERS (HKU): </em></strong><em>Sistemdeki tüm kullanıcı hesaplarının bilgilerini içerir. HKCU aslında HKU içerisindeki ilgili SID’nin (Security Identifier) bir kopyasıdır.</em></p><p><strong><em>HKEY_CURRENT_CONFIG (HKCC): </em></strong><em>Donanıma bağlı geçici yapılandırmaları barındırır. Genellikle donanım profilleri için kullanılır ve kalıcılık açısından daha az hedef alınır.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*sSA0BUMt5WxBz9-U_SO4ZQ.png" /></figure><p><strong>Registryler neden önemlidir? </strong>Registry; sistemin davranışlarını doğrudan etkileyebilen, saldırganların iz bırakmadan işlem yapabileceği, kalıcılık ve savunma aşma tekniklerinin uygulanabildiği kritik bir alandır. Bu nedenle loglanmalı ve izlenmelidir.</p><ul><li><strong>Client sistemlerde</strong>: HKCU öncelikli, çünkü kullanıcı üzerinden ilerleyen saldırılar yaygındır.</li><li><strong>Server sistemlerde</strong>: HKLM öncelikli, çünkü sistem bütünlüğüne yönelik saldırılar daha olasıdır.</li></ul><p>Registry logları, çok fazla detay içermesi ve günlük sistem işlemleri sırasında sıkça tetiklenmesi nedeniyle çoğu zaman fazla gürültü üretir ve bu yüzden göz ardı edilebilir. Ancak bu durum, kalıcılık, AV bypass ve sistem manipülasyonu gibi saldırıların fark edilmeden gerçekleşmesine yol açabilir. Bu nedenle en azından kritik registry pathlerinin loglamaya açık olması ve bu pathlere özel spesifik kuralların oluşturulması detayda kaybolmamak ve gürültünün önüne geçmek için önemlidir.</p><p>Yazının çok uzun olmaması için yaklaşımımı ve mantığımı aşağıda örneklerle anlatmaya çalıştım. Aynı şekilde keyler kontrol edilebilir. Custom uygulamaların custom keyleri olduğu için internette bulamadığınız bir key sizin custom bir uygulamanızın veya Picus, Nessus gibi atack toolunuzun oluşturduğu bir key değilse önceden oraya yerleşmiş bir zararlının keyi olmadığına emin olmak isteyebilirsiniz.</p><h3><strong>Path</strong> / Neden Önemli?</h3><p><strong>HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</strong> Sistem açılışında tüm kullanıcılar için program başlatır. Sunucuda çalıştırılan her hizmet hesabı etkilenir.</p><p><strong>HKCU\Software\Microsoft\Windows\CurrentVersion\Run</strong> Kullanıcı oturumu açıldığında otomatik çalıştırma. Client tarafında en sık suistimal edilen anahtarlardan biridir.</p><p><strong>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image</strong> File Execution Options Herhangi bir EXE çağrıldığında örn. debugger aracılığıyla bambaşka dosya çalıştırmaya imkan verir.</p><p><strong>HKLM\SYSTEM\CurrentControlSet\Control\Lsa\Notification</strong> Packages LSASS başlarken listelenen DLL’leri yükler. Yetkisiz DLL eklemek kimlik bilgisi hırsızlığına sebep olabilir.</p><p><strong>HKLM\SYSTEM\CurrentControlSet\Control\Lsa\RunAsPPL</strong> LSASS’in korumalı process olarak çalışıp çalışmayacağını belirler.</p><h3><strong><em>Client vs Sunucu Spesifik Loglama Örnekleri</em></strong></h3><p><strong>[WinRegMon://hklm_print_server] </strong>Client tarafında loglanması kapatılabilirken, sunucu tarafında açılmak istenebilir. Çünkü yazıcı sunucusu ayarları, server tarafında güvenlik açıklarına neden olabilir. (PrintNightmare (CVE-2021–34527) gibi açıklar kullanılarak sunucu istismar edilebilir.)</p><p><strong>[WinRegMon://hkcu_CurrentVersion]</strong> Client de loglanması gerekirken, sunucularda Opsiyonel bırakılabilir. Çünkü Internet ayarları, client tarafında kötü amaçlı yazılımların etkisini artırabilir. MITM atakları en çok clientlerde görülür. (İnternet ve proxy ayarlarını tutar sunucularda ayarlar sınırlı olduğundan sadece client alınabilir.)</p><p><strong>[WinRegMon://hkcu_accessvbom]</strong> Client tarafında loglanması gerekirken, sunucu tarafında alınması şart değildir. Client tarafında Office VBA makro güvenliği, kötü amaçlı yazılımların etkisini artırabilir. Sunucularda yüklenmiş olunması beklenmez. (Office uygulamalarında VBA makrolarına erişimi belirler saldırganlar bu ayarı değiştirerek makroları erişimi etkinleştirilebilir bu key 1 mi diye kontrol edilebilir.)</p><h3><strong>GAP oluşturmadan Registry Loglamasında öncelikli olarak dikkat etmemiz gereken bir kaç adım;</strong></h3><ul><li><strong>Kritik path listesi hazırlanırsa</strong>, loglar içinde kaybolmadan ve logdan kar ederek izlenebilir.</li><li><strong>Sysmon kurulumu</strong> Event ID 12–13–14–15, 4657 event ID’sinde görülmeyen detayları verir.</li><li><strong>GPO ile kritik HKCU/HKLM anahtarları</strong> kilitli değilse kilitlenmelidir.</li><li>Ve tabii ki alınan loglar ve onlar için yazılan <strong>her güvenlik kuralı, purple team çalışmasında test edilmelidir</strong>.</li></ul><p><strong>References:</strong> <a href="https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/windows-registry-advanced-users">https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/windows-registry-advanced-users</a></p><p><a href="https://redcanary.com/threat-detection-report/techniques/modify-registry/">https://redcanary.com/threat-detection-report/techniques/modify-registry/</a></p><h3>ENG</h3><h3><strong>What is the Windows Registry?</strong></h3><p>The Windows Registry is a hierarchical database that Windows continually refers to while it runs. It contains information such as each user’s profile, the applications installed on the computer and the document types they can create, property-sheet settings for folders and application icons, the hardware present in the system, and the ports that are in use.</p><p>Windows Registry is divided into five main hives:</p><p><strong>HKEY_LOCAL_MACHINE (HKLM):</strong> Contains computer-wide settings that apply to all users. Hardware information, drivers, services, and software configurations are stored here. On servers, the most critical keys are usually found in this hive.</p><p><strong>HKEY_CURRENT_USER (HKCU):</strong> Stores settings specific to the user who is currently logged on. Desktop layout, application preferences, and user-level persistence techniques reside here. It is especially important for security monitoring on client devices.</p><p><strong>HKEY_CLASSES_ROOT (HKCR):</strong> Holds file-extension associations and application bindings. Malicious software can manipulate these associations to trigger itself.</p><p><strong>HKEY_USERS (HKU):</strong> Contains profile data for every user account on the system. HKCU is essentially a view of the relevant SID under HKU for the active user.</p><p><strong>HKEY_CURRENT_CONFIG (HKCC):</strong> Stores hardware-dependent, temporary configuration data. It is mainly used for hardware profiles and is less frequently targeted for persistence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*sSA0BUMt5WxBz9-U_SO4ZQ.png" /></figure><p><strong>Why are registry logs important?</strong><br> The Windows registry is a critical area that can directly influence system behaviour, let attackers operate without leaving obvious traces, and enable persistence or security-evasion techniques. For that reason it should always be logged and monitored.</p><ul><li><strong>On client systems:</strong> <em>HKCU</em> is the main focus, because user-context attacks are most common.</li><li><strong>On server systems:</strong> <em>HKLM</em> is the priority, because attacks are more likely to target overall system integrity.</li></ul><p>Registry logging is often noisy — keys are touched constantly during routine operations — so teams sometimes disable it. Yet skipping registry logs allows persistence, AV bypass and system manipulation to happen unnoticed. The answer is to keep at least the <strong>critical paths</strong> under audit and write dedicated rules for them, so you avoid drowning in noise.</p><p>To keep the article concise I illustrate the approach with examples below. The same logic applies to any key. If you discover a key that is not documented online and does not belong to one of your custom applications or an attack-simulation tool (e.g. Picus, Nessus), double-check that it is not left behind by malware.</p><h3>Path / Why it matters</h3><p><strong>HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</strong> Starts programs for <em>all</em> users at system boot; every service account on a server is affected.</p><p><strong>HKCU\Software\Microsoft\Windows\CurrentVersion\Run</strong> Auto-runs when the user logs on — one of the most abused client-side keys.</p><p><strong>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options</strong> Lets an attacker launch an entirely different binary (debugger hijack) whenever any EXE is called.</p><p><strong>HKLM\SYSTEM\CurrentControlSet\Control\Lsa\Notification Packages</strong> Loads listed DLLs into LSASS during boot; adding an unauthorised DLL can steal credentials.</p><p><strong>HKLM\SYSTEM\CurrentControlSet\Control\Lsa\RunAsPPL</strong> Enables or disables LSASS Protected Process Light; disabling it makes credential dumping easier.</p><h3>Client- vs Server-specific logging examples</h3><p><strong>[WinRegMon://hklm_print_server]</strong> May be disabled on clients, but should stay enabled on servers, because printer-server settings can expose vulnerabilities such as <em>PrintNightmare</em> (CVE-2021–34527).</p><p><strong>[WinRegMon://hkcu_CurrentVersion]</strong> Should be logged on clients, optional on servers. Internet and proxy settings are a prime target for malware on workstations; MITM attacks are rare on locked-down servers.</p><p><strong>[WinRegMon://hkcu_accessvbom]</strong> Important on clients, less so on servers. It governs access to Office VBA macros; attackers flip this setting to enable malicious macros — unlikely on a typical server where Office is not installed.</p><h3>Key steps to avoid gaps in registry logging</h3><ol><li>Build a <strong>critical-path list</strong> so you can watch what matters and save log volume.</li><li>Deploy <strong>Sysmon</strong>: Event IDs 12–13–14–15 reveal registry details that standard Event ID 4657 does not.</li><li>If critical HKCU/HKLM keys are not locked down, <strong>enforce them via GPO</strong>.</li><li>Test every rule you create in a <strong>purple-team exercise</strong> to ensure it really fires when an attacker (or your test tool) changes the key.</li></ol><p>By following these steps you can cut registry noise yet still catch persistence, AV bypass and configuration tampering.</p><p><strong>References:</strong> <a href="https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/windows-registry-advanced-users">https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/windows-registry-advanced-users</a></p><p><a href="https://redcanary.com/threat-detection-report/techniques/modify-registry/">https://redcanary.com/threat-detection-report/techniques/modify-registry/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=920ad8fca30a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beatiful Threat Hunter Mind]]></title>
            <link>https://justmoii.medium.com/a-beatiful-threat-hunter-mind-597bd49c1992?source=rss-46011f015c2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/597bd49c1992</guid>
            <category><![CDATA[soc]]></category>
            <category><![CDATA[analysis]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[cyber-security-awareness]]></category>
            <category><![CDATA[siem]]></category>
            <dc:creator><![CDATA[Just Moi]]></dc:creator>
            <pubDate>Sun, 14 Jan 2024 23:09:37 GMT</pubDate>
            <atom:updated>2024-01-15T06:35:21.550Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Threat Hunting Nedir?</strong></h3><p>Threat Hunting, siber güvenlik tehditlerini bulma yaklaşımıdır, burada kötü niyetli faaliyet belirtilerini aramak için proaktif bir uygulama olur.</p><p>Genellikle kurumlarda bir vaka olduğunda Incident Response ekibi toplanır bu vaka için araştırmalara başlanır, Threat Hunting, bu vaka araştırmasını başlatan atak gerçekleştiği andan araştırmalara başlanma arasındaki boşluğu kapatmayı amaçlar, sürekli olarak mevcut detection mekanizmalarına eklemeler ve iyileştirmeler için yollar bulur. Böylece gelecekte benzer kötü senaryolar otomatik olarak hemen tespit edilmesini sağlar.</p><p>Threat Intelligence (Tehdit istihbaratı), Threat Hunting için çok ciddi bir önem taşır. Threat intelligence, potansiyel tehditler ve saldırı aktörleri hakkında detaylı bilgiler içerir. Threat hunting sırasında threat intelligence, organizasyonun spesifik tehdit durumunu anlamak ve güncel bilgilerle çalışmak için kullanılabilir.</p><p>Bu verileri sağlayan bazı ücretli ve ücretsiz platformlar mevcut. MISP, açık kaynaklı Tehdit İstihbaratı için bir örnek fazlasına sitesinden ulaşabilirsiniz: <a href="https://www.misp-project.org/">MISP</a></p><h3>Peki Biz Neyi Avlıyoruz?</h3><p>Başta bir amacımız olmadan arayışa çıkarsak samanlıkta iğne aramaya benzer, logların içinde boğulabiliriz. Bu yüzden aşağıdaki başlıklar bize yardımcı olabilecek bazı yollar olabilir.</p><p><strong>Kullanılan Ürün ve Uygulamalardaki Bilinen Zafiyetler: </strong>Henüz yaması geçilmemiş zafiyetli bir uygulama veya ürün varsa zafiyetin tarih verileri ne kadar izin veriyorsa o kadar süre boyunca sömürülüp sömürülmediği kontrolü yapılmalı ve organizasyonlar 0 day duyurularına karşı ekstra dikkatli olmalıdırlar.</p><p><strong>Bilinen Kötü Amaçlı Yazılımlar (Malwares): </strong>Bilinen malwareler çoğu güvenlik ürününde bilindikleri için engellenecektir ama internette çokça malware örnekleri ve analizleri mevcut, bunları inceleyip belirli çevresel koşullar içinde nasıl çalışacağına dair anlayışlar kazanabilirsiniz.</p><p>(<a href="https://github.com/ytisf/theZoo/tree/master/malware/Binaries">Malware örnekleri için site</a>: — <a href="https://www.trendmicro.com/vinfo/us/threat-encyclopedia/">Malware analizleri için site</a>: )</p><p><strong>Kötü Amaçlı Saldırılar: </strong>Özellikle bir saldırının gerçekleştiğini düşünüyorsanız harika bir başlangıç noktasıdır. İyi Tehdit İstihbaratı ile özellikle iyi çalışır.</p><p>Ancak buradaki zorlayıcı kısım, çevrenizi yeterince iyi bilmek ve saldırıyı normal davranışlardan ayırabilmektir. Şirketlerde çoğu meslek için geçerli olsa da Threat Hunting yapan kişi için aynı şirkette uzun süre çalışıyor olmak daha önemlidir. Bir çok saldırı, normal işleyişteki trafikler ile karışabilir. İş gereği yetkili kullanıcıların yaptığı trafikleri, teyit etmekle daha az vakit harcayıp, araştırması gerektiği yöne daha çok odaklanabilir.</p><p>Bir çok taktik ile çok farklı şekilde ataklar görülebilir. Hepsini ele alıp tüm ihtimalleri yazmak imkansız ama bazı ana taktikler altında olabilecek ataklara elimden geldiğince örnekler vereceğim böylece bakış açımızı güçlendirebiliriz.</p><h3><strong>Tactic: Initial Access</strong></h3><ul><li>Sosyal Mühendislik teknikleri, örneğin phishing.</li><li>Açık sunucular üzerinden zafiyetlerin sömürülmesi (Anomali trafikler varsa o IP’lerin trafikleri kontrol edilebilir.)</li><li>Açık kimlik doğrulama noktalarından login denemeleri (SSH ile Brute Force Saldırıları kontrol edilebilir.)</li><li>Flaş bellekler aracılığıyla zararlı komutlar yürütme.</li></ul><h3><strong>Tactic: Execution</strong></h3><ul><li>powershell.exe veya cmd.exe kullanarak hazırlanmış payloadı indirmek</li><li>certutil.exe veya bitsadmin.exe kullanarak remote, payloadu indirmek ve rundll32.exe ile bunu çalıştırmak</li><li>İşletim sisteminin içinde doğrudan bulunan Python veya PHP’nin doğrudan kullanımı (Her zaman bulunmayabilir ama örneğin backend app i çalışan bir sunucuda PHP olduğu öngörülebilir.)</li></ul><p>Tüm örneklerde parent process, komut satırında herhangi bir siteye yapılan istek varsa sitenin güvenirliği, python veya PHP’lerin scriptleri gözüküyorsa bunlar kontrol edilebilir.</p><p>Parent veya child processlerde çıkan exeleri kontrol edebileceğimiz bir site: <a href="https://lolbas-project.github.io/#">LOLBAS</a></p><h3>Tactic : Persistence</h3><ul><li>Sistem/program startuplarını ele geçirmek için kayıt defteri anahtarlarının değiştirilmesi. (reg.exe) (Event ID: 13)</li><li>Yerleştirilmiş kötü amaçlı yazılımın düzenli olarak güncellemek ve çalıştırmak için zamanlanmış görevlerin oluşturulması (schtasks.exe) (Event ID: 4698)</li><li>Yüksek ayrıcalıklı arka kapı hesaplarının oluşturulması (net.exe ile oluşturulabilir.)</li></ul><h3><strong>Tactic: Defense Evasion</strong></h3><ul><li>Güvenlik yazılımını devre dışı bırakma.</li></ul><p>-<strong>DisableRealtimeMonitoring</strong>: PowerShell’ın Set-MPPreference ile gerçek zamanlı izlemeyi devre dışı bırakmak için kullanılır.<br>-<strong>RemoveDefinitions</strong>: Windows Defender’ın mevcut tüm imzalarını kaldırmak için genellikle yerleşik MpCmdRun.exe ile kullanılır.</p><ul><li>Saldırı izlerini loglardan silme. (Event ID: 1102)</li><li>Maskelenme, gizleme(obfuscation) ve şifreleme ile analistleri aldatma.</li><li>Güvenlik kontrollerine karşı bilinen atlamaları gerçekleştirme. (Örn: MFA)</li></ul><p>Threat hunting için de defans evasion olabilir bunlar;</p><ul><li>Güvenlik yazılımını devre dışı bırakma.</li><li>Log silme girişimleri.</li><li>Process injection ile shellcode çalıştırma (Event ID: 8)</li></ul><h3><strong>Tactic: Collection</strong></h3><ul><li>Ortadaki adam saldırısı</li><li>ARP / LLMNR Zehirlenmesi</li><li>SMB Relay</li><li>DHCP Spoofing</li><li>Hijacking</li><li>Traffic dump</li><li>Keylogging</li></ul><p>Hepsi kendine özel ve spesifik olduğundan isimlerini yerelleştiremedim. Keylogging için fonksiyonlar arkada bunları çağırıyor, bunlar için searchler yapılabilir; “GetKeyboardState, SetWindowsHook, GetKeyState, GetAsynKeyState, VirtualKey, vKey, filesCreated, DrawText”</p><h3><strong>Tactic: Exfiltration</strong></h3><ul><li>Alternatif protokoller üzerinden veri transferi</li><li>Encrypted/unencrypted C2 Kanalı üzerinden veri transferi</li><li>Web hizmeti ve bulut depolama ortamları üzerinden veri sızdırma</li><li>Veriyi bluetooth veya taşınabilir cihazlar ile dışarıya çıkarma</li></ul><h3><strong>Tactic: Impact</strong></h3><ul><li>Ransomware</li><li>Dosya bozma ve silme</li><li>Veri manipülasyonu</li></ul><p>-del, rm (Windows, linux dosya silme komutları) <br>-vssadmin, wbadmin (Shadow ve Backup admin kullanıcıları)<br>-bcdedit, wevutil (Önyükleme seçeneklerini düzenlemek)<br>-shadow, recovery, bootstatuspolicy</p><p>Üstteki komut, kullanıcı veya .exe’leri spesifik sunucu veya cihazlar üzerinde aratmak bize yol gösterebilir.</p><p>Yukarıda bahsettiğim taktiler ve onlar için bazı yöntemler sadece başlangıç için yol gösterebilir, bir saldırgan gibi düşünüp başarılı hamlelerinden sonra neler yapabileceğini içgüdümüz ile tahmin edip kontrolleri sağlamalıyız. Threat huntingde olan dezavantaj, CTF lerin aksine kimse Flagi alıp almadığımızı söylemiyor o yüzden kontrolleri dikkatli yapmalıyız.</p><p>Ayrıca SANS’a göre Siber Güvenlikte en cool kariyer olarak görülüyor:)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CIPTDdAIHUaU8zPY238JQA.png" /></figure><p>Yazımı A Beatiful Mind filminden meşhur bir sahneyle (Do you like apples?) bitiriyorum ve umarım faydalı olmuştur, okuduğunuz için teşekkürler :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QMVQ-bcylLScAU5Ka8tfMw.png" /></figure><p>Kaynaklar: THM, MitreAtt&amp;ck, Microsoft, SANS</p><h3><strong>What is Threat Hunting?</strong></h3><p>Threat Hunting is an approach to finding cybersecurity threats, involving a proactive application to search for indicators of malicious activities. Typically, when an incident occurs in an organization, the Incident Response team is assembled, and investigations are initiated for that case. Threat Hunting aims to bridge the gap between the occurrence of the attack that triggers the investigation and the beginning of the investigation, continuously finding ways to add enhancements to existing detection mechanisms. This ensures that similar malicious scenarios are automatically detected promptly in the future.</p><p>Threat Intelligence plays a crucial role in Threat Hunting. Threat intelligence includes detailed information about potential threats and threat actors. During Threat hunting, threat intelligence can be utilized to understand the organization’s specific threat landscape and work with up-to-date information.</p><p>There are both paid and free platforms that provide such data. MISP is an example of an open-source Threat Intelligence platform; you can find more on their website: <a href="https://www.misp-project.org/">MISP</a></p><h3>What Do We Hunt For?</h3><p>Embarking on a search without a clear goal is similar to looking for a needle in a haystack; we might drown in the logs. Therefore, the following topics could be some ways that might help us:</p><p><strong>Known Vulnerabilities in Used Products and Applications:</strong> If there is an application or product with an unpatched vulnerability, the exploitation of the vulnerability should be checked for as long as the vulnerability’s historical data allows. Organizations should be extra cautious about zero-day announcements.</p><p><strong>Known Relevant Malware:</strong> Known malware will be blocked by most security products, but there are numerous examples and analyses of malware on the internet. Examining them can provide insights into how they operate under specific environmental conditions.</p><p>(<a href="https://github.com/ytisf/theZoo/tree/master/malware/Binaries">For malware examples is site</a>: — <a href="https://www.trendmicro.com/vinfo/us/threat-encyclopedia/">For malware analyses is site</a>: )</p><p><strong>Attack Residues:</strong> This is a great starting point, especially if you suspect that an attack has occurred. It works particularly well with good Threat Intelligence.</p><p>However, the challenging part here is knowing your environment well enough to be able to separate attacks from normal behavior. While this is applicable to most professions in companies, it is more critical for individuals engaged in Threat Hunting to have worked in the same company for an extended period. Many attacks can blend with normal traffic patterns. For those involved in Threat Hunting, focusing more on the direction that requires investigation and spending less time confirming the traffic of authorized users can be more efficient.</p><p>Attacks can be seen in various ways with many tactics. It’s impossible to cover them all and write down all possibilities, but I will provide examples of attacks that could occur under some main tactics as much as possible. This way, we can strengthen our perspective.</p><h3>Tactic: Initial Access</h3><ul><li>Social Engineering techniques such as phishing.</li><li>Exploiting vulnerabilities through public-facing servers. (If there are anomalous traffics, the traffic of those IPs can be checked.)</li><li>Spraying credentials through exposed authentication endpoints. Brute force attacks with SSH can be monitored.)</li><li>Executing commands through malicious flash drives.</li><li>Installing cracked software with hidden malicious code.</li></ul><h3>Tactic: Execution</h3><ul><li>Using built-in commands through powershell.exe and cmd.exe to download and execute the staged payload.</li><li>Using certutil.exe or bitsadmin.exe for downloading the remote payload and rundll32.exe to run it.</li><li>Using built-in functionalities of programming tools such as Python’s os.system() or PHP’s exec(). (May not always be present, but for example, if PHP is assumed to be running on a server where a backend app is running.)</li></ul><p>In all examples, the reliability of the site can be checked if there is any request to a site on the command line. If scripts of Python or PHP are visible, they can be examined.</p><p>A site where we can check the exes that appear in parent or child processes: <a href="https://lolbas-project.github.io/#">LOLBAS</a></p><h3>Tactic : Persistence</h3><ul><li>Modification of registry keys to hijack the typical system/program startup. (reg.exe) (Event ID: 13)</li><li>Creating scheduled tasks to regularly update and execute implanted malware (schtasks.exe) (Event ID: 4698)</li><li>Creation of additional high-privileged backdoor accounts. (can be created with net.exe.)</li></ul><h3>Tactic: Defense Evasion</h3><ul><li>Disabling security software.</li></ul><p><strong>-DisableRealtimeMonitoring: </strong>Commonly used with PowerShell’s Set-MPPreference to disable its real-time monitoring.<br>-<strong>RemoveDefinitions: </strong>Commonly used with built-in MpCmdRun.exe to remove all existing signatures of Windows Defender.</p><ul><li>Deleting attack footprints on logs. (Event ID: 1102)</li><li>Deceiving analysts through masquerading, obfuscation, and encryption.</li><li>Executing known bypasses to security controls. (Etc; MFA)</li></ul><p>These can also be considered as defense evasion for threat hunting;</p><ul><li>Disabling security software.</li><li>Log deletion attempts.</li><li>Executing shellcode through process injection. (Event ID: 8)</li></ul><h3>Tactic: Collection</h3><ul><li>Man-in-the-middle</li><li>ARP / LLMNR Poisoning</li><li>SMB Relay</li><li>DHCP Spoofing</li><li>Hijacking</li><li>Traffic dump</li><li>Keylogging</li></ul><p>Keylogging with API and function calls and searches can be made for these; “GetKeyboardState, SetWindowsHook, GetKeyState, GetAsynKeyState, VirtualKey, vKey, filesCreated, DrawText.”</p><h3>Tactic: Exfiltration</h3><ul><li>Traffic Duplication</li><li>Data transfer over alternative protocols</li><li>Data transfer over encrypted/unencrypted C2 Channel</li><li>Exfiltration over web service and cloud storage mediums</li><li>Exfiltration over Bluetooth and portable devices</li></ul><h3>Tactic: Impact</h3><ul><li>Ransomware</li><li>File destruction and removal</li><li>Data manipulation</li></ul><p>-del, rm (File deletion commands in Windows and Linux)<br>-vssadmin, wbadmin (Used by Shadow and Backup admins)<br>-bcdedit, wevutil (Modify boot options)<br>-shadow, recovery, bootstatuspolicy</p><p>The above commands can guide us to search for specific users or executables on particular servers or devices.</p><p>The tactics mentioned above and some methods for them can only provide guidance for the beginning of hunting. We should think like an attacker, anticipate what they might do after successful moves, and secure controls accordingly. The disadvantage in threat hunting is that, unlike CTFs, no one tells us whether we’ve found the “flag,” so we need to be meticulous with our controls.</p><p>Moreover, according to SANS, it is considered the coolest career in cybersecurity :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CIPTDdAIHUaU8zPY238JQA.png" /></figure><p>I’m concluding my writing with a famous scene from the movie “A Beautiful Mind” (Do you like apples?), and I hope it has been helpful. Thank you for reading :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QMVQ-bcylLScAU5Ka8tfMw.png" /></figure><p>References: THM, MitreAtt&amp;ck, Microsoft, SANS</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=597bd49c1992" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Since everything is expensive, dont make regex too]]></title>
            <link>https://justmoii.medium.com/since-everything-is-expensive-dont-make-regex-too-448bfae1a00d?source=rss-46011f015c2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/448bfae1a00d</guid>
            <category><![CDATA[training]]></category>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[regex]]></category>
            <dc:creator><![CDATA[Just Moi]]></dc:creator>
            <pubDate>Sun, 10 Dec 2023 08:39:57 GMT</pubDate>
            <atom:updated>2023-12-10T08:39:57.878Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba,</p><p>Regex nedir? Regex, “Regular Expression” ifadesinin kısaltmasıdır ve düzenli ifadeleri temsil eder. Kısaca regex, metinle ilgili belirli kurallara uyan karakter dizilerini tanımlamak için kullanılan güçlü bir araçtır. Bugün ben de kendi alanımda kullandığım yerlerden örneklerle bu yazıda bahsediyor olacağım umarım faydalı olur, iyi okumalar.</p><p>Öncelikle bir kaç temel regex ifadesinden bahsedip temelde neler yapabildiklerini görelim</p><h3><strong>Metnimiz: “abcdef123.!” olsun</strong></h3><p><strong>[abc]:</strong> a,b,c harflerinden tek bir karakteri alır. Group olarak 1 seçilirse “a” harfini 2 seçilirse “b” harfini parse edicek şekilde ilerler.</p><p><strong>[^abc]:</strong> a,b,c harfleri haricinde tek bir karakteri alır. Group olarak 1 seçilirse “d” 2 seçilirse “e”harfini, group 4 seçilirse “1” rakamını group 7 seçilirse “.” karakterini parse edicek şekilde ilerler.</p><p><strong>[a-z]:</strong> a-z arasındaki küçük harflerden tek bir karakteri alır. Group 1 seçilirse “a” group 6 seçilirse “f” karakterini alıcak şekilde <strong>[A-Z]</strong> aynısını büyük harfler için yapar yani bu metinden hiç bir harfi parse edemez. <strong>[a-zA-Z] </strong>şeklinde kullanımda bu a-z arasında ki harflerden büyük veya küçük tek bir karakteri alır.</p><p><strong>a|b: </strong>a veya b harfini parse eder. Group 1 “a”, group 2 “b”</p><p><strong>\w</strong> herhangi bir harf, rakam veya “_” karakterini çeker <strong>\W</strong> ise \w nin çektiklerinin haricinde kalanları çeker bu metinde group 1 “.” karakteri olur.</p><p><strong>\d </strong>herhangi bir rakamı çeker (aynı zamanda eşleniği [0–9] ) <strong>\D </strong>ise bunun haricinde kalanları çeker. Rakam olmayan bir karakteri alır.</p><p>Tabi bunları tek tek çekemeyiz sürekli o yüzden “+” parametremiz var, bu metindeki ilk örneğimiz için <strong>[abc]+ </strong>kullanırsak parse edeceği kısım “abc” olcaktır.</p><h3><strong>Son örneklerimiz için metnimiz aaaabcd123. olsun</strong></h3><p><strong>a?:</strong> Varsa 1 a harfini alır. Group 1 den Group 4 e kadar çektiği parsing a harfi olur</p><p><strong>a*: </strong>0 veya 0 dan fazla kaç tane a varsa alır. Group 1 “aaaa” çeker.</p><p><strong>a+: </strong>1 veya 1 den fazla kaç tane a varsa alır. Group 1 yine “aaaa” çeker.</p><p>a{3}: Tam olarak 3 tane arka arkaya bulunuyorsa çeker. Group 1 “aaa”</p><p><strong>a{3,}:</strong> 3 veya daha fazla a varsa çekmeye yardımcı olur. Group 1 “aaaa”</p><p><strong>a{2,4}:</strong> 2 veya 4 arasında kaç tane a varsa çeker (2 ve 4 dahil) Group 1 “aaaa”</p><p>Şimdi öğrendiğimiz basit temel regexleri birleştirip metinlerden çekeceğimiz örnekler yapalım</p><p>Yeni metnimiz:</p><p>User named Mustafa Onur Inan from SOC department accessed the resource SOC.com/regex.html from the source IP 192.168.0.1 and country <br>Turkey at: Thu Dec 10 00:13:46 2023</p><p>Burdan user ve resource, IP bilgilerini çekmek istiyorum.</p><p>Yukarıda öğrendiğimiz bilgileri harmanladığımızda farklı yollarla bunlara ulaşıyor olacağız</p><p><strong>User\s\named\s([\w\s]+)\sfrom </strong>veya <strong>User\snamed\s([a-zA-Z\s]+)\sfrom</strong>: bize “Mustafa Onur Inan” ı parse edecektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*MmRjEjo617cnPJ4UNOMSuw.png" /></figure><p>Parantez içi bizim regeximizi aldığı için öncesini ve sonrasını belirtmek regeximizi daha isabetli, doğru kılar o yüzden öncesinde öncesinde User\s(boşluk)named\s önce kısmı belli ederken içersinde sadece büyük, küçük harflerden oluştuğunu için “\w” veya “[a-zA-Z]” boşluk olduğu için ”\s” bunlardan birden fazla olduğu içinde ardına “+” koyup sonrasında gelecek kelimeyi de tamamlayıp regeximi bitirdim.</p><p><strong>source\sIP ([\w\.]+)</strong> veya <strong>source\sIP ([\0–9\.]+)</strong> veya <strong>source\sIP\s(\d{1,3}(?:\.\d{1,3}){3}) </strong>bize source IP’i parse edecektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*TIWIJQEb0hwgAHzq8UTs5w.png" /></figure><p>Başlangıcımızı belirttikten sonra \w herhangi bir rakam,harf veya alt çizgi alıyordu, IP’ler arasında da . olduğu için \. ve bunlardan kaç tane görürsen al dedik. IP bittiğinde boşluk olduğu için orada duracağından bitişini belirtmemize gerek kalmadı. 2. Regex de aynı şekildeydi. 3. Regeximiz biraz daha komplike gözüküp yine basit başını yine belirttikten sonra \d ile rakam olacağını 1 veya 3 basamak olabilceğini söyledik sonrasında arasında nokta bulunacağını “\.” ile söyledik. Ve bunlardan 3 tane daha olup toplamda 4 tane 3 basamaklı IP olacağını belirttik ve tamamladık.</p><p>Exchange loglarından 1 mail logunda farklı bir örnekle bitirelim</p><p>sender-adress=sndr@moiexample.com.tr den domain kısmını çekmek istiyorum, sonra belki SIEM’in üzerinde externaldan bana başarılı gelen maillerde elimdeki CTI verileriyle zararlı domainlerden internalıma başarılı mail trafiği var mı diye kontrol edebilirim.</p><p>Bu senaryoda “ @ “ i başlangıç kabul etmek mantıklı gelebilir ama mail logu olcağı için birden fazla @ bulunacaktır ve bize doğru sonuç haricinde de sonuçlar verecektir, yazının başından beri bahsettiğimiz groupları kullanmak burda bize fayda sağlayacaktır.</p><p>sender-address=([^@]+)@([a-zA-Z0–9]+).com</p><p>Bu örnekte sadece harften oluşsada öncesi farklı karakterler veya sayılar içerebileceğinden “^@” kullandık bu da; “ @ ”harici “ @ ” işaretine kadar her şey group 1 ondan sonrasında da büyük küçük ve rakamlardan oluşan “.com” a kadar olan her şey de group 2 oldu. Sonrasında istediğimiz kontrolü yapabiliriz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*65VaN5zMWunOpKQ-KuWeRA.png" /></figure><p>Temelden başlayıp genele doğru gitmeye ve temeldeki her şeyi kullanmaya çalıştım bu örnekler türetilip her şey parse edilebilir diye düşünüyorum umarım faydalı olmuştur, okuduğunuz için teşekkürler :)</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>EN VERSION</p><p>Hello,</p><p>Regex, short for “Regular Expression,” represents a powerful tool used to define character strings that adhere to specific rules in text. In this article, I will be discussing examples from my field, hoping it will be helpful.</p><p>Firstly, let’s talk about a few basic regex expressions and see what they can do in essence.</p><h3>Our text: “abcdef123.!”</h3><p>[abc]: Picks a single character from the letters a, b, or c. If Group 1 is selected, it will parse “a,” and if Group 2 is selected, it will parse “b.”</p><p>[^abc]: Matches any single character except for the letters a, b, or c. If Group 1 is selected, it will parse &quot;d&quot;; if Group 2 is selected, it will parse &quot;e&quot;; if Group 4 is selected, it will parse &quot;1&quot;; if Group 7 is selected, it will parse &quot;.&quot;. It progresses to capture the specified character according to the selected group.</p><p>[a-z]: Picks a single character from lowercase letters a to z. If Group 1 is selected, it will pick “a”; if Group 6 is selected, it will pick “f.” [A-Z] does the same for uppercase letters. [a-zA-Z] picks a single character from lowercase or uppercase letters.</p><p>a|b: Parses either “a” or “b.” If Group 1 is “a,” Group 2 is “b.”</p><p>\w picks any letter, digit, or “_” character. \W picks characters other than what \w picks; in this text, Group 1 will be “.”</p><p>\d picks any digit (equivalent to [0–9]). \D picks characters other than digits, taking a non-digit character.</p><p>These selections cannot be done one by one; that’s why we have the “+” parameter. If we use [abc]+ for the first example in this text, it will parse “abc.”</p><h3>For the final examples, let our text be “aaaabcd123.”</h3><p>a?: Takes one “a” if it exists. From Group 1 to Group 4, it parses the “a” character.</p><p>a*: Takes 0 or more “a”s. Group 1 picks “aaaa.”</p><p>a+: Takes 1 or more “a”s. Group 1 again picks “aaaa.”</p><p>a{3}: Picks exactly 3 consecutive “a”s. Group 1 is “aaa.”</p><p>a{3,}: If there are 3 or more “a”s, it helps to pick them. Group 1 is “aaaa.”</p><p>a{2,4}: Picks 2 to 4 “a”s (including 2 and 4). Group 1 is “aaaa.”</p><p>Now, let’s combine the basic regex we learned and create examples of extracting information from texts.</p><p>New text:</p><p>“User named Mustafa Onur Inan from SOC department accessed the resource SOC.com/regex.html from the source IP 192.168.0.1 and country Turkey at: Thu Dec 10 00:13:46 2023.”</p><p>From this, I want to extract user and resource information, as well as IP details.</p><p>By combining the information we learned above, we will approach these in different ways.</p><p>For example, “User\s\named\s([\w\s]+)\sfrom” or “User\snamed\s([a-zA-Z\s]+)\sfrom” will parse “Mustafa Onur Inan” for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*MmRjEjo617cnPJ4UNOMSuw.png" /></figure><p>Since parentheses capture our regex, specifying the before and after makes our regex more precise and accurate. Therefore, by specifying before as “User\s(space)named\s,” indicating that inside it consists only of lowercase and uppercase letters with “\w” or “[a-zA-Z],” and as there is a space, adding “+” after it and completing with the upcoming word, I finalized my regex.</p><p>For the source IP, “source\sIP ([\w.]+)” or “source\sIP ([\0–9.]+)” or “source\sIP\s(\d{1,3}(?:.\d{1,3}){3})” will parse the source IP for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*TIWIJQEb0hwgAHzq8UTs5w.png" /></figure><p>After specifying our start, \w was capturing any digit, letter, or underscore. Since there are dots (.) between IPs, we used . and instructed it to capture as many as it encounters. Since there is a space when the IP ends, there’s no need to specify the end. The second regex was similar. Our third regex looks a bit more complex, but again, after specifying the start, we used \d to indicate that it will be a digit, and it could be 1 or 3 digits. Then, we stated there would be a dot (.) in between. We mentioned there would be three more of these, making a total of four 3-digit IPs, and we completed it.</p><p>Let’s conclude with a different example from an Exchange log. I want to extract the domain part from “sender-address=<a href="/service/mailto:sndr@moiexample.com.tr">sndr@moiexample.com.tr</a>”. Later, maybe on my SIEM, I can check if there is successful mail traffic from external to internal with my CTI data for potentially harmful domains.</p><p>In this scenario, starting with “@” might seem logical, but since it’s a mail log, there will be multiple “@” signs, and it will give us results other than the correct one. Using the groups we’ve been talking about from the beginning can be beneficial here.</p><p>sender-address=([^@]+)@([a-zA-Z0–9]+).com</p><p>In this example, even though it consists only of letters, we used “^@” because the preceding part may contain different characters or numbers. This means anything up to the “@” sign is Group 1, and everything after that, up to the “.com” consisting of uppercase, lowercase letters, and numbers, is Group 2. After this, we can perform the desired check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*65VaN5zMWunOpKQ-KuWeRA.png" /></figure><p>I tried to start from the basics and move towards the general, attempting to use everything in the fundamentals. I believe these examples can be derived and used to parse anything. I hope it has been helpful, thanks for reading! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=448bfae1a00d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>