-
Notifications
You must be signed in to change notification settings - Fork 1
/
crackcat
executable file
·147 lines (122 loc) · 3.87 KB
/
crackcat
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
145
146
147
#!/bin/bash
echo ""
echo -e "\033[1;32m$(cat ./assets/banner)\033[0m"
echo ""
touch /home/$(whoami)/.local/share/hashcat/hashcat.potfile
hash=$1
cracked=0
not_installed=0
check(){
which $1 >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
echo -n ""
else
echo -e "\033[41m$1 is not installed.\033[0m"
not_installed=1
fi
}
check hashcat
touch /tmp/err
if [ $not_installed -eq 1 ]
then
echo -e "\033[1;41mInstall the required tool(s)\033[0m"
exit
fi
touch /tmp/crack
x=$(timeout 2 hashcat $hash 2>/dev/null >/tmp/abcd; cat /tmp/abcd | grep "your input" | cut -d " " -f 8)
echo -e "\033[1;32m[+] Finding Possible Hash Types\033[0m"
if [ "$x" == "only" ]
then
cat /tmp/abcd | grep "your input" -C 2 | tail -n 1 >/tmp/possible-hashtypes
else
hashcat $hash 2>/dev/null | grep "your input" -A $((x+3)) | tail -n $x 2>/dev/null | awk '{$1=$1};1' >/tmp/possible-hashtypes
fi
if [ $(cat /tmp/possible-hashtypes | wc -l) -eq 0 ]
then
echo -e "\033[1;31m No possible hashes found, I suggest You to take a look at (https://hashcat.net/wiki/doku.php?id=example_hashes) manually and run the command below \033[0m"
if [ $# -eq 2 ]
then
echo "hashcat -m <hashvalue> -a 0 -d 1 $hash $2"
else
echo "hashcat -m <hashvalue> -a 0 -d 1 $hash /usr/share/wordlists/rockyou.txt"
fi
exit
fi
cat /tmp/possible-hashtypes | cut -d "|" -f 2 | while read line
do
echo -e " \033[1;35;43m $line \033[0m"
done
cat /home/$(whoami)/.local/share/hashcat/hashcat.potfile | grep -i $hash >/dev/null
if [ $? -eq 0 ]
then
echo -e "\033[1;32m[+] Found The Hash in Potfile\033[0m"
echo $hash | grep ":" > /dev/null
if [ $? -eq 0 ]
then
cat "/home/$(whoami)/.local/share/hashcat/hashcat.potfile" | grep -i $hash | cut -d ":" -f 3 | xargs -I{} bash -c "echo -e '\033[1;32mThe Plaintext Is : \033[7;34m{}\033[0m'"
else
cat "/home/$(whoami)/.local/share/hashcat/hashcat.potfile" | grep -i $hash | cut -d ":" -f 2 | xargs -I{} bash -c "echo -e '\033[1;32mThe Plaintext Is : \033[7;34m{}\033[0m'"
fi
exit
fi
if [ $# -eq 1 ] & [ ! -f "/usr/share/wordlists/rockyou.txt" ]
then
echo "The file rockyou.txt doesn't seem to exist at its default path, You need to pass a wordlist."
exit
fi
n=$(cat /tmp/possible-hashtypes | wc -l)
echo ""
echo -e "\033[1;32m[+] Trying To Crack Different Possible Hash Types\033[0m"
for (( i=1; i<=$n; i++))
do
line=$(cat /tmp/possible-hashtypes | head -n $i | tail -n 1);
hashname=$(echo $line | cut -d "|" -f 2 | awk '{$1=$1};1')
hashval=$(echo $line | cut -d "|" -f 1 | awk '{$1=$1};1')
echo -e "Trying \033[1;35;47m $(echo $line | cut -d "|" -f 2 | awk '{$1=$1};1') \033[0m"
if [ $# -eq 2 ]
then
hashcat -m $hashval -a 0 -d 1 $hash $2 2>/tmp/err >/tmp/crack
if [ $? -ne 0 ]
then
echo -e "\033[1;35;47m $(echo $line | cut -d "|" -f 2 | awk '{$1=$1};1') \033[0m Failed"
echo ''
continue
else
cracked=1
fi
else
hashcat -m $hashval -a 0 -d 1 $hash /usr/share/wordlists/rockyou.txt 2>/tmp/err >/tmp/crack
if [ $? -ne 0 ]
then
echo -e "\033[1;35;47m $(echo $line | cut -d "|" -f 2 | awk '{$1=$1};1') \033[0m Failed"
echo ''
continue
else
cracked=1
fi
fi
cat /tmp/crack | grep "Cracked\|found as potfile" >/dev/null
if [ $? -eq 0 ]
then
cat /tmp/crack | grep Cracked >/dev/null
if [ $? -eq 0 ]
then
echo $hash | grep ":" > /dev/null
if [ $? -eq 0 ]
then
cat /tmp/crack | grep Cracked -B 3 | head -n 1 | cut -d ":" -f 3 | xargs -I{} bash -c "echo -e '\033[1;32mThe Plaintext Is : \033[7;34m{}\033[0m'"
else
cat /tmp/crack | grep Cracked -B 3 | head -n 1 | cut -d ":" -f 2 | xargs -I{} bash -c "echo -e '\033[1;32mThe Plaintext Is : \033[7;34m{}\033[0m'"
fi
exit
fi
else
continue
fi
done
rm /tmp/crack /tmp/err /tmp/possible-hashtypes /tmp/abcd
if [ $cracked -eq 0 ]
then
echo -e "\033[1;31;47m Password Not Found In Wordlist/The hash type doesn't match \033[0m"
fi