yarx/yarx.sh
2026-06-02 11:14:39 +03:00

298 lines
No EOL
8.4 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
read -p "Вы хотите установить VLESS (Y/N)?: " VLESSYN
if [ $VLESSYN = "Y" ] || [ $VLESSYN = "y" ]; then
#Качаем и ставим пакет
wget https://github.com/XTLS/Xray-core/releases/download/v1.8.4/Xray-linux-64.zip
sudo apt install unzip -y
sudo mkdir /opt/xray
sudo unzip ./Xray-linux-64.zip -d /opt/xray
sudo chmod +x /opt/xray/xray
#Накатываем конфиг для XRAY
read -p "Вы хотите, чтобы через VPN был доступ до сайтов на территории РФ? Есть вариант спалиться (Y/N):" GEOIP
if [ $GEOIP = "Y"] || [ $GEOIP = "y" ]; then
ROUTES=$(cat << EOF
"rules": [],
"domainStrategy": "AsIs"
EOF
)
else
echo "Ну нет так нет"
ROUTES=$(cat << EOF
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "block"
},
{
"type": "field",
"ip": ["geoip:ru"],
"outboundTag": "block"
},
{
"type": "field",
"domain": [
"geosite:category-ads-all"
],
"outboundTag": "block"
}
]
EOF
)
#Накатываем конфиг для сервиса
sudo cat << EOF > /usr/lib/systemd/system/xray.service
[Unit]
Description=Xray Service
Documentation=https://github.com/xtls
After=network.target nss-lookup.target
[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/opt/xray/xray run -config /opt/xray/config.json
Restart=on-failure
RestartPreventExitStatus=23
LimitNPROC=10000
LimitNOFILE=1000000
LogLevelMax=4
[Install]
WantedBy=multi-user.target
EOF
#Определяем переменные и накатываем конфиг для пользователя
sites=("vk" "yandex" "mail" "mts" "gosuslugi")
random_index=$((RANDOM % ${#sites[@]}))
RANDOM_SITE=${sites[$random_index]}
UUID=$(/opt/xray/xray uuid)
KEYS=$(/opt/xray/xray x25519)
PRIVATE=$(echo $KEYS | awk '{print $3}')
PUBLIC=$(echo $KEYS | awk '{print $6}')
SHORT=$(openssl rand -hex 8)
MAIL=$(hostname)
IP=$(ip r get 8.8.8.8 | awk '{print $7}')
sudo cat << EOF > /opt/xray/config.json
{
"log": {
"loglevel": "warning"
},
"routing": {
$ROUTES
},
"inbounds": [
{
"port": 443,
"protocol": "vless",
"tag": "vless_tls",
"settings": {
"clients": [
{
"id": "$UUID",
"email": "$USER@$MAIL",
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "www.$RANDOM_SITE.ru:443",
"xver": 0,
"serverNames": [
"www.$RANDOM_SITE.ru"
],
"privateKey": "$PRIVATE",
"minClientVer": "",
"maxClientVer": "",
"maxTimeDiff": 0,
"shortIds": [
"$SHORT"
]
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
]
}
EOF
sudo systemctl start xray
sudo systemctl enable xray
#Делаем скрипт для мониторинга работоспособности службы и её подъёма, если упала
sudo cat <<EOF > /usr/local/bin/xray_monitor.sh
#!/bin/bash
SERVICE_NAME="xray"
check_service() {
if systemctl is-active --quiet $SERVICE_NAME; then
echo "XRAY working"
else
systemctl restart $SERVICE_NAME
if systemctl is-active --quiet $SERVICE_NAME; then
echo "XRAY успешно перезапущен"
else
echo "XRAY не стартует"
fi
fi
}
check_service
EOF
(crontab -l 2>/dev/null; echo "*/5 * * * * /usr/local/bin/xray_monitor.sh >> /var/log/xray_monitor.log 2>&1") | crontab -
echo "Клиент https://github.com/MatsuriDayo/nekoray/releases"
echo ""
echo "ПАРАМЕТРЫ ДЛЯ НАСТРОЙКИ ПРИЛОЖЕНИЯ. СОХРАНИТЕ ИХ!!!"
echo "Название: Любое"
echo "Адрес: $IP"
echo "Порт: 443"
echo "ID: $UUID"
echo "Поток: xtls-rprx-vision"
echo "Шифрование: none"
echo "Сеть: tcp"
echo "Тип заголовка: none"
echo "Узел HTTP и Путь пустые"
echo "TLS: reality"
echo "SNI www.$RANDOM_SITE.ru"
echo "ОТПЕЧАТОК: Chrome"
echo "ОТКРЫТЫЙ КЛЮЧ: $PUBLIC"
echo "ShortID: $SHORT"
echo "SpiderX: Пусто"
echo ""
echo "ТАКЖЕ МОЖНО ПРОСТО ИМПОРТИРОВАТЬ НАСТРОЙКИ ИЗ ДАННОЙ СТРОКИ"
echo "vless://$UUID@$IP:443?security=reality&encryption=none&pbk=$PUBLIC&headerType=none&fp=chrome&type=tcp&flow=xtls-rprx-vision&sni=www.$RANDOM_SITE.com&sid=$SHORT#VLESS%20HEILTZEENTCH"
else
echo "Понял, идём дальше"
fi
echo "Для установки hysterya Вам нужно иметь свой домен"
read -p "Вы хотите установить HYSTERIA2 (Y/N)?: " HYSTERIAYN
if [ $HYSTERIAYN = "Y" ] || [ $HYSTERIAYN = "y" ]; then
curl -fsSL https://get.hy2.sh/ > hysterya.sh
chmod +x hysterya.sh
sudo ./hysterya.sh
read -p "Введите Ваш домен: " HYSTERIADOMEN
read -p "Введите Ваш пароль от пользователя Hysteria: " HYSTERIAPASS
read -p "Введите Ваш пароль от обфускатора Salamander: " SALAMANDERPASS
read -p "Введите почту для уведомлений: " EMAILFORNOTIFICATIONS
read -p "Хотите использовать маскировку под HTTP3 и обычный сайт или обфускацию (H/O)?: " TYPEMASQ
if [ $TYPEMASQ = "O" ] || [ $TYPEMASQ = "o" ]; then
sudo rm /etc/hysteria/config.yaml
sudo tee /etc/hysteria/config.yaml <<EOF
listen: :443
acme:
domains:
- $HYSTERIADOMEN
email: $EMAILFORNOTIFICATIONS
obfs:
type: salamander
salamander:
password: $SALAMANDERPASS
auth:
type: password
password: $HYSTERIAPASS
EOF
elif [ $TYPEMASQ = "H" ] || [ $TYPEMASQ = "h" ]; then
sudo rm /var/www/masq/index.html
sudo tee /var/www/masq/index.html <<EOF
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
EOF
sudo rm /etc/hysteria/config.yaml
sudo tee /etc/hysteria/config.yaml <<EOF
listen: :443
acme:
domains:
- $HYSTERIADOMEN
email: $EMAILFORNOTIFICATIONS
auth:
type: password
password: $HYSTERIAPASS
masquerade:
type: file
file:
dir: /var/www/masq
listenHTTP: :80
listenHTTPS: :443
forceHTTPS: true
EOF
sudo systemctl restart hysteria-server.service
sudo systemctl enable hysteria-server.service
sudo tee hysteria-client.yaml <<EOF
server: $HYSTERIADOMEN:443
auth: $HYSTERIAPASS
obfs:
type: salamander
salamander:
password: $SALAMANDERPASS
bandwidth:
up: 50 mbps
down: 200 mbps
socks5:
listen: 127.0.0.1:1080
EOF
echo "Ваша строка для подключения:"
hysteria share -c hysteria-client.yaml
echo "И она же в виде QR-кода:"
hysteria share -c hysteria-client.yaml --qr
else
echo "Тогда заканчиваем"
fi