-
Notifications
You must be signed in to change notification settings - Fork 2
/
qunlocker2.sh
71 lines (52 loc) · 2.2 KB
/
qunlocker2.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
#!/bin/bash
#`7z e IMG_20180103_145734163_HDR.jpg.7z -pZAMwQKyHG482TFVjkcbYpPr5nz3DSCEe`
CMD=/usr/local/sbin/7z
PW=ZANwQKyHG482TFVjkcbYpPr5nz3DSCEe
# Make a list of all directories under root and put in a file
file='all_dirs.txt'
find ./ -type d > $file
# If these are found in the file name replace these chars with _ in the logic below
declare weirdchars=" !)=(&\'"
# Go through all directories in that file
i=1
while read line;
do
#Reading each line
#echo "Line No. $i : $line"
search_dir=$line
for the_file in "$search_dir"/*
do
#echo File : "$the_file"
if [[ $the_file == *.7z ]];
then
echo "============> Found 7z file $the_file"
new_file_name="${the_file//[${weirdchars}]/_}"
[[ ! -a "$new_file_name" ]] && \
mv -f "$the_file" "$new_file_name" && the_file=${new_file_name}
echo new file: $new_file_name
the_file_without_extn="${the_file%.*}"
echo "basename: $the_file_without_extn"
if [[ -f "$the_file_without_extn" ]];
then
echo "Deleting already extracted file $the_file"
rm -f "$the_file"
else
echo "Need to Extract File..trying"
$CMD e "$the_file" -o"$search_dir" -p$PW 1> /dev/null
if [ $? -ne 0 ]
then
echo "failed to extract"
else
echo success remove file!
rm -f "$the_file"
fi
fi
fi
if [[ $the_file == *!!!READ_ME.txt ]]
then
echo "Getting rid of hackers message"
rm -f $the_file
fi
done
i=$((i+1))
done < $file