-
Notifications
You must be signed in to change notification settings - Fork 0
/
find-smb.sh
executable file
·48 lines (40 loc) · 1.02 KB
/
find-smb.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
#!/bin/sh
set -eu
usage() {
echo "Usage: ${0##*/} <target-hosts-list.txt> <exclude-hosts-list.txt>"
}
if [ "$#" -eq 0 ]; then
echo "Error: Target hosts must be specified"
usage
exit 1
fi
if [ "$1" = "-h" ]; then
usage
exit 0
fi
hosts=`cat $1`
echo $hosts
echo "Target: ${hosts}"
today=`date +%Y%m%d`
if [ ! -d ./results/${today} ]; then
mkdir -p ./results/${today}
fi
if [ "$#" -eq 2 ]; then
exclude_hosts=`cat $2`
for h in $hosts
do
host_name=`echo $h | tr "/" "_"`
now=`date +%Y%m%d_%H%M%S`
echo "Now Launching: nmap --exclude ${exclude_hosts} -p445 -v -oX results/${today}/${host_name}_smb_${now}.xml ${h}"
nmap --exclude ${exclude_hosts} -p445 -v -oX results/${today}/${host_name}_smb_${now}.xml ${h}
done
fi
if [ "$#" -eq 1 ]; then
for h in $hosts
do
host_name=`echo $h | tr "/" "_"`
now=`date +%Y%m%d_%H%M%S`
echo "Now Launching: nmap -p445 -v -oX results/${today}/${host_name}_smb_${now}.xml ${h}"
nmap -p445 -v -oX results/${today}/${host_name}_smb_${now}.xml ${h}
done
fi