伪站搭建 (以apache2为例)
1.www
下新建zibll
目录, 添加index.php文件:
<?php
$url = $_SERVER['REQUEST_URI'];
function getRandom($length) {
$characters = 'abcdefghijklmnopqrstuvwxyz1234567890';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$index = rand(0, strlen($characters) - 1);
$randomString .= $characters[$index];
}
return $randomString;
}
function generate_randstr($url) {
$key = strrev(md5($url));
$num1 = rand(70,99);
$num1r = strrev(strval($num1));
$num2 = rand(70,99);
$num2r = strrev(strval($num2));
$key = substr($key,22).substr($key,0,22);
$keystr = substr_replace($key,getRandom(3),$num1-69,0);
$randstr = getRandom(3).$num1r.getRandom(rand(5,10)).$keystr.getRandom(100-$num2).$num2r;
return $randstr;
}
header('Content-Type: application/json; charset=UTF-8');
if(strpos($url, '/api/auth') !== false){
$time = time();
$token = md5(uniqid(mt_rand(), true) . microtime());
$randstr = generate_randstr($_POST['url']);
$sign = md5($randstr.$time.$token.'ok');
$data = ['error'=>true, 'error_code'=>0, 'msg'=>'', 'time'=>$time, 'token'=>$token, 'randstr'=>$randstr, 'code'=>base64_encode('恭喜您,授权验证成功'), 'sign'=>$sign];
echo json_encode($data);
}
elseif(strpos($url, '/api/update') !== false){
$version = $_POST['version'];
$data = ['result'=>false, 'aut_error'=>false, 'msg'=>'暂无更新,您当前的版本已是最新版', 'version'=>$version];
echo serialize($data);
}
添加伪静态.htaccess文件:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
3. 添加VirtualHost
:
nano /etc/apache2/sites-enabled/000-default.conf
## 添加api.zibll.com
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName api.zibll.com
DocumentRoot /var/www/zibll
ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
nano /etc/apache2/sites-enabled/
- 添加HTTPS,SSL用自签证书:
cd /etc/apache2/ssl
# 私钥文件
openssl genrsa -out private.key 2048
## 证书请求文件 默认回车即可
openssl req -new -key private.key -out server.csr
## 自签名证书
openssl x509 -req -days 365 -in server.csr -signkey private.key -out server.crt
cat server.crt private.key > server.pem
nano /etc/apache2/sites-enabled/default-ssl.conf
## 添加api.zibll.com
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName api.zibll.com
DocumentRoot /var/www/zibll
LogLevel error
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/private.key
</VirtualHost>
BT搭建伪授权站
1.创建api.zibll.com网站,将上面index.php添加到网站目录
2.网站设置->SSL添加自签证书private.key
和server.pem
3.添加伪静态
location / {
try_files $uri $uri/ /index.php?$query_string;
}
4.修改hosts:
nano /etc/hosts
# 添加
127.0.0.1 api.zibll.com
service apache2 restart
6.登录后台,点击授权
附属文件
This content requires 登录 and is visible after refresh