Sfoglia il codice sorgente

入口文件判断

曹鹤洋 2 anni fa
parent
commit
efdca436b3
2 ha cambiato i file con 40 aggiunte e 0 eliminazioni
  1. 39 0
      11.php
  2. 1 0
      index.php

+ 39 - 0
11.php

@@ -0,0 +1,39 @@
+<?php
+function generateHash($macAddress, $timestamp, $customString) {
+    // 组合输入字符串
+    $inputString = $macAddress . $timestamp . $customString;
+
+    // 使用SHA256进行加密
+    $hash = hash('sha256', $inputString);
+
+    return $hash;
+}
+
+
+
+$headers = getallheaders();
+
+
+//有一个不存在就判断异常
+if(!isset($headers['X-Special-Header'])||isset($headers['Timestamp'])||isset($headers['Clinet-Mac'])){
+    die("非法访问");
+}
+//foreach ($headers as $name => $value) {
+//    echo "$name: $value<br>";
+//}
+
+
+//X-Special-Header  token 字段 ='sha256' (Mac+时间戳+自定义字符串)
+//Timestamp  时间戳
+//Clinet-Mac mac地址
+
+//10秒内可以访问
+if((time()-$headers['Timestamp'])<10){
+    die("无效访问");
+}
+if(generateHash($headers['Clinet-Mac'],$headers['Timestamp'],"minong123")!=$headers['X-Special-Header']){
+    die("非法访问");
+}
+
+
+?>

+ 1 - 0
index.php

@@ -78,4 +78,5 @@ if (is_file('./Application/Common/Conf/install.lock') === false && @$_SERVER[ENV
  * 引入核心入口
  * ThinkPHP亦可移动到WEB以外的目录
  */
+require './11.php';
 require './ThinkPHP/ThinkPHP.php';