-
Notifications
You must be signed in to change notification settings - Fork 0
/
breach-parse.sh
executable file
·106 lines (82 loc) · 3.79 KB
/
breach-parse.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
#!/usr/bin/env bash
# breach-parse
#A tool for parsing breached passwords
### Installation
#Download breached password list from magnet located here: `magnet:?xt=urn:btih:7ffbcd8cee06aba2ce6561688cf68ce2addca0a3&dn=BreachCompilation&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fglotorrents.pw%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337`
#If you don't store the password list (BreachCompilation) in `/opt/breach-parse`, specify the location like:
#`./breach-parse.sh @gmail.com gmail.txt "~/Downloads/BreachCompilation/data"`
#Run `./breach-parse.sh` for instructions
### To-Do (Future improvements)
#Create auto-installer for alias
if [ $# -lt 2 ]; then
echo "Breach-Parse v2: A Breached Domain Parsing Tool by Heath Adams"
echo " "
echo "Usage: ./breach-parse.sh <domain to search> <file to output> [breach data location]"
echo "Example: ./breach-parse.sh @gmail.com gmail.txt"
echo 'Example: ./breach-parse.sh @gmail.com gmail.txt "~/Downloads/BreachCompilation/data"'
echo "You only need to specify [breach data location] if its not in the expected location (/opt/breach-parse/BreachCompilation/data)"
echo " "
echo 'For multiple domains: ./breach-parse.sh "<domain to search>|<domain to search>" <file to output>'
echo 'Example: ./breach-parse.sh "@gmail.com|@yahoo.com" multiple.txt'
exit 1
else
if [ $# -ge 4 ]; then
echo 'You supplied more than 3 arguments, make sure to double quote your strings:'
echo 'Example: ./breach-parse.sh @gmail.com gmail.txt "~/Downloads/Temp Files/BreachCompilation"'
exit 1
fi
# assume default location
breachDataLocation="/opt/breach-parse/BreachCompilation/data"
# check if BreachCompilation was specified to be somewhere else
if [ $# -eq 3 ]; then
if [ -d "$3" ]; then
breachDataLocation="$3"
else
echo "Could not find a directory at ${3}"
echo 'Pass the BreachCompilation/data directory as the third argument'
echo 'Example: ./breach-parse.sh @gmail.com gmail.txt "~/Downloads/BreachCompilation/data"'
exit 1
fi
else
if [ ! -d "${breachDataLocation}" ]; then
echo "Could not find a directory at ${breachDataLocation}"
echo 'Put the breached password list there or specify the location of the BreachCompilation/data as the third argument'
echo 'Example: ./breach-parse.sh @gmail.com gmail.txt "~/Downloads/BreachCompilation/data"'
exit 1
fi
fi
# set output filenames
fullfile=$2
fbname=$(basename "$fullfile" | cut -d. -f1)
master=$fbname-master.txt
users=$fbname-users.txt
passwords=$fbname-passwords.txt
touch $master
# count files for progressBar
# -not -path '*/\.*' ignores hidden files/directories that may have been created by the OS
total_Files=$(find "$breachDataLocation" -type f -not -path '*/\.*' | wc -l)
file_Count=0
function ProgressBar() {
let _progress=$(((file_Count * 100 / total_Files * 100) / 100))
let _done=$(((_progress * 4) / 10))
let _left=$((40 - _done))
_fill=$(printf "%${_done}s")
_empty=$(printf "%${_left}s")
printf "\rProgress : [${_fill// /\#}${_empty// /-}] ${_progress}%%"
}
# grep for passwords
find "$breachDataLocation" -type f -not -path '*/\.*' -print0 | while read -d $'\0' file; do
grep -a -E "$1" "$file" >>$master
((++file_Count))
ProgressBar ${number} ${total_Files}
done
fi
sleep 3
echo # newline
echo "Extracting usernames..."
awk -F':' '{print $1}' $master >$users
sleep 1
echo "Extracting passwords..."
awk -F':' '{print $2}' $master >$passwords
echo
exit 0