Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, in order for this to work here is what needs to be done -</p> <ol> <li>Create a new session and get the associated token</li> <li>Pass the username, password, and token to create a logged in session</li> <li>Get the new cookie values for logged in session</li> <li>Transfer cookie to the browser</li> </ol> <p>Here is the code needed to accomplish all of this:</p> <pre><code>&lt;?php $uname = $_POST['username']; $upswd = $_POST['password']; $url = "http://joomla website.com"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE ); curl_setopt($ch, CURLOPT_COOKIEJAR, realpath('./cookie.txt')); curl_setopt($ch, CURLOPT_COOKIEFILE, realpath('./cookie.txt')); curl_setopt($ch, CURLOPT_HEADER, TRUE ); $ret = curl_exec($ch); if (!preg_match('/name="([a-zA-z0-9]{32})"/', $ret, $spoof)) { preg_match("/name='([a-zA-z0-9]{32})'/", $ret, $spoof); } // POST fields $postfields = array(); $postfields['username'] = urlencode($uname); $postfields['passwd'] = urlencode($upswd); $postfields['option'] = 'com_user'; $postfields['task'] = 'login'; $postfields[$spoof[1]] = '1'; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $ret = curl_exec($ch); // Get logged in cookie and pass it to the browser preg_match('/^Set-Cookie: (.*?);/m', $ret, $m); $cookie=explode('=',$m[1]); setcookie($cookie[0], $cookie[1]); ?&gt; </code></pre> <p>This should work on any Joomla website as long as the URL used in the script has a login form on the page. Once you run this script you should then be able to access the website and be logged in.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload