-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrojan
More file actions
95 lines (92 loc) · 3.28 KB
/
trojan
File metadata and controls
95 lines (92 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
function send-log(){
CHATID=$(grep -E "^#bot# " "/etc/bot/.bot.db" | cut -d ' ' -f 3)
KEY=$(grep -E "^#bot# " "/etc/bot/.bot.db" | cut -d ' ' -f 2)
TIME="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
TEXT="
<code>────────────────────</code>
<b>⚠️NOTIF QUOTA HABIS⚠️</b>
<code>────────────────────</code>
<code>Username : </code><code>$user</code>
<code>Usage : </code><code>$total</code>
<code>────────────────────</code>
"
curl -s --max-time $TIME -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
}
function con() {
local -i bytes=$1;
if [[ $bytes -lt 1024 ]]; then
echo "${bytes}B"
elif [[ $bytes -lt 1048576 ]]; then
echo "$(( (bytes + 1023)/1024 ))KB"
elif [[ $bytes -lt 1073741824 ]]; then
echo "$(( (bytes + 1048575)/1048576 ))MB"
else
echo "$(( (bytes + 1073741823)/1073741824 ))GB"
fi
}
while true; do
sleep 30
data=($(cat /etc/xray/config.json | grep '^#!' | cut -d ' ' -f 2 | sort | uniq))
if [[ ! -e /etc/limit/trojan ]]; then
mkdir -p /etc/limit/trojan
fi
for user in ${data[@]}
do
xray api stats --server=127.0.0.1:10000 -name "user>>>${user}>>>traffic>>>downlink" >& /tmp/${user}
getThis=$(cat /tmp/${user} | awk '{print $1}');
if [[ ${getThis} != "failed" ]]; then
downlink=$(xray api stats --server=127.0.0.1:10000 -name "user>>>${user}>>>traffic>>>downlink" | grep -w "value" | awk '{print $2}' | cut -d '"' -f2);
if [ -e /etc/limit/trojan/${user} ]; then
plus2=$(cat /etc/limit/trojan/${user});
if [[ ${#plus2} -gt 0 ]]; then
plus3=$(( ${downlink} + ${plus2} ));
echo "${plus3}" > /etc/limit/trojan/"${user}"
xray api stats --server=127.0.0.1:10000 -name "user>>>${user}>>>traffic>>>downlink" -reset > /dev/null 2>&1
else
echo "${downlink}" > /etc/limit/trojan/"${user}"
xray api stats --server=127.0.0.1:10000 -name "user>>>${user}>>>traffic>>>downlink" -reset > /dev/null 2>&1
fi
else
echo "${downlink}" > /etc/limit/trojan/"${user}"
xray api stats --server=127.0.0.1:10000 -name "user>>>${user}>>>traffic>>>downlink" -reset > /dev/null 2>&1
fi
else
echo ""
fi
done
# Check ur Account
for user in ${data[@]}
do
if [ -e /etc/trojan/${user} ]; then
checkLimit=$(cat /etc/trojan/${user});
if [[ ${#checkLimit} -gt 1 ]]; then
if [ -e /etc/limit/trojan/${user} ]; then
Usage=$(cat /etc/limit/trojan/${user});
if [[ ${Usage} -gt ${checkLimit} ]]; then
exp=$(grep -w "^#! $user" "/etc/xray/config.json" | cut -d ' ' -f 3 | sort | uniq)
sed -i "/^#! $user $exp/,/^},{/d" /etc/xray/config.json
sed -i "/^#! $user $exp/d" /etc/trojan/.trojan.db
total=$(con ${Usage})
send-log
rm -f /etc/funny/limit/trojan/ip/$user
rm -f /etc/limit/trojan/$user
rm -f /etc/limit/trojan/quota/$user
rm -f /etc/trojan/$user
rm -f /var/www/html/trojan-$user.txt
systemctl restart xray >> /dev/null 2>&1
else
echo ""
fi
else
echo ""
fi
else
echo ""
fi
else
echo ""
fi
done
done