This commit is contained in:
2024-02-06 17:49:08 +08:00
parent a3a8476bc4
commit 9130d8c2b0
6 changed files with 1557 additions and 79 deletions
+6 -47
View File
@@ -1,48 +1,7 @@
<?php
$data='a7df00100001000000000001013103646e730457434c4d0264650000010001000029057800008000000b00080007000118007541b3';
$id=substr($data,0,4);
$flag=substr($data,4,4);
$questions=substr($data,8,4);
$answerRRs=substr($data,12,4);
$authorityRRs=substr($data,16,4);
$additionalRRs=substr($data,20,4);
$startbyte=24;
$dlen=substr($data,$startbyte,2);
$startbyte=26;
$i=1;
while($dlen!='00'){
$domain[$i]=hex2bin(substr($data,$startbyte,hexdec($dlen)*2));
$startbyte=$startbyte+(hexdec($dlen)*2);
$dlen=substr($data,$startbyte,2);
$startbyte=$startbyte+2;
$i++;
}
$name=join(".",$domain);
$type=substr($data,$startbyte,4);
switch($type){
case '0001':
$type='A';
break;
case '0002':
$type='NS';
break;
case '000c':
$type='PTR';
break;
case '0006':
$type='SOA';
break;
case '001c':
$type='AAAA';
break;
case '0005':
$type='CNAME';
break;
case '0010':
$type='TEXT';
break;
case '000f':
$type='MX';
break;
}
$query=substr($data,24,$startbyte-20);
use Workerman\Worker;
use Workerman\Protocols\Dns;
require_once __DIR__ . '/php-ipv6.php'; #IPv6支持
require_once __DIR__ . '/vendor/autoload.php';
echo long2ip(hexdec(substr('7541b3'.'00000000',0,8)));