-
Notifications
You must be signed in to change notification settings - Fork 64
/
encall.sh
120 lines (104 loc) · 2.94 KB
/
encall.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
#!/bin/bash
#cito M:755 O:0 G:0 T:/usr/local/bin/crypto
#----------------------------------------------------------------------------------
# A Bourne POSIX shell script acting as a wrapper for another written in Python, -
# called 'crypto.py', available with the following:
#
# wget https://raw.githubusercontent.com/bing0o/Python-Scripts/master/crypto.py
# chmod 755 crypto.py; chown 0:0 crypto.py
# sudo mv crypto.py /usr/local/bin/crypto
#
# If you have Cito (https://github.com/terminalforlife/Extra):
#
# sudo cito -r bing0o Python-Scripts master crypto.py
#
# WARNING: Change the default password!
#----------------------------------------------------------------------------------
#set -x
#CurVer='2019-12-13'
CurVer='2020-03-21'
Progrm=${0##*/}
Err(){
printf "ERROR: %s\n" "$2" 1>&2
[ $1 -gt 0 ] && exit $1
}
Domain='https://github.com'
Usage(){
while read -r CurLine; do
printf "%b\n" "$CurLine"
done <<-EOF
\r ENCALL ($CurVer)
\r Originally written by bing0o <[email protected]>
\r Revised by terminalforlife <[email protected]>
\r A simple Bourne POSIX wrapper for Python script Crypto.
\rSYNTAX: $Progrm [OPTS] [FILE_1 [FILE_2] ...]
\rOPTS: --help|-h|-? - Displays this help information.
\r --version|-v - Output only the version datestamp.
\r --encrypt|-e - Encrypts one or more files.
\r --decrypt|-d - Decrypts one or more files.
\r --password|-p STR - Where STR is the password to use.
\r --depth|-t INT - Where INT is the Number of depth(Default:1).
\rSITE: $Domain/bing0o/bash_scripting
\r $Domain/bing0o/Python-Scripts
EOF
}
Password='P4ssw@rD'
if [ $# -eq 0 ]; then
Usage; exit 1
fi
num=1
while [ "$1" ]; do
case $1 in
--encrypt|-e)
Action='-e'
Actioning='Encrypting' ;;
#shift ;;
--decrypt|-d)
Action='-d'
Actioning='Decrypting' ;;
#shift ;;
--password|-p)
shift
if [ -z "$1" ]; then
Err 1 "Password mising for the '--password|-p' option."
else
Password=$1
fi ;;
-t|--depth)
num=$2
shift ;;
--help|-h|-\?)
Usage; exit 0 ;;
--version|-v)
printf "%s\n" "$CurVer"; exit 0 ;;
*)
Usage; exit 1 ;;
esac
shift
done
if ! command -v crypto 1> /dev/null 2>&1; then
Err 1 "Dependency 'crypto' not met."
fi
list=()
path="."
for i in $(seq 1 $num); do
path=$path"/*"
for i in $path; do
if [ "$Action" = '-e' ]; then
[ "${i##*.}" = 'hacklab' ] && continue
elif [ "$Action" = '-d' ]; then
[ "${i##*.}" = 'hacklab' ] || continue
fi
[ -f "$i" ] && list+=("$i")
done
done
c=1
all=${#list[@]}
for CurFile in "${list[@]}"; do
printf "[+] %s: %s\n" "$Actioning ($c/$all)" "$CurFile"
crypto "$Action" "$CurFile" -p "$Password" 1>/dev/null
# make the deleted file unrecoverable using shred.
shred -n 10 -z --remove "${CurFile}"
let c+=1
done
printf "[*] Done!\n"