Skip to content

Commit

Permalink
Add scanhost-parallel.sh and documentation for it
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaran committed Dec 20, 2024
1 parent 4c6d712 commit f786fdf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,23 @@ Run in the following order:

Both tools output pipe separated values.

Use e.g. `bin/split-up-into-slash24.sh` to split up IP ranges into
/24 chunks for parallel scanning.
### Helper Tools

* Use `bin/split-up-into-slash24.sh` to split up IP ranges into /24
chunks for parallel scanning.

Understands CIDR ranges as commandline options as well as on STDIN.

* `bin/scanhost-parallel.sh` uses above script to scan large IP ranges
splitted up into /24 chunks and scanning as many as the CPU provides
threads in parallel. Amount can be set via the `-p <n>` option to
override number of scans in parallel.

Understands CIDR ranges as commandline options as well as on STDIN.

Writes results to `log/<timestamp>/{raw,interpreted}/<ip-range>.log`
and interpreted results to STDOUT, too, to provide a progress
indicator.

TODO
----
Expand Down
25 changes: 25 additions & 0 deletions bin/scanhost-parallel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#?bin/sh

bindir=$(dirname $0);
datadir="${bindir}/../log/$(date -Iminutes)"
rawdir="${datadir}/raw"
intdir="${datadir}/interpreted"

mkdir -pv "${rawdir}" "${intdir}"

if [ "$1" = "-j" ]; then
shift
p=$1
shift;
else
p=$(grep -E '^processor' /proc/cpuinfo | tail -1 | awk '{print $3+1}')
fi

if [ -n "$*" ]; then
echo "$@"
else
cat
fi | \
"${bindir}/split-up-into-slash24.sh" | \
xargs -P${p} -I'{}' sh -c \
"echo Scanning '{}'; '${bindir}/scanhost.pl' '{}' | tee '${rawdir}'"/'$(echo "{}" | sed -e "s:/[0-9]*\$:.log:") | '"'${bindir}/interpret-versions.pl' | tee '${intdir}'"/'$(echo "{}" | sed -e "s:/[0-9]*\$:.log:")'

0 comments on commit f786fdf

Please sign in to comment.