<?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 Eren Can Ozmen on Medium]]></title>
        <description><![CDATA[Stories by Eren Can Ozmen on Medium]]></description>
        <link>https://medium.com/@erencan.ozmen01?source=rss-c5a90639850f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cAbjgmtXkIC36VEV</url>
            <title>Stories by Eren Can Ozmen on Medium</title>
            <link>https://medium.com/@erencan.ozmen01?source=rss-c5a90639850f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:01:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@erencan.ozmen01/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[XSS with Charset Manipulation]]></title>
            <link>https://medium.com/@erencan.ozmen01/xss-with-charset-manipulation-5352ee294c4e?source=rss-c5a90639850f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5352ee294c4e</guid>
            <category><![CDATA[poc]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[charsets]]></category>
            <category><![CDATA[xs]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Eren Can Ozmen]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 23:37:59 GMT</pubDate>
            <atom:updated>2025-01-20T23:37:59.371Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, today I will simulate an interesting XSS scenario and try to explain this simulation for you. Enjoy reading.</p><p>First of all, look at this PHP code, It seems to be safe against XSS thanks to the htmlspecialchars() function for the search parameter. On the other hand, the lang parameter uses the addslashes() function to protect against characters like “ and removes ‘&lt;’, ‘&gt;’ characters. So it looks like safe.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;There is a XSS&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>    &lt;link rel=&quot;icon&quot; type=&quot;image/x-icon&quot; href=&quot;favicon.ico&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    //some html code in here<br>    &lt;/form&gt;<br><br>    &lt;?php<br>    $search = isset($_GET[&#39;search&#39;]) ? $_GET[&#39;search&#39;] : &#39;&#39;;<br>    $lang = isset($_GET[&#39;lang&#39;]) ? $_GET[&#39;lang&#39;] : &#39;tr&#39;;<br><br>    $search = htmlspecialchars($search);<br>    $lang = str_replace([&#39;&lt;&#39;, &#39;&gt;&#39;], &#39;&#39;, $lang); //remove `&lt;` ve `&gt;`<br>    $lang = addslashes($lang); // add \ for escape<br><br>    echo &quot;&lt;p&gt;You searched for: &lt;b&gt;$search&lt;/b&gt;&lt;/p&gt;&quot;;<br>    echo &quot;&lt;script&gt;<br>        var lang = \&quot;$lang\&quot;;<br>        console.log(&#39;Language set to: &#39; + lang);<br>    &lt;/script&gt;&quot;;<br>    ?&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>However, it would be useful to observe whether the code really works as we think. And unsurprisingly xss was not triggered.<br><em>http://localhost/PHP/XSS/gallipoli/test/test.php?search=&#39;&quot;&gt;&lt;img+src=x+onerror=alert()&gt;&amp;lang=en&quot;;&lt;/script&gt;&lt;script&gt;alert()&lt;/script&gt;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yNJa9LR4xBmD5n3daFrmmw.png" /></figure><p>But there is a XSS so lets try with magical words.<br><a href="http://localhost/PHP/XSS/gallipoli/test/test.php?search=%1B(Jabra_kadabra&amp;lang=en%22;alert(document.title)//">http://localhost/PHP/XSS/gallipoli/test/test.php?search=%1B(Jabra_kadabra&amp;lang=en%22;alert(document.title)//</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-sBOvfRSe8MD67xUY8URw.png" /></figure><p>But how its possible ? There’s no such thing as magic, right? That’s exactly what my article today will be about. So let’s start step by step</p><h4>What is Charset</h4><p>Can you see a vulnerability in the response below? Take a good look. If you didn’t notice an anomaly, what should have caught your attention was the lack of a Content-Type header like this ‘Content-Type: text/html; charset=utf-8’. Well, how could this cause a vulnerability?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*o_TsH2Vtf9bXFEE02omQbg.png" /></figure><p>Charset is a system that determines how computers and browsers encode and read text. For example, a charset like UTF-8 can encode thousands of characters used in languages ​​around the world.</p><p>If we look at how it works, as we know, computers do not communicate with each other using alphabetical characters like we humans do. Instead, they use binary expressions, but how these binary expressions are interpreted and converted into a character is up to the charset to be used. There are many charsets in the world, and the interpreted binary expression is reflected differently to the user according to these charsets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*4gowv7sm3cnOj9Sdim53ng.png" /></figure><h4>How Do Computers Know Which Character Set to Use?</h4><p>The BOM (Byte Order Mark) is like a little signature at the very beginning of a text file or data stream that tells the computer, “Hey, this is the encoding and byte order you need to use to read me!” In the world of Unicode encodings like UTF-8, UTF-16, or UTF-32, the BOM acts as a guide to ensure that characters are interpreted correctly. For UTF-8, the BOM appears as the hexadecimal sequence EF BB BF.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*PU7dPjhSmNN2begHKmonMg.png" /></figure><p>So how does it work for a web server? As a developer, how do you tell your server what charset it should use to return responses? The answer is very simple, “<strong><em>&lt;meta charset=”UTF-8&quot;&gt;”</em></strong>. You can write this in your html file or you can make various settings so that your server always returns utf-8 responses, for example, you can make a setting like default_charset = “utf-8” in your php.ini file.</p><h4>What If You Don’t Tell it What Charset it Should be Interpreted with</h4><p>Let me explain what will happen now. Your server will try to interpret the request it receives and decide which character set is appropriate, interpret it according to that character set and respond to you according to the character set it interpreted from the server. This is like the person in front of you telling you something in a random language, for example, you look for the language’s unique features such as familiar words and pronunciation to understand which language they are speaking. The server will behave similarly.</p><p>For example, when I sent a query as a test on my server where the content-type was not specified, the content-type was windows-1252.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiz-S3_U1AZMGD3Vmb1tVA.png" /></figure><h4>The Birth of the XSS Vulnerability</h4><p>Look at the table below and you will see the JIS X 0201 table. They are very similar to the ASCII table. The only difference is that the \ character has been replaced with the ¥ character and the ~ character has been replaced with the ‘ ‾ ’character.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*QWcazMutePZOJTMcrGlhWQ.png" /></figure><p>I hope most of you have had the “aha” moment by now. The XSS wasn’t actually triggered by “magic words” but by manipulating the charset! By forcing the server to use the JIS X 0201 charset, I can make it replace the \ character with the ¥ character. In this case, I can terminate the string in JavaScript using the &quot; character and freely inject my own scripts!</p><p>Now let’s remember the value I sent with the search parameter: search=%1B(Jabra_kadabra where %1B represents the escape character and B(J tells the server to interpret it as JIS X 0201. As a result, in the response returned by the server, the addslashes() function places the ¥ character instead of the \ and XSS is triggered. So there was no magic :(</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FwrnNStuXiGTC2zWcZzorg.png" /></figure><h3>Resources</h3><ul><li><a href="https://owasp.org/www-project-web-security-testing-guide/latest/6-Appendix/D-Encoded_Injection">WSTG - Latest</a></li><li><a href="https://www.sonarsource.com/blog/encoding-differentials-why-charset-matters/">Encoding Differentials: Why Charset Matters</a></li><li><a href="https://en.wikipedia.org/wiki/JIS_X_0201#Codepage_layout">JIS X 0201 - Wikipedia</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5352ee294c4e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XSS Zafiyeti ve Türleri]]></title>
            <link>https://medium.com/@erencan.ozmen01/xss-zafiyeti-ve-t%C3%BCrleri-862b931bce91?source=rss-c5a90639850f------2</link>
            <guid isPermaLink="false">https://medium.com/p/862b931bce91</guid>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Eren Can Ozmen]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 19:46:26 GMT</pubDate>
            <atom:updated>2024-07-01T19:46:26.549Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhabalar, ben Eren Can Özmen. Gallipoli’nin ilk bize verilmiş görevi için ve tabii sizlere bir şeyler katabilmek adına bu yazıyı yazıyorum yazdığım zafiyetli kodları şuradan kontrol edebilirsiniz http://159.89.22.234 . İyi okumalar dilerim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qqnuadGN8JP479gNoybM0w.jpeg" /></figure><p><strong>İlk Adım VPS Deploy Etme</strong></p><p>Öncelikle, VPS’i deploy edeceğiniz platformu seçmek gerekiyor. Ben, tamamen bir arkadaşımın tavsiyesi üzerine Digital Ocean’dan VPS deploy ettim. 2 ay kadar kullanabileceğiniz 200 dolar ücretsiz bakiye veriyor. Kurulum işleminde ise sağ üstten “Create” tuşuna basıp basitçe VPS deploy edebilirsiniz. Burada dağıtım olarak LAMP seçmeniz sizin için kolaylık sağlayacaktır. LAMP, size Apache Server, MySQL gibi işinize yarayacak yazılımları paket halinde sunan bir framework’tür.</p><p><strong>Nedir Bu XSS</strong></p><p>Kısaca cevap verecek olursam, açılımı Cross-Site Scripting (XSS) olup, anlamı siteler arası komut dosyası çalıştırma denebilir. Zafiyet, kullanıcı girdilerinin doğrulanmaması veya filtrelenmemesi ve diğer kullanıcıların bu girdiler sonucu mağdur olmasıdır. Genelde JavaScript kodlarından kaynaklanan bu durum, çerezlerin ve kredi kartı bilgilerinin çalınması, oturum bilgilerinin ele geçirilmesi gibi ciddi sonuçlar doğurabilmektedir. Genel anlamda üç kategoriye ayrılabilirler:</p><ul><li><strong>Reflected XSS</strong></li><li><strong>Stored XSS</strong></li><li><strong>DOM-based XSS</strong></li></ul><p><strong>Reflected XSS</strong></p><p>Zararlı kodların bir veritabanı vb. bir yapıda saklanmadığı, doğrudan tetiklendiği XSS türüdür. Saldırıda, saldırgan zararlı kodu web sitesine gönderir ve bu kod hemen kullanıcıya geri yansıtılır. Kabaca bir örnekle, normal bir insanın canı lahmacun çeker ve arama yerine girerek bu aramayı yapar. Ancak kötü niyetli bir kişi arama yerine zararlı kod yazar ve ardından ulaştığı sonucu size gönderir. Bi tıkla istersen :) <a href="https://tls.tc/R81dS">https://tls.tc/R81dS</a></p><p><strong>Reflected XSS GET isteği ile:</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Reflected XSS Örneği&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Arama Sayfası&lt;/h1&gt;<br>    &lt;form method=&quot;GET&quot; action=&quot;&quot;&gt;<br>        &lt;label for=&quot;query&quot;&gt;Arama:&lt;/label&gt;<br>        &lt;input type=&quot;text&quot; id=&quot;query&quot; name=&quot;query&quot;&gt;<br>        &lt;input type=&quot;submit&quot; value=&quot;Ara&quot;&gt;<br>    &lt;/form&gt;<br><br>    &lt;?php<br>    if (isset($_GET[&#39;query&#39;])) {<br>        $query = $_GET[&#39;query&#39;];<br>        echo &quot;&lt;p&gt;Arama Sonucu: &quot; . $query . &quot;&lt;/p&gt;&quot;;<br>    }<br>    ?&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Görüleceği üzere herhangi bir filtreleme veya doğrulama yok. Bu ne demek? Arama yerine yazacağınız zararlı kod çalışacak. Basitçe, input olarak &lt;script&gt;alert(1)&lt;/script&gt; yazabilirsiniz ya da yaratıcı biriyseniz baya eğlenebilirsiniz. Bu örnekte GET isteği ile bunu gerçekleştirdim. Farklı durumlara bakacak olursak...</p><p><strong>Reflected XSS POST isteği ile:</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Reflected XSS Örneği (POST)&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Arama Sayfası&lt;/h1&gt;<br>    &lt;form method=&quot;POST&quot; action=&quot;&quot;&gt;<br>        &lt;label for=&quot;query&quot;&gt;Arama:&lt;/label&gt;<br>        &lt;input type=&quot;text&quot; id=&quot;query&quot; name=&quot;query&quot;&gt;<br>        &lt;input type=&quot;submit&quot; value=&quot;Ara&quot;&gt;<br>    &lt;/form&gt;<br><br>    &lt;?php<br>    if ($_SERVER[&#39;REQUEST_METHOD&#39;] == &#39;POST&#39; &amp;&amp; isset($_POST[&#39;query&#39;])) {<br>        $query = $_POST[&#39;query&#39;];<br>        echo &quot;&lt;p&gt;Arama Sonucu: &quot; . $query . &quot;&lt;/p&gt;&quot;;<br>    }<br>    ?&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>GET isteğinden farklı olarak Farklı olarak POST isteği ile girdiler gönderilir ve işlenir.</p><p><strong>Reflected XSS Header ile:</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Reflected XSS Örneği (Header)&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Hoş Geldiniz&lt;/h1&gt;<br><br>    &lt;?php<br>    if (isset($_SERVER[&#39;HTTP_USER_AGENT&#39;])) {<br>        $userAgent = $_SERVER[&#39;HTTP_USER_AGENT&#39;];<br>        echo &quot;&lt;p&gt;Tarayıcı Bilgisi: &quot; . $userAgent . &quot;&lt;/p&gt;&quot;;<br>    }<br>    ?&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Burada site bizden header ile gönderdiğimiz user-agent bilgisini çeker ve bunu siteye yazdırır giden isteğe Burp Suite ile araya girerek bakarsak</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*kEWfm3ZGDNWTeK9e-T950A.png" /></figure><p>ve burada User-Agnet bilgisini değiştirirsek XSS tetiklenmiş olacak yazımın başında verdiğim sitede deneyebilirsiniz.</p><p><strong>Stored XSS</strong></p><p>Reflected XSS’den farklı olarak, bu sefer yazılan zararlı kodlar bir veritabanında tutulur ve sitede kalıcıdır. Bu tür XSS, en korkunçlarından biridir. Şöyle düşünün, bir kişi bu zafiyeti tespit etti ve söz konusu sayfaya zararlı kodunu enjekte etti. Bundan habersiz ziyaretçilerin hepsi, meşru olan bu siteyi ziyaret ettiklerinde zarar görecekler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*M_VulKlmt03j5f8llwltVQ.jpeg" /></figure><p>Bu kod, kalp emojisini gören herkesin bu tweeti retweet etmesine yol açan bir stored XSS örneğidir. Bunu retweetleyen 40.000 kişi ise sadece bu tweeti gördükleri için zincirleme olarak retweet (ettiler belki daha fazladır). Neyse ki, Andy sadece eğlenmek istemiş.</p><p>GET Stored XSS</p><pre>&lt;?php<br>$db = new Database();<br><br>if ($_SERVER[&#39;REQUEST_METHOD&#39;] === &#39;GET&#39; &amp;&amp; isset($_GET[&#39;username&#39;]) &amp;&amp; isset($_GET[&#39;message&#39;])) {<br>    $username = $_GET[&#39;username&#39;];<br>    $message = $_GET[&#39;message&#39;];<br>    $db-&gt;saveMessage($username, $message);<br>}<br>?&gt;<br><br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Stored XSS Örneği&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body class=&quot;container-top&quot;&gt;<br>    &lt;h1&gt;Dızmana&#39;nın Stored XSS&#39;li Yeri&lt;/h1&gt;<br>    &lt;form method=&quot;GET&quot; action=&quot;&quot;&gt;<br>        &lt;div class=&quot;form&quot;&gt;<br>            &lt;label for=&quot;username&quot; class=&quot;form-label&quot;&gt;Kullanıcı Adı&lt;/label&gt;<br>            &lt;input type=&quot;text&quot; id=&quot;username&quot; name=&quot;username&quot; class=&quot;form-control&quot; required&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;form&quot;&gt;<br>            &lt;label for=&quot;message&quot; class=&quot;form-label&quot;&gt;Mesaj&lt;/label&gt;<br>            &lt;textarea id=&quot;message&quot; name=&quot;message&quot; class=&quot;form-control&quot; rows=&quot;3&quot; required&gt;&lt;/textarea&gt;<br>        &lt;/div&gt;<br>        &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Gönder&lt;/button&gt;<br>    &lt;/form&gt;<br><br>    &lt;h2 class=&quot;messages&quot;&gt;Mesajlar&lt;/h2&gt;<br>    &lt;ul class=&quot;list-group&quot;&gt;<br>        &lt;?php<br>        $messages = $db-&gt;getMessages();<br>        foreach ($messages as $message) {<br>            echo &#39;&lt;li class=&quot;list-group-item&quot;&gt;&lt;strong&gt;&#39; . $message-&gt;username . &#39;:&lt;/strong&gt; &#39; . $message-&gt;message . &#39;&lt;/li&gt;&#39;;<br>        }<br>        ?&gt;<br>    &lt;/ul&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Bu örnek GET isteği ile kullanıcının adını ve mesajını alır ve siteye işler ve evet gene sıkıntı bir filtreleme işleminin olmaması. Bu arada reflected’dan farklı olarak burada kullanıcıdan alınan girdiler veri tabanına işleniyor.</p><p>POST Stored XSS</p><pre>&lt;?php<br>$db = new Database();<br><br>if ($_SERVER[&#39;REQUEST_METHOD&#39;] === &#39;POST&#39;) {<br>    $username = $_POST[&#39;username&#39;];<br>    $message = $_POST[&#39;message&#39;];<br>    $db-&gt;saveMessage($username, $message);<br>}<br>?&gt;<br><br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Stored XSS Örneği&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>    <br>&lt;/head&gt;<br>&lt;body class=&quot;container-top&quot;&gt;<br>    &lt;h1&gt;Dızmana&#39;nın Stored XSS&#39;li Yeri&lt;/h1&gt;<br>    &lt;form method=&quot;POST&quot; action=&quot;&quot;&gt;<br>        &lt;div class=&quot;form&quot;&gt;<br>            &lt;label for=&quot;username&quot; class=&quot;form-label&quot;&gt;Kullanıcı Adı&lt;/label&gt;<br>            &lt;input type=&quot;text&quot; id=&quot;username&quot; name=&quot;username&quot; class=&quot;form-control&quot; required&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;form&quot;&gt;<br>            &lt;label for=&quot;message&quot; class=&quot;form-label&quot;&gt;Mesaj&lt;/label&gt;<br>            &lt;textarea id=&quot;message&quot; name=&quot;message&quot; class=&quot;form-control&quot; rows=&quot;3&quot; required&gt;&lt;/textarea&gt;<br>        &lt;/div&gt;<br>        &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Gönder&lt;/button&gt;<br>    &lt;/form&gt;<br><br><br>    &lt;h2 class=&quot;messages&quot;&gt;Mesajlar&lt;/h2&gt;<br>    &lt;ul class=&quot;list-group&quot;&gt;<br>        &lt;?php<br>        $messages = $db-&gt;getMessages();<br>        foreach ($messages as $message) {<br>            echo &#39;&lt;li class=&quot;list-group-item&quot;&gt;&lt;strong&gt;&#39; . $message-&gt;username . &#39;:&lt;/strong&gt; &#39; . $message-&gt;message . &#39;&lt;/li&gt;&#39;;<br>        }<br>        ?&gt;<br>    &lt;/ul&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Önceki örnekten farklı olarak GET isteğinin yerini POST almış. Gene isim bilgisi ve mesaj bilgisi alınıyor veri tabanına kayıt ediliyor ve siteye işlenmiş oluyor.</p><pre>$db = new Database();<br><br>if ($_SERVER[&#39;REQUEST_METHOD&#39;] === &#39;GET&#39; &amp;&amp; isset($_GET[&#39;username&#39;]) &amp;&amp; isset($_GET[&#39;message&#39;])) {<br>    $username = $_GET[&#39;username&#39;];<br>    $message = $_GET[&#39;message&#39;];<br>    $db-&gt;saveMessage($username, $message);<br>    // Kullanıcı girişini HTTP başlığına ekle<br>    header(&quot;X-User-Input-Username: &quot; . $username);<br>    header(&quot;X-User-Input-Message: &quot; . $message);<br>}<br>?&gt;<br><br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Stored XSS Örneği&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body class=&quot;container-top&quot;&gt;<br>    &lt;h1&gt;Dızmana&#39;nın Stored XSS&#39;li Yeri&lt;/h1&gt;<br>    &lt;form method=&quot;GET&quot; action=&quot;&quot;&gt;<br>        &lt;div class=&quot;form&quot;&gt;<br>            &lt;label for=&quot;username&quot; class=&quot;form-label&quot;&gt;Kullanıcı Adı&lt;/label&gt;<br>            &lt;input type=&quot;text&quot; id=&quot;username&quot; name=&quot;username&quot; class=&quot;form-control&quot; required&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;form&quot;&gt;<br>            &lt;label for=&quot;message&quot; class=&quot;form-label&quot;&gt;Mesaj&lt;/label&gt;<br>            &lt;textarea id=&quot;message&quot; name=&quot;message&quot; class=&quot;form-control&quot; rows=&quot;3&quot; required&gt;&lt;/textarea&gt;<br>        &lt;/div&gt;<br>        &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Gönder&lt;/button&gt;<br>    &lt;/form&gt;<br><br>    &lt;h2 class=&quot;messages&quot;&gt;Mesajlar&lt;/h2&gt;<br>    &lt;ul class=&quot;list-group&quot;&gt;<br>        &lt;?php<br>        $messages = $db-&gt;getMessages();<br>        foreach ($messages as $message) {<br>            echo &#39;&lt;li class=&quot;list-group-item&quot;&gt;&lt;strong&gt;&#39; . htmlspecialchars($message-&gt;username, ENT_QUOTES, &#39;UTF-8&#39;) . &#39;:&lt;/strong&gt; &#39; . htmlspecialchars($message-&gt;message, ENT_QUOTES, &#39;UTF-8&#39;) . &#39;&lt;/li&gt;&#39;;<br>        }<br>        ?&gt;<br>    &lt;/ul&gt;</pre><p>Burada da gene header üzerinden bir injection mümkündür. Burp Suite ile araya girerek gönderdiğimiz request’e bakacak olursak, giden response’un en altında username ve message bilgisini değiştirip zararlı kodumuzu yazdığımız takdirde, başarılı bir şekilde injection işlemi tamamlanmış olur.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-dTGoHi-E_cZNB03Veiew.png" /></figure><p><strong>DOM XSS</strong></p><p>DOM Tabanlı XSS (Cross-Site Scripting), geleneksel XSS saldırılarından farklı olarak, sunucu tarafında değil, istemci tarafında gerçekleşen bir güvenlik açığıdır. Bu tür saldırılar, doğrudan kullanıcı tarayıcısında (istemci tarafında) çalışır ve zararlı komut dosyalarının web sayfasının Document Object Model’ine (DOM) enjekte edilmesiyle gerçekleşir.</p><p><strong>Reflected ve DOM XSS Farkı</strong></p><p>Reflected XSS, kullanıcıdan gelen verilerin sunucuya gönderilip anında yansıtılarak kullanıcıya geri dönmesiyle oluşur. Kullanıcı form doldurur veya URL’deki parametreleri gönderir, sunucu bu verileri kontrol etmeden geri gönderir ve tarayıcı bu yanıtı alarak zararlı kodu çalıştırır. DOM XSS ise tamamen istemci tarafında gerçekleşir, sunucu bu sürece dahil olmaz. Kullanıcı, tarayıcıda URL parametreleri veya diğer giriş yöntemleriyle veri girer. JavaScript bu verileri alır ve doğrudan DOM üzerinde işlem yapar. Eğer JavaScript bu verileri güvenli işleyemezse, zararlı kod kullanıcı tarayıcısında çalıştırılır.</p><p><strong>GET DOM XSS</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;DOM XSS Örneği&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;DOM XSS Örneği&lt;/h1&gt;<br>    &lt;form method=&quot;get&quot; action=&quot;&quot;&gt;<br>        &lt;input type=&quot;text&quot; name=&quot;userInput&quot; placeholder=&quot;Adınızı girin&quot;&gt;<br>        &lt;button type=&quot;submit&quot;&gt;Gönder&lt;/button&gt;<br>    &lt;/form&gt;<br>    &lt;div id=&quot;display&quot;&gt;&lt;/div&gt;<br><br>    &lt;script&gt;<br>        // URL parametresinden kullanıcı girişini almak<br>        function getParameterByName(name) {<br>            name = name.replace(/[\[\]]/g, &#39;\\$&amp;&#39;);<br>            var url = window.location.href;<br>            var regex = new RegExp(&#39;[?&amp;]&#39; + name + &#39;(=([^&amp;#]*)|&amp;|#|$)&#39;);<br>            var results = regex.exec(url);<br>            if (!results) return null;<br>            if (!results[2]) return &#39;&#39;;<br>            return decodeURIComponent(results[2].replace(/\+/g, &#39; &#39;));<br>        }<br><br>        var userInput = getParameterByName(&#39;userInput&#39;);<br><br>        if (userInput) {<br>            // Güvenli olmayan kod: Kullanıcı girişi doğrudan innerHTML ile ekleniyor<br>            document.getElementById(&#39;display&#39;).innerHTML = &quot;Merhaba, &quot; + userInput;<br>        }<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>POST DOM XSS</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;DOM XSS Örneği&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;DOM XSS Örneği&lt;/h1&gt;<br>    &lt;form method=&quot;get&quot; action=&quot;&quot;&gt;<br>        &lt;input type=&quot;text&quot; name=&quot;userInput&quot; placeholder=&quot;Adınızı girin&quot;&gt;<br>        &lt;button type=&quot;submit&quot;&gt;Gönder&lt;/button&gt;<br>    &lt;/form&gt;<br>    &lt;div id=&quot;display&quot;&gt;&lt;/div&gt;<br><br>    &lt;script&gt;<br>        // PHP ile kullanıcı girişini almak<br>        &lt;?php<br>        if (isset($_GET[&#39;userInput&#39;])) {<br>            $userInput = $_GET[&#39;userInput&#39;];<br>            echo &quot;var userInput = &quot; . json_encode($userInput) . &quot;;&quot;;<br>        } else {<br>            echo &quot;var userInput = &#39;&#39;;&quot;;<br>        }<br>        ?&gt;<br><br>        if (userInput) {<br>            document.getElementById(&#39;display&#39;).innerHTML = &quot;Merhaba, &quot; + userInput;<br>        }<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>HEADER XSS</strong></p><pre>&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;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;DOM XSS HEADER&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br><br>    &lt;h1 id=&quot;user-agent-header&quot;&gt;&lt;/h1&gt;<br>    &lt;script&gt;<br>        var userAgent = &#39;&lt;?php echo $_SERVER[&#39;HTTP_USER_AGENT&#39;]; ?&gt;&#39;;<br>        document.getElementById(&#39;user-agent-header&#39;).innerHTML = &#39;User Agent: &#39; + userAgent;<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Buraya kadar okuduysanız teşekkür ederim umarım faydalı olabilmişimdir iyi çalışmalar dilerim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*3jdPQWFJK5AogytgjVLtBA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=862b931bce91" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>