<commit_before><?php
/*
 * This page is used to test the cookiejar.
 *
 * You should login and then pass the cookiejar to Aarachni in order
 * to find the session protected vulnerabilities.
 *
 * You should also exclude the logout url to keep Arachni logged in.
 *
 */
 
error_reporting( E_ALL );

session_start();

if( $_GET['logout'] ) {
    session_destroy();

    header( 'Location: ' .  $_SERVER['PHP_SELF'] );
}

// check that we have valid credentials and if so login the user in
if( $_POST['username'] == 'user' &&
    $_POST['password'] == '<PASSWORD>' )
{
    $_SESSION['logged_in'] = true;
    $_SESSION['__csrf'] = md5( rand(  ) );

    header( 'Location: ' .  $_SERVER['PHP_SELF'] );
}

// if the user is not logged in show him the login form
if( !$_SESSION['logged_in'] ) {
  echo <<<EOHTML
    <form method="post" action="{$_SERVER['PHP_SELF']}">

    <p>
      <label>Username:</label>
      <input type="text" name="username" value=""> (user)
    </p>
    <p>
      <label>Password:</label>
      <input type="text" name="password" value=""> (<PASSWORD>)
    </p>
    <p>
      <input type="submit" value="Login">
    </p>
    </form>

EOHTML;
exit;

}

echo <<<EOHTML
    <p>
      <a href="?logout=true">Logout</a>
    </p>

    <form method="get" action="{$_SERVER['PHP_SELF']}" name="csrf_form">
    <p>
      <label>Vulnerable form</label>
      <input type="text" name="vuln" value="">
      <input type="submit">
    </p>
    </form>

EOHTML;


if( $_REQUEST['vuln'] ) {
    echo "<pre>";
    
    if( $_SESSION['__csrf'] != $_REQUEST['__csrf'] ) {
        echo 'Invalid CSRF token...';
        exit;
    }

    echo 'Ok...';
    
    echo "</pre>";
}

?><commit_msg>removed<commit_after><?php
/*
 * This page is used to test the cookiejar.
 *
 * You should login and then pass the cookiejar to Aarachni in order
 * to find the session protected vulnerabilities.
 *
 * You should also exclude the logout url to keep Arachni logged in.
 *
 */

session_start();

if( $_GET['logout'] ) {
    session_destroy();

    header( 'Location: ' .  $_SERVER['PHP_SELF'] );
}

// check that we have valid credentials and if so login the user in
if( $_POST['username'] == 'user' &&
    $_POST['password'] == '<PASSWORD>' )
{
    $_SESSION['logged_in'] = true;
    $_SESSION['__csrf'] = md5( rand(  ) );

    header( 'Location: ' .  $_SERVER['PHP_SELF'] );
}

// if the user is not logged in show him the login form
if( !$_SESSION['logged_in'] ) {
  echo <<<EOHTML
    <form method="post" action="{$_SERVER['PHP_SELF']}">

    <p>
      <label>Username:</label>
      <input type="text" name="username" value=""> (user)
    </p>
    <p>
      <label>Password:</label>
      <input type="text" name="password" value=""> (pass)
    </p>
    <p>
      <input type="submit" value="Login">
    </p>
    </form>

EOHTML;
exit;

}

echo <<<EOHTML
    <p>
      <a href="?logout=true">Logout</a>
    </p>

    <form method="get" action="{$_SERVER['PHP_SELF']}" name="csrf_form">
    <p>
      <label>Vulnerable form</label>
      <input type="text" name="vuln" value="">
      <input type="submit">
    </p>
    </form>

EOHTML;


if( $_REQUEST['vuln'] ) {
    echo "<pre>";

    if( $_SESSION['__csrf'] != $_REQUEST['__csrf'] ) {
        echo 'Invalid CSRF token...';
        exit;
    }

    echo 'Ok...';

    echo "</pre>";
}

?>
{'fraction_non_alphanumeric': 0.1916616676664667, 'fraction_numerical': 0.0005998800239952009, 'mean_word_length': 2.877906976744186, 'pattern_counts': {'":': 0, '<': 78, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4079855', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1178, 'n_words': 308}