main
This commit is contained in:
parent
658eaa098d
commit
3b4371326c
14128
.exp/scripts/repos/LATAM_Oficial/Codigo-Base/menu.sh
Normal file
14128
.exp/scripts/repos/LATAM_Oficial/Codigo-Base/menu.sh
Normal file
File diff suppressed because it is too large
Load Diff
1
.exp/scripts/repos/LATAM_Oficial/Control-IP
Normal file
1
.exp/scripts/repos/LATAM_Oficial/Control-IP
Normal file
@ -0,0 +1 @@
|
|||||||
|
155.138.245.13 (Panel-NetVPS 6.0)
|
||||||
73
.exp/scripts/repos/LATAM_Oficial/Ejecutables/4gcheck.py
Normal file
73
.exp/scripts/repos/LATAM_Oficial/Ejecutables/4gcheck.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
from crypt import methods
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import typing as t
|
||||||
|
import json
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from flask import Flask, jsonify, request
|
||||||
|
|
||||||
|
a = "{"
|
||||||
|
b = "}"
|
||||||
|
LISTENING_PORT = int(sys.argv[1])
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True
|
||||||
|
app.config['JSON_SORT_KEYS'] = False
|
||||||
|
|
||||||
|
def get_user(username: str) -> t.Optional[str]:
|
||||||
|
command = 'check %s 1' % username
|
||||||
|
result = os.popen(command).readlines()
|
||||||
|
final = result[0].strip()
|
||||||
|
return final
|
||||||
|
|
||||||
|
def cont_online(username: str) -> t.Optional[str]:
|
||||||
|
command = 'check %s 2' % username
|
||||||
|
result = os.popen(command).readlines()
|
||||||
|
final = result[0].strip()
|
||||||
|
return final
|
||||||
|
|
||||||
|
def limiter_user(username: str) -> t.Optional[str]:
|
||||||
|
command = 'check %s 3' % username
|
||||||
|
result = os.popen(command).readlines()
|
||||||
|
final = result[0].strip()
|
||||||
|
return final
|
||||||
|
|
||||||
|
def check_data(username: str) -> t.Optional[str]:
|
||||||
|
command = 'check %s 4' % username
|
||||||
|
result = os.popen(command).readlines()
|
||||||
|
final = result[0].strip()
|
||||||
|
return final
|
||||||
|
|
||||||
|
def check_dias(username: str) -> t.Optional[str]:
|
||||||
|
command = 'check %s 5' % username
|
||||||
|
result = os.popen(command).readlines()
|
||||||
|
final = result[0].strip()
|
||||||
|
return final
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/checkUser',methods = ['POST', 'GET'])
|
||||||
|
def check_user():
|
||||||
|
if request.method == 'POST':
|
||||||
|
try:
|
||||||
|
req_data = request.get_json()
|
||||||
|
user_get = req_data.get("user")
|
||||||
|
username = get_user(user_get)
|
||||||
|
user = get_user(username)
|
||||||
|
if user == "Not exist":
|
||||||
|
return ("{0}\"username\":\"{1}\",\"count_connection\":\"Null\",\"expiration_date\":\"Null\",\"expiration_days\":\"Null\",\"limiter_user\":\"Null\"{2}" .format(a, user, b))
|
||||||
|
else:
|
||||||
|
return ("{0}\"username\":\"{1}\",\"count_connection\":\"{2}\",\"expiration_date\":\"{3}\",\"expiration_days\":\"{4}\",\"limiter_user\":\"{5}\"{6}" .format(a, username, cont_online(username), check_data(username), check_dias(username), limiter_user(username), b))
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'error': str(e)})
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
return 'Cannot GET /checkUser'
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'error': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(
|
||||||
|
host='0.0.0.0',
|
||||||
|
port=int(sys.argv[1]) if len(sys.argv) > 1 else LISTENING_PORT,
|
||||||
|
)
|
||||||
5
.exp/scripts/repos/LATAM_Oficial/Ejecutables/SPR.sh
Normal file
5
.exp/scripts/repos/LATAM_Oficial/Ejecutables/SPR.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Soporte Remoto (SPR)
|
||||||
|
echo "" >/dev/null 2>&1
|
||||||
|
wget https://raw.githubusercontent.com/NetVPS/LATAM_Oficial/main/Fixs%20Remotos/SOPORTE.sh -O /usr/bin/SOPORTE > /dev/null 2>&1
|
||||||
|
chmod +x /usr/bin/SOPORTE > /dev/null 2>&1
|
||||||
27
.exp/scripts/repos/LATAM_Oficial/Ejecutables/autoinicios
Normal file
27
.exp/scripts/repos/LATAM_Oficial/Ejecutables/autoinicios
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
##-->> DESACTIVAR UFW TEMPORAL
|
||||||
|
ufw disable
|
||||||
|
##-->> CHECK IP
|
||||||
|
MEU_IP=$(wget -qO- ifconfig.me)
|
||||||
|
echo "$MEU_IP" >/tmp/IP
|
||||||
|
##-->> REINICIAR DROPBEAR
|
||||||
|
service dropbear stop &>/dev/null
|
||||||
|
service ssh restart &>/dev/null
|
||||||
|
sed -i "s/=1/=0/g" /etc/default/dropbear &>/dev/null
|
||||||
|
service dropbear restart &>/dev/null
|
||||||
|
sed -i "s/=0/=1/g" /etc/default/dropbear &>/dev/null
|
||||||
|
##-->> MSG DE REINICIO
|
||||||
|
if [[ -e "/etc/SCRIPT-LATAM/temp/keyapk" ]]; then
|
||||||
|
KEY=$(cat /etc/SCRIPT-LATAM/temp/keyapk)
|
||||||
|
IP=$(cat /root/.ssh/authrized_key.reg)
|
||||||
|
NOMBREVPS=$(cat /etc/SCRIPT-LATAM/temp/nomvpsapk | tr '[:space:]' '+' | tr -d 'ñ' | sed '/^$/d')
|
||||||
|
curl -s "http://xdroid.net/api/message?k=$KEY&t=%E2%9D%95Reboot+Detectado+&c=%F0%9F%96%A5%EF%B8%8F+En+VPS%3A+$NOMBREVPS%0A%F0%9F%8C%90+IP+del+VPS%3A+$IP%0A%F0%9F%94%BASe+detect%C3%B3+un+reinicio+en+su+VPS%2C+verifique+los+puertos+y+encaso+de+tener+limitadores+verificarlos&u=http%3A%2F%2Fgoogle.com" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
##-->> AUTOINICIO BADVPN
|
||||||
|
if [[ -e "/etc/SCRIPT-LATAM/PortM/Badvpn.log" ]]; then
|
||||||
|
portasx=$(cat /etc/SCRIPT-LATAM/PortM/Badvpn.log)
|
||||||
|
totalporta=($portasx)
|
||||||
|
for port in "${totalporta[@]}"; do
|
||||||
|
screen -dmS "badvpn-$port" /bin/badvpn-udpgw --listen-addr "127.0.0.1:$port" --max-clients 1000 --max-connections-for-client 10
|
||||||
|
done
|
||||||
|
fi
|
||||||
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/backsocz.zip
Normal file
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/backsocz.zip
Normal file
Binary file not shown.
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/badvpn-udpgw
Normal file
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/badvpn-udpgw
Normal file
Binary file not shown.
77
.exp/scripts/repos/LATAM_Oficial/Ejecutables/check
Normal file
77
.exp/scripts/repos/LATAM_Oficial/Ejecutables/check
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
user=$1
|
||||||
|
type=$2
|
||||||
|
[[ $(awk -F" " '{print $2}' /usr/lib/licence) != "@LATAM" ]] && exit 0
|
||||||
|
[[ $(awk -F" " '{print $2}' /etc/rec/licence) != "@LATAM" ]] && exit 0
|
||||||
|
database="/root/usuarios.db"
|
||||||
|
user_exist() {
|
||||||
|
[[ "$(grep -wc $user /etc/passwd)" != '0' ]] && {
|
||||||
|
echo $user
|
||||||
|
} || {
|
||||||
|
echo 'Not exist'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cont_online() {
|
||||||
|
limit="$(grep -w $user $database | cut -d' ' -f2)"
|
||||||
|
conssh="$(ps -u $user | grep sshd | wc -l)"
|
||||||
|
[[ -z $limit ]] && limit="1"
|
||||||
|
[[ $conssh -gt $limit ]] && screen -dmS pkill pkill.sh $user
|
||||||
|
echo $conssh
|
||||||
|
}
|
||||||
|
|
||||||
|
limiter_user() {
|
||||||
|
limit="$(grep -w $user $database | cut -d' ' -f2)"
|
||||||
|
[[ -z $limit ]] && limit="1"
|
||||||
|
echo $limit
|
||||||
|
}
|
||||||
|
|
||||||
|
check_data() {
|
||||||
|
datauser=$(chage -l $user | grep -i co | awk -F : '{print $2}')
|
||||||
|
dat="$(date -d"$datauser" '+%d/%m/%Y')"
|
||||||
|
echo $dat
|
||||||
|
}
|
||||||
|
|
||||||
|
check_dias() {
|
||||||
|
datauser=$(chage -l $user | grep -i co | awk -F : '{print $2}')
|
||||||
|
dat="$(date -d"$datauser" '+%Y-%m-%d')"
|
||||||
|
data=$(echo -e "$((($(date -ud $dat +%s) - $(date -ud $(date +%Y-%m-%d) +%s)) / 86400))")
|
||||||
|
echo $data
|
||||||
|
}
|
||||||
|
|
||||||
|
check_new_data() {
|
||||||
|
[[ "$(grep -wc $user /etc/passwd)" != '0' ]] && {
|
||||||
|
datauser=$(chage -l $user | grep -i co | awk -F : '{print $2}')
|
||||||
|
dat="$(date -d"$datauser" '+%Y%m%d')"
|
||||||
|
echo $dat
|
||||||
|
} || {
|
||||||
|
echo 'Not exist'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
datacheck_new() {
|
||||||
|
[[ "$(grep -wc $user /etc/passwd)" != '0' ]] && {
|
||||||
|
datauser=$(chage -l $user | grep -i co | awk -F : '{print $2}')
|
||||||
|
dat="$(date -d"$datauser" '+%d%m%Y')"
|
||||||
|
echo $dat
|
||||||
|
} || {
|
||||||
|
echo 'Not exist'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ $type -eq 1 ]; then
|
||||||
|
user_exist
|
||||||
|
elif [ $type -eq 2 ]; then
|
||||||
|
cont_online
|
||||||
|
elif [ $type -eq 3 ]; then
|
||||||
|
limiter_user
|
||||||
|
elif [ $type -eq 4 ]; then
|
||||||
|
check_data
|
||||||
|
elif [ $type -eq 5 ]; then
|
||||||
|
check_dias
|
||||||
|
elif [ $type -eq 6 ]; then
|
||||||
|
check_new_data
|
||||||
|
elif [ $type -eq 7 ]; then
|
||||||
|
datacheck_new
|
||||||
|
fi
|
||||||
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/check-O
Normal file
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/check-O
Normal file
Binary file not shown.
30
.exp/scripts/repos/LATAM_Oficial/Ejecutables/check-update
Normal file
30
.exp/scripts/repos/LATAM_Oficial/Ejecutables/check-update
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
last_check_file="/etc/SCRIPT-LATAM/temp/last_check"
|
||||||
|
server_url="http://155.138.245.13:81/RegKey/BanKeyID"
|
||||||
|
ban_status_file="/etc/SCRIPT-LATAM/temp/ban_status"
|
||||||
|
if [[ -f "$last_check_file" && $(find "$last_check_file" -mmin +60 -print) ]]; then
|
||||||
|
ip=$(wget -qO- ipinfo.io/ip || wget -qO- ifconfig.me)
|
||||||
|
if curl -sSL "$server_url" | grep -q "$ip"; then
|
||||||
|
echo "banned" >"$ban_status_file"
|
||||||
|
echo -e "\a\a\a\a"
|
||||||
|
echo -e "\n\n\033[1;31m————————————————————————————————————————————————————\n ¡KEY POSIBLEMENTE NO REGISTRADA! CONTATE A \e[1;93m@Kalix1\033[1;31m \n————————————————————————————————————————————————————\n"
|
||||||
|
echo -e " \e[1;32m --- CONSULTANDO BASE DE IP DE NUEVO --- " | pv -qL 10
|
||||||
|
echo -e "\n \e[1;93m --- DIGITE DENUEVO \e[1;97mmenu \e[1;93m --- " | pv -qL 10
|
||||||
|
echo -e "\n\033[1;31m————————————————————————————————————————————————————\n\n"
|
||||||
|
pid=$(cat /etc/SCRIPT-LATAM/temp/menuid)
|
||||||
|
kill "$pid"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "not_banned" >"$ban_status_file"
|
||||||
|
fi
|
||||||
|
date "+%Y-%m-%d %H:%M:%S" >"$last_check_file"
|
||||||
|
else
|
||||||
|
status=$(cat "$ban_status_file")
|
||||||
|
if [[ "$status" == "banned" ]]; then
|
||||||
|
pid=$(cat /etc/SCRIPT-LATAM/temp/menuid)
|
||||||
|
kill "$pid"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "" &>/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
50
.exp/scripts/repos/LATAM_Oficial/Ejecutables/check.py
Normal file
50
.exp/scripts/repos/LATAM_Oficial/Ejecutables/check.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
from crypt import methods
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import typing as t
|
||||||
|
import json
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from flask import Flask, jsonify, url_for, request, redirect
|
||||||
|
|
||||||
|
LISTENING_PORT = int(sys.argv[1])
|
||||||
|
FORMATO = sys.argv[2]
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True
|
||||||
|
app.config['JSON_SORT_KEYS'] = False
|
||||||
|
|
||||||
|
def get_user(username: str) -> t.Optional[str]:
|
||||||
|
if FORMATO == '1':
|
||||||
|
command = 'check %s 6' % username
|
||||||
|
result = os.popen(command).readlines()
|
||||||
|
final = result[0].strip()
|
||||||
|
return final
|
||||||
|
elif FORMATO == '2':
|
||||||
|
command = 'check %s 7' % username
|
||||||
|
result = os.popen(command).readlines()
|
||||||
|
final = result[0].strip()
|
||||||
|
return final
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/checkUser',methods = ['POST', 'GET'])
|
||||||
|
def check_user():
|
||||||
|
if request.method == 'POST':
|
||||||
|
try:
|
||||||
|
req_data = request.get_json()
|
||||||
|
user = req_data.get("user")
|
||||||
|
x = get_user(user)
|
||||||
|
return x
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'error': str(e)})
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
return 'Cannot GET /checkUser'
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'error': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(
|
||||||
|
host='0.0.0.0',
|
||||||
|
port=int(sys.argv[1]) if len(sys.argv) > 1 else LISTENING_PORT,
|
||||||
|
)
|
||||||
85
.exp/scripts/repos/LATAM_Oficial/Ejecutables/colores
Normal file
85
.exp/scripts/repos/LATAM_Oficial/Ejecutables/colores
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#Colores Instalador
|
||||||
|
msgi() {
|
||||||
|
BLANCO='\033[1;37m' && ROJO='\e[1;31m' && VERDE='\e[32m' && AMARELO='\e[33m'
|
||||||
|
AZUL='\e[34m' && MAGENTA='\e[35m' && MAG='\033[1;36m' && NEGRITA='\e[1m' && SINCOLOR='\e[0m'
|
||||||
|
case $1 in
|
||||||
|
-ne) cor="${ROJO}${NEGRITA}" && echo -ne "${cor}${2}${SINCOLOR}" ;;
|
||||||
|
-ama) cor="${AMARELO}${NEGRITA}" && echo -e "${cor}${2}${SINCOLOR}" ;;
|
||||||
|
-verm) cor="${AMARELO}${NEGRITA}[!] ${ROJO}" && echo -e "${cor}${2}${SINCOLOR}" ;;
|
||||||
|
-azu) cor="${MAG}${NEGRITA}" && echo -e "${cor}${2}${SINCOLOR}" ;;
|
||||||
|
-verd) cor="${VERDE}${NEGRITA}" && echo -e "${cor}${2}${SINCOLOR}" ;;
|
||||||
|
-bra) cor="${ROJO}" && echo -ne "${cor}${2}${SINCOLOR}" ;;
|
||||||
|
"-bar2" | "-bar") cor="${ROJO}════════════════════════════════════════════════════" && echo -e "${SINCOLOR}${cor}${SINCOLOR}" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
# ------- BARRA DE INTALL BASICO
|
||||||
|
barra_intallb() {
|
||||||
|
comando="$1"
|
||||||
|
_=$(
|
||||||
|
$comando >/dev/null 2>&1
|
||||||
|
) &
|
||||||
|
>/dev/null
|
||||||
|
pid=$!
|
||||||
|
while [[ -d /proc/$pid ]]; do
|
||||||
|
echo -ne " \033[1;33m["
|
||||||
|
for ((i = 0; i < 40; i++)); do
|
||||||
|
echo -ne "\033[1;31m>"
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
echo -ne "\033[1;33m]"
|
||||||
|
sleep 1s
|
||||||
|
echo
|
||||||
|
tput cuu1 && tput dl1
|
||||||
|
done
|
||||||
|
echo -ne " \033[1;33m[\033[1;31m>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[1;33m] - \033[1;32m OK \033[0m\n"
|
||||||
|
sleep 1s
|
||||||
|
}
|
||||||
|
# ------- BARRA DE INSTALL PAQUETES
|
||||||
|
barra_intall() {
|
||||||
|
comando="$1"
|
||||||
|
_=$(
|
||||||
|
$comando >/dev/null 2>&1
|
||||||
|
) &
|
||||||
|
>/dev/null
|
||||||
|
pid=$!
|
||||||
|
while [[ -d /proc/$pid ]]; do
|
||||||
|
echo -ne " \033[1;33m["
|
||||||
|
for ((i = 0; i < 20; i++)); do
|
||||||
|
echo -ne "\033[1;31m>"
|
||||||
|
sleep 0.08
|
||||||
|
done
|
||||||
|
echo -ne "\033[1;33m]"
|
||||||
|
sleep 0.5s
|
||||||
|
echo
|
||||||
|
tput cuu1 && tput dl1
|
||||||
|
done
|
||||||
|
[[ $(dpkg --get-selections | grep -w "$paquete" | head -1) ]] || ESTATUS=$(echo -e "\033[91m FALLO DE INSTALACION") &>/dev/null
|
||||||
|
[[ $(dpkg --get-selections | grep -w "$paquete" | head -1) ]] && ESTATUS=$(echo -e "\033[1;33m \033[92mINSTALADO") &>/dev/null
|
||||||
|
echo -ne " \033[1;33m[\033[1;31m>>>>>>>>>>>>>>>>>>>>\033[1;33m] $ESTATUS \033[0m\n"
|
||||||
|
sleep 0.5s
|
||||||
|
}
|
||||||
|
# ------- BARRA CENTRADORA
|
||||||
|
print_center() {
|
||||||
|
if [[ -z $2 ]]; then
|
||||||
|
text="$1"
|
||||||
|
else
|
||||||
|
col="$1"
|
||||||
|
text="$2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read line; do
|
||||||
|
unset space
|
||||||
|
x=$(((54 - ${#line}) / 2))
|
||||||
|
for ((i = 0; i < $x; i++)); do
|
||||||
|
space+=' '
|
||||||
|
done
|
||||||
|
space+="$line"
|
||||||
|
if [[ -z $2 ]]; then
|
||||||
|
msgi -azu "$space"
|
||||||
|
else
|
||||||
|
msgi "$col" "$space"
|
||||||
|
fi
|
||||||
|
done <<<$(echo -e "$text")
|
||||||
|
}
|
||||||
33
.exp/scripts/repos/LATAM_Oficial/Ejecutables/common-password
Normal file
33
.exp/scripts/repos/LATAM_Oficial/Ejecutables/common-password
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#
|
||||||
|
# /etc/pam.d/common-password - password-related modules common to all services
|
||||||
|
#
|
||||||
|
# This file is included from other service-specific PAM config files,
|
||||||
|
# and should contain a list of modules that define the services to be
|
||||||
|
# used to change user passwords. The default is pam_unix.
|
||||||
|
|
||||||
|
# Explanation of pam_unix options:
|
||||||
|
#
|
||||||
|
# The "sha512" option enables salted SHA512 passwords. Without this option,
|
||||||
|
# the default is Unix crypt. Prior releases used the option "md5".
|
||||||
|
#
|
||||||
|
# The "obscure" option replaces the old `OBSCURE_CHECKS_ENAB' option in
|
||||||
|
# login.defs.
|
||||||
|
#
|
||||||
|
# See the pam_unix manpage for other options.
|
||||||
|
|
||||||
|
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
|
||||||
|
# To take advantage of this, it is recommended that you configure any
|
||||||
|
# local modules either before or after the default block, and use
|
||||||
|
# pam-auth-update to manage selection of other modules. See
|
||||||
|
# pam-auth-update(8) for details.
|
||||||
|
|
||||||
|
# here are the per-package modules (the "Primary" block)
|
||||||
|
password [success=1 default=ignore] pam_unix.so obscure sha512
|
||||||
|
# here's the fallback if no module succeeds
|
||||||
|
password requisite pam_deny.so
|
||||||
|
# prime the stack with a positive return value if there isn't one already;
|
||||||
|
# this avoids us returning an error just because nothing sets a success code
|
||||||
|
# since the modules above will each just jump around
|
||||||
|
password required pam_permit.so
|
||||||
|
# and here are more per-package modules (the "Additional" block)
|
||||||
|
# end of pam-auth-update config
|
||||||
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/dns-server
Normal file
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/dns-server
Normal file
Binary file not shown.
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Mi script de inicio
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
ExecStart=/bin/autoinicios
|
||||||
|
StandardOutput=null
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
13
.exp/scripts/repos/LATAM_Oficial/Ejecutables/notify-lroot.sh
Normal file
13
.exp/scripts/repos/LATAM_Oficial/Ejecutables/notify-lroot.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
##-->>AVISO DE LOGIN ROOT
|
||||||
|
notify() {
|
||||||
|
|
||||||
|
KEY=$(cat /etc/SCRIPT-LATAM/temp/keyapk)
|
||||||
|
if [ "$(whoami)" = "root" ]; then
|
||||||
|
IP=$(echo $SSH_CONNECTION | awk '{print $1}')
|
||||||
|
LOCATION=$(curl -s "http://api.ipapi.com/$IP?access_key=751c2a246e5cbeb5d89d5a6663b64ff7&format=2" | jq -r '.country_name')
|
||||||
|
LOCATION2=${LOCATION// /+}
|
||||||
|
curl -s "http://xdroid.net/api/message?k=$KEY&t=%F0%9F%93%A3+Login+ROOT+Detectado+%E2%9D%95&c=%F0%9F%96%A5%EF%B8%8F+VPS%3A+KALIX1%0A%F0%9F%8C%90+IP%3A+$IP%0A%F0%9F%97%BA%EF%B8%8F+GEO%3A+$LOCATION2%0A%E2%9A%A0%EF%B8%8FHacer+caso+omiso+a+este+mensaje+encaso+de+que+usted+inicio+su+VPS%2C+si+no+cambie+su+pass+lo+antes+posible%E2%9A%A0%EF%B8%8F%0A%F0%9F%98%8E+By+SCRIPT+LATAM+%E2%9C%8C%EF%B8%8F"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
notify
|
||||||
551
.exp/scripts/repos/LATAM_Oficial/Ejecutables/rebootnb.sh
Normal file
551
.exp/scripts/repos/LATAM_Oficial/Ejecutables/rebootnb.sh
Normal file
@ -0,0 +1,551 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# LIMITADOR AUTO
|
||||||
|
find /etc/SCRIPT-LATAM/temp/RegTimeT -mmin +1440 -type f -delete >/dev/null 2>&1
|
||||||
|
[[ -e /etc/SCRIPT-LATAM/temp/RegTimeT ]] || {
|
||||||
|
check_keyoficial() {
|
||||||
|
IP=$(wget -qO- ipinfo.io/ip || wget -qO- ifconfig.me)
|
||||||
|
IP2="$IP"
|
||||||
|
permited=$(curl -sSL "https://raw.githubusercontent.com/NetVPS/LATAM_Oficial/main/IP-Block")
|
||||||
|
[[ $(echo $permited | grep "$IP2") = "" ]] || {
|
||||||
|
clear && clear
|
||||||
|
cat <<EOF >/usr/bin/menu
|
||||||
|
clear && clear
|
||||||
|
echo -e "\n\n\033[1;31m————————————————————————————————————————————————————\n ¡KEY POSIBLEMENTE NO REGISTRADA! CONTATE A \e[1;93m@Kalix1\033[1;31m \n————————————————————————————————————————————————————\n"
|
||||||
|
echo -e " \e[1;32m --- CONSULTANDO BASE DE IP DE NUEVO --- " | pv -qL 10
|
||||||
|
echo -e "\n \e[1;93m --- DIGITE DENUEVO \e[1;97mmenu \e[1;93m --- " | pv -qL 10
|
||||||
|
echo -e "\n\033[1;31m————————————————————————————————————————————————————\n\n"
|
||||||
|
echo "/etc/SCRIPT-LATAM/menu.sh" >/usr/bin/menu && chmod +x /usr/bin/menu
|
||||||
|
echo "/etc/SCRIPT-LATAM/menu.sh" >/usr/bin/MENU && chmod +x /usr/bin/MENU
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF >/usr/bin/MENU
|
||||||
|
clear && clear
|
||||||
|
echo -e "\n\n\033[1;31m————————————————————————————————————————————————————\n ¡KEY POSIBLEMENTE NO REGISTRADA! CONTATE A \e[1;93m@Kalix1\033[1;31m \n————————————————————————————————————————————————————\n"
|
||||||
|
echo -e " \e[1;32m --- CONSULTANDO BASE DE IP DE NUEVO --- " | pv -qL 10
|
||||||
|
echo -e "\n \e[1;93m --- DIGITE DENUEVO \e[1;97mmenu \e[1;93m --- " | pv -qL 10
|
||||||
|
echo -e "\n\033[1;31m————————————————————————————————————————————————————\n\n"
|
||||||
|
echo "/etc/SCRIPT-LATAM/menu.sh" >/usr/bin/menu && chmod +x /usr/bin/menu
|
||||||
|
echo "/etc/SCRIPT-LATAM/menu.sh" >/usr/bin/MENU && chmod +x /usr/bin/MENU
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/bin/menu
|
||||||
|
chmod +x /usr/bin/MENU
|
||||||
|
echo -e "\a\a\a\a"
|
||||||
|
echo -e "\n\n\033[1;31m————————————————————————————————————————————————————\n ¡KEY POSIBLEMENTE NO REGISTRADA! CONTATE A \e[1;93m@Kalix1\033[1;31m \n————————————————————————————————————————————————————\n"
|
||||||
|
echo -e " \e[1;32m --- CONSULTANDO BASE DE IP DE NUEVO --- " | pv -qL 10
|
||||||
|
echo -e "\n \e[1;93m --- DIGITE DENUEVO \e[1;97mmenu \e[1;93m --- " | pv -qL 10
|
||||||
|
echo -e "\n\033[1;31m————————————————————————————————————————————————————\n\n"
|
||||||
|
|
||||||
|
kill -9 $(ps aux | grep -v grep | grep -w menu.sh | grep '' | awk '{print $2}') &
|
||||||
|
exit
|
||||||
|
} && {
|
||||||
|
echo "Actulizacion OFF" >/etc/SCRIPT-LATAM/temp/RegTimeT
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
check_keyoficial &
|
||||||
|
}
|
||||||
|
|
||||||
|
#BACKUP BASE DE USER
|
||||||
|
backupbase_fun() {
|
||||||
|
find /etc/SCRIPT-LATAM/backuplog -mtime +7 -type f -delete
|
||||||
|
Fecha=$(date +%d-%m-%y-%R)
|
||||||
|
rm -rf /etc/SCRIPT-LATAM/backuplog/principal/*
|
||||||
|
mkdir -p /etc/SCRIPT-LATAM/backuplog/principal
|
||||||
|
cp /etc/SCRIPT-LATAM/cuentassh /etc/SCRIPT-LATAM/backuplog/principal/cuentassh
|
||||||
|
cp /etc/SCRIPT-LATAM/cuentahwid /etc/SCRIPT-LATAM/backuplog/principal/cuentahwid
|
||||||
|
cp /etc/SCRIPT-LATAM/cuentatoken /etc/SCRIPT-LATAM/backuplog/principal/cuentatoken
|
||||||
|
cd /etc/SCRIPT-LATAM/backuplog
|
||||||
|
tar -czvf ./Backup-$Fecha.tar.gz principal >/dev/null 2>&1
|
||||||
|
cd
|
||||||
|
}
|
||||||
|
if [[ "$1" = "backbaseu" ]]; then
|
||||||
|
backupbase_fun >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg_reboot() {
|
||||||
|
sudo ufw disable >/dev/null 2>&1
|
||||||
|
[[ -e /etc/SCRIPT-LATAM/temp/idtelegram ]] && {
|
||||||
|
|
||||||
|
NOM=$(less /etc/SCRIPT-LATAM/temp/idtelegram) >/dev/null 2>&1
|
||||||
|
ID=$(echo $NOM) >/dev/null 2>&1
|
||||||
|
NOMG=$(less /etc/SCRIPT-LATAM/temp/idgrupo) >/dev/null 2>&1
|
||||||
|
IDG=$(echo $NOMG) >/dev/null 2>&1
|
||||||
|
NOM2=$(less /etc/SCRIPT-LATAM/temp/vpstelegram) >/dev/null 2>&1
|
||||||
|
VPS=$(echo $NOM2) >/dev/null 2>&1
|
||||||
|
KEY="5179637690:AAExt2gHMurxUmuJBdKJ6BCHg-D0Uzlt0rM"
|
||||||
|
TIMEOUT="10"
|
||||||
|
URL="https://api.telegram.org/bot$KEY/sendMessage"
|
||||||
|
SONIDO="0"
|
||||||
|
TEXTO="❗═════ *-REGISTRO-* ═════ ❗\n▫️ *>* VPS: *$VPS* \n🟢 ═ _ REINICIADA CON EXITO_ ═ 🟢"
|
||||||
|
#PV
|
||||||
|
curl -s --max-time $TIMEOUT -d "parse_mode=Markdown&disable_notification=$SONIDO&chat_id=$ID&disable_web_page_preview=1&text=$(echo -e "$TEXTO")" $URL
|
||||||
|
echo "" &>/dev/null
|
||||||
|
#GP
|
||||||
|
curl -s --max-time $TIMEOUT -d "parse_mode=Markdown&disable_notification=$SONIDO&chat_id=$IDG &disable_web_page_preview=1&text=$(echo -e "$TEXTO")" $URL
|
||||||
|
echo "" &>/dev/null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if [[ "$1" = "reboot" ]]; then
|
||||||
|
msg_reboot >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# LIMITADOR AUTO
|
||||||
|
msg_login() {
|
||||||
|
sudo ufw disable >/dev/null 2>&1
|
||||||
|
[[ -e /etc/SCRIPT-LATAM/temp/idtelegram ]] && {
|
||||||
|
|
||||||
|
NOM=$(less /etc/SCRIPT-LATAM/temp/idtelegram) >/dev/null 2>&1
|
||||||
|
ID=$(echo $NOM) >/dev/null 2>&1
|
||||||
|
NOMG=$(less /etc/SCRIPT-LATAM/temp/idgrupo) >/dev/null 2>&1
|
||||||
|
IDG=$(echo $NOMG) >/dev/null 2>&1
|
||||||
|
NOM2=$(less /etc/SCRIPT-LATAM/temp/vpstelegram) >/dev/null 2>&1
|
||||||
|
VPS=$(echo $NOM2) >/dev/null 2>&1
|
||||||
|
KEY="5179637690:AAExt2gHMurxUmuJBdKJ6BCHg-D0Uzlt0rM"
|
||||||
|
TIMEOUT="10"
|
||||||
|
URL="https://api.telegram.org/bot$KEY/sendMessage"
|
||||||
|
SONIDO="0"
|
||||||
|
TEXTO="❗═════ *-REGISTRO-* ═════ ❗\n▫️ *>* VPS: *$VPS* \n▫️ *>* EN IP: $(echo $SSH_CLIENT | awk '{ print $1}')\n⚠️ ═ _ LOGIN ROOT DETECTADO_ ═ ⚠️"
|
||||||
|
curl -s --max-time $TIMEOUT -d "parse_mode=Markdown&disable_notification=$SONIDO&chat_id=$ID&disable_web_page_preview=1&text=$(echo -e "$TEXTO")" $URL
|
||||||
|
echo "" &>/dev/null
|
||||||
|
#GP
|
||||||
|
curl -s --max-time $TIMEOUT -d "parse_mode=Markdown&disable_notification=$SONIDO&chat_id=$IDG &disable_web_page_preview=1&text=$(echo -e "$TEXTO")" $URL
|
||||||
|
echo "" &>/dev/null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if [[ "$1" = "login" ]]; then
|
||||||
|
msg_login >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# REINICIO DE SERVICE
|
||||||
|
reset_service() {
|
||||||
|
service dropbear stop &>/dev/null
|
||||||
|
sed -i "s/=1/=0/g" /etc/default/dropbear &>/dev/null
|
||||||
|
service dropbear restart &>/dev/null
|
||||||
|
sed -i "s/=0/=1/g" /etc/default/dropbear &>/dev/null
|
||||||
|
service ssh restart &>/dev/null
|
||||||
|
}
|
||||||
|
if [[ "$1" = "service" ]]; then
|
||||||
|
reset_service >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
#---------------------------AUTO INICIO---------------------------#
|
||||||
|
# REINICIO DE BADVPN
|
||||||
|
reset_badvpn() {
|
||||||
|
portasx=$(cat /etc/SCRIPT-LATAM/PortM/Badvpn.log)
|
||||||
|
totalporta=($portasx)
|
||||||
|
for ((i = 0; i < ${#totalporta[@]}; i++)); do
|
||||||
|
screen -dmS badvpn /bin/badvpn-udpgw --listen-addr 127.0.0.1:${totalporta[$i]} --max-clients 1000 --max-connections-for-client 10
|
||||||
|
done
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetbadvpn" ]]; then
|
||||||
|
reset_badvpn >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AUTO WEBSOKET
|
||||||
|
reset_psoket() {
|
||||||
|
for portdic in $(cat /etc/SCRIPT-LATAM/PortM/PDirect.log); do
|
||||||
|
screen -dmS pydic-"$portdic" python /etc/SCRIPT-LATAM/filespy/PDirect-$portdic.py
|
||||||
|
done
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetwebsocket" ]]; then
|
||||||
|
reset_psoket >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AUTO MONITOR PROTO
|
||||||
|
resetprotos_fun() {
|
||||||
|
tiemmoni=$(cat /etc/SCRIPT-LATAM/temp/T-Mon)
|
||||||
|
screen -dmS monitorproto watch -n $tiemmoni /etc/SCRIPT-LATAM/menu.sh "monitorservi"
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetprotos" ]]; then
|
||||||
|
resetprotos_fun >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AUTO LIMITADOR
|
||||||
|
resetlimitador_fun() {
|
||||||
|
tiemlim=$(cat /etc/SCRIPT-LATAM/temp/T-Lim)
|
||||||
|
screen -dmS limitador watch -n $tiemlim /etc/SCRIPT-LATAM/menu.sh "verificar"
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetlimitador" ]]; then
|
||||||
|
resetlimitador_fun >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AUTO DESBLOQUEO
|
||||||
|
resetdesbloqueador_fun() {
|
||||||
|
tiemdes=$(cat /etc/SCRIPT-LATAM/temp/T-Des)
|
||||||
|
screen -dmS desbloqueador watch -n $tiemdes /etc/SCRIPT-LATAM/menu.sh "desbloqueo"
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetdesbloqueador" ]]; then
|
||||||
|
resetdesbloqueador_fun >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#---------------------------MONITOR DE PROTOCOLOS---------------------------#
|
||||||
|
#--AVISO DE SERVIDOR
|
||||||
|
|
||||||
|
msg_service() {
|
||||||
|
[[ -e /etc/SCRIPT-LATAM/temp/idtelegram ]] && {
|
||||||
|
|
||||||
|
NOM=$(less /etc/SCRIPT-LATAM/temp/idtelegram) >/dev/null 2>&1
|
||||||
|
ID=$(echo $NOM) >/dev/null 2>&1
|
||||||
|
NOMG=$(less /etc/SCRIPT-LATAM/temp/idgrupo) >/dev/null 2>&1
|
||||||
|
IDG=$(echo $NOMG) >/dev/null 2>&1
|
||||||
|
NOM2=$(less /etc/SCRIPT-LATAM/temp/vpstelegram) >/dev/null 2>&1
|
||||||
|
VPS=$(echo $NOM2) >/dev/null 2>&1
|
||||||
|
KEY="5179637690:AAExt2gHMurxUmuJBdKJ6BCHg-D0Uzlt0rM"
|
||||||
|
TIMEOUT="10"
|
||||||
|
URL="https://api.telegram.org/bot$KEY/sendMessage"
|
||||||
|
SONIDO="0"
|
||||||
|
TEXTO="❗═ *- FALLA DETECTADA -*═ ❗\n⚙️ _ -- $1 REINICIADO --_ ⚙️ \n▫️ *>* EN VPS: *$VPS* "
|
||||||
|
curl -s --max-time $TIMEOUT -d "parse_mode=Markdown&disable_notification=$SONIDO&chat_id=$ID&disable_web_page_preview=1&text=$(echo -e "$TEXTO")" $URL
|
||||||
|
echo "" &>/dev/null
|
||||||
|
#GP
|
||||||
|
curl -s --max-time $TIMEOUT -d "parse_mode=Markdown&disable_notification=$SONIDO&chat_id=$IDG &disable_web_page_preview=1&text=$(echo -e "$TEXTO")" $URL
|
||||||
|
echo "" &>/dev/null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#--- REINICIAR SSH
|
||||||
|
reset_ssh() {
|
||||||
|
|
||||||
|
# BACKUP DIARIO
|
||||||
|
find /etc/SCRIPT-LATAM/temp/BackTotal -mmin +1440 -type f -delete >/dev/null 2>&1
|
||||||
|
[[ -e /etc/SCRIPT-LATAM/temp/BackTotal ]] || {
|
||||||
|
|
||||||
|
rm -rf /root/Backup-Latam.tar.gz >/dev/null 2>&1
|
||||||
|
mkdir /root/backup-latam/
|
||||||
|
export UGIDLIMIT=1000
|
||||||
|
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd >/root/backup-latam/passwd.mig
|
||||||
|
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group >/root/backup-latam/group.mig
|
||||||
|
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - | egrep -f - /etc/shadow >/root/backup-latam/shadow.mig
|
||||||
|
cp /etc/gshadow /root/backup-latam/gshadow.mig >/dev/null 2>&1
|
||||||
|
cp /etc/SCRIPT-LATAM/cuentassh /root/backup-latam/cuentassh >/dev/null 2>&1
|
||||||
|
cp /etc/SCRIPT-LATAM/cuentahwid /root/backup-latam/cuentahwid >/dev/null 2>&1
|
||||||
|
cp /etc/SCRIPT-LATAM/cuentatoken /root/backup-latam/cuentatoken >/dev/null 2>&1
|
||||||
|
cp /etc/SCRIPT-LATAM/temp/.passw /root/backup-latam/.passw >/dev/null 2>&1
|
||||||
|
tar -zcvpf /root/backup-latam/home.tar.gz /home >/dev/null 2>&1
|
||||||
|
cd /root
|
||||||
|
tar -czvf Backup-Latam.tar.gz backup-latam >/dev/null 2>&1
|
||||||
|
[[ -e /etc/SCRIPT-LATAM/temp/idtelegram ]] && {
|
||||||
|
NOM=$(less /etc/SCRIPT-LATAM/temp/idtelegram) >/dev/null 2>&1
|
||||||
|
ID=$(echo $NOM) >/dev/null 2>&1
|
||||||
|
NOMG=$(less /etc/SCRIPT-LATAM/temp/idgrupo) >/dev/null 2>&1
|
||||||
|
IDG=$(echo $NOMG) >/dev/null 2>&1
|
||||||
|
NOM2=$(less /etc/SCRIPT-LATAM/temp/vpstelegram) >/dev/null 2>&1
|
||||||
|
VPS=$(echo $NOM2) >/dev/null 2>&1
|
||||||
|
KEY="5179637690:AAExt2gHMurxUmuJBdKJ6BCHg-D0Uzlt0rM"
|
||||||
|
TIMEOUT="10"
|
||||||
|
URL="https://api.telegram.org/bot$KEY/sendMessage"
|
||||||
|
SONIDO="0"
|
||||||
|
TEXTO="❗═════ *-REGISTRO-* ═════ ❗\n▫️ *>* VPS: *$VPS* \n⚠️ ══ _ BACKUP DIARIO _ ══ ⚠️"
|
||||||
|
#DOCL
|
||||||
|
Fecha=$(date +%d-%m-%y)
|
||||||
|
URL2="https://api.telegram.org/bot$KEY/sendDocument"
|
||||||
|
FILE="/root/backup-latam/Backup-Latam.tar.gz"
|
||||||
|
curl --fail -F chat_id="$ID" -F caption="$VPS | Fecha: $Fecha" -F document=@"$FILE" $URL2 --connect-timeout 0
|
||||||
|
echo "" &>/dev/null
|
||||||
|
}
|
||||||
|
echo "Backup Diario Activo | $Fecha " >/etc/SCRIPT-LATAM/temp/BackTotal
|
||||||
|
} &>/dev/null
|
||||||
|
|
||||||
|
SSH=$(ps x | grep "/usr/sbin/sshd" | grep -v "grep" | awk -F "pts" '{print $1}')
|
||||||
|
if [[ ! $SSH ]]; then
|
||||||
|
service ssh restart
|
||||||
|
msg_service SSH
|
||||||
|
else
|
||||||
|
echo "ok"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetssh" ]]; then
|
||||||
|
reset_ssh >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--- REINICIAR SSL
|
||||||
|
reset_ssl() {
|
||||||
|
SSL=$(ps x | grep "stunnel4" | grep -v "grep" | awk -F "pts" '{print $1}')
|
||||||
|
if [[ ! $SSL ]]; then
|
||||||
|
service stunnel4 restart
|
||||||
|
msg_service SSL
|
||||||
|
else
|
||||||
|
echo "ok"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetssl" ]]; then
|
||||||
|
reset_ssl >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--- REINICIAR DROPBEAR
|
||||||
|
reset_drop() {
|
||||||
|
DROPBEAR=$(ps x | grep "/usr/sbin/dropbear" | grep -v "grep" | awk -F "pts" '{print $1}')
|
||||||
|
if [[ ! $DROPBEAR ]]; then
|
||||||
|
sed -i "s/=1/=0/g" /etc/default/dropbear
|
||||||
|
service dropbear restart
|
||||||
|
sed -i "s/=0/=1/g" /etc/default/dropbear
|
||||||
|
#msg_service DROPBEAR
|
||||||
|
else
|
||||||
|
echo "ok"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetdropbear" ]]; then
|
||||||
|
reset_drop >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--- REINICIAR SQUID
|
||||||
|
reset_squid() {
|
||||||
|
SQUID=$(ps x | grep "/usr/sbin/squid" | grep -v "grep" | awk -F "pts" '{print $1}')
|
||||||
|
if [[ ! $SQUID ]]; then
|
||||||
|
service squid restart
|
||||||
|
msg_service SQUID
|
||||||
|
else
|
||||||
|
echo "ok"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetsquid" ]]; then
|
||||||
|
reset_squid >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--- REINICIAR APACHE
|
||||||
|
reset_apache() {
|
||||||
|
APACHE=$(ps x | grep "apache" | grep -v "grep" | awk -F "pts" '{print $1}')
|
||||||
|
if [[ ! $APACHE ]]; then
|
||||||
|
service apache2 restart
|
||||||
|
msg_service APACHE
|
||||||
|
else
|
||||||
|
echo "ok"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetapache" ]]; then
|
||||||
|
reset_apache >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--- REINICIAR V2RAY
|
||||||
|
reset_v2ray() {
|
||||||
|
V2RAY=$(ps x | grep "v2ray" | grep -v "grep" | awk -F "pts" '{print $1}')
|
||||||
|
if [[ ! $V2RAY ]]; then
|
||||||
|
service v2ray restart
|
||||||
|
msg_service V2RAY
|
||||||
|
else
|
||||||
|
echo "ok"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetv2ray" ]]; then
|
||||||
|
reset_v2ray >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--- REINICIAR WEBSOCKET
|
||||||
|
reset_websocket() {
|
||||||
|
for portdic in $(cat /etc/SCRIPT-LATAM/PortM/PDirect.log); do
|
||||||
|
|
||||||
|
WEBSOCKET=$(ps x | grep "pydic-$portdic" | grep -v "grep" | awk -F "pts" '{print $1}')
|
||||||
|
if [[ ! $WEBSOCKET ]]; then
|
||||||
|
screen -dmS pydic-"$portdic" python /etc/SCRIPT-LATAM/filespy/PDirect-$portdic.py
|
||||||
|
msg_service WEBSOCKET-$portdic
|
||||||
|
else
|
||||||
|
|
||||||
|
echo "ok"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
}
|
||||||
|
if [[ "$1" = "resetwebp" ]]; then
|
||||||
|
reset_websocket >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--- CONTADOR DE SSH TOTAL
|
||||||
|
ssh_total() {
|
||||||
|
mostrar_usuariossh() {
|
||||||
|
for u in $(cat /etc/SCRIPT-LATAM/cuentassh | cut -d'|' -f1); do
|
||||||
|
echo "$u"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
mostrar_usuariohwid() {
|
||||||
|
for u in $(cat /etc/SCRIPT-LATAM/cuentahwid | cut -d'|' -f1); do
|
||||||
|
echo "$u"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
mostrar_usuariotoken() {
|
||||||
|
for u in $(cat /etc/SCRIPT-LATAM/cuentatoken | cut -d'|' -f1); do
|
||||||
|
echo "$u"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
[[ -e "/etc/SCRIPT-LATAM/cuentassh" ]] && usuarios_ativos1=($(mostrar_usuariossh))
|
||||||
|
[[ -e "/etc/SCRIPT-LATAM/cuentahwid" ]] && usuarios_ativos2=($(mostrar_usuariohwid))
|
||||||
|
[[ -e "/etc/SCRIPT-LATAM/cuentatoken" ]] && usuarios_ativos3=($(mostrar_usuariotoken))
|
||||||
|
for us in $(echo ${usuarios_ativos1[@]}); do
|
||||||
|
echo "${us}"
|
||||||
|
done >/etc/SCRIPT-LATAM/cuentasactivast
|
||||||
|
for us in $(echo ${usuarios_ativos2[@]}); do
|
||||||
|
echo "${us}"
|
||||||
|
done >>/etc/SCRIPT-LATAM/cuentasactivast
|
||||||
|
for us in $(echo ${usuarios_ativos3[@]}); do
|
||||||
|
echo "${us}"
|
||||||
|
done >>/etc/SCRIPT-LATAM/cuentasactivast
|
||||||
|
mostrar_totales() {
|
||||||
|
for u in $(cat /etc/SCRIPT-LATAM/cuentasactivast | cut -d'|' -f1); do
|
||||||
|
echo "$u"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
SSH="$(wc -l /etc/SCRIPT-LATAM/cuentasactivast | awk '{print $1}')"
|
||||||
|
SSH2="$(echo ${SSH} | bc)0"
|
||||||
|
SSH3="/10"
|
||||||
|
echo "${SSH2}${SSH3}" | bc >/etc/SCRIPT-LATAM/temp/sshtotal
|
||||||
|
}
|
||||||
|
if [[ "$1" = "totallssh" ]]; then
|
||||||
|
ssh_total >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#---CONTADOR ONLINE
|
||||||
|
contador_online() {
|
||||||
|
|
||||||
|
mostrar_totales() {
|
||||||
|
for u in $(cat /etc/SCRIPT-LATAM/cuentasactivast | cut -d'|' -f1); do
|
||||||
|
echo "$u"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
dropbear_pids() {
|
||||||
|
local pids
|
||||||
|
local portasVAR=$(lsof -V -i tcp -P -n | grep -v "ESTABLISHED" | grep -v "COMMAND" | grep "LISTEN")
|
||||||
|
local NOREPEAT
|
||||||
|
local reQ
|
||||||
|
local Port
|
||||||
|
while read port; do
|
||||||
|
reQ=$(echo ${port} | awk '{print $1}')
|
||||||
|
Port=$(echo {$port} | awk '{print $9}' | awk -F ":" '{print $2}')
|
||||||
|
[[ $(echo -e $NOREPEAT | grep -w "$Port") ]] && continue
|
||||||
|
NOREPEAT+="$Port\n"
|
||||||
|
case ${reQ} in
|
||||||
|
dropbear)
|
||||||
|
[[ -z $DPB ]] && local DPB=""
|
||||||
|
DPB+="$Port "
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done <<<"${portasVAR}"
|
||||||
|
[[ ! -z $DPB ]] && echo -e $DPB
|
||||||
|
#local port_dropbear="$DPB"
|
||||||
|
local port_dropbear=$(ps aux | grep dropbear | awk NR==1 | awk '{print $17;}')
|
||||||
|
cat /var/log/auth.log | grep -a -i dropbear | grep -a -i "Password auth succeeded" >/var/log/authday.log
|
||||||
|
#cat /var/log/auth.log|grep "$(date|cut -d' ' -f2,3)" > /var/log/authday.log
|
||||||
|
#cat /var/log/auth.log | tail -1000 >/var/log/authday.log
|
||||||
|
local log=/var/log/authday.log
|
||||||
|
local loginsukses='Password auth succeeded'
|
||||||
|
[[ -z $port_dropbear ]] && return 1
|
||||||
|
for port in $(echo $port_dropbear); do
|
||||||
|
for pidx in $(ps ax | grep dropbear | grep "$port" | awk -F" " '{print $1}'); do
|
||||||
|
pids="${pids}$pidx\n"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
for pid in $(echo -e "$pids"); do
|
||||||
|
pidlogs=$(grep $pid $log | grep "$loginsukses" | awk -F" " '{print $3}')
|
||||||
|
i=0
|
||||||
|
for pidend in $pidlogs; do
|
||||||
|
let i++
|
||||||
|
done
|
||||||
|
if [[ $pidend ]]; then
|
||||||
|
login=$(grep $pid $log | grep "$pidend" | grep "$loginsukses")
|
||||||
|
PID=$pid
|
||||||
|
user=$(echo $login | awk -F" " '{print $10}' | sed -r "s/'//g")
|
||||||
|
waktu=$(echo $login | awk -F" " '{print $2"-"$1,$3}')
|
||||||
|
[[ -z $user ]] && continue
|
||||||
|
echo "$user|$PID|$waktu"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
openvpn_pids() {
|
||||||
|
mostrar_usuariossh() {
|
||||||
|
for u in $(cat /etc/SCRIPT-LATAM/cuentassh | cut -d'|' -f1); do
|
||||||
|
echo "$u"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
byte() {
|
||||||
|
while read B dummy; do
|
||||||
|
[[ "$B" -lt 1024 ]] && echo "${B} bytes" && break
|
||||||
|
KB=$(((B + 512) / 1024))
|
||||||
|
[[ "$KB" -lt 1024 ]] && echo "${KB} Kb" && break
|
||||||
|
MB=$(((KB + 512) / 1024))
|
||||||
|
[[ "$MB" -lt 1024 ]] && echo "${MB} Mb" && break
|
||||||
|
GB=$(((MB + 512) / 1024))
|
||||||
|
[[ "$GB" -lt 1024 ]] && echo "${GB} Gb" && break
|
||||||
|
echo $(((GB + 512) / 1024)) terabytes
|
||||||
|
done
|
||||||
|
}
|
||||||
|
for user in $(mostrar_usuariossh); do
|
||||||
|
user="$(echo $user | sed -e 's/[^a-z0-9 -]//ig')"
|
||||||
|
[[ ! $(sed -n "/^${user},/p" /etc/openvpn/openvpn-status.log) ]] && continue
|
||||||
|
i=0
|
||||||
|
unset RECIVED
|
||||||
|
unset SEND
|
||||||
|
unset HOUR
|
||||||
|
while read line; do
|
||||||
|
IDLOCAL=$(echo ${line} | cut -d',' -f2)
|
||||||
|
RECIVED+="$(echo ${line} | cut -d',' -f3)+"
|
||||||
|
SEND+="$(echo ${line} | cut -d',' -f4)+"
|
||||||
|
DATESEC=$(date +%s --date="$(echo ${line} | cut -d',' -f5 | cut -d' ' -f1,2,3,4)")
|
||||||
|
TIMEON="$(($(date +%s) - ${DATESEC}))"
|
||||||
|
MIN=$(($TIMEON / 60)) && SEC=$(($TIMEON - $MIN * 60)) && HOR=$(($MIN / 60)) && MIN=$(($MIN - $HOR * 60))
|
||||||
|
HOUR+="${HOR}h:${MIN}m:${SEC}s\n"
|
||||||
|
let i++
|
||||||
|
done <<<"$(sed -n "/^${user},/p" /etc/openvpn/openvpn-status.log)"
|
||||||
|
RECIVED=$(echo $(echo ${RECIVED}0 | bc) | byte)
|
||||||
|
SEND=$(echo $(echo ${SEND}0 | bc) | byte)
|
||||||
|
HOUR=$(echo -e $HOUR | sort -n | tail -1)
|
||||||
|
echo -e "$user|$i|$RECIVED|$SEND|$HOUR"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ $(dpkg --get-selections | grep -w "openssh" | head -1) ]] && SSH=ON || SSH=OFF
|
||||||
|
[[ $(dpkg --get-selections | grep -w "dropbear" | head -1) ]] && DROP=ON || DROP=OFF
|
||||||
|
[[ $(dpkg --get-selections | grep -w "openvpn" | head -1) ]] && [[ -e /etc/openvpn/openvpn-status.log ]] && OPEN=ON || OPEN=OFF
|
||||||
|
while read user; do
|
||||||
|
|
||||||
|
#----CONTADOR DE ONLINES
|
||||||
|
PID="0+"
|
||||||
|
[[ $SSH = ON ]] && PID+="$(ps aux | grep -v grep | grep sshd | grep -w "$user" | grep -v root | wc -l 2>/dev/null)+"
|
||||||
|
[[ $DROP = ON ]] && PID+="$(dropbear_pids | grep -w "$user" | wc -l 2>/dev/null)+"
|
||||||
|
[[ $OPEN = ON ]] && [[ $(openvpn_pids | grep -w "$user" | cut -d'|' -f2) ]] && PID+="$(openvpn_pids | grep -w "$user" | cut -d'|' -f2)+"
|
||||||
|
ONLINES+="$(echo ${PID}0 | bc)+"
|
||||||
|
echo "${ONLINES}0" | bc >/etc/SCRIPT-LATAM/temp/Tonli
|
||||||
|
done <<<"$(mostrar_totales)"
|
||||||
|
}
|
||||||
|
if [[ "$1" = "contadortotal" ]]; then
|
||||||
|
contador_online >/dev/null 2>&1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
reset_drop() {
|
||||||
|
sed -i "s/=1/=0/g" /etc/default/dropbear
|
||||||
|
service dropbear restart
|
||||||
|
sed -i "s/=0/=1/g" /etc/default/dropbear
|
||||||
|
|
||||||
|
}
|
||||||
|
if [[ "$1" = "rd" ]]; then
|
||||||
|
fun_bar "reset_drop" "FIX BANNER DROPBEAR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
selec_lag() {
|
||||||
|
sudo apt-get -y install language-pack-en-base
|
||||||
|
export LANGUAGE=en_US.UTF-8 && export LANG=en_US.UTF-8 && export LC_ALL=en_US.UTF-8 && export LC_CTYPE="en_US.UTF-8" &&
|
||||||
|
locale-gen en_US.UTF-8
|
||||||
|
}
|
||||||
|
if [[ "$1" = "es" ]]; then
|
||||||
|
fun_bar "selec_lag" "FIX LEGUAGE"
|
||||||
|
sudo dpkg-reconfigure locales
|
||||||
|
fi
|
||||||
2013
.exp/scripts/repos/LATAM_Oficial/Ejecutables/speedtest.py
Normal file
2013
.exp/scripts/repos/LATAM_Oficial/Ejecutables/speedtest.py
Normal file
File diff suppressed because it is too large
Load Diff
27
.exp/scripts/repos/LATAM_Oficial/Ejecutables/sshd_config
Normal file
27
.exp/scripts/repos/LATAM_Oficial/Ejecutables/sshd_config
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Port 22
|
||||||
|
Protocol 2
|
||||||
|
KeyRegenerationInterval 3600
|
||||||
|
ServerKeyBits 1024
|
||||||
|
SyslogFacility AUTH
|
||||||
|
LogLevel INFO
|
||||||
|
LoginGraceTime 120
|
||||||
|
PermitRootLogin yes
|
||||||
|
StrictModes yes
|
||||||
|
RSAAuthentication yes
|
||||||
|
PubkeyAuthentication yes
|
||||||
|
IgnoreRhosts yes
|
||||||
|
RhostsRSAAuthentication no
|
||||||
|
HostbasedAuthentication no
|
||||||
|
PermitEmptyPasswords no
|
||||||
|
ChallengeResponseAuthentication no
|
||||||
|
PasswordAuthentication yes
|
||||||
|
X11Forwarding yes
|
||||||
|
X11DisplayOffset 10
|
||||||
|
PrintMotd no
|
||||||
|
PrintLastLog yes
|
||||||
|
TCPKeepAlive yes
|
||||||
|
#UseLogin no
|
||||||
|
AcceptEnv LANG LC_*
|
||||||
|
Subsystem sftp /usr/lib/openssh/sftp-server
|
||||||
|
UsePAM yes
|
||||||
|
|
||||||
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/udpServer
Normal file
BIN
.exp/scripts/repos/LATAM_Oficial/Ejecutables/udpServer
Normal file
Binary file not shown.
304
.exp/scripts/repos/LATAM_Oficial/Ejecutables/v2ray.sh
Normal file
304
.exp/scripts/repos/LATAM_Oficial/Ejecutables/v2ray.sh
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Author: Jrohy
|
||||||
|
# github: https://github.com/Jrohy/multi-v2ray
|
||||||
|
|
||||||
|
#定时任务北京执行时间(0~23)
|
||||||
|
BEIJING_UPDATE_TIME=3
|
||||||
|
|
||||||
|
#记录最开始运行脚本的路径
|
||||||
|
BEGIN_PATH=$(pwd)
|
||||||
|
|
||||||
|
#安装方式, 0为全新安装, 1为保留v2ray配置更新
|
||||||
|
INSTALL_WAY=0
|
||||||
|
|
||||||
|
#定义操作变量, 0为否, 1为是
|
||||||
|
HELP=0
|
||||||
|
|
||||||
|
REMOVE=0
|
||||||
|
|
||||||
|
CHINESE=0
|
||||||
|
|
||||||
|
BASE_SOURCE_PATH="https://multi.netlify.app"
|
||||||
|
|
||||||
|
UTIL_PATH="/etc/v2ray_util/util.cfg"
|
||||||
|
|
||||||
|
UTIL_CFG="$BASE_SOURCE_PATH/v2ray_util/util_core/util.cfg"
|
||||||
|
|
||||||
|
BASH_COMPLETION_SHELL="$BASE_SOURCE_PATH/v2ray"
|
||||||
|
|
||||||
|
CLEAN_IPTABLES_SHELL="$BASE_SOURCE_PATH/v2ray_util/global_setting/clean_iptables.sh"
|
||||||
|
|
||||||
|
#Centos 临时取消别名
|
||||||
|
[[ -f /etc/redhat-release && -z $(echo $SHELL|grep zsh) ]] && unalias -a
|
||||||
|
|
||||||
|
[[ -z $(echo $SHELL|grep zsh) ]] && ENV_FILE=".bashrc" || ENV_FILE=".zshrc"
|
||||||
|
|
||||||
|
#######color code########
|
||||||
|
RED="31m"
|
||||||
|
GREEN="32m"
|
||||||
|
YELLOW="33m"
|
||||||
|
BLUE="36m"
|
||||||
|
FUCHSIA="35m"
|
||||||
|
|
||||||
|
colorEcho(){
|
||||||
|
COLOR=$1
|
||||||
|
echo -e "\033[${COLOR}${@:2}\033[0m"
|
||||||
|
}
|
||||||
|
|
||||||
|
#######get params#########
|
||||||
|
while [[ $# > 0 ]];do
|
||||||
|
key="$1"
|
||||||
|
case $key in
|
||||||
|
--remove)
|
||||||
|
REMOVE=1
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
HELP=1
|
||||||
|
;;
|
||||||
|
-k|--keep)
|
||||||
|
INSTALL_WAY=1
|
||||||
|
colorEcho ${BLUE} "keep config to update\n"
|
||||||
|
;;
|
||||||
|
--zh)
|
||||||
|
CHINESE=1
|
||||||
|
colorEcho ${BLUE} "安装中文版..\n"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# unknown option
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift # past argument or value
|
||||||
|
done
|
||||||
|
#############################
|
||||||
|
|
||||||
|
help(){
|
||||||
|
echo "bash v2ray.sh [-h|--help] [-k|--keep] [--remove]"
|
||||||
|
echo " -h, --help Show help"
|
||||||
|
echo " -k, --keep keep the config.json to update"
|
||||||
|
echo " --remove remove v2ray,xray && multi-v2ray"
|
||||||
|
echo " no params to new install"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
removeV2Ray() {
|
||||||
|
#卸载V2ray脚本
|
||||||
|
bash <(curl -L -s https://www.dropbox.com/s/33zgfxu20ln68s0/go.sh) --remove >/dev/null 2>&1
|
||||||
|
rm -rf /etc/v2ray >/dev/null 2>&1
|
||||||
|
rm -rf /var/log/v2ray >/dev/null 2>&1
|
||||||
|
|
||||||
|
#卸载Xray脚本
|
||||||
|
bash <(curl -L -s https://www.dropbox.com/s/33zgfxu20ln68s0/go.sh) --remove -x >/dev/null 2>&1
|
||||||
|
rm -rf /etc/xray >/dev/null 2>&1
|
||||||
|
rm -rf /var/log/xray >/dev/null 2>&1
|
||||||
|
|
||||||
|
#清理v2ray相关iptable规则
|
||||||
|
bash <(curl -L -s $CLEAN_IPTABLES_SHELL)
|
||||||
|
|
||||||
|
#卸载multi-v2ray
|
||||||
|
pip uninstall v2ray_util -y
|
||||||
|
rm -rf /usr/share/bash-completion/completions/v2ray.bash >/dev/null 2>&1
|
||||||
|
rm -rf /usr/share/bash-completion/completions/v2ray >/dev/null 2>&1
|
||||||
|
rm -rf /usr/share/bash-completion/completions/xray >/dev/null 2>&1
|
||||||
|
rm -rf /etc/bash_completion.d/v2ray.bash >/dev/null 2>&1
|
||||||
|
rm -rf /usr/local/bin/v2ray >/dev/null 2>&1
|
||||||
|
rm -rf /etc/v2ray_util >/dev/null 2>&1
|
||||||
|
rm -rf /etc/profile.d/iptables.sh >/dev/null 2>&1
|
||||||
|
rm -rf /root/.iptables >/dev/null 2>&1
|
||||||
|
|
||||||
|
#删除v2ray定时更新任务
|
||||||
|
crontab -l|sed '/SHELL=/d;/v2ray/d'|sed '/SHELL=/d;/xray/d' > crontab.txt
|
||||||
|
crontab crontab.txt >/dev/null 2>&1
|
||||||
|
rm -f crontab.txt >/dev/null 2>&1
|
||||||
|
|
||||||
|
if [[ ${PACKAGE_MANAGER} == 'dnf' || ${PACKAGE_MANAGER} == 'yum' ]];then
|
||||||
|
systemctl restart crond >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
systemctl restart cron >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#删除multi-v2ray环境变量
|
||||||
|
sed -i '/v2ray/d' ~/$ENV_FILE
|
||||||
|
sed -i '/xray/d' ~/$ENV_FILE
|
||||||
|
source ~/$ENV_FILE
|
||||||
|
|
||||||
|
RC_SERVICE=`systemctl status rc-local|grep loaded|egrep -o "[A-Za-z/]+/rc-local.service"`
|
||||||
|
|
||||||
|
RC_FILE=`cat $RC_SERVICE|grep ExecStart|awk '{print $1}'|cut -d = -f2`
|
||||||
|
|
||||||
|
sed -i '/iptables/d' ~/$RC_FILE
|
||||||
|
|
||||||
|
colorEcho ${GREEN} "uninstall success!"
|
||||||
|
}
|
||||||
|
|
||||||
|
closeSELinux() {
|
||||||
|
#禁用SELinux
|
||||||
|
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
|
||||||
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
||||||
|
setenforce 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
checkSys() {
|
||||||
|
#检查是否为Root
|
||||||
|
[ $(id -u) != "0" ] && { colorEcho ${RED} "Error: You must be root to run this script"; exit 1; }
|
||||||
|
|
||||||
|
if [[ `command -v apt-get` ]];then
|
||||||
|
PACKAGE_MANAGER='apt-get'
|
||||||
|
elif [[ `command -v dnf` ]];then
|
||||||
|
PACKAGE_MANAGER='dnf'
|
||||||
|
elif [[ `command -v yum` ]];then
|
||||||
|
PACKAGE_MANAGER='yum'
|
||||||
|
else
|
||||||
|
colorEcho $RED "Not support OS!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#安装依赖
|
||||||
|
installDependent(){
|
||||||
|
if [[ ${PACKAGE_MANAGER} == 'dnf' || ${PACKAGE_MANAGER} == 'yum' ]];then
|
||||||
|
${PACKAGE_MANAGER} install socat crontabs bash-completion which -y
|
||||||
|
else
|
||||||
|
${PACKAGE_MANAGER} update
|
||||||
|
${PACKAGE_MANAGER} install socat cron bash-completion ntpdate gawk -y
|
||||||
|
fi
|
||||||
|
|
||||||
|
#install python3 & pip
|
||||||
|
source <(curl -sL https://python3.netlify.app/install.sh)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProject() {
|
||||||
|
[[ ! $(type pip 2>/dev/null) ]] && colorEcho $RED "pip no install!" && exit 1
|
||||||
|
|
||||||
|
[[ -e /etc/profile.d/iptables.sh ]] && rm -f /etc/profile.d/iptables.sh
|
||||||
|
|
||||||
|
RC_SERVICE=`systemctl status rc-local|grep loaded|egrep -o "[A-Za-z/]+/rc-local.service"`
|
||||||
|
|
||||||
|
RC_FILE=`cat $RC_SERVICE|grep ExecStart|awk '{print $1}'|cut -d = -f2`
|
||||||
|
|
||||||
|
if [[ ! -e $RC_FILE || -z `cat $RC_FILE|grep iptables` ]];then
|
||||||
|
LOCAL_IP=`curl -s http://api.ipify.org 2>/dev/null`
|
||||||
|
[[ `echo $LOCAL_IP|grep :` ]] && IPTABLE_WAY="ip6tables" || IPTABLE_WAY="iptables"
|
||||||
|
if [[ ! -e $RC_FILE || -z `cat $RC_FILE|grep "/bin/bash"` ]];then
|
||||||
|
echo "#!/bin/bash" >> $RC_FILE
|
||||||
|
fi
|
||||||
|
if [[ -z `cat $RC_SERVICE|grep "\[Install\]"` ]];then
|
||||||
|
cat >> $RC_SERVICE << EOF
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
echo "[[ -e /root/.iptables ]] && $IPTABLE_WAY-restore -c < /root/.iptables" >> $RC_FILE
|
||||||
|
chmod +x $RC_FILE
|
||||||
|
systemctl restart rc-local
|
||||||
|
systemctl enable rc-local
|
||||||
|
|
||||||
|
$IPTABLE_WAY-save -c > /root/.iptables
|
||||||
|
fi
|
||||||
|
|
||||||
|
pip install -U v2ray_util
|
||||||
|
|
||||||
|
if [[ -e $UTIL_PATH ]];then
|
||||||
|
[[ -z $(cat $UTIL_PATH|grep lang) ]] && echo "lang=en" >> $UTIL_PATH
|
||||||
|
else
|
||||||
|
mkdir -p /etc/v2ray_util
|
||||||
|
curl $UTIL_CFG > $UTIL_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ $CHINESE == 1 ]] && sed -i "s/lang=en/lang=zh/g" $UTIL_PATH
|
||||||
|
|
||||||
|
rm -f /usr/local/bin/v2ray >/dev/null 2>&1
|
||||||
|
ln -s $(which v2ray-util) /usr/local/bin/v2ray
|
||||||
|
rm -f /usr/local/bin/xray >/dev/null 2>&1
|
||||||
|
ln -s $(which v2ray-util) /usr/local/bin/xray
|
||||||
|
|
||||||
|
#移除旧的v2ray bash_completion脚本
|
||||||
|
[[ -e /etc/bash_completion.d/v2ray.bash ]] && rm -f /etc/bash_completion.d/v2ray.bash
|
||||||
|
[[ -e /usr/share/bash-completion/completions/v2ray.bash ]] && rm -f /usr/share/bash-completion/completions/v2ray.bash
|
||||||
|
|
||||||
|
#更新v2ray bash_completion脚本
|
||||||
|
curl $BASH_COMPLETION_SHELL > /usr/share/bash-completion/completions/v2ray
|
||||||
|
curl $BASH_COMPLETION_SHELL > /usr/share/bash-completion/completions/xray
|
||||||
|
if [[ -z $(echo $SHELL|grep zsh) ]];then
|
||||||
|
source /usr/share/bash-completion/completions/v2ray
|
||||||
|
source /usr/share/bash-completion/completions/xray
|
||||||
|
fi
|
||||||
|
|
||||||
|
#安装V2ray主程序
|
||||||
|
[[ ${INSTALL_WAY} == 0 ]] && bash <(curl -L -s https://www.dropbox.com/s/33zgfxu20ln68s0/go.sh)
|
||||||
|
}
|
||||||
|
|
||||||
|
#时间同步
|
||||||
|
timeSync() {
|
||||||
|
if [[ ${INSTALL_WAY} == 0 ]];then
|
||||||
|
echo -e "${Info} Time Synchronizing.. ${Font}"
|
||||||
|
if [[ `command -v ntpdate` ]];then
|
||||||
|
ntpdate pool.ntp.org
|
||||||
|
elif [[ `command -v chronyc` ]];then
|
||||||
|
chronyc -a makestep
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $? -eq 0 ]];then
|
||||||
|
echo -e "${OK} Time Sync Success ${Font}"
|
||||||
|
echo -e "${OK} now: `date -R`${Font}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
profileInit() {
|
||||||
|
|
||||||
|
#清理v2ray模块环境变量
|
||||||
|
[[ $(grep v2ray ~/$ENV_FILE) ]] && sed -i '/v2ray/d' ~/$ENV_FILE && source ~/$ENV_FILE
|
||||||
|
|
||||||
|
#解决Python3中文显示问题
|
||||||
|
[[ -z $(grep PYTHONIOENCODING=utf-8 ~/$ENV_FILE) ]] && echo "export PYTHONIOENCODING=utf-8" >> ~/$ENV_FILE && source ~/$ENV_FILE
|
||||||
|
|
||||||
|
#全新安装的新配置
|
||||||
|
[[ ${INSTALL_WAY} == 0 ]] && v2ray new
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
installFinish() {
|
||||||
|
#回到原点
|
||||||
|
cd ${BEGIN_PATH}
|
||||||
|
|
||||||
|
[[ ${INSTALL_WAY} == 0 ]] && WAY="install" || WAY="update"
|
||||||
|
colorEcho ${GREEN} "multi-v2ray ${WAY} success!\n"
|
||||||
|
|
||||||
|
if [[ ${INSTALL_WAY} == 0 ]]; then
|
||||||
|
clear
|
||||||
|
|
||||||
|
v2ray info
|
||||||
|
|
||||||
|
echo -e "please input 'v2ray' command to manage v2ray\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main() {
|
||||||
|
|
||||||
|
[[ ${HELP} == 1 ]] && help && return
|
||||||
|
|
||||||
|
[[ ${REMOVE} == 1 ]] && removeV2Ray && return
|
||||||
|
|
||||||
|
[[ ${INSTALL_WAY} == 0 ]] && colorEcho ${BLUE} "new install\n"
|
||||||
|
|
||||||
|
checkSys
|
||||||
|
|
||||||
|
installDependent
|
||||||
|
|
||||||
|
closeSELinux
|
||||||
|
|
||||||
|
timeSync
|
||||||
|
|
||||||
|
updateProject
|
||||||
|
|
||||||
|
profileInit
|
||||||
|
|
||||||
|
installFinish
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
5
.exp/scripts/repos/LATAM_Oficial/Fixs Remotos/HELP.sh
Normal file
5
.exp/scripts/repos/LATAM_Oficial/Fixs Remotos/HELP.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Soporte Remoto (HELP)
|
||||||
|
echo "" >/dev/null 2>&1
|
||||||
|
wget https://raw.githubusercontent.com/NetVPS/LATAM_Oficial/main/Fixs%20Remotos/SOPORTE.sh -O /usr/bin/SOPORTE > /dev/null 2>&1
|
||||||
|
chmod +x /usr/bin/SOPORTE > /dev/null 2>&1
|
||||||
117
.exp/scripts/repos/LATAM_Oficial/Fixs Remotos/SOPORTE.sh
Normal file
117
.exp/scripts/repos/LATAM_Oficial/Fixs Remotos/SOPORTE.sh
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Soporte Remoto (SPR) #23-03-23
|
||||||
|
fun_bar() {
|
||||||
|
comando="$1"
|
||||||
|
fix=" \e[1;97m$2"
|
||||||
|
_=$(
|
||||||
|
$comando >/dev/null 2>&1
|
||||||
|
) &
|
||||||
|
>/dev/null
|
||||||
|
pid=$!
|
||||||
|
while [[ -d /proc/$pid ]]; do
|
||||||
|
echo -ne "\e[1;93m APLICANDO FIX:"$fix"\n \033[1;33m["
|
||||||
|
for ((i = 0; i < 10; i++)); do
|
||||||
|
echo -ne "\033[1;31m##"
|
||||||
|
sleep 0.2
|
||||||
|
done
|
||||||
|
echo -ne "\033[1;33m]"
|
||||||
|
sleep 1s
|
||||||
|
echo
|
||||||
|
tput cuu1 && tput dl1
|
||||||
|
tput cuu1 && tput dl1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -ne "\e[1;93m APLICANDO FIX:"$fix"\n \033[1;33m[\033[1;31m####################\033[1;33m] - \033[1;32mOK\033[0m\n"
|
||||||
|
sleep 1s
|
||||||
|
}
|
||||||
|
|
||||||
|
###CODIGO DE FIX
|
||||||
|
clear && clear
|
||||||
|
echo -e "\e[1;93m————————————————————————————————————————————————————"
|
||||||
|
echo -e "\033[1;97m VERIFICANDO ERRORES v1.8"
|
||||||
|
echo -e "\e[1;93m————————————————————————————————————————————————————"
|
||||||
|
reset_drop() {
|
||||||
|
sed -i "s/=1/=0/g" /etc/default/dropbear
|
||||||
|
service dropbear restart
|
||||||
|
sed -i "s/=0/=1/g" /etc/default/dropbear
|
||||||
|
}
|
||||||
|
if [[ "$1" = "rd" ]]; then
|
||||||
|
fun_bar "reset_drop" "FIX BANNER DROPBEAR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#CORREGIR IDIOMA DE SO A EN
|
||||||
|
selec_lag() {
|
||||||
|
sudo apt-get -y install language-pack-en-base
|
||||||
|
export LANGUAGE=en_US.UTF-8 && export LANG=en_US.UTF-8 && export LC_ALL=en_US.UTF-8 && export LC_CTYPE="en_US.UTF-8" &&
|
||||||
|
locale-gen en_US.UTF-8
|
||||||
|
}
|
||||||
|
if [[ "$1" = "en" ]]; then
|
||||||
|
fun_bar "selec_lag" "FIX LEGUAGE"
|
||||||
|
sudo dpkg-reconfigure locales
|
||||||
|
fi
|
||||||
|
|
||||||
|
#REINICIAR SERVICIOS SSH Y DROPBEAR
|
||||||
|
reset_service() {
|
||||||
|
service dropbear stop
|
||||||
|
service ssh restart
|
||||||
|
sed -i "s/=1/=0/g" /etc/default/dropbear
|
||||||
|
service dropbear restart
|
||||||
|
sed -i "s/=0/=1/g" /etc/default/dropbear
|
||||||
|
}
|
||||||
|
if [[ "$1" = "rs" ]]; then
|
||||||
|
fun_bar "reset_service" "FIX RESET SERVICE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#ELIMINAR USER MANUAL
|
||||||
|
del_usermanual(){
|
||||||
|
userdel --force $cuenta &>/dev/null
|
||||||
|
userb=$(cat /etc/SCRIPT-LATAM/cuentassh | grep -n -w "$cuenta" | cut -d'|' -f1 )
|
||||||
|
sed -i '/'${userb}'/d' /etc/SCRIPT-LATAM/cuentassh >/dev/null 2>&1
|
||||||
|
sed -i '/'$cuenta'/d' /etc/SCRIPT-LATAM/cuentahwid >/dev/null 2>&1
|
||||||
|
sed -i '/'$cuenta'/d' /etc/SCRIPT-LATAM/cuentatoken >/dev/null 2>&1
|
||||||
|
service dropbear stop
|
||||||
|
service ssh restart
|
||||||
|
sed -i "s/=1/=0/g" /etc/default/dropbear
|
||||||
|
service dropbear restart
|
||||||
|
sed -i "s/=0/=1/g" /etc/default/dropbear
|
||||||
|
}
|
||||||
|
cuenta="$2"
|
||||||
|
if [[ "$1" = "del" ]]; then
|
||||||
|
fun_bar "del_usermanual " "FORZANDO ELIMINACION DE USER"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# apt install at -y &>/dev/null
|
||||||
|
|
||||||
|
# echo "nameserver 1.1.1.1 " >/etc/resolv.conf
|
||||||
|
# echo "nameserver 1.0.0.1 " >>/etc/resolv.conf
|
||||||
|
|
||||||
|
# dpkg --configure -a >/dev/null 2>&1
|
||||||
|
# apt -f install -y >/dev/null 2>&1
|
||||||
|
|
||||||
|
# apt update >/dev/null 2>&1
|
||||||
|
# apt upgrade -y >/dev/null 2>&1
|
||||||
|
|
||||||
|
|
||||||
|
fix_ip() {
|
||||||
|
wget -O /bin/rebootnb https://raw.githubusercontent.com/NetVPS/LATAM_Oficial/main/Ejecutables/rebootnb.sh &>/dev/null
|
||||||
|
chmod +x /bin/rebootnb
|
||||||
|
|
||||||
|
wget -O /bin/check-update https://raw.githubusercontent.com/NetVPS/LATAM_Oficial/main/Ejecutables/check-update &>/dev/null
|
||||||
|
chmod +rwx /bin/check-update
|
||||||
|
|
||||||
|
cd /etc
|
||||||
|
wget https://raw.githubusercontent.com/NetVPS/LATAM_Oficial/main/SCRIPT-LATAM.tar.gz >/dev/null 2>&1
|
||||||
|
tar -xf SCRIPT-LATAM.tar.gz >/dev/null 2>&1
|
||||||
|
chmod +x SCRIPT-LATAM.tar.gz >/dev/null 2>&1
|
||||||
|
rm -rf SCRIPT-LATAM.tar.gz
|
||||||
|
cd
|
||||||
|
MEU_IP=$(wget -qO- ipinfo.io/ip || wget -qO- ifconfig.me)
|
||||||
|
echo "$MEU_IP" >/etc/SCRIPT-LATAM/MEUIPvps
|
||||||
|
}
|
||||||
|
if [[ "$1" = "ip" ]]; then
|
||||||
|
fun_bar "fix_ip" "FIX IP VPS LOCAL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "\e[1;93m————————————————————————————————————————————————————"
|
||||||
|
exit
|
||||||
5
.exp/scripts/repos/LATAM_Oficial/Fixs Remotos/SPR.sh
Normal file
5
.exp/scripts/repos/LATAM_Oficial/Fixs Remotos/SPR.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Soporte Remoto (SPR)
|
||||||
|
echo "" >/dev/null 2>&1
|
||||||
|
wget https://raw.githubusercontent.com/NetVPS/LATAM_Oficial/main/Fixs%20Remotos/SOPORTE.sh -O /usr/bin/SOPORTE > /dev/null 2>&1
|
||||||
|
chmod +x /usr/bin/SOPORTE > /dev/null 2>&1
|
||||||
2
.exp/scripts/repos/LATAM_Oficial/IP-Block
Normal file
2
.exp/scripts/repos/LATAM_Oficial/IP-Block
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
1.2.3.4
|
||||||
|
159.203.59.191
|
||||||
26
.exp/scripts/repos/LATAM_Oficial/README.md
Normal file
26
.exp/scripts/repos/LATAM_Oficial/README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# 💻 𝙎 𝘾 𝙍 𝙄 𝙋 𝙏 | 𝙇 𝘼 𝙏 𝘼 𝙈 💻 v 2.0
|
||||||
|
|
||||||
|
## **Script Manager de VPS**
|
||||||
|
_Este es un script para la administracion de Cuentas SSH sucesor de VPS-MX_
|
||||||
|
|
||||||
|
## **PROTOCOLOS**
|
||||||
|
_▫️SSH/SSL/DROPBEAR/OPENVPN/SHADOWSOCK/SHADOWSOCK-liv/SHADOWSOCKR(PERSONAL)/V2RAY (PERSONAL)/GETTUNEL/SLOWDNS_
|
||||||
|
_▫️**PROXYS**_
|
||||||
|
_(PYTHON-PUB,PYTHON-SEG,PYTHON-DIR(WEBSOKET EDIT ESTATUS),TCP OVER,SQUID)_
|
||||||
|
|
||||||
|
## **MONITOREO DE:**
|
||||||
|
▫️USUARIOS SSH/DROPBEAR/SSL/OPENVPN
|
||||||
|
▫️TIEMPO
|
||||||
|
▫️EXPIRACION
|
||||||
|
▫️MONITOR DE PROTOCOLOS
|
||||||
|
▫️NOTIFY DE CUENTA BLOQUEADA,EXPIRADA,REBOOT, LOGIN ROOT
|
||||||
|
|
||||||
|
## **CREAR SSH CON:**
|
||||||
|
▫️NOMBRE Y USUARIO
|
||||||
|
▫️HWID (INICIO DE SECION CON HWID DE HTTP INYECTOR)
|
||||||
|
▫️TOKEN (APKS PERSONALIZADAS)
|
||||||
|
|
||||||
|
## **BOT MANAGER**
|
||||||
|
-CONTROLA EL USO DE TUS CUENTAS SSH DESDE UN BOT DE TELEGRAM
|
||||||
|
(AGERAGR,ELIMINAR,RENOVAR,MIRAR CONECTADOS,SERVICOS DE TU VPS, IFO DE CUENTAS,ETC..)
|
||||||
|
-RECIBE NOTIFICACIONES CON BOT ESPECIAL
|
||||||
BIN
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM.tar.gz
Normal file
BIN
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM.tar.gz
Normal file
Binary file not shown.
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#12-02-2022
|
||||||
|
clear && clear
|
||||||
|
msg -bar
|
||||||
|
echo -e "\e[1;91 <<<<<< PROXIMAMENTE >>>>>"
|
||||||
|
msg -bar
|
||||||
268
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/PDirect.py
Normal file
268
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/PDirect.py
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
import socket, threading, thread, select, signal, sys, time, getopt
|
||||||
|
|
||||||
|
# Listen
|
||||||
|
LISTENING_ADDR = '0.0.0.0'
|
||||||
|
if sys.argv[1:]:
|
||||||
|
LISTENING_PORT = sys.argv[1]
|
||||||
|
else:
|
||||||
|
LISTENING_PORT = 80
|
||||||
|
#Pass
|
||||||
|
PASS = ''
|
||||||
|
|
||||||
|
# CONST
|
||||||
|
BUFLEN = 4096 * 4
|
||||||
|
TIMEOUT = 60
|
||||||
|
DEFAULT_HOST = '127.0.0.1:443'
|
||||||
|
RESPONSE = 'HTTP/1.1 200 <strong>By SCRIP | LATAM</strong>\r\nContent-length: 0\r\n\r\nHTTP/1.1 200 Connection established\r\n\r\n'
|
||||||
|
#RESPONSE = 'HTTP/1.1 200 Hello_World!\r\nContent-length: 0\r\n\r\nHTTP/1.1 200 Connection established\r\n\r\n' # lint:ok
|
||||||
|
|
||||||
|
class Server(threading.Thread):
|
||||||
|
def __init__(self, host, port):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
self.running = False
|
||||||
|
self.host = host
|
||||||
|
self.port = port
|
||||||
|
self.threads = []
|
||||||
|
self.threadsLock = threading.Lock()
|
||||||
|
self.logLock = threading.Lock()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.soc = socket.socket(socket.AF_INET)
|
||||||
|
self.soc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
self.soc.settimeout(2)
|
||||||
|
intport = int(self.port)
|
||||||
|
self.soc.bind((self.host, intport))
|
||||||
|
self.soc.listen(0)
|
||||||
|
self.running = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
while self.running:
|
||||||
|
try:
|
||||||
|
c, addr = self.soc.accept()
|
||||||
|
c.setblocking(1)
|
||||||
|
except socket.timeout:
|
||||||
|
continue
|
||||||
|
|
||||||
|
conn = ConnectionHandler(c, self, addr)
|
||||||
|
conn.start()
|
||||||
|
self.addConn(conn)
|
||||||
|
finally:
|
||||||
|
self.running = False
|
||||||
|
self.soc.close()
|
||||||
|
|
||||||
|
def printLog(self, log):
|
||||||
|
self.logLock.acquire()
|
||||||
|
print log
|
||||||
|
self.logLock.release()
|
||||||
|
|
||||||
|
def addConn(self, conn):
|
||||||
|
try:
|
||||||
|
self.threadsLock.acquire()
|
||||||
|
if self.running:
|
||||||
|
self.threads.append(conn)
|
||||||
|
finally:
|
||||||
|
self.threadsLock.release()
|
||||||
|
|
||||||
|
def removeConn(self, conn):
|
||||||
|
try:
|
||||||
|
self.threadsLock.acquire()
|
||||||
|
self.threads.remove(conn)
|
||||||
|
finally:
|
||||||
|
self.threadsLock.release()
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
try:
|
||||||
|
self.running = False
|
||||||
|
self.threadsLock.acquire()
|
||||||
|
|
||||||
|
threads = list(self.threads)
|
||||||
|
for c in threads:
|
||||||
|
c.close()
|
||||||
|
finally:
|
||||||
|
self.threadsLock.release()
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionHandler(threading.Thread):
|
||||||
|
def __init__(self, socClient, server, addr):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
self.clientClosed = False
|
||||||
|
self.targetClosed = True
|
||||||
|
self.client = socClient
|
||||||
|
self.client_buffer = ''
|
||||||
|
self.server = server
|
||||||
|
self.log = 'Connection: ' + str(addr)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
try:
|
||||||
|
if not self.clientClosed:
|
||||||
|
self.client.shutdown(socket.SHUT_RDWR)
|
||||||
|
self.client.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
self.clientClosed = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not self.targetClosed:
|
||||||
|
self.target.shutdown(socket.SHUT_RDWR)
|
||||||
|
self.target.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
self.targetClosed = True
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
self.client_buffer = self.client.recv(BUFLEN)
|
||||||
|
|
||||||
|
hostPort = self.findHeader(self.client_buffer, 'X-Real-Host')
|
||||||
|
|
||||||
|
if hostPort == '':
|
||||||
|
hostPort = DEFAULT_HOST
|
||||||
|
|
||||||
|
split = self.findHeader(self.client_buffer, 'X-Split')
|
||||||
|
|
||||||
|
if split != '':
|
||||||
|
self.client.recv(BUFLEN)
|
||||||
|
|
||||||
|
if hostPort != '':
|
||||||
|
passwd = self.findHeader(self.client_buffer, 'X-Pass')
|
||||||
|
|
||||||
|
if len(PASS) != 0 and passwd == PASS:
|
||||||
|
self.method_CONNECT(hostPort)
|
||||||
|
elif len(PASS) != 0 and passwd != PASS:
|
||||||
|
self.client.send('HTTP/1.1 400 WrongPass!\r\n\r\n')
|
||||||
|
elif hostPort.startswith('127.0.0.1') or hostPort.startswith('localhost'):
|
||||||
|
self.method_CONNECT(hostPort)
|
||||||
|
else:
|
||||||
|
self.client.send('HTTP/1.1 403 Forbidden!\r\n\r\n')
|
||||||
|
else:
|
||||||
|
print '- No X-Real-Host!'
|
||||||
|
self.client.send('HTTP/1.1 400 NoXRealHost!\r\n\r\n')
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
self.log += ' - error: ' + e.strerror
|
||||||
|
self.server.printLog(self.log)
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
self.close()
|
||||||
|
self.server.removeConn(self)
|
||||||
|
|
||||||
|
def findHeader(self, head, header):
|
||||||
|
aux = head.find(header + ': ')
|
||||||
|
|
||||||
|
if aux == -1:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
aux = head.find(':', aux)
|
||||||
|
head = head[aux+2:]
|
||||||
|
aux = head.find('\r\n')
|
||||||
|
|
||||||
|
if aux == -1:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
return head[:aux];
|
||||||
|
|
||||||
|
def connect_target(self, host):
|
||||||
|
i = host.find(':')
|
||||||
|
if i != -1:
|
||||||
|
port = int(host[i+1:])
|
||||||
|
host = host[:i]
|
||||||
|
else:
|
||||||
|
if self.method=='CONNECT':
|
||||||
|
port = 443
|
||||||
|
else:
|
||||||
|
port = sys.argv[1]
|
||||||
|
|
||||||
|
(soc_family, soc_type, proto, _, address) = socket.getaddrinfo(host, port)[0]
|
||||||
|
|
||||||
|
self.target = socket.socket(soc_family, soc_type, proto)
|
||||||
|
self.targetClosed = False
|
||||||
|
self.target.connect(address)
|
||||||
|
|
||||||
|
def method_CONNECT(self, path):
|
||||||
|
self.log += ' - CONNECT ' + path
|
||||||
|
|
||||||
|
self.connect_target(path)
|
||||||
|
self.client.sendall(RESPONSE)
|
||||||
|
self.client_buffer = ''
|
||||||
|
|
||||||
|
self.server.printLog(self.log)
|
||||||
|
self.doCONNECT()
|
||||||
|
|
||||||
|
def doCONNECT(self):
|
||||||
|
socs = [self.client, self.target]
|
||||||
|
count = 0
|
||||||
|
error = False
|
||||||
|
while True:
|
||||||
|
count += 1
|
||||||
|
(recv, _, err) = select.select(socs, [], socs, 3)
|
||||||
|
if err:
|
||||||
|
error = True
|
||||||
|
if recv:
|
||||||
|
for in_ in recv:
|
||||||
|
try:
|
||||||
|
data = in_.recv(BUFLEN)
|
||||||
|
if data:
|
||||||
|
if in_ is self.target:
|
||||||
|
self.client.send(data)
|
||||||
|
else:
|
||||||
|
while data:
|
||||||
|
byte = self.target.send(data)
|
||||||
|
data = data[byte:]
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
error = True
|
||||||
|
break
|
||||||
|
if count == TIMEOUT:
|
||||||
|
error = True
|
||||||
|
if error:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def print_usage():
|
||||||
|
print 'Usage: proxy.py -p <port>'
|
||||||
|
print ' proxy.py -b <bindAddr> -p <port>'
|
||||||
|
print ' proxy.py -b 0.0.0.0 -p 80'
|
||||||
|
|
||||||
|
def parse_args(argv):
|
||||||
|
global LISTENING_ADDR
|
||||||
|
global LISTENING_PORT
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(argv,"hb:p:",["bind=","port="])
|
||||||
|
except getopt.GetoptError:
|
||||||
|
print_usage()
|
||||||
|
sys.exit(2)
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt == '-h':
|
||||||
|
print_usage()
|
||||||
|
sys.exit()
|
||||||
|
elif opt in ("-b", "--bind"):
|
||||||
|
LISTENING_ADDR = arg
|
||||||
|
elif opt in ("-p", "--port"):
|
||||||
|
LISTENING_PORT = int(arg)
|
||||||
|
|
||||||
|
|
||||||
|
def main(host=LISTENING_ADDR, port=LISTENING_PORT):
|
||||||
|
print "\n:-------PythonProxy-------:\n"
|
||||||
|
print "Listening addr: " + LISTENING_ADDR
|
||||||
|
print "Listening port: " + str(LISTENING_PORT) + "\n"
|
||||||
|
print ":-------------------------:\n"
|
||||||
|
server = Server(LISTENING_ADDR, LISTENING_PORT)
|
||||||
|
server.start()
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
time.sleep(2)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print 'Stopping...'
|
||||||
|
server.close()
|
||||||
|
break
|
||||||
|
|
||||||
|
####### parse_args(sys.argv[1:])
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
682
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/PGet.py
Normal file
682
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/PGet.py
Normal file
@ -0,0 +1,682 @@
|
|||||||
|
import sys, time, getopt, socket, threading, base64
|
||||||
|
|
||||||
|
|
||||||
|
# CONFIG
|
||||||
|
CONFIG_LISTENING = '0.0.0.0:8799'
|
||||||
|
CONFIG_PASS = 'pwd.pwd'
|
||||||
|
|
||||||
|
|
||||||
|
class Logger:
|
||||||
|
|
||||||
|
logLock = threading.Lock()
|
||||||
|
LOG_INFO = 1
|
||||||
|
LOG_WARN = 2
|
||||||
|
LOG_ERROR = 3
|
||||||
|
|
||||||
|
def printWarn(self, log):
|
||||||
|
self.log(log)
|
||||||
|
|
||||||
|
def printInfo(self, log):
|
||||||
|
self.log(log)
|
||||||
|
|
||||||
|
def printError(self, log):
|
||||||
|
self.log(log)
|
||||||
|
|
||||||
|
def printLog(self, log, logLevel):
|
||||||
|
if logLevel == Logger.LOG_INFO:
|
||||||
|
self.printInfo('<-> ' + log)
|
||||||
|
elif logLevel == Logger.LOG_WARN:
|
||||||
|
self.printWarn('<!> ' + log)
|
||||||
|
elif logLevel == Logger.LOG_ERROR:
|
||||||
|
self.printError('<#> ' + log)
|
||||||
|
|
||||||
|
def log(self, log):
|
||||||
|
with Logger.logLock:
|
||||||
|
print log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordSet:
|
||||||
|
FILE_EXEMPLE = 'master=passwd123\n127.0.0.1:22=pwd321;321pawd\n1.23.45.67:443=pass123'
|
||||||
|
|
||||||
|
def __init__(self, masterKey=None):
|
||||||
|
self.masterKey = masterKey
|
||||||
|
|
||||||
|
def parseFile(self, fileName):
|
||||||
|
isValid = False
|
||||||
|
|
||||||
|
with open(fileName) as f:
|
||||||
|
content = f.readlines()
|
||||||
|
|
||||||
|
content = [x.strip() for x in content]
|
||||||
|
content = [item for item in content if not str(item).startswith('#')]
|
||||||
|
|
||||||
|
if len(content) > 0:
|
||||||
|
masterKey = content[0]
|
||||||
|
|
||||||
|
if self.splitParam(masterKey, '=') is not None and masterKey.startswith('master'):
|
||||||
|
self.masterKey = self.splitParam(masterKey, '=')[1]
|
||||||
|
|
||||||
|
isValid = True
|
||||||
|
self.map = dict()
|
||||||
|
|
||||||
|
for i, v in enumerate(content[1:]):
|
||||||
|
hostAndPass = self.splitParam(v, '=')
|
||||||
|
|
||||||
|
if hostAndPass is not None:
|
||||||
|
self.map[hostAndPass[0]] = hostAndPass[1].split(';')
|
||||||
|
|
||||||
|
return isValid
|
||||||
|
|
||||||
|
def isValidKey(self, key, target):
|
||||||
|
valid = False
|
||||||
|
|
||||||
|
if not self.masterKey == key:
|
||||||
|
if hasattr(self, 'map'):
|
||||||
|
if self.map.has_key(target):
|
||||||
|
valid = key in self.map[target]
|
||||||
|
else:
|
||||||
|
valid = True
|
||||||
|
|
||||||
|
return valid
|
||||||
|
|
||||||
|
|
||||||
|
def splitParam(self, param, c):
|
||||||
|
index = param.find(c)
|
||||||
|
|
||||||
|
ret = None
|
||||||
|
|
||||||
|
if index != -1:
|
||||||
|
ret = []
|
||||||
|
ret.append(param[0:index])
|
||||||
|
ret.append(param[index+1:])
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class ClientRequest:
|
||||||
|
MAX_LEN_CLIENT_REQUEST = 1024 * 100
|
||||||
|
HEADER_CONTENT_LENGTH = 'Content-Length'
|
||||||
|
HEADER_ACTION = 'X-Action'
|
||||||
|
ACTION_CLOSE = 'close'
|
||||||
|
ACTION_DATA = 'data'
|
||||||
|
|
||||||
|
def __init__(self, socket):
|
||||||
|
self.socket = socket
|
||||||
|
self.readConent = False
|
||||||
|
|
||||||
|
def parse(self):
|
||||||
|
line = ''
|
||||||
|
count = 0
|
||||||
|
self.isValid = False
|
||||||
|
self.data = None
|
||||||
|
self.contentLength = None
|
||||||
|
self.action = None
|
||||||
|
|
||||||
|
while line != '\r\n' and count < ClientRequest.MAX_LEN_CLIENT_REQUEST:
|
||||||
|
line = self.readHttpLine()
|
||||||
|
|
||||||
|
if line is None:
|
||||||
|
break
|
||||||
|
|
||||||
|
if line.startswith(ClientRequest.HEADER_ACTION):
|
||||||
|
self.action = self.getHeaderVal(line)
|
||||||
|
|
||||||
|
if not self.action is None:
|
||||||
|
if self.action == ClientRequest.ACTION_CLOSE or self.action == ClientRequest.ACTION_DATA:
|
||||||
|
self.isValid = True
|
||||||
|
|
||||||
|
count += len(line)
|
||||||
|
|
||||||
|
if self.readConent:
|
||||||
|
if self.contentLength > 0 and self.contentLength < ClientRequest.MAX_LEN_CLIENT_REQUEST:
|
||||||
|
self.data = self.readFully(self.contentLength)
|
||||||
|
|
||||||
|
return self.isValid
|
||||||
|
|
||||||
|
def readHttpLine(self):
|
||||||
|
line = ''
|
||||||
|
count = 0
|
||||||
|
socket = self.socket
|
||||||
|
|
||||||
|
b = socket.recv(1)
|
||||||
|
|
||||||
|
if not b:
|
||||||
|
return None
|
||||||
|
|
||||||
|
while count < ClientRequest.MAX_LEN_CLIENT_REQUEST:
|
||||||
|
count += 1
|
||||||
|
line += b
|
||||||
|
|
||||||
|
if b == '\r':
|
||||||
|
b = socket.recv(1)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
if not b:
|
||||||
|
break
|
||||||
|
|
||||||
|
line += b
|
||||||
|
|
||||||
|
if b == '\n':
|
||||||
|
break
|
||||||
|
|
||||||
|
b = socket.recv(1)
|
||||||
|
|
||||||
|
if not b:
|
||||||
|
break
|
||||||
|
|
||||||
|
if not b:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return line
|
||||||
|
|
||||||
|
def getHeaderVal(self, header):
|
||||||
|
ini = header.find(':')
|
||||||
|
|
||||||
|
if ini == -1:
|
||||||
|
return None
|
||||||
|
|
||||||
|
ini += 2
|
||||||
|
|
||||||
|
fim = header.find('\r\n')
|
||||||
|
|
||||||
|
if fim == -1:
|
||||||
|
header = header[ini:]
|
||||||
|
|
||||||
|
return header[ini:fim]
|
||||||
|
|
||||||
|
def readFully(self, n):
|
||||||
|
count = 0
|
||||||
|
data = ''
|
||||||
|
|
||||||
|
while count < n:
|
||||||
|
packet = self.socket.recv(n - count)
|
||||||
|
|
||||||
|
if not packet:
|
||||||
|
break
|
||||||
|
|
||||||
|
count += len(packet)
|
||||||
|
data += packet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Client(threading.Thread):
|
||||||
|
ACTION_DATA = 'data'
|
||||||
|
BUFFER_SIZE = 4096
|
||||||
|
|
||||||
|
def __init__(self, id, readSocket, target):
|
||||||
|
super(Client, self).__init__()
|
||||||
|
self.targetHostPort = target
|
||||||
|
self.id = id
|
||||||
|
self.readSocket = readSocket
|
||||||
|
self.logger = Logger()
|
||||||
|
self.isStopped = False
|
||||||
|
self.onCloseFunction = None
|
||||||
|
self.closeLock = threading.Lock()
|
||||||
|
self.threadEndCount = 0
|
||||||
|
self.writeSocket = None
|
||||||
|
|
||||||
|
def connectTarget(self):
|
||||||
|
aux = self.targetHostPort.find(':')
|
||||||
|
|
||||||
|
host = self.targetHostPort[:aux]
|
||||||
|
port = int(self.targetHostPort[aux + 1:])
|
||||||
|
|
||||||
|
self.target = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
self.target.connect((host, port))
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
self.connectTarget()
|
||||||
|
|
||||||
|
request = ClientRequest(self.readSocket)
|
||||||
|
request.readConent = False
|
||||||
|
|
||||||
|
if not request.parse() or not Client.ACTION_DATA == request.action:
|
||||||
|
raise Exception('client sends invalid request')
|
||||||
|
|
||||||
|
threadRead = ThreadRelay(self.readSocket, self.target, self.finallyClose)
|
||||||
|
threadRead.logFunction = self.log
|
||||||
|
threadRead.start()
|
||||||
|
|
||||||
|
threadWrite = ThreadRelay(self.target, self.writeSocket, self.finallyClose)
|
||||||
|
threadWrite.logFunction = self.log
|
||||||
|
threadWrite.start()
|
||||||
|
except Exception as e:
|
||||||
|
self.log('connection error - ' + str(type(e)) + ' - ' + str(e), Logger.LOG_ERROR)
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def finallyClose(self):
|
||||||
|
with self.closeLock:
|
||||||
|
self.threadEndCount += 1
|
||||||
|
|
||||||
|
if self.threadEndCount == 2:
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if not self.isStopped:
|
||||||
|
self.isStopped = True
|
||||||
|
|
||||||
|
if hasattr(self, 'target'):
|
||||||
|
try:
|
||||||
|
self.target.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if hasattr(self, 'writeSocket'):
|
||||||
|
try:
|
||||||
|
self.writeSocket.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if hasattr(self, 'readSocket'):
|
||||||
|
try:
|
||||||
|
self.readSocket.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.onClose()
|
||||||
|
self.log('closed', Logger.LOG_INFO)
|
||||||
|
|
||||||
|
def onClose(self):
|
||||||
|
if not self.onCloseFunction is None:
|
||||||
|
self.onCloseFunction(self)
|
||||||
|
|
||||||
|
def log(self, msg, logLevel):
|
||||||
|
msg = 'Client ' + str(self.id) + ': ' + msg
|
||||||
|
self.logger.printLog(msg, logLevel)
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadRelay(threading.Thread):
|
||||||
|
def __init__(self, readSocket, writeSocket, closeFunction=None):
|
||||||
|
super(ThreadRelay, self).__init__()
|
||||||
|
self.readSocket = readSocket
|
||||||
|
self.writeSocket = writeSocket
|
||||||
|
self.logFunction = None
|
||||||
|
self.closeFuntion = closeFunction
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
data = self.readSocket.recv(Client.BUFFER_SIZE)
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
self.writeSocket.sendall(data)
|
||||||
|
|
||||||
|
self.writeSocket.shutdown(socket.SHUT_WR)
|
||||||
|
except Exception as e:
|
||||||
|
if not self.logFunction is None:
|
||||||
|
self.logFunction('threadRelay error: ' + str(type(e)) + ' - ' + str(e), Logger.LOG_ERROR)
|
||||||
|
finally:
|
||||||
|
if not self.closeFuntion is None:
|
||||||
|
self.closeFuntion()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class AcceptClient(threading.Thread):
|
||||||
|
MAX_QTD_BYTES = 5000
|
||||||
|
HEADER_BODY = 'X-Body'
|
||||||
|
HEADER_ACTION = 'X-Action'
|
||||||
|
HEADER_TARGET = 'X-Target'
|
||||||
|
HEADER_PASS = 'X-Pass'
|
||||||
|
HEADER_ID = 'X-Id'
|
||||||
|
ACTION_CREATE = 'create'
|
||||||
|
ACTION_COMPLETE = 'complete'
|
||||||
|
MSG_CONNECTION_CREATED = 'Created'
|
||||||
|
MSG_CONNECTION_COMPLETED = 'Completed'
|
||||||
|
|
||||||
|
ID_COUNT = 0
|
||||||
|
ID_LOCK = threading.Lock()
|
||||||
|
|
||||||
|
def __init__(self, socket, server, passwdSet=None):
|
||||||
|
super(AcceptClient, self).__init__()
|
||||||
|
self.server = server
|
||||||
|
self.passwdSet = passwdSet
|
||||||
|
self.socket = socket
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
needClose = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
head = self.readHttpRequest()
|
||||||
|
|
||||||
|
bodyLen = self.getHeaderVal(head, AcceptClient.HEADER_BODY)
|
||||||
|
if not bodyLen is None:
|
||||||
|
try:
|
||||||
|
self.readFully(int(bodyLen))
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
action = self.getHeaderVal(head, AcceptClient.HEADER_ACTION)
|
||||||
|
|
||||||
|
if action is None:
|
||||||
|
self.log('client sends no action header', Logger.LOG_WARN)
|
||||||
|
self.socket.sendall('HTTP/1.1 400 NoActionHeader!\r\nServer: GetTunnelServer\r\n\r\n')
|
||||||
|
return
|
||||||
|
|
||||||
|
if action == AcceptClient.ACTION_CREATE:
|
||||||
|
target = self.getHeaderVal(head, AcceptClient.HEADER_TARGET)
|
||||||
|
|
||||||
|
if not self.passwdSet is None:
|
||||||
|
passwd = self.getHeaderVal(head, AcceptClient.HEADER_PASS)
|
||||||
|
|
||||||
|
try:
|
||||||
|
passwd = base64.b64decode(passwd)
|
||||||
|
except:
|
||||||
|
passwd = None
|
||||||
|
pass
|
||||||
|
|
||||||
|
if passwd is None or not self.passwdSet.isValidKey(passwd, target):
|
||||||
|
self.log('client sends wrong key', Logger.LOG_WARN)
|
||||||
|
self.socket.sendall('HTTP/1.1 403 Forbidden\r\nServer: GetTunnelServer\r\n\r\n')
|
||||||
|
return
|
||||||
|
|
||||||
|
if target is not None and self.isValidHostPort(target):
|
||||||
|
id = self.generateId()
|
||||||
|
|
||||||
|
client = Client(id, self.socket, target)
|
||||||
|
client.onCloseFunction = self.server.removeClient
|
||||||
|
self.server.addClient(client)
|
||||||
|
self.socket.sendall('HTTP/1.1 200 '+ AcceptClient.MSG_CONNECTION_CREATED + '\r\nServer: GetTunnelServer\r\nX-Id: ' + str(id) + '\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: Keep-Alive\r\n\r\n')
|
||||||
|
self.log('connection created - ' + str(id), Logger.LOG_INFO)
|
||||||
|
needClose = False
|
||||||
|
else:
|
||||||
|
self.log('client sends no valid target', Logger.LOG_WARN)
|
||||||
|
self.socket.sendall('HTTP/1.1 400 Target!\r\nServer: GetTunnelServer\r\n\r\n')
|
||||||
|
|
||||||
|
elif action == AcceptClient.ACTION_COMPLETE:
|
||||||
|
id = self.getHeaderVal(head, AcceptClient.HEADER_ID)
|
||||||
|
|
||||||
|
if not id is None:
|
||||||
|
client = self.server.getClient(id)
|
||||||
|
|
||||||
|
if not client is None:
|
||||||
|
client.writeSocket = self.socket
|
||||||
|
|
||||||
|
self.log('connection completed - ' + str(id), Logger.LOG_INFO)
|
||||||
|
self.socket.sendall('HTTP/1.1 200 ' + AcceptClient.MSG_CONNECTION_COMPLETED + '\r\nServer: GetTunnelServer\r\nConnection: Keep-Alive\r\n\r\n')
|
||||||
|
|
||||||
|
client.start()
|
||||||
|
needClose = False
|
||||||
|
else:
|
||||||
|
self.log('client try to complete non existing connection', Logger.LOG_WARN)
|
||||||
|
self.socket.sendall('HTTP/1.1 400 CreateFirst!\r\nServer: GetTunnelServer\r\n\r\n')
|
||||||
|
else:
|
||||||
|
self.log('client sends no id header', Logger.LOG_WARN)
|
||||||
|
self.socket.sendall('HTTP/1.1 400 NoID!\r\nServer: GetTunnelServer\r\n\r\n')
|
||||||
|
else:
|
||||||
|
self.log('client sends invalid action', Logger.LOG_WARN)
|
||||||
|
self.socket.sendall('HTTP/1.1 400 InvalidAction!\r\nServer: GetTunnelServer\r\n\r\n')
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
self.log('connection error - ' + str(type(e)) + ' - ' + str(e), Logger.LOG_ERROR)
|
||||||
|
finally:
|
||||||
|
if needClose:
|
||||||
|
try:
|
||||||
|
self.socket.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def log(self, msg, logLevel):
|
||||||
|
self.server.log(msg, logLevel)
|
||||||
|
|
||||||
|
def readHttpRequest(self):
|
||||||
|
request = ''
|
||||||
|
linha = ''
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
while linha != '\r\n' and count < AcceptClient.MAX_QTD_BYTES:
|
||||||
|
linha = self.readHttpLine()
|
||||||
|
|
||||||
|
if linha is None:
|
||||||
|
break
|
||||||
|
|
||||||
|
request += linha
|
||||||
|
count += len(linha)
|
||||||
|
|
||||||
|
return request
|
||||||
|
|
||||||
|
def readHttpLine(self):
|
||||||
|
line = ''
|
||||||
|
count = 0
|
||||||
|
socket = self.socket
|
||||||
|
|
||||||
|
b = socket.recv(1)
|
||||||
|
|
||||||
|
if not b:
|
||||||
|
return None
|
||||||
|
|
||||||
|
while count < AcceptClient.MAX_QTD_BYTES:
|
||||||
|
count += 1
|
||||||
|
line += b
|
||||||
|
|
||||||
|
if b == '\r':
|
||||||
|
b = socket.recv(1)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
if not b:
|
||||||
|
break
|
||||||
|
|
||||||
|
line += b
|
||||||
|
|
||||||
|
if b == '\n':
|
||||||
|
break
|
||||||
|
|
||||||
|
b = socket.recv(1)
|
||||||
|
|
||||||
|
if not b:
|
||||||
|
break
|
||||||
|
|
||||||
|
if not b:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return line
|
||||||
|
|
||||||
|
def getHeaderVal(self, head, header):
|
||||||
|
if not head.startswith('\r\n'):
|
||||||
|
header = '\r\n' + header
|
||||||
|
|
||||||
|
if not header.endswith(': '):
|
||||||
|
header = header + ': '
|
||||||
|
|
||||||
|
ini = head.find(header)
|
||||||
|
|
||||||
|
if ini == -1:
|
||||||
|
return None
|
||||||
|
|
||||||
|
end = head.find('\r\n', ini+2)
|
||||||
|
|
||||||
|
ini += len(header)
|
||||||
|
|
||||||
|
if end == -1 or ini > end or ini >= len(head):
|
||||||
|
return None
|
||||||
|
|
||||||
|
return head[ini:end]
|
||||||
|
|
||||||
|
def readFully(self, n):
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
while count < n:
|
||||||
|
packet = self.socket.recv(n - count)
|
||||||
|
|
||||||
|
if not packet:
|
||||||
|
break
|
||||||
|
|
||||||
|
count += len(packet)
|
||||||
|
|
||||||
|
def isValidHostPort(self, hostPort):
|
||||||
|
aux = hostPort.find(':')
|
||||||
|
|
||||||
|
if aux == -1 or aux >= len(hostPort) -1:
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
int(hostPort[aux+1:])
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def generateId(self):
|
||||||
|
with AcceptClient.ID_LOCK:
|
||||||
|
AcceptClient.ID_COUNT += 1
|
||||||
|
return AcceptClient.ID_COUNT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Server(threading.Thread):
|
||||||
|
|
||||||
|
def __init__(self, listening, passwdSet=None):
|
||||||
|
super(Server, self).__init__()
|
||||||
|
self.listening = listening
|
||||||
|
self.passwdSet = passwdSet
|
||||||
|
self.running = False
|
||||||
|
self.logger = Logger()
|
||||||
|
self.isStopped = False
|
||||||
|
self.clientsLock = threading.Lock()
|
||||||
|
self.clients = []
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
self.soc = socket.socket(socket.AF_INET)
|
||||||
|
self.soc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
self.soc.settimeout(2)
|
||||||
|
self.soc.bind((self.listening[:self.listening.find(':')], int(self.listening[self.listening.find(':') + 1:])))
|
||||||
|
self.soc.listen(0)
|
||||||
|
|
||||||
|
self.log('running on ' + self.listening, Logger.LOG_INFO)
|
||||||
|
|
||||||
|
self.running = True
|
||||||
|
while self.running:
|
||||||
|
try:
|
||||||
|
c, addr = self.soc.accept()
|
||||||
|
c.setblocking(1)
|
||||||
|
|
||||||
|
self.log('opennig connection - ' + str(addr), Logger.LOG_INFO)
|
||||||
|
self.acceptClient(c)
|
||||||
|
except socket.timeout:
|
||||||
|
continue
|
||||||
|
except Exception as e:
|
||||||
|
self.log('connection error - ' + str(type(e)) + ' - ' + str(e), Logger.LOG_ERROR)
|
||||||
|
finally:
|
||||||
|
self.running = False
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def acceptClient(self, socket):
|
||||||
|
accept = AcceptClient(socket, self, self.passwdSet)
|
||||||
|
accept.start()
|
||||||
|
|
||||||
|
def addClient(self, client):
|
||||||
|
with self.clientsLock:
|
||||||
|
self.clients.append(client)
|
||||||
|
|
||||||
|
def removeClient(self, client):
|
||||||
|
with self.clientsLock:
|
||||||
|
self.clients.remove(client)
|
||||||
|
|
||||||
|
def getClient(self, id):
|
||||||
|
client = None
|
||||||
|
with self.clientsLock:
|
||||||
|
for c in self.clients:
|
||||||
|
if str(c.id) == str(id):
|
||||||
|
client = c
|
||||||
|
break
|
||||||
|
return client
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if not self.isStopped:
|
||||||
|
self.isStopped = True
|
||||||
|
|
||||||
|
if hasattr(self, 'soc'):
|
||||||
|
try:
|
||||||
|
self.soc.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
with self.clientsLock:
|
||||||
|
clientsCopy = self.clients[:]
|
||||||
|
|
||||||
|
for c in clientsCopy:
|
||||||
|
c.close()
|
||||||
|
|
||||||
|
self.log('closed', Logger.LOG_INFO)
|
||||||
|
|
||||||
|
def log(self, msg, logLevel):
|
||||||
|
msg = 'Server: ' + msg
|
||||||
|
self.logger.printLog(msg, logLevel)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def print_usage():
|
||||||
|
print '\nUsage : python get.py -b listening -p pass'
|
||||||
|
print 'Ex. : python get.py -b 0.0.0.0:80 -p pass123'
|
||||||
|
print ' : python get.py -b 0.0.0.0:80 -p passFile.pwd\n'
|
||||||
|
print '___Password file ex.:___'
|
||||||
|
print PasswordSet.FILE_EXEMPLE
|
||||||
|
|
||||||
|
def parse_args(argv):
|
||||||
|
global CONFIG_LISTENING
|
||||||
|
global CONFIG_PASS
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(argv, "hb:p:", ["bind=", "pass="])
|
||||||
|
except getopt.GetoptError:
|
||||||
|
print_usage()
|
||||||
|
sys.exit(2)
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt == '-h':
|
||||||
|
print_usage()
|
||||||
|
sys.exit()
|
||||||
|
elif opt in ('-b', '--bind'):
|
||||||
|
CONFIG_LISTENING = arg
|
||||||
|
elif opt in ('-p', '--pass'):
|
||||||
|
CONFIG_PASS = arg
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print '\n-->GetTunnelPy - Server v.' + '25/06/2017' + '\n'
|
||||||
|
print '-->Listening: ' + CONFIG_LISTENING
|
||||||
|
|
||||||
|
pwdSet = None
|
||||||
|
|
||||||
|
if not CONFIG_PASS is None:
|
||||||
|
if CONFIG_PASS.endswith('.pwd'):
|
||||||
|
pwdSet = PasswordSet()
|
||||||
|
|
||||||
|
try:
|
||||||
|
isValidFile = pwdSet.parseFile(CONFIG_PASS)
|
||||||
|
except IOError as e:
|
||||||
|
print '--#Error reading file: ' + str(type(e)) + ' - ' + str(e)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
if not isValidFile:
|
||||||
|
print '--#Error on parsing file!\n'
|
||||||
|
print_usage()
|
||||||
|
return
|
||||||
|
|
||||||
|
print '-->Pass file: ' + CONFIG_PASS + '\n'
|
||||||
|
else:
|
||||||
|
if (len(CONFIG_PASS) > 0):
|
||||||
|
print '-->Pass : yes\n'
|
||||||
|
pwdSet = PasswordSet(CONFIG_PASS)
|
||||||
|
else:
|
||||||
|
print '-->Pass : no\n'
|
||||||
|
|
||||||
|
server = Server(CONFIG_LISTENING)
|
||||||
|
server.passwdSet = pwdSet
|
||||||
|
server.start()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
time.sleep(2)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print '<-> Stopping server...'
|
||||||
|
server.running = False
|
||||||
|
break
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parse_args(sys.argv[1:])
|
||||||
|
main()
|
||||||
313
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/POpen.py
Normal file
313
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/POpen.py
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import httplib
|
||||||
|
from SocketServer import ThreadingMixIn
|
||||||
|
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
|
||||||
|
from threading import Lock, Timer
|
||||||
|
from cStringIO import StringIO
|
||||||
|
from urlparse import urlsplit
|
||||||
|
import socket
|
||||||
|
import select
|
||||||
|
import gzip
|
||||||
|
import zlib
|
||||||
|
import re
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
|
||||||
|
|
||||||
|
address_family = socket.AF_INET
|
||||||
|
|
||||||
|
def handle_error(self, request, client_address):
|
||||||
|
|
||||||
|
print >>sys.stderr, '-'*40
|
||||||
|
print >>sys.stderr, 'Exception happened during processing of request from', client_address
|
||||||
|
traceback.print_exc()
|
||||||
|
print >>sys.stderr, '-'*40
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadingHTTPServer6(ThreadingHTTPServer):
|
||||||
|
|
||||||
|
address_family = socket.AF_INET6
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleHTTPProxyHandler(BaseHTTPRequestHandler):
|
||||||
|
global_lock = Lock()
|
||||||
|
conn_table = {}
|
||||||
|
timeout = 300
|
||||||
|
upstream_timeout = 300
|
||||||
|
proxy_via = None
|
||||||
|
|
||||||
|
def log_error(self, format, *args):
|
||||||
|
if format == "Request timed out: %r":
|
||||||
|
return
|
||||||
|
self.log_message(format, *args)
|
||||||
|
|
||||||
|
def do_CONNECT(self):
|
||||||
|
|
||||||
|
|
||||||
|
req = self
|
||||||
|
reqbody = None
|
||||||
|
req.path = "https://%s/" % req.path.replace(':443', '')
|
||||||
|
|
||||||
|
replaced_reqbody = self.request_handler(req, reqbody)
|
||||||
|
if replaced_reqbody is True:
|
||||||
|
return
|
||||||
|
|
||||||
|
u = urlsplit(req.path)
|
||||||
|
address = (u.hostname, u.port or 443)
|
||||||
|
try:
|
||||||
|
conn = socket.create_connection(address)
|
||||||
|
except socket.error:
|
||||||
|
return
|
||||||
|
self.send_response(200, 'SOCKS5')
|
||||||
|
self.send_header('Connection', 'close')
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
conns = [self.connection, conn]
|
||||||
|
keep_connection = True
|
||||||
|
while keep_connection:
|
||||||
|
keep_connection = False
|
||||||
|
rlist, wlist, xlist = select.select(conns, [], conns, self.timeout)
|
||||||
|
if xlist:
|
||||||
|
break
|
||||||
|
for r in rlist:
|
||||||
|
other = conns[1] if r is conns[0] else conns[0]
|
||||||
|
data = r.recv(8192)
|
||||||
|
if data:
|
||||||
|
other.sendall(data)
|
||||||
|
keep_connection = True
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def do_HEAD(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_GET(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_POST(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_SPAM(self):
|
||||||
|
req = self
|
||||||
|
content_length = int(req.headers.get('Content-Length', 0))
|
||||||
|
if content_length > 0:
|
||||||
|
reqbody = self.rfile.read(content_length)
|
||||||
|
else:
|
||||||
|
reqbody = None
|
||||||
|
|
||||||
|
replaced_reqbody = self.request_handler(req, reqbody)
|
||||||
|
if replaced_reqbody is True:
|
||||||
|
return
|
||||||
|
elif replaced_reqbody is not None:
|
||||||
|
reqbody = replaced_reqbody
|
||||||
|
if 'Content-Length' in req.headers:
|
||||||
|
req.headers['Content-Length'] = str(len(reqbody))
|
||||||
|
|
||||||
|
|
||||||
|
self.remove_hop_by_hop_headers(req.headers)
|
||||||
|
if self.upstream_timeout:
|
||||||
|
req.headers['Connection'] = 'Keep-Alive'
|
||||||
|
else:
|
||||||
|
req.headers['Connection'] = 'close'
|
||||||
|
if self.proxy_via:
|
||||||
|
self.modify_via_header(req.headers)
|
||||||
|
|
||||||
|
try:
|
||||||
|
res, resdata = self.request_to_upstream_server(req, reqbody)
|
||||||
|
except socket.error:
|
||||||
|
return
|
||||||
|
|
||||||
|
content_encoding = res.headers.get('Content-Encoding', 'identity')
|
||||||
|
resbody = self.decode_content_body(resdata, content_encoding)
|
||||||
|
|
||||||
|
replaced_resbody = self.response_handler(req, reqbody, res, resbody)
|
||||||
|
if replaced_resbody is True:
|
||||||
|
return
|
||||||
|
elif replaced_resbody is not None:
|
||||||
|
resdata = self.encode_content_body(replaced_resbody, content_encoding)
|
||||||
|
if 'Content-Length' in res.headers:
|
||||||
|
res.headers['Content-Length'] = str(len(resdata))
|
||||||
|
resbody = replaced_resbody
|
||||||
|
|
||||||
|
self.remove_hop_by_hop_headers(res.headers)
|
||||||
|
if self.timeout:
|
||||||
|
res.headers['Connection'] = 'Keep-Alive'
|
||||||
|
else:
|
||||||
|
res.headers['Connection'] = 'close'
|
||||||
|
if self.proxy_via:
|
||||||
|
self.modify_via_header(res.headers)
|
||||||
|
|
||||||
|
self.send_response(res.status, res.reason)
|
||||||
|
for k, v in res.headers.items():
|
||||||
|
if k == 'set-cookie':
|
||||||
|
|
||||||
|
for value in self.split_set_cookie_header(v):
|
||||||
|
self.send_header(k, value)
|
||||||
|
else:
|
||||||
|
self.send_header(k, v)
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
if self.command != 'HEAD':
|
||||||
|
self.wfile.write(resdata)
|
||||||
|
with self.global_lock:
|
||||||
|
self.save_handler(req, reqbody, res, resbody)
|
||||||
|
|
||||||
|
def request_to_upstream_server(self, req, reqbody):
|
||||||
|
u = urlsplit(req.path)
|
||||||
|
origin = (u.scheme, u.netloc)
|
||||||
|
|
||||||
|
|
||||||
|
req.headers['Host'] = u.netloc
|
||||||
|
selector = "%s?%s" % (u.path, u.query) if u.query else u.path
|
||||||
|
|
||||||
|
while True:
|
||||||
|
with self.lock_origin(origin):
|
||||||
|
conn = self.open_origin(origin)
|
||||||
|
try:
|
||||||
|
conn.request(req.command, selector, reqbody, headers=dict(req.headers))
|
||||||
|
except socket.error:
|
||||||
|
|
||||||
|
self.close_origin(origin)
|
||||||
|
raise
|
||||||
|
try:
|
||||||
|
res = conn.getresponse(buffering=True)
|
||||||
|
except httplib.BadStatusLine as e:
|
||||||
|
if e.line == "''":
|
||||||
|
|
||||||
|
self.close_origin(origin)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
resdata = res.read()
|
||||||
|
res.headers = res.msg
|
||||||
|
if not self.upstream_timeout or 'close' in res.headers.get('Connection', ''):
|
||||||
|
self.close_origin(origin)
|
||||||
|
else:
|
||||||
|
self.reset_timer(origin)
|
||||||
|
return res, resdata
|
||||||
|
|
||||||
|
def lock_origin(self, origin):
|
||||||
|
d = self.conn_table.setdefault(origin, {})
|
||||||
|
if not 'lock' in d:
|
||||||
|
d['lock'] = Lock()
|
||||||
|
return d['lock']
|
||||||
|
|
||||||
|
def open_origin(self, origin):
|
||||||
|
conn = self.conn_table[origin].get('connection')
|
||||||
|
if not conn:
|
||||||
|
scheme, netloc = origin
|
||||||
|
if scheme == 'https':
|
||||||
|
conn = httplib.HTTPSConnection(netloc)
|
||||||
|
else:
|
||||||
|
conn = httplib.HTTPConnection(netloc)
|
||||||
|
self.reset_timer(origin)
|
||||||
|
self.conn_table[origin]['connection'] = conn
|
||||||
|
return conn
|
||||||
|
|
||||||
|
def reset_timer(self, origin):
|
||||||
|
timer = self.conn_table[origin].get('timer')
|
||||||
|
if timer:
|
||||||
|
timer.cancel()
|
||||||
|
if self.upstream_timeout:
|
||||||
|
timer = Timer(self.upstream_timeout, self.close_origin, args=[origin])
|
||||||
|
timer.daemon = True
|
||||||
|
timer.start()
|
||||||
|
else:
|
||||||
|
timer = None
|
||||||
|
self.conn_table[origin]['timer'] = timer
|
||||||
|
|
||||||
|
def close_origin(self, origin):
|
||||||
|
timer = self.conn_table[origin]['timer']
|
||||||
|
if timer:
|
||||||
|
timer.cancel()
|
||||||
|
conn = self.conn_table[origin]['connection']
|
||||||
|
conn.close()
|
||||||
|
del self.conn_table[origin]['connection']
|
||||||
|
|
||||||
|
def remove_hop_by_hop_headers(self, headers):
|
||||||
|
hop_by_hop_headers = ['Connection', 'Keep-Alive', 'Proxy-Authenticate', 'Proxy-Authorization', 'TE', 'Trailers', 'Trailer', 'Transfer-Encoding', 'Upgrade']
|
||||||
|
connection = headers.get('Connection')
|
||||||
|
if connection:
|
||||||
|
keys = re.split(r',\s*', connection)
|
||||||
|
hop_by_hop_headers.extend(keys)
|
||||||
|
|
||||||
|
for k in hop_by_hop_headers:
|
||||||
|
if k in headers:
|
||||||
|
del headers[k]
|
||||||
|
|
||||||
|
def modify_via_header(self, headers):
|
||||||
|
via_string = "%s %s" % (self.protocol_version, self.proxy_via)
|
||||||
|
via_string = re.sub(r'^HTTP/', '', via_string)
|
||||||
|
|
||||||
|
original = headers.get('Via')
|
||||||
|
if original:
|
||||||
|
headers['Via'] = original + ', ' + via_string
|
||||||
|
else:
|
||||||
|
headers['Via'] = via_string
|
||||||
|
|
||||||
|
def decode_content_body(self, data, content_encoding):
|
||||||
|
if content_encoding in ('gzip', 'x-gzip'):
|
||||||
|
io = StringIO(data)
|
||||||
|
with gzip.GzipFile(fileobj=io) as f:
|
||||||
|
body = f.read()
|
||||||
|
elif content_encoding == 'deflate':
|
||||||
|
body = zlib.decompress(data)
|
||||||
|
elif content_encoding == 'identity':
|
||||||
|
body = data
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown Content-Encoding: %s" % content_encoding)
|
||||||
|
return body
|
||||||
|
|
||||||
|
def encode_content_body(self, body, content_encoding):
|
||||||
|
if content_encoding in ('gzip', 'x-gzip'):
|
||||||
|
io = StringIO()
|
||||||
|
with gzip.GzipFile(fileobj=io, mode='wb') as f:
|
||||||
|
f.write(body)
|
||||||
|
data = io.getvalue()
|
||||||
|
elif content_encoding == 'deflate':
|
||||||
|
data = zlib.compress(body)
|
||||||
|
elif content_encoding == 'identity':
|
||||||
|
data = body
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown Content-Encoding: %s" % content_encoding)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def split_set_cookie_header(self, value):
|
||||||
|
re_cookies = r'([^=]+=[^,;]+(?:;\s*Expires=[^,]+,[^,;]+|;[^,;]+)*)(?:,\s*)?'
|
||||||
|
return re.findall(re_cookies, value, flags=re.IGNORECASE)
|
||||||
|
|
||||||
|
def request_handler(self, req, reqbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
def response_handler(self, req, reqbody, res, resbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
def save_handler(self, req, reqbody, res, resbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Port
|
||||||
|
|
||||||
|
def test(HandlerClass=SimpleHTTPProxyHandler, ServerClass=ThreadingHTTPServer, protocol="HTTP/1.1"):
|
||||||
|
if sys.argv[1:]:
|
||||||
|
port = int(sys.argv[1])
|
||||||
|
else:
|
||||||
|
port = 80
|
||||||
|
server_address = ('', port)
|
||||||
|
|
||||||
|
HandlerClass.protocol_version = protocol
|
||||||
|
httpd = ServerClass(server_address, HandlerClass)
|
||||||
|
|
||||||
|
sa = httpd.socket.getsockname()
|
||||||
|
print "Serving HTTP on", sa[0], "port", sa[1], "..."
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
test()
|
||||||
|
|
||||||
335
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/PPriv.py
Normal file
335
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/PPriv.py
Normal file
@ -0,0 +1,335 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Edit By GlEmYsSoN & @e8th4ever
|
||||||
|
|
||||||
|
from pprint import pprint
|
||||||
|
import sys
|
||||||
|
import http.client
|
||||||
|
from socketserver import ThreadingMixIn
|
||||||
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||||
|
from threading import Lock, Timer
|
||||||
|
from io import StringIO
|
||||||
|
from urllib.parse import urlsplit
|
||||||
|
import socket
|
||||||
|
import select
|
||||||
|
import gzip
|
||||||
|
import zlib
|
||||||
|
import re
|
||||||
|
import traceback
|
||||||
|
import subprocess
|
||||||
|
subprocess.call("clear",shell=True)
|
||||||
|
|
||||||
|
if sys.argv[2:]:
|
||||||
|
msg1 = sys.argv[2]
|
||||||
|
else:
|
||||||
|
msg1 = 'ADM-ULTIMATE'
|
||||||
|
|
||||||
|
if sys.argv[3:]:
|
||||||
|
server = sys.argv[3]
|
||||||
|
else:
|
||||||
|
server = "127.0.0.1"
|
||||||
|
|
||||||
|
msg2 = 'Server Forbidden'
|
||||||
|
|
||||||
|
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
|
||||||
|
|
||||||
|
address_family = socket.AF_INET
|
||||||
|
|
||||||
|
def handle_error(self, request, client_address):
|
||||||
|
|
||||||
|
print('-'*40, file=sys.stderr)
|
||||||
|
print('Exception happened during processing of request from', client_address, file=sys.stderr)
|
||||||
|
traceback.print_exc()
|
||||||
|
print('-'*40, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadingHTTPServer6(ThreadingHTTPServer):
|
||||||
|
|
||||||
|
address_family = socket.AF_INET6
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleHTTPProxyHandler(BaseHTTPRequestHandler):
|
||||||
|
global_lock = Lock()
|
||||||
|
conn_table = {}
|
||||||
|
timeout = 300
|
||||||
|
upstream_timeout = 300
|
||||||
|
proxy_via = None
|
||||||
|
|
||||||
|
def log_error(self, format, *args):
|
||||||
|
if format == "Request timed out: %r":
|
||||||
|
return
|
||||||
|
self.log_message(format, *args)
|
||||||
|
|
||||||
|
def do_CONNECT(self):
|
||||||
|
|
||||||
|
req = self
|
||||||
|
reqbody = None
|
||||||
|
if ':22' in req.path:
|
||||||
|
hostip = req.path.replace(':22', '')
|
||||||
|
elif ':443' in req.path:
|
||||||
|
hostip = req.path.replace(':443', '')
|
||||||
|
req.path = "https://%s/" % req.path.replace(':443', '')
|
||||||
|
|
||||||
|
replaced_reqbody = self.request_handler(req, reqbody)
|
||||||
|
if replaced_reqbody is True:
|
||||||
|
return
|
||||||
|
|
||||||
|
u = urlsplit(req.path)
|
||||||
|
address = (u.hostname, u.port or 443)
|
||||||
|
try:
|
||||||
|
conn = socket.create_connection(address)
|
||||||
|
except socket.error:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.send_response(200, msg1)
|
||||||
|
self.send_header('Connection', 'close')
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
conns = [self.connection, conn]
|
||||||
|
keep_connection = True
|
||||||
|
while keep_connection:
|
||||||
|
if not server.find(hostip) != -1:
|
||||||
|
self.send_error(403, msg2)
|
||||||
|
self.close_connection
|
||||||
|
keep_connection = False
|
||||||
|
rlist, wlist, xlist = select.select(conns, [], conns, self.timeout)
|
||||||
|
if xlist:
|
||||||
|
break
|
||||||
|
for r in rlist:
|
||||||
|
other = conns[1] if r is conns[0] else conns[0]
|
||||||
|
data = r.recv(8192)
|
||||||
|
if data:
|
||||||
|
other.sendall(data)
|
||||||
|
keep_connection = True
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def do_HEAD(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_GET(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_POST(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_SPAM(self):
|
||||||
|
req = self
|
||||||
|
|
||||||
|
content_length = int(req.headers.get('Content-Length', 0))
|
||||||
|
if content_length > 0:
|
||||||
|
reqbody = self.rfile.read(content_length)
|
||||||
|
else:
|
||||||
|
reqbody = None
|
||||||
|
|
||||||
|
replaced_reqbody = self.request_handler(req, reqbody)
|
||||||
|
if replaced_reqbody is True:
|
||||||
|
return
|
||||||
|
elif replaced_reqbody is not None:
|
||||||
|
reqbody = replaced_reqbody
|
||||||
|
if 'Content-Length' in req.headers:
|
||||||
|
req.headers['Content-Length'] = str(len(reqbody))
|
||||||
|
|
||||||
|
|
||||||
|
self.remove_hop_by_hop_headers(req.headers)
|
||||||
|
if self.upstream_timeout:
|
||||||
|
req.headers['Connection'] = 'Keep-Alive'
|
||||||
|
else:
|
||||||
|
req.headers['Connection'] = 'close'
|
||||||
|
if self.proxy_via:
|
||||||
|
self.modify_via_header(req.headers)
|
||||||
|
|
||||||
|
try:
|
||||||
|
res, resdata = self.request_to_upstream_server(req, reqbody)
|
||||||
|
except socket.error:
|
||||||
|
return
|
||||||
|
|
||||||
|
content_encoding = res.headers.get('Content-Encoding', 'identity')
|
||||||
|
resbody = self.decode_content_body(resdata, content_encoding)
|
||||||
|
|
||||||
|
replaced_resbody = self.response_handler(req, reqbody, res, resbody)
|
||||||
|
if replaced_resbody is True:
|
||||||
|
return
|
||||||
|
elif replaced_resbody is not None:
|
||||||
|
resdata = self.encode_content_body(replaced_resbody, content_encoding)
|
||||||
|
if 'Content-Length' in res.headers:
|
||||||
|
res.headers['Content-Length'] = str(len(resdata))
|
||||||
|
resbody = replaced_resbody
|
||||||
|
|
||||||
|
self.remove_hop_by_hop_headers(res.headers)
|
||||||
|
if self.timeout:
|
||||||
|
res.headers['Connection'] = 'Keep-Alive'
|
||||||
|
else:
|
||||||
|
res.headers['Connection'] = 'close'
|
||||||
|
if self.proxy_via:
|
||||||
|
self.modify_via_header(res.headers)
|
||||||
|
|
||||||
|
self.send_response(res.status, res.reason)
|
||||||
|
for k, v in list(res.headers.items()):
|
||||||
|
if k == 'set-cookie':
|
||||||
|
|
||||||
|
for value in self.split_set_cookie_header(v):
|
||||||
|
self.send_header(k, value)
|
||||||
|
else:
|
||||||
|
self.send_header(k, v)
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
if self.command != 'HEAD':
|
||||||
|
self.wfile.write(resdata)
|
||||||
|
with self.global_lock:
|
||||||
|
self.save_handler(req, reqbody, res, resbody)
|
||||||
|
|
||||||
|
def request_to_upstream_server(self, req, reqbody):
|
||||||
|
u = urlsplit(req.path)
|
||||||
|
|
||||||
|
origin = (u.scheme, u.netloc)
|
||||||
|
|
||||||
|
|
||||||
|
req.headers['Host'] = u.netloc
|
||||||
|
selector = "%s?%s" % (u.path, u.query) if u.query else u.path
|
||||||
|
|
||||||
|
while True:
|
||||||
|
with self.lock_origin(origin):
|
||||||
|
conn = self.open_origin(origin)
|
||||||
|
try:
|
||||||
|
conn.request(req.command, selector, reqbody, headers=dict(req.headers))
|
||||||
|
except socket.error:
|
||||||
|
|
||||||
|
self.close_origin(origin)
|
||||||
|
raise
|
||||||
|
try:
|
||||||
|
res = conn.getresponse(buffering=True)
|
||||||
|
except http.client.BadStatusLine as e:
|
||||||
|
if e.line == "''":
|
||||||
|
|
||||||
|
self.close_origin(origin)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
resdata = res.read()
|
||||||
|
res.headers = res.msg
|
||||||
|
if not self.upstream_timeout or 'close' in res.headers.get('Connection', ''):
|
||||||
|
self.close_origin(origin)
|
||||||
|
else:
|
||||||
|
self.reset_timer(origin)
|
||||||
|
return res, resdata
|
||||||
|
|
||||||
|
def lock_origin(self, origin):
|
||||||
|
d = self.conn_table.setdefault(origin, {})
|
||||||
|
if not 'lock' in d:
|
||||||
|
d['lock'] = Lock()
|
||||||
|
return d['lock']
|
||||||
|
|
||||||
|
def open_origin(self, origin):
|
||||||
|
conn = self.conn_table[origin].get('connection')
|
||||||
|
if not conn:
|
||||||
|
scheme, netloc = origin
|
||||||
|
if scheme == 'https':
|
||||||
|
conn = http.client.HTTPSConnection(netloc)
|
||||||
|
else:
|
||||||
|
conn = http.client.HTTPConnection(netloc)
|
||||||
|
self.reset_timer(origin)
|
||||||
|
self.conn_table[origin]['connection'] = conn
|
||||||
|
return conn
|
||||||
|
|
||||||
|
def reset_timer(self, origin):
|
||||||
|
timer = self.conn_table[origin].get('timer')
|
||||||
|
if timer:
|
||||||
|
timer.cancel()
|
||||||
|
if self.upstream_timeout:
|
||||||
|
timer = Timer(self.upstream_timeout, self.close_origin, args=[origin])
|
||||||
|
timer.daemon = True
|
||||||
|
timer.start()
|
||||||
|
else:
|
||||||
|
timer = None
|
||||||
|
self.conn_table[origin]['timer'] = timer
|
||||||
|
|
||||||
|
def close_origin(self, origin):
|
||||||
|
timer = self.conn_table[origin]['timer']
|
||||||
|
if timer:
|
||||||
|
timer.cancel()
|
||||||
|
conn = self.conn_table[origin]['connection']
|
||||||
|
conn.close()
|
||||||
|
del self.conn_table[origin]['connection']
|
||||||
|
|
||||||
|
def remove_hop_by_hop_headers(self, headers):
|
||||||
|
hop_by_hop_headers = ['Connection', 'Keep-Alive', 'Proxy-Authenticate', 'Proxy-Authorization', 'TE', 'Trailers', 'Trailer', 'Transfer-Encoding', 'Upgrade']
|
||||||
|
connection = headers.get('Connection')
|
||||||
|
if connection:
|
||||||
|
keys = re.split(r',\s*', connection)
|
||||||
|
hop_by_hop_headers.extend(keys)
|
||||||
|
|
||||||
|
for k in hop_by_hop_headers:
|
||||||
|
if k in headers:
|
||||||
|
del headers[k]
|
||||||
|
|
||||||
|
def modify_via_header(self, headers):
|
||||||
|
via_string = "%s %s" % (self.protocol_version, self.proxy_via)
|
||||||
|
via_string = re.sub(r'^HTTP/', '', via_string)
|
||||||
|
|
||||||
|
original = headers.get('Via')
|
||||||
|
if original:
|
||||||
|
headers['Via'] = original + ', ' + via_string
|
||||||
|
else:
|
||||||
|
headers['Via'] = via_string
|
||||||
|
|
||||||
|
def decode_content_body(self, data, content_encoding):
|
||||||
|
if content_encoding in ('gzip', 'x-gzip'):
|
||||||
|
io = StringIO(data)
|
||||||
|
with gzip.GzipFile(fileobj=io) as f:
|
||||||
|
body = f.read()
|
||||||
|
elif content_encoding == 'deflate':
|
||||||
|
body = zlib.decompress(data)
|
||||||
|
elif content_encoding == 'identity':
|
||||||
|
body = data
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown Content-Encoding: %s" % content_encoding)
|
||||||
|
return body
|
||||||
|
|
||||||
|
def encode_content_body(self, body, content_encoding):
|
||||||
|
if content_encoding in ('gzip', 'x-gzip'):
|
||||||
|
io = StringIO()
|
||||||
|
with gzip.GzipFile(fileobj=io, mode='wb') as f:
|
||||||
|
f.write(body)
|
||||||
|
data = io.getvalue()
|
||||||
|
elif content_encoding == 'deflate':
|
||||||
|
data = zlib.compress(body)
|
||||||
|
elif content_encoding == 'identity':
|
||||||
|
data = body
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown Content-Encoding: %s" % content_encoding)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def split_set_cookie_header(self, value):
|
||||||
|
re_cookies = r'([^=]+=[^,;]+(?:;\s*Expires=[^,]+,[^,;]+|;[^,;]+)*)(?:,\s*)?'
|
||||||
|
return re.findall(re_cookies, value, flags=re.IGNORECASE)
|
||||||
|
|
||||||
|
def request_handler(self, req, reqbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
def response_handler(self, req, reqbody, res, resbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
def save_handler(self, req, reqbody, res, resbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def test(HandlerClass=SimpleHTTPProxyHandler, ServerClass=ThreadingHTTPServer, protocol="HTTP/1.1"):
|
||||||
|
port = int(sys.argv[1])
|
||||||
|
server_address = ('', port)
|
||||||
|
|
||||||
|
HandlerClass.protocol_version = protocol
|
||||||
|
httpd = ServerClass(server_address, HandlerClass)
|
||||||
|
|
||||||
|
sa = httpd.socket.getsockname()
|
||||||
|
print("Servidor: " + str(sa[0]) + " Porta " + str(sa[1]))
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
test()
|
||||||
318
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/PPub.py
Normal file
318
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/filespy/PPub.py
Normal file
@ -0,0 +1,318 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import httplib
|
||||||
|
from SocketServer import ThreadingMixIn
|
||||||
|
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
|
||||||
|
from threading import Lock, Timer
|
||||||
|
from cStringIO import StringIO
|
||||||
|
from urlparse import urlsplit
|
||||||
|
import socket
|
||||||
|
import select
|
||||||
|
import gzip
|
||||||
|
import zlib
|
||||||
|
import re
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
if sys.argv[2:]:
|
||||||
|
msg1 = sys.argv[2]
|
||||||
|
else:
|
||||||
|
msg1 = "ADM-ULTIMATE"
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
|
||||||
|
|
||||||
|
address_family = socket.AF_INET
|
||||||
|
|
||||||
|
def handle_error(self, request, client_address):
|
||||||
|
|
||||||
|
print >>sys.stderr, '-'*40
|
||||||
|
print >>sys.stderr, 'Exception happened during processing of request from', client_address
|
||||||
|
traceback.print_exc()
|
||||||
|
print >>sys.stderr, '-'*40
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadingHTTPServer6(ThreadingHTTPServer):
|
||||||
|
|
||||||
|
address_family = socket.AF_INET6
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleHTTPProxyHandler(BaseHTTPRequestHandler):
|
||||||
|
global_lock = Lock()
|
||||||
|
conn_table = {}
|
||||||
|
timeout = 300
|
||||||
|
upstream_timeout = 300
|
||||||
|
proxy_via = None
|
||||||
|
|
||||||
|
def log_error(self, format, *args):
|
||||||
|
if format == "Request timed out: %r":
|
||||||
|
return
|
||||||
|
self.log_message(format, *args)
|
||||||
|
|
||||||
|
def do_CONNECT(self):
|
||||||
|
|
||||||
|
|
||||||
|
req = self
|
||||||
|
reqbody = None
|
||||||
|
req.path = "https://%s/" % req.path.replace(':443', '')
|
||||||
|
|
||||||
|
replaced_reqbody = self.request_handler(req, reqbody)
|
||||||
|
if replaced_reqbody is True:
|
||||||
|
return
|
||||||
|
|
||||||
|
u = urlsplit(req.path)
|
||||||
|
address = (u.hostname, u.port or 443)
|
||||||
|
try:
|
||||||
|
conn = socket.create_connection(address)
|
||||||
|
except socket.error:
|
||||||
|
return
|
||||||
|
self.send_response(200, msg1)
|
||||||
|
self.send_header('Connection', 'close')
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
conns = [self.connection, conn]
|
||||||
|
keep_connection = True
|
||||||
|
while keep_connection:
|
||||||
|
keep_connection = False
|
||||||
|
rlist, wlist, xlist = select.select(conns, [], conns, self.timeout)
|
||||||
|
if xlist:
|
||||||
|
break
|
||||||
|
for r in rlist:
|
||||||
|
other = conns[1] if r is conns[0] else conns[0]
|
||||||
|
data = r.recv(8192)
|
||||||
|
if data:
|
||||||
|
other.sendall(data)
|
||||||
|
keep_connection = True
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def do_HEAD(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_GET(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_POST(self):
|
||||||
|
self.do_SPAM()
|
||||||
|
|
||||||
|
def do_SPAM(self):
|
||||||
|
req = self
|
||||||
|
content_length = int(req.headers.get('Content-Length', 0))
|
||||||
|
if content_length > 0:
|
||||||
|
reqbody = self.rfile.read(content_length)
|
||||||
|
else:
|
||||||
|
reqbody = None
|
||||||
|
|
||||||
|
replaced_reqbody = self.request_handler(req, reqbody)
|
||||||
|
if replaced_reqbody is True:
|
||||||
|
return
|
||||||
|
elif replaced_reqbody is not None:
|
||||||
|
reqbody = replaced_reqbody
|
||||||
|
if 'Content-Length' in req.headers:
|
||||||
|
req.headers['Content-Length'] = str(len(reqbody))
|
||||||
|
|
||||||
|
|
||||||
|
self.remove_hop_by_hop_headers(req.headers)
|
||||||
|
if self.upstream_timeout:
|
||||||
|
req.headers['Connection'] = 'Keep-Alive'
|
||||||
|
else:
|
||||||
|
req.headers['Connection'] = 'close'
|
||||||
|
if self.proxy_via:
|
||||||
|
self.modify_via_header(req.headers)
|
||||||
|
|
||||||
|
try:
|
||||||
|
res, resdata = self.request_to_upstream_server(req, reqbody)
|
||||||
|
except socket.error:
|
||||||
|
return
|
||||||
|
|
||||||
|
content_encoding = res.headers.get('Content-Encoding', 'identity')
|
||||||
|
resbody = self.decode_content_body(resdata, content_encoding)
|
||||||
|
|
||||||
|
replaced_resbody = self.response_handler(req, reqbody, res, resbody)
|
||||||
|
if replaced_resbody is True:
|
||||||
|
return
|
||||||
|
elif replaced_resbody is not None:
|
||||||
|
resdata = self.encode_content_body(replaced_resbody, content_encoding)
|
||||||
|
if 'Content-Length' in res.headers:
|
||||||
|
res.headers['Content-Length'] = str(len(resdata))
|
||||||
|
resbody = replaced_resbody
|
||||||
|
|
||||||
|
self.remove_hop_by_hop_headers(res.headers)
|
||||||
|
if self.timeout:
|
||||||
|
res.headers['Connection'] = 'Keep-Alive'
|
||||||
|
else:
|
||||||
|
res.headers['Connection'] = 'close'
|
||||||
|
if self.proxy_via:
|
||||||
|
self.modify_via_header(res.headers)
|
||||||
|
|
||||||
|
self.send_response(res.status, res.reason)
|
||||||
|
for k, v in res.headers.items():
|
||||||
|
if k == 'set-cookie':
|
||||||
|
|
||||||
|
for value in self.split_set_cookie_header(v):
|
||||||
|
self.send_header(k, value)
|
||||||
|
else:
|
||||||
|
self.send_header(k, v)
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
if self.command != 'HEAD':
|
||||||
|
self.wfile.write(resdata)
|
||||||
|
with self.global_lock:
|
||||||
|
self.save_handler(req, reqbody, res, resbody)
|
||||||
|
|
||||||
|
def request_to_upstream_server(self, req, reqbody):
|
||||||
|
u = urlsplit(req.path)
|
||||||
|
origin = (u.scheme, u.netloc)
|
||||||
|
|
||||||
|
|
||||||
|
req.headers['Host'] = u.netloc
|
||||||
|
selector = "%s?%s" % (u.path, u.query) if u.query else u.path
|
||||||
|
|
||||||
|
while True:
|
||||||
|
with self.lock_origin(origin):
|
||||||
|
conn = self.open_origin(origin)
|
||||||
|
try:
|
||||||
|
conn.request(req.command, selector, reqbody, headers=dict(req.headers))
|
||||||
|
except socket.error:
|
||||||
|
|
||||||
|
self.close_origin(origin)
|
||||||
|
raise
|
||||||
|
try:
|
||||||
|
res = conn.getresponse(buffering=True)
|
||||||
|
except httplib.BadStatusLine as e:
|
||||||
|
if e.line == "''":
|
||||||
|
|
||||||
|
self.close_origin(origin)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
resdata = res.read()
|
||||||
|
res.headers = res.msg
|
||||||
|
if not self.upstream_timeout or 'close' in res.headers.get('Connection', ''):
|
||||||
|
self.close_origin(origin)
|
||||||
|
else:
|
||||||
|
self.reset_timer(origin)
|
||||||
|
return res, resdata
|
||||||
|
|
||||||
|
def lock_origin(self, origin):
|
||||||
|
d = self.conn_table.setdefault(origin, {})
|
||||||
|
if not 'lock' in d:
|
||||||
|
d['lock'] = Lock()
|
||||||
|
return d['lock']
|
||||||
|
|
||||||
|
def open_origin(self, origin):
|
||||||
|
conn = self.conn_table[origin].get('connection')
|
||||||
|
if not conn:
|
||||||
|
scheme, netloc = origin
|
||||||
|
if scheme == 'https':
|
||||||
|
conn = httplib.HTTPSConnection(netloc)
|
||||||
|
else:
|
||||||
|
conn = httplib.HTTPConnection(netloc)
|
||||||
|
self.reset_timer(origin)
|
||||||
|
self.conn_table[origin]['connection'] = conn
|
||||||
|
return conn
|
||||||
|
|
||||||
|
def reset_timer(self, origin):
|
||||||
|
timer = self.conn_table[origin].get('timer')
|
||||||
|
if timer:
|
||||||
|
timer.cancel()
|
||||||
|
if self.upstream_timeout:
|
||||||
|
timer = Timer(self.upstream_timeout, self.close_origin, args=[origin])
|
||||||
|
timer.daemon = True
|
||||||
|
timer.start()
|
||||||
|
else:
|
||||||
|
timer = None
|
||||||
|
self.conn_table[origin]['timer'] = timer
|
||||||
|
|
||||||
|
def close_origin(self, origin):
|
||||||
|
timer = self.conn_table[origin]['timer']
|
||||||
|
if timer:
|
||||||
|
timer.cancel()
|
||||||
|
conn = self.conn_table[origin]['connection']
|
||||||
|
conn.close()
|
||||||
|
del self.conn_table[origin]['connection']
|
||||||
|
|
||||||
|
def remove_hop_by_hop_headers(self, headers):
|
||||||
|
hop_by_hop_headers = ['Connection', 'Keep-Alive', 'Proxy-Authenticate', 'Proxy-Authorization', 'TE', 'Trailers', 'Trailer', 'Transfer-Encoding', 'Upgrade']
|
||||||
|
connection = headers.get('Connection')
|
||||||
|
if connection:
|
||||||
|
keys = re.split(r',\s*', connection)
|
||||||
|
hop_by_hop_headers.extend(keys)
|
||||||
|
|
||||||
|
for k in hop_by_hop_headers:
|
||||||
|
if k in headers:
|
||||||
|
del headers[k]
|
||||||
|
|
||||||
|
def modify_via_header(self, headers):
|
||||||
|
via_string = "%s %s" % (self.protocol_version, self.proxy_via)
|
||||||
|
via_string = re.sub(r'^HTTP/', '', via_string)
|
||||||
|
|
||||||
|
original = headers.get('Via')
|
||||||
|
if original:
|
||||||
|
headers['Via'] = original + ', ' + via_string
|
||||||
|
else:
|
||||||
|
headers['Via'] = via_string
|
||||||
|
|
||||||
|
def decode_content_body(self, data, content_encoding):
|
||||||
|
if content_encoding in ('gzip', 'x-gzip'):
|
||||||
|
io = StringIO(data)
|
||||||
|
with gzip.GzipFile(fileobj=io) as f:
|
||||||
|
body = f.read()
|
||||||
|
elif content_encoding == 'deflate':
|
||||||
|
body = zlib.decompress(data)
|
||||||
|
elif content_encoding == 'identity':
|
||||||
|
body = data
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown Content-Encoding: %s" % content_encoding)
|
||||||
|
return body
|
||||||
|
|
||||||
|
def encode_content_body(self, body, content_encoding):
|
||||||
|
if content_encoding in ('gzip', 'x-gzip'):
|
||||||
|
io = StringIO()
|
||||||
|
with gzip.GzipFile(fileobj=io, mode='wb') as f:
|
||||||
|
f.write(body)
|
||||||
|
data = io.getvalue()
|
||||||
|
elif content_encoding == 'deflate':
|
||||||
|
data = zlib.compress(body)
|
||||||
|
elif content_encoding == 'identity':
|
||||||
|
data = body
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown Content-Encoding: %s" % content_encoding)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def split_set_cookie_header(self, value):
|
||||||
|
re_cookies = r'([^=]+=[^,;]+(?:;\s*Expires=[^,]+,[^,;]+|;[^,;]+)*)(?:,\s*)?'
|
||||||
|
return re.findall(re_cookies, value, flags=re.IGNORECASE)
|
||||||
|
|
||||||
|
def request_handler(self, req, reqbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
def response_handler(self, req, reqbody, res, resbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
def save_handler(self, req, reqbody, res, resbody):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def test(HandlerClass=SimpleHTTPProxyHandler, ServerClass=ThreadingHTTPServer, protocol="HTTP/1.1"):
|
||||||
|
if sys.argv[1:]:
|
||||||
|
port = int(sys.argv[1])
|
||||||
|
else:
|
||||||
|
port = 8799
|
||||||
|
server_address = ('', port)
|
||||||
|
|
||||||
|
HandlerClass.protocol_version = protocol
|
||||||
|
httpd = ServerClass(server_address, HandlerClass)
|
||||||
|
|
||||||
|
sa = httpd.socket.getsockname()
|
||||||
|
print "Serving HTTP on", sa[0], "port", sa[1], "..."
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
test()
|
||||||
|
|
||||||
14128
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/menu.sh
Normal file
14128
.exp/scripts/repos/LATAM_Oficial/SCRIPT-LATAM/menu.sh
Normal file
File diff suppressed because it is too large
Load Diff
8
.exp/scripts/repos/LATAM_Oficial/Source-List/10.list
Normal file
8
.exp/scripts/repos/LATAM_Oficial/Source-List/10.list
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
## Debian 10
|
||||||
|
|
||||||
|
deb http://deb.debian.org/debian/ buster main contrib non-free
|
||||||
|
deb-src http://deb.debian.org/debian/ buster main contrib non-free
|
||||||
|
deb http://security.debian.org/debian-security buster/updates main contrib non-free
|
||||||
|
deb-src http://security.debian.org/debian-security buster/updates main contrib non-free
|
||||||
|
deb http://deb.debian.org/debian/ buster-updates main contrib non-free
|
||||||
|
deb-src http://deb.debian.org/debian/ buster-updates main contrib non-free
|
||||||
8
.exp/scripts/repos/LATAM_Oficial/Source-List/11.list
Normal file
8
.exp/scripts/repos/LATAM_Oficial/Source-List/11.list
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
## Debian 11
|
||||||
|
|
||||||
|
deb http://deb.debian.org/debian/ bullseye main contrib non-free
|
||||||
|
deb-src http://deb.debian.org/debian/ bullseye main contrib non-free
|
||||||
|
deb http://security.debian.org/debian-security bullseye/updates main contrib non-free
|
||||||
|
deb-src http://security.debian.org/debian-security bullseye/updates main contrib non-free
|
||||||
|
deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free
|
||||||
|
deb-src http://deb.debian.org/debian/ bullseye-updates main contrib non-free
|
||||||
12
.exp/scripts/repos/LATAM_Oficial/Source-List/14.04.list
Normal file
12
.exp/scripts/repos/LATAM_Oficial/Source-List/14.04.list
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
## Ubuntu 14.04
|
||||||
|
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ trusty universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu trusty-security main restricted
|
||||||
|
deb http://security.ubuntu.com/ubuntu trusty-security universe
|
||||||
|
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
|
||||||
12
.exp/scripts/repos/LATAM_Oficial/Source-List/16.04.list
Normal file
12
.exp/scripts/repos/LATAM_Oficial/Source-List/16.04.list
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
## Ubuntu 16.04
|
||||||
|
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
|
||||||
|
deb http://security.ubuntu.com/ubuntu xenial-security universe
|
||||||
|
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
|
||||||
11
.exp/scripts/repos/LATAM_Oficial/Source-List/18.04.list
Normal file
11
.exp/scripts/repos/LATAM_Oficial/Source-List/18.04.list
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
## Ubuntu 18.04
|
||||||
|
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
|
||||||
|
deb http://security.ubuntu.com/ubuntu bionic-security universe
|
||||||
|
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
|
||||||
12
.exp/scripts/repos/LATAM_Oficial/Source-List/20.04.list
Normal file
12
.exp/scripts/repos/LATAM_Oficial/Source-List/20.04.list
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
## Ubuntu 20.04
|
||||||
|
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ focal universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ focal multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu focal-security main restricted
|
||||||
|
deb http://security.ubuntu.com/ubuntu focal-security universe
|
||||||
|
deb http://security.ubuntu.com/ubuntu focal-security multiverse
|
||||||
12
.exp/scripts/repos/LATAM_Oficial/Source-List/20.10.list
Normal file
12
.exp/scripts/repos/LATAM_Oficial/Source-List/20.10.list
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
## Ubuntu 20.10
|
||||||
|
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ groovy main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ groovy-updates main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ groovy universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ groovy-updates universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ groovy multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ groovy-updates multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ groovy-backports main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu groovy-security main restricted
|
||||||
|
deb http://security.ubuntu.com/ubuntu groovy-security universe
|
||||||
|
deb http://security.ubuntu.com/ubuntu groovy-security multiverse
|
||||||
12
.exp/scripts/repos/LATAM_Oficial/Source-List/21.04.list
Normal file
12
.exp/scripts/repos/LATAM_Oficial/Source-List/21.04.list
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
## Ubuntu 21.04
|
||||||
|
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ hirsute main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ hirsute-updates main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ hirsute universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ hirsute-updates universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ hirsute multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ hirsute-updates multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ hirsute-backports main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu hirsute-security main restricted
|
||||||
|
deb http://security.ubuntu.com/ubuntu hirsute-security universe
|
||||||
|
deb http://security.ubuntu.com/ubuntu hirsute-security multiverse
|
||||||
12
.exp/scripts/repos/LATAM_Oficial/Source-List/21.10.list
Normal file
12
.exp/scripts/repos/LATAM_Oficial/Source-List/21.10.list
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
## Ubuntu 21.10
|
||||||
|
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ impish main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ impish-updates main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ impish universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ impish-updates universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ impish multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ impish-updates multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ impish-backports main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu impish-security main restricted
|
||||||
|
deb http://security.ubuntu.com/ubuntu impish-security universe
|
||||||
|
deb http://security.ubuntu.com/ubuntu impish-security multiverse
|
||||||
12
.exp/scripts/repos/LATAM_Oficial/Source-List/22.04.list
Normal file
12
.exp/scripts/repos/LATAM_Oficial/Source-List/22.04.list
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
## Ubuntu 22.04
|
||||||
|
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ jammy main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates main restricted
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ jammy universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates universe
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ jammy multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates multiverse
|
||||||
|
deb http://us.archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu jammy-security main restricted
|
||||||
|
deb http://security.ubuntu.com/ubuntu jammy-security universe
|
||||||
|
deb http://security.ubuntu.com/ubuntu jammy-security multiverse
|
||||||
8
.exp/scripts/repos/LATAM_Oficial/Source-List/8.list
Normal file
8
.exp/scripts/repos/LATAM_Oficial/Source-List/8.list
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
## Debian 8
|
||||||
|
|
||||||
|
deb http://deb.debian.org/debian/ jessie main contrib non-free
|
||||||
|
deb-src http://deb.debian.org/debian/ jessie main contrib non-free
|
||||||
|
deb http://security.debian.org/debian-security jessie/updates main contrib non-free
|
||||||
|
deb-src http://security.debian.org/debian-security jessie/updates main contrib non-free
|
||||||
|
deb http://deb.debian.org/debian/ jessie-updates main contrib non-free
|
||||||
|
deb-src http://deb.debian.org/debian/ jessie-updates main contrib non-free
|
||||||
8
.exp/scripts/repos/LATAM_Oficial/Source-List/9.list
Normal file
8
.exp/scripts/repos/LATAM_Oficial/Source-List/9.list
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
## Debian 9
|
||||||
|
|
||||||
|
deb http://deb.debian.org/debian/ stretch main contrib non-free
|
||||||
|
deb-src http://deb.debian.org/debian/ stretch main contrib non-free
|
||||||
|
deb http://security.debian.org/debian-security stretch/updates main contrib non-free
|
||||||
|
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free
|
||||||
|
deb http://deb.debian.org/debian/ stretch-updates main contrib non-free
|
||||||
|
deb-src http://deb.debian.org/debian/ stretch-updates main contrib non-free
|
||||||
5
.exp/scripts/repos/LATAM_Oficial/Source-List/README.md
Normal file
5
.exp/scripts/repos/LATAM_Oficial/Source-List/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Lista de APT sources.list
|
||||||
|
|
||||||
|
Ubuntu 14, 16, 18.04, 20.04, 20.10, 21.04, 21.10, 22.04
|
||||||
|
|
||||||
|
Debian 8, 9, 10, 11
|
||||||
1
.exp/scripts/repos/LATAM_Oficial/Version
Normal file
1
.exp/scripts/repos/LATAM_Oficial/Version
Normal file
@ -0,0 +1 @@
|
|||||||
|
2.1h
|
||||||
4
.exp/scripts/repos/LATAM_Oficial/cambios
Normal file
4
.exp/scripts/repos/LATAM_Oficial/cambios
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
\e[1;31m Vercion: \e[32m2.1h\e[97m
|
||||||
|
- Fix Install Psiphond
|
||||||
|
|
||||||
|
####
|
||||||
Loading…
x
Reference in New Issue
Block a user