forked from irsdl/IIS-ShortName-Scanner
/
multi_targets.sh
57 lines (46 loc) · 1.58 KB
/
multi_targets.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
#!/bin/bash
if [ -z "$1" ]; then
echo "[*] Scanning multiple targets using IIS Short Name (8.3) Scanner by Soroush Dalili - @irsdl"
echo "[*] Usage: $0 <scope file> <is_default_https (1=https)>"
echo "[*] Example: $0 scope.txt 1"
exit 0
fi
default_scheme="http"
if [ "$2" = "1" ]; then
default_scheme="https"
fi
# current directory
CUR=`pwd`
# Load scope
if [ ! -f "$1" ]; then
echo "File not found: $1"
exit 1
fi
scope=`cat "$1"`
### IIS Shortname Scanner time!
resultDir="$CUR"/iis_shortname_results
mkdir "$resultDir"
uniquehostname=()
while read target; do
if [[ "$target" =~ [\'\"]+ ]]; then
echo "Error: an invalid character was found in $1"
exit 1
fi
if [[ "$target" =~ ^[[:space:]]*$ ]]; then
# the input is whitespace!
myhostname=""
else
myhostname=`python -c "from urlparse import urlparse;url = urlparse('$target','$default_scheme');print url.scheme+'://'+url.netloc+url.path"`
if [ -z "$myhostname" ]; then
# when target is not a url (ip address for example), python variable will be empty
myhostname="$target"
fi
uniquehostname+=("$myhostname")
fi
done <<<"$scope"
# unique hosts only
uniquehostname=($(printf "%s\n" "${uniquehostname[@]}" | sort -u));
for myhostname in "${uniquehostname[@]}"; do
targetFile=$(echo "$myhostname" | tr '[\/\\\:\000-\017\177\377]' '_')
java -jar iis_shortname_scanner.jar 0 20 "$myhostname" > "$resultDir/iis_shortname_${targetFile}.txt"
done