-
Notifications
You must be signed in to change notification settings - Fork 0
/
secure_recieve.sh
144 lines (136 loc) · 3.64 KB
/
secure_recieve.sh
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
# (c) J~NET 2021
# jnet.sytes.net
#
# https://jnet.forumotion.com/t1729-jnet-multi-tool-2021#2677
# https://jnet.forumotion.com/t1744-secure-chat-bash-app#2702
#
lport=777
if [ ! -f server.pem ]
then
echo "This will now attempt to help you create a Certificate key file, fill out the following!..."
openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout server.pem -out server.crt
fi
SSL_crt="server.crt"
SSL_pem="server.pem"
host_ip=`cat config/remote_host.txt`
port=`cat config/port.txt`
echo "Welcome To Recieve A Message"
echo "You will need port $port open in your firewall and router port fowarding rules setup!"
echo ""
echo "If asked about an admin alias, create one and dont share it with anyone else for security"
echo "Unless you TRUST them!"
echo ""
echo ""
echo "Enter Key"
read -s key
#
if test -z "$key"
then
key_icon="🔓 No Key"
else
key_icon="🔒 Locked!"
fi
sound=`cat config/sound.txt`
function Atone(){
aplay -q $1
#echo -e "\07"
}
function showdate(){
date=$(date) # +%Y-%m-%d
data="Date Is: $date"
#output=${data} | openssl enc -d -des3 -base64 -pass pass:$1 -pbkdf2
echo $data
}
function cmmd(){
local_ip="config/ip.txt"
if [ ! -f "$local_ip" ];
then
echo "Please Confirm Local IP"
read local_ip
echo "$local_ip" > config/ip.txt
fi
localip=`cat config/ip.txt`
#/bin/bash -i >& /dev/tcp/$localip/$port 0>&1
#
#sudo nc -l -p $lport > config/rmsg.txt #&& cat config/rmsg.txt
#while ! echo exit | sudo nc -l -p $port > config/rmsg.txt 13; do sleep 10; done
valuec=`cat config/rmsg.txt`
#decode:
echo "$valuec" | openssl enc -d -des3 -base64 -pass pass:$key -pbkdf2 > cmd.txt
cat cmd.txt
IN=`cat cmd.txt`
delim=":"
arrIN=(${IN//$delim/ })
cmd_out=${arrIN[0]}
cmd_out_req=${arrIN[2]}
#cmd_out_req=${arrIN[2]}
echo "Reqesting Admin $cmd_out"
echo "Requested Command $cmd_out_req"
admin_file="config/admins.txt"
if test -f "$admin_file";
then
echo "$admin_file exists."
if grep -q $cmd_out "$admin_file"; # Where cmd_out is admin alias name!
then
# Some Actions # $string was found
echo "Admin Authenticated"
# Running Command Code Goes Here!
#output=$($cmd_out_req)
#echo $output > remote/output.txt
#cat remote/output.txt
else
echo "Not A Valid Admin"
fi
else
# Setting up Admins
echo "Setting Up Your Admin Account Name"
echo "What Alias you want to accept admin commands from remotely? (Leave blank for none!)"
read admin
echo "$admin" > config/admins.txt
echo "OK Admin Added to admins file found in config/admins.txt"
fi
}
while true;
do
echo -en "\e[92m "
echo "$key_icon"
echo ""
echo "Previous Message: "
echo ""
cat config/decrypted.txt
echo "Waiting For New Message"
echo ""
sudo ncat -l -w 550ms -v -p $port --ssl-key $SSL_pem --ssl-cert $SSL_crt > config/rmsg.txt &&
cat config/rmsg.txt | openssl enc -d -des3 -base64 -pass pass:$key -pbkdf2 > config/decrypted.txt
cat config/decrypted.txt
sleep 0.006
cat config/decrypted.txt >> config/all_messages.txt
Atone $sound
data=`cat config/decrypted.txt`
if [[ $data = *#Date* ]];
then
echo "Admin Command Recieved"
echo $data
# Function Test!
showdate "$key"
elif [[ $data = *#Cmd* ]];
then
echo "Admin Command Recieved"
echo $data
cmmd
elif [[ $data = *#Alert* ]];
then
echo "Admin Command Recieved"
echo $data
Atone $sound
else
echo $data
fi
#echo -en "\e[70m \c"
sleep 5
#bash recieve.sh
done
exit
#bash recieve.sh
#