andrewb icon

K@H Quick Client

andrewb | PRO | 04/04/15 03:22:00 AM UTC | 0 ⭐ | 1054 👁️ | Never ⏰ | []
PHP |

2.35 KB

|

None

|

0 👍

/

0 👎

<?php
 
function postData($url, $data) {
    $ch = curl_init($url);    
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $back = array();
    $back['url'] = $url;
    $back['file'] = curl_exec($ch);
    $back['type'] = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
    $back['size'] = curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
    curl_close($ch);
    return $back;
}
 
function pickPath($method, $activity="check_activity") {
    $url = sprintf("http://algersoft.net/kriegerathome/%s",
                   ($method=="calibrate"?"calibrate_attack.php":"attack.php"));
    if ($method == "calibrate") {
        return postData($url, "auth=calibration_authentication");
    } else {
        return postData($url, sprintf("activity=%s", $activity));
    }
}
 
function pageShow($data,$msg,$delay="30") {
    $refresh = sprintf("kats.php?method=%s", $data);
?>
<html><head><meta http-equiv="refresh" content="<?php echo($delay) ?>; url=<?php echo($refresh); ?>"></head>
<body><h3><?php echo($msg); ?></h3>
<p><a href="<?php echo($refresh); ?>"><?php echo($refresh); ?></a></p>
</body></html>
<?php
}
 
$method = isset($_REQUEST['method']) ? $_REQUEST['method'] : "none";
 
switch($method) {
    case "calibrate":
        $res = pickPath("calibrate");
        $json = json_decode($res['file']);
        if ($json->status == "accepted") {
            pageShow("attack1", "Calibrating...", "2");
        } else {
            pageShow("calibrate", "Whoops...");
        }
        break;
    case "attack1":
        $res = pickPath("attack", "check_activity");
        $json = json_decode($res['file']);
        if ($json->status == "calibrated") {
            pageShow("attack2", "Attacking...", "2");
        } else {
            pageShow("calibrate", "Starting over...", "2");
        }
        break;
    case "attack2":
        $res = pickPath("attack", "record_progress");
        $json = json_decode($res['file']);
        pageShow("calibrate", $json->status);
        break;
    default:
        pageShow("calibrate", "Starting...", "2");
}
 
?>

Comments