#!/bin/bash
clear
m="\033[0;1;36m"
y="\033[0;1;37m"
yy="\033[0;1;32m"
yl="\033[0;1;33m"
wh="\033[0m"
## Foreground
DEFBOLD='\e[39;1m'
RB='\e[31;1m'
GB='\e[32;1m'
YB='\e[33;1m'
BB='\e[34;1m'
MB='\e[35;1m'
CB='\e[35;1m'
WB='\e[37;1m'
clear
function udepe(){
clear
echo 
echo -e "\e[0m UDP Setup install....\e[0m"
sleep 0.7
echo -e "\e[0m Success...\e[0m"
sleep 0.7
echo
echo -e "\e[0m By NevermoreSSH..\e[0m"
sleep 0.7
echo
clear
cd
rm -rf /root/udp
mkdir -p /root/udp
# change to time GMT+8
echo "Change to time GMT+8"
ln -fs /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

# install udp-custom
echo downloading udp-custom
wget -q --show-progress --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1ixz82G_ruRBnEEp4vLPNF2KZ1k8UfrkV' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1ixz82G_ruRBnEEp4vLPNF2KZ1k8UfrkV" -O /root/udp/udp-custom && rm -rf /tmp/cookies.txt
chmod +x /root/udp/udp-custom

echo downloading default config
wget -q --show-progress --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1klXTiKGUd2Cs5cBnH3eK2Q1w50Yx3jbf' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1klXTiKGUd2Cs5cBnH3eK2Q1w50Yx3jbf" -O /root/udp/config.json && rm -rf /tmp/cookies.txt
chmod 644 /root/udp/config.json

if [ -z "$1" ]; then
cat <<EOF > /etc/systemd/system/udp-custom.service
[Unit]
Description=UDP Custom by ePro Dev. Team

[Service]
User=root
Type=simple
ExecStart=/root/udp/udp-custom server
WorkingDirectory=/root/udp/
Restart=always
RestartSec=2s

[Install]
WantedBy=default.target
EOF
else
cat <<EOF > /etc/systemd/system/udp-custom.service
[Unit]
Description=UDP Custom by ePro Dev. Team

[Service]
User=root
Type=simple
ExecStart=/root/udp/udp-custom server -exclude $1
WorkingDirectory=/root/udp/
Restart=always
RestartSec=2s

[Install]
WantedBy=default.target
EOF
fi

echo start service udp-custom
systemctl start udp-custom &>/dev/null

echo enable service udp-custom
systemctl enable udp-custom &>/dev/null

#echo reboot
#reboot
clear
echo -e ""
echo -e "\033[96;1m WAIT IN 4 SECCOND......."
sleep 4
clear
echo -e ""
echo -e ""
read -p "ENTER BACK TO MENU"
menu
}
function update(){
clear
dateFromServer=$(curl -v --insecure --silent https://google.com/ 2>&1 | grep Date | sed -e 's/< Date: //')
biji=`date +"%Y-%m-%d" -d "$dateFromServer"`
red() { echo -e "\\033[32;1m${*}\\033[0m"; }
clear
fun_bar() {
    CMD[0]="$1"
    CMD[1]="$2"
    (
        [[ -e $HOME/fim ]] && rm $HOME/fim
        ${CMD[0]} -y >/dev/null 2>&1
        ${CMD[1]} -y >/dev/null 2>&1
        touch $HOME/fim
    ) >/dev/null 2>&1 &
    tput civis
    echo -ne "  \033[0;33mPlease Wait Loading \033[1;37m- \033[0;33m["
    while true; do
        for ((i = 0; i < 18; i++)); do
            echo -ne "\033[0;32m#"
            sleep 0.1s
        done
        [[ -e $HOME/fim ]] && rm $HOME/fim && break
        echo -e "\033[0;33m]"
        sleep 1s
        tput cuu1
        tput dl1
        echo -ne "  \033[0;33mPlease Wait Loading \033[1;37m- \033[0;33m["
    done
    echo -e "\033[0;33m]\033[1;37m -\033[1;32m OK !\033[1;37m"
    tput cnorm
}
res1() {
    wget https://autoscript.interflazz.web.id/v3.4/menu/menu.zip
    unzip menu.zip
    chmod +x menu/*
    mv menu/* /usr/local/sbin
    rm -rf menu
    rm -rf menu.zip
    rm -rf update.sh
}
netfilter-persistent
clear
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e " \e[1;97;101m          UPDATE SCRIPT        \e[0m"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e ""
echo -e "  \033[1;91m update script service\033[1;37m"
fun_bar 'res1'
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e ""
read -n 1 -s -r -p "Press [ Enter ] to back on menu"
menu
}
# COLOR VALIDATION
clear
y='\033[1;33m' #yellow
BGX="\033[42m"
CYAN="\033[96m"
z="\033[96m"
f="\033[1;97;41m"
RED='\033[0;31m'
NC='\033[0m'
gray="\e[1;30m"
Blue="\033[0;34m"
green='\033[0;32m'
grenbo="\e[92;1m"
purple="\033[95m"
YELL='\033[0;33m'
#INTALLER-UDP
UDPX="https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1S3IE25v_fyUfCLslnujFBSBMNunDHDk2' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1S3IE25v_fyUfCLslnujFBSBMNunDHDk2"
ISP=$(cat /etc/xray/isp)
CITY=$(cat /etc/xray/city)
IPVPS=$(curl -s ipv4.icanhazip.com)
domain=$(cat /etc/xray/domain)
RAM=$(free -m | awk 'NR==2 {print $2}')
USAGERAM=$(free -m | awk 'NR==2 {print $3}')
MEMOFREE=$(printf '%-1s' "$(free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2 }')")
LOADCPU=$(printf '%-0.00001s' "$(top -bn1 | awk '/Cpu/ { cpu = "" 100 - $8 "%" }; END { print cpu }')")
MODEL=$(cat /etc/os-release | grep -w PRETTY_NAME | head -n1 | sed 's/=//g' | sed 's/"//g' | sed 's/PRETTY_NAME//g')
CORE=$(printf '%-1s' "$(grep -c cpu[0-9] /proc/stat)")
DATEVPS=$(date +'%d-%m-%Y')
TIMEZONE=$(printf '%(%H-%M-%S)T')
SERONLINE=$(uptime -p | cut -d " " -f 2-10000)
clear
MYIP=$(curl -sS ipv4.icanhazip.com)
echo ""
izinsc="https://autoscript.interflazz.web.id/v3.4/main-ip"
# USERNAME
rm -f /usr/bin/user
username=$(curl ${izinsc} | grep $MYIP | awk '{print $2}')
echo "$username" >/usr/bin/user
# validity
rm -f /usr/bin/e
valid=$(curl ${izinsc} | grep $MYIP | awk '{print $3}')
echo "$valid" >/usr/bin/e
# DETAIL ORDER
username=$(cat /usr/bin/user)
oid=$(cat /usr/bin/ver)
exp=$(cat /usr/bin/e)
clear
# CERTIFICATE STATUS
d1=$(date -d "$valid" +%s)
d2=$(date -d "$today" +%s)
certifacate=$(((d1 - d2) / 86400))
# VPS Information
DATE=$(date +'%Y-%m-%d')
datediff() {
    d1=$(date -d "$1" +%s)
    d2=$(date -d "$2" +%s)
    echo -e "$COLOR1 $NC Expiry In   : $(( (d1 - d2) / 86400 )) Days"
}
mai="datediff "$Exp" "$DATE""

# Status Expired Or Active
Info="(${green}Active${NC})"
Error="(${RED}Expired${NC})"
today=`date -d "0 days" +"%Y-%m-%d"`
Exp1=$(curl ${izinsc} | grep $MYIP | awk '{print $3}')
if [[ $today < $Exp1 ]]; then
sts="${Info}"
else
sts="${Error}"
fi
clear

# OS Uptime
uptime="$(uptime -p | cut -d " " -f 2-10)"
# Interface vnstat
interface1="$(ifconfig | awk 'NR==1 {sub(/:$/, "", $1); print $1}')"
# Download/Upload today
dtoday="$(vnstat -i "$interface1" | grep "today" | awk '{print $2" "substr ($3, 1, 1)}')"
utoday="$(vnstat -i "$interface1" | grep "today" | awk '{print $5" "substr ($6, 1, 1)}')"
ttoday="$(vnstat -i "$interface1" | grep "today" | awk '{print $8" "substr ($9, 1, 1)}')"
# Download/Upload yesterday
dyest="$(vnstat -i "$interface1" | grep "yesterday" | awk '{print $2" "substr ($3, 1, 1)}')"
uyest="$(vnstat -i "$interface1" | grep "yesterday" | awk '{print $5" "substr ($6, 1, 1)}')"
tyest="$(vnstat -i "$interface1" | grep "yesterday" | awk '{print $8" "substr ($9, 1, 1)}')"
# Download/Upload current month
dmon="$(vnstat -i "$interface1" -m | awk 'NR==6 {print $2" "substr ($3, 1, 1)}')"
umon="$(vnstat -i "$interface1" -m | awk 'NR==6 {print $5" "substr ($6, 1, 1)}')"
tmon="$(vnstat -i "$interface1" -m | awk 'NR==6 {print $8" "substr ($9, 1, 1)}')"
totalmon="$(vnstat | grep "total:" | awk '{print $8, $9}')"
# Getting CPU Information
cpu_usage1="$(ps aux | awk 'BEGIN {sum=0} {sum+=$3}; END {print sum}')"
cpu_usage="$((${cpu_usage1/\.*} / ${coREDiilik:-1}))"
cpu_usage+=" %"
ISP=$(curl -s ipinfo.io/org | cut -d " " -f 2-10 )
CITY=$(curl -s ipinfo.io/city )
WKT=$(curl -s ipinfo.io/timezone )
DAY=$(date +%A)
DATE=$(date +%m/%d/%Y)
DATE2=$(date -R | cut -d " " -f -5)
IPVPS=$(curl -s ipv4.icanhazip.com)
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo )
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
freq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo )
tram=$( free -m | awk 'NR==2 {print $2}' )
uram=$( free -m | awk 'NR==2 {print $3}' )
fram=$( free -m | awk 'NR==2 {print $4}' )
clear
ssh_service=$(/etc/init.d/ssh status | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1)
dropbear_service=$(/etc/init.d/dropbear status | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1)
haproxy_service=$(systemctl status haproxy | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1)
xray_service=$(systemctl status xray | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1)
nginx_service=$(systemctl status nginx | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1)
#Status | Geo Project
clear
# STATUS SERVICE  SSH 
if [[ $ssh_service == "running" ]]; then 
   status_ssh="${green}ON${NC}"
else
   status_ssh="${RED}ðŸ”´${NC} "
fi

# // SSH Websocket Proxy
ssh_ws=$( systemctl status ws | grep Active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g' )
if [[ $ssh_ws == "running" ]]; then
    status_ws_epro="${green}ON${NC}"
else
    status_ws_epro="${RED}ðŸ”´${NC} "
fi

# STATUS SERVICE HAPROXY
if [[ $haproxy_service == "running" ]]; then 
   status_haproxy="${green}ON${NC}"
else
   status_haproxy="${RED}ðŸ”´${NC} "
fi

# STATUS SERVICE XRAY
if [[ $xray_service == "running" ]]; then 
   status_xray="${green}ON${NC}"
else
   status_xray="${RED}ðŸ”´${NC} "
fi

# STATUS SERVICE NGINX
if [[ $nginx_service == "running" ]]; then 
   status_nginx="${green}ON${NC}"
else
   status_nginx="${RED}ðŸ”´${NC} "
fi

# STATUS SERVICE Dropbear
if [[ $dropbear_service == "running" ]]; then 
   status_dropbear="${green}ON${NC}"
else
   status_dropbear="${RED}ðŸ”´${NC} "
fi
#####INFOAKUN
vlx=$(grep -c -E "^#& " "/etc/xray/config.json")
let vla=$vlx/2
vmc=$(grep -c -E "^### " "/etc/xray/config.json")
let vma=$vmc/2
ssh1="$(awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd | wc -l)"
trx=$(grep -c -E "^#! " "/etc/xray/config.json")
let trb=$trx/2
ssx=$(grep -c -E "^#ss# " "/etc/xray/config.json")
let ssa=$ssx/2
###########
KANAN="\033[1;32m<\033[1;33m<\033[1;31m<\033[1;31m$NC"
KIRI="\033[1;32m>\033[1;33m>\033[1;31m>\033[1;31m$NC"
########
r="\033[1;31m"  #REDTERANG
a=" ${CYAN}ACCOUNT PREMIUM" 
echo -e " "
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e " ${z}$NC${NC}             Autoscript SSH XRAY Websocket              $NC${NC}$NC"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e " ${z}$NC$r  $NC$wh System OS ${NC}     $Blue=$NC $MODEL${NC}"
echo -e " ${z}$NC$r  $NC$wh Server RAM ${NC}    $Blue=$NC $uram / $tram MB $NC"
echo -e " ${z}$NC$r  $NC$wh Uptime Server ${NC} $Blue=$NC $SERONLINE${NC}"
echo -e " ${z}$NC$r  $NC$wh Date ${NC}          $Blue=$NC $DATEVPS${NC}"
echo -e " ${z}$NC$r  $NC$wh Time ${NC}          $Blue=$NC $TIMEZONE${NC}"
echo -e " ${z}$NC$r  $NC$wh IP VPS ${NC}        $Blue=$NC $IPVPS${NC}"
echo -e " ${z}$NC$r  $NC$wh Domain ${NC}        $Blue=$NC $domain${NC}"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e "           ${CYAN}SSH/OPENVPN${NC}    $y=$NC $ssh1${NC}" "$a"
echo -e "           VMESS/WS/GRPC${NC}  $y=$NC $vma$NC" "$a"
echo -e "           VLESS/WS/GRPC${NC}  $y=$NC $vla$NC" "$a"
echo -e "           TROJAN/WS/GRPC${NC} $y=$NC $trb${NC}" "$a"
echo -e "           SHADOW/WS/GRPC${NC} $y=$NC $ssa${NC} $a"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e " ${z} ${NC}$y SSH$NC : $status_ssh" "        $y NGINX$NC : $status_nginx" "        $y XRAY$NC : $status_xray         $NC${z}$NC" 
echo -e " ${z} ${NC}$y WS-ePRO$NC : $status_ws_epro" "    $y DROPBEAR$NC : $status_dropbear" "     $y HAPROXY$NC : $status_haproxy      $NC${z}$NC" 
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e " ${z}$NC [${r}01${NC}]$purple MENU SSH$NC     ${z}$NC [${r}08${NC}]$purple DELL ALL EXP$NC ${z}$NC [${r}15${NC}]$purple BCKP/RSTR   $NC${z}$NC"
echo -e " ${z}$NC [${r}02${NC}]$purple MENU VMESS$NC   ${z}$NC [${r}09${NC}]$purple AUTOREBOOT$NC  ${z} $NC [${r}16${NC}]$purple REBOOT      $NC${z}$NC"    
echo -e " ${z}$NC [${r}03${NC}]$purple MENU VLESS$NC   ${z}$NC [${r}10${NC}]$purple INFO PORT$NC   ${z} $NC [${r}17${NC}]$purple RESTART     $NC${z}$NC"   
echo -e " ${z}$NC [${r}04${NC}]$purple MENU TROJAN$NC  ${z}$NC [${r}11${NC}]$purple BACKUP vBOT$NC ${z} $NC [${r}18${NC}]$purple DOMAIN      $NC${z}$NC" 
echo -e " ${z}$NC [${r}05${NC}]$purple MENU SHADOW$NC  ${z}$NC [${r}12${NC}]$purple RUNNING$NC     ${z} $NC [${r}19${NC}]$purple CERT SSL    $NC${z}$NC"
echo -e " ${z}$NC [${r}06${NC}]$purple MENU TRIAL$NC   ${z}$NC [${r}13${NC}]$purple CLEAR LOG$NC   ${z} $NC [${r}20${NC}]$purple INS. UDP    $NC${z}$NC"
echo -e " ${z}$NC [${r}07${NC}]$purple CEK RAM/CPU$NC  ${z}$NC [${r}14${NC}]$purple DNS CHANGER$NC ${z} $NC [${r}21${NC}]$purple XRAYCORE MOD $NC${z}$NC"
echo -e " ${z}$NC [${r}22${NC}]$purple CEK BANDWITH$NC ${z}$NC [${r}23${NC}]$purple NETFLIX PROXY$NC${z}$NC [${r}24${NC}]$purple MENU BOT    $NC${z}$NC"
echo -e " ${z}                                                          $NC${z}$NC"
echo -e " ${z}$NC [${r}25${NC}]$purple CHANGE BANNER SSH$NC ${KANAN} \E[0m\033[0;34m                              $NC${z}$NC"
echo -e " ${z}$NC [${r}26${NC}]$purple LOG CREATE USER ACCOUNT ${KANAN} \E[0m\033[0;34m                        $NC${z}$NC"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e " ${z}$NC$wh Daily Usage         : $ttoday ${NC}"
echo -e " ${z}$NC$wh Yesterday Usage     : $tyest ${NC}"
echo -e " ${z}$NC$wh Monthly Usage       : $tmon ${NC}"
echo -e "${BB}————————————————————————————————————————————————————————${NC}"
echo -e ""
read -p " Select menu : " opt
echo -e ""
case $opt in
1 | 01)
clear
m-sshws
;;
2 | 02)
clear
m-vmess
;;
3 | 03)
clear
m-vless
;;
4 | 04)
clear
m-trojan
;;
5 | 05)
clear
m-ssws
;;
6 | 06)
clear
m-trial
;;
7 | 07)
clear
gotop
echo ""
echo -e " ${GREEN} Back to menu in 1 sec ${NC}"
sleep 1
menu
;;
8 | 08)
clear
xp
echo ""
echo -e " ${GREEN} Back to menu in 1 sec ${NC}"
sleep 1
menu
;;
9 | 09)
clear
autoreboot
;;
10)
clear
prot
echo ""
read -n 1 -s -r -p "Press any key to back on menu"
menu
;;
11)
clear
mbot-backup
;;
12)
clear
run
;;
13)
clear
clearlog
;;
14)
clear
dns
;;
15)
clear
menu-backup
;;
16)
clear
reboot
;;
17)
clear
restart
;;
18)
clear
addhost
;;
19)
clear
fixcert
;;
20)
clear
udepe
;;
21)
clear
wget -q -O /usr/bin/xraychanger "https://raw.githubusercontent.com/NevermoreSSH/Xcore-custompath/main/xraychanger.sh" && chmod +x /usr/bin/xraychanger && xraychanger
;;
22)
clear
bw
;;
23)
clear
netf
;;
24)
clear
wget -q https://raw.githubusercontent.com/NevermoreSSH/aiov2/main/bot/bot.sh && chmod +x bot.sh && ./bot.sh
;;
25)
clear
echo -e "Edit Banner SSH Message " | lolcat
sleep 2
echo -e "Loading..........â³" | lolcat
sleep 5
nano /etc/kyt.txt
clear
echo -e "${green}ANDA YAKIN UNTUK MEMASANG BANNER INI ? $NC"
echo -e ""
read -p "SILAHKAN PILIH OPSI BERIKUT [Y/N]:" arg
if [[ $arg == 'Y' ]]; then
  echo -e "${Blue}Tindakan Diteruskan! $NC"
  echo -e "${green}START. . . $NC"
elif [[ $arg == 'y' ]]; then
  echo -e "${Blue}Tindakan Diteruskan! $NC"
  clear
  echo -e "${Blue}START . . .$NC"
elif [[ $arg == 'N' ]]; then
  echo -e "${RED}Tindakan Dihentikan! $NC"
  sleep 1
  clear
  menu
  exit 0
elif [[ $arg == 'n' ]]; then
  echo -e "${RED}Tindakan Dihentikan! $NC"
  sleep 1
  clear
  rm -f /root/update.sh
  exit 0
else
  echo -e "${RED}Argumen Tidak Diketahui! $NC"
  sleep 1
  clear
  rm -f /root/update.sh
  exit 0
fi
##########
clear
reboot
;;
26)
clear
cat /etc/user-create/user.log
echo ""
read -p "Press enter Back To menu"
menu
;;
0 | 00)
exit
;;
x)
menu
;;
*) clear ;
echo -e ""
menu
;;
esac
