#!/bin/bash
# -*- ENCODING: UTF-8 -*-

# verificacion primarias
meu_ip_fun () {
MIP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
MIP2=$(wget -qO- ipv4.icanhazip.com)
[[ "$MIP" != "$MIP2" ]] && IP="$MIP2" || IP="$MIP"
}

[[ -e /etc/newadm-instalacao ]] && BASICINST="$(cat /etc/newadm-instalacao)" || BASICINST="cabecalho menu_credito ferramentas menu_inst PPub.py usercodes payloads PDirect.py v-local.log PGet.py ultrahost menu POpen.py shadowsocks.sh fai2ban PPriv.py"
SCPT_DIR="/etc/SCRIPT"
[[ ! -e ${SCPT_DIR} ]] && mkdir ${SCPT_DIR}
INSTA_ARQUIVOS="ADMVPS.zip"
DIR="/etc/http-shell"
LIST="$(echo "NewVPS-" | rev)"
[[ -e /etc/menu_ito ]] && nomkey="$(cat /etc/menu_ito)" || nomkey="$(curl -sSL "https://www.dropbox.com/s/z38hj1mz3q9krso/menu_credito")"

gerar_key () {
unset usrLOP nombrevalue nBot nBotSS
[[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
[[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
[[ -z ${callback_query_from_username} ]] && usrLOP=${message_from_username} || usrLOP=${callback_query_from_username}
#[[ -z ${usrLOP} ]] && LIST="$(echo "NewVPS-" | rev)" || LIST="$(echo "${usrLOP}-" | rev)"
numkey_gen=$(grep -o -i $nombrevalue /etc/ADM-db/num-key.cont | wc -l)
limcont=$(cat /etc/ADM-db/limit) 
[[ "$limcont" -ge "998" ]] && limted="∞" || limted=$(cat /etc/ADM-db/limit)
[[ "$(( $limcont - $numkey_gen ))" -ge "900" ]] && credres="∞" || credres=$(( $limcont - $numkey_gen))
meu_ip_fun
[[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
[[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
[[ -z $nBot ]] && nBot=$(ShellBot.username)
[[ -e ${CIDdir}/ress ]] && echo $nomkey > ${SCPT_DIR}/menu_credito || echo -e "${firsnme} ${lastnme}" > ${SCPT_DIR}/menu_credito
adminV="$(less ${SCPT_DIR}/menu_credito)";
valuekey="$(date | md5sum | head -c11)"
valuekey+="$(echo $(($RANDOM*10))|head -c 6)"
#valuekey="$(date | md5sum | head -c4)"
#valuekey+="$(echo $(($RANDOM*10))|head -c 3)"
#valuekey+="$(date | md5sum | head -c5)"
#valuekey+="$(echo $(($RANDOM*10))|head -c 2)"
oUP=$(wget -qO- ipv4.icanhazip.com)
fun_list "$valuekey"
keyfinal="$(ofus "$oUP:8888/${valuekey}/$LIST")"
#local bot_retorno=" ═--💻  𝙎 𝘾 𝙍 𝙄 𝙋 𝙏  |  𝘾𝙝𝙪𝙢𝙤𝙂𝙃|𝘼𝘿𝙈   💻  --═\n" #--------------------------------------------------------------------------------------
local bot_retorno=" $LINE\n"  #--------------------------------------------------------------------------------------
#   🚫 Sin TU RESELLER EN LA KEY 🚫\n
[[ -z ${message_chat_tittle} ]] && grupCHAT="" || grupCHAT="ChatID : ${chatuser} "
#bot_retorno+="  KEY { $numkey_gen } DE @${usrLOP} con ID: ${nombrevalue} $grupCHAT \n ⚠️ VENCE EN 1 HORA O AL SER USADA ⚠️\n"
[[ -z ${usrLOP} ]] && bot_retorno+=" 🪧 USUARIO SIN ALIAS CON ID: ⚠️ADVERTIDO⚠️ \n  ⚠️ KEY VENCE EN 4 HORAS O AL USARLA ⚠️\n ⚠️\n" || bot_retorno+="  KEY { $numkey_gen } DE @${usrLOP} con ID: <tg-spoiler>${nombrevalue}</tg-spoiler> $grupCHAT \n ⚠️ VENCE EN 4 HORAS O AL SER USADA ⚠️\n"
bot_retorno+="$LINE\n"
bot_retorno+=" 🛡️ 𝚁𝙴𝚂𝙴𝙻𝙻𝙴𝚁 🛡️ : ${adminV}\n"
bot_retorno+="$LINE\n"
bot_retorno+=" 🗝️  <pre>${keyfinal}</pre> 🗝️\n"
bot_retorno+="$LINE\n"
bot_retorno+="  🛡️  𝙸𝚗𝚜𝚝𝚊𝚕𝚊𝚍𝚘𝚛  𝙾𝚏𝚒𝚌𝚒𝚊𝚕 $(cat < /etc/SCRIPT/v-local.log) 🔐 \n"
bot_retorno+="$LINE\n"
bot_retorno+='<pre>apt update -y; apt upgrade -y; wget -q https://raw.githubusercontent.com/ChumoGH/ScriptCGH/main/setup; chmod 777 setup; ./setup --install</pre>\n'
bot_retorno+="$LINE\n"
bot_retorno+="     𝙍𝙚𝙘𝙤𝙢𝙚𝙣𝙙𝙖𝙙𝙤 𝙐𝙗𝙪𝙣𝙩𝙪 18.04 \n   🧬🧬 S.O Ubuntu 14 a 22 X64(x86|ARM) 🧬🧬 \n          Debian 7,8,9,11 (x64) \n  🪦 ADQUIERE TU ACCESO EN @${nBot} 🛡️⚔️\n"
bot_retorno+="$LINE\n"
msj_fun
bot_file+="  🛡️  𝙸𝚗𝚜𝚝𝚊𝚕𝚊𝚍𝚘𝚛  𝙾𝚏𝚒𝚌𝚒𝚊𝚕 $(cat < /etc/SCRIPT/v-local.log) 🛡️ \n\n"
bot_file+="apt update -y && apt upgrade -y && wget -q https://raw.githubusercontent.com/ChumoGH/ScriptCGH/main/setup && chmod +x setup && ./setup --install\n\n"
bot_file+="  ${keyfinal} \n"
echo -e ${bot_file} > ${keytxt}/key_${usrLOP}.txt
upfile_fun ${keytxt}/key_${usrLOP}.txt
rm ${keytxt}/key_${usrLOP}.txt
}
fun_list () {
rm ${SCPT_DIR}/*.x.c &> /dev/null
unset KEY
KEY="$1"
#CRIA DIR
[[ ! -e ${DIR} ]] && mkdir ${DIR}
#ENVIA ARQS
i=0
VALUE+="gerar.sh http-server.py lista-arq $BASICINST"
for arqx in `ls ${SCPT_DIR}`; do
[[ $(echo $VALUE|grep -w "${arqx}") ]] && continue 
echo -e "[$i] -> ${arqx}"
arq_list[$i]="${arqx}"
let i++
done
#CRIA KEY
[[ ! -e ${DIR}/${KEY} ]] && mkdir ${DIR}/${KEY}
#PASSA ARQS 
unset nombrevalue
[[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
[[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
[[ "$(grep -o -i $nombrevalue /etc/ADM-db/num-key.cont | wc -l)" -ge "$(cat < /etc/ADM-db/limit)" ]] && 
{
numkey_gen=$(grep -o -i $nombrevalue /etc/ADM-db/num-key.cont | wc -l)
local bot_retorno="$LINE\n"
bot_retorno+=" 🚫 OOOH!, @${callback_query_from_username} con ID:$nombrevalue ‼️\n Tus Creditos se han Agotado \n"
bot_retorno+="  TUS CREDITOS PERMITIDOS :『 $(cat < /etc/ADM-db/limit) 』, 𝙆𝙚𝙮𝙨 𝙂𝙚𝙣𝙚𝙧𝙖𝙙𝙖𝙨『 $numkey_gen 』🗝️\n"
bot_retorno+="$LINE\n"
bot_retorno+=" Si deseas Usar el Generador sin Limite , Contacta con $(cat < /etc/ADM-db/resell)\n"
bot_retorno+=" Recuerda que Todo Esfuerzo Vale, Solicita Acceso \n"
bot_retorno+=" 𝙍𝙚𝙘𝙤𝙢𝙚𝙣𝙙𝙖𝙙𝙤 𝙐𝙗𝙪𝙣𝙩𝙪 18.04 \n   🧬🧬 S.O Ubuntu 16,18,20 X64(x86|ARM) 🧬🧬 \n          Debian 7,8,9,10 (x64) \n  🪦 ADQUIERE TU ACCESO EN @${nBot} 🛡️⚔️\n"
bot_retorno+=" 🔐 𝙆𝙚𝙮𝙨 𝙐𝙨𝙖𝙙𝙖𝙨『 $(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l) 』 🔓, 𝘒𝘦𝘺𝘴 𝘈𝘤𝘵𝘪𝘷𝘢𝘴 『 $(ls /etc/http-shell/ | grep name | wc -l) 』 🗝️ \n"
bot_retorno+="$LINE\n"
msj_fun
exit
} ||
echo "$nombrevalue" >> /etc/ADM-db/num-key.cont
numkey_used=$(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l)
numkey_gen=$(grep -o -i $nombrevalue /etc/ADM-db/num-key.cont | wc -l)
#ADM BASIC
arqslist="$BASICINST"
for arqx in `echo "${arqslist}"`; do
[[ -e ${DIR}/${KEY}/$arqx ]] && continue #ANULA ARQUIVO CASO EXISTA
cp ${SCPT_DIR}/$arqx ${DIR}/${KEY}/
echo "$arqx" >> ${DIR}/${KEY}/${LIST}
done
rm ${SCPT_DIR}/*.x.c &> /dev/null
echo "$nombrevalue" > ${DIR}/${KEY}.name
[[ ! -z $IPFIX ]] && echo "$IPFIX" > ${DIR}/${KEY}/keyfixa
_hora=$(printf '%(%D-%H:%M:%S)T') 
TOKEN="$(cat /etc/ADM-db/token)"
urlBOT="https://api.telegram.org/bot$TOKEN/sendMessage"
MENSAJE=" ••••📩𝙈𝙀𝙉𝙎𝘼𝙅𝙀 𝙍𝙀𝘾𝙄𝘽𝙄𝘿𝙊📩••••\n"
MENSAJE+=" KEY : ${keyfinal} \n"
MENSAJE+=" CADUCADA : $_hora\n"
MENSAJE+=" ••••••••••••••••••••••••••••••••••••••••••••••••\n"
MENSAJE+='       🔰 Bot generador de key 🔰\n'
MENSAJE+='           ⚜ By @drowkid01 ⚜ \n'
MENSAJE+=" ••••••••••••••••••••••••••••••••••••••••••••••••\n"
#&& curl -s -X POST $urlBOT -d chat_id=$nombrevalue -d text="$(echo -e "$MENSAJE")" &>/dev/null
at now +4 hours <<< "rm -rf ${DIR}/${KEY} && rm -f ${DIR}/${KEY}.name"
}

ofus () {
unset server
server=$(echo ${txt_ofuscatw}|cut -d':' -f1)
unset txtofus
number=$(expr length $1)
for((i=1; i<$number+1; i++)); do
txt[$i]=$(echo "$1" | cut -b $i)
case ${txt[$i]} in
".")txt[$i]="x";;
"x")txt[$i]=".";;
"5")txt[$i]="s";;
"s")txt[$i]="5";;
"1")txt[$i]="@";;
"@")txt[$i]="1";;
"2")txt[$i]="?";;
"?")txt[$i]="2";;
"4")txt[$i]="0";;
"0")txt[$i]="4";;
"/")txt[$i]="K";;
"K")txt[$i]="/";;
esac
txtofus+="${txt[$i]}"
done
echo "$txtofus" | rev
}