Skip to content

Refactor access control in config.php instead of range ip and add webhook secret token generation in wizwiz.sh #1419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,13 @@ function alert($txt, $type = false, $callid = null){
]);
}

$range = [
'149.154.160.0/22',
'149.154.164.0/22',
'91.108.4.0/22',
'91.108.56.0/22',
'91.108.8.0/22',
'95.161.64.0/20',
];
function check($return = false){
global $range;
foreach ($range as $rg) {
if (ip_in_range($_SERVER['REMOTE_ADDR'], $rg)) {
return true;
}
}
if ($return == true) {
return false;
global $botSecret;

$secretToken = $_SERVER['HTTP_X_TELEGRAM_BOT_API_SECRET_TOKEN'] ?? '';

if ($secretToken == $botSecret) {
return true;
}

die('You do not have access');
Expand Down
5 changes: 4 additions & 1 deletion wizwiz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,14 @@ wait
fi

sleep 2

SECRET_TOKEN=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 128)

# print file
echo -e "<?php" >> /var/www/html/wizwizxui-timebot/baseInfo.php
echo -e "error_reporting(0);" >> /var/www/html/wizwizxui-timebot/baseInfo.php
echo -e "${ASAS}botToken = '${YOUR_BOT_TOKEN}';" >> /var/www/html/wizwizxui-timebot/baseInfo.php
echo -e "${ASAS}botSecret = '${SECRET_TOKEN}';" >> /var/www/html/wizwizxui-timebot/baseInfo.php
echo -e "${ASAS}dbUserName = '${dbuser}';" >> /var/www/html/wizwizxui-timebot/baseInfo.php
echo -e "${ASAS}dbPassword = '${dbpass}';" >> /var/www/html/wizwizxui-timebot/baseInfo.php
echo -e "${ASAS}dbName = '${dbname}';" >> /var/www/html/wizwizxui-timebot/baseInfo.php
Expand All @@ -316,7 +319,7 @@ wait

sleep 1

curl -F "url=https://${YOUR_DOMAIN}/wizwizxui-timebot/bot.php" "https://api.telegram.org/bot${YOUR_BOT_TOKEN}/setWebhook"
curl -F "url=https://${YOUR_DOMAIN}/wizwizxui-timebot/bot.php" -F "secret_token=${SECRET_TOKEN}" "https://api.telegram.org/bot${YOUR_BOT_TOKEN}/setWebhook"
MESSAGE="✅ The wizwiz bot has been successfully installed! @wizwizch"
curl -s -X POST "https://api.telegram.org/bot${YOUR_BOT_TOKEN}/sendMessage" -d chat_id="${YOUR_CHAT_ID}" -d text="$MESSAGE"

Expand Down