Saturday, 15 July 2017

shell - bash script: suppress intermediate output

I am running example scripts from "Kali Network Scanning" book.
Script is using hping3 to scan for a network, first of all it will scan then create a file to operate with. This file will be filtered for only alive addresses on the network:



#!/bin/bash

if [ $# != 1 ]; then
echo 1>&2 "Usage: $0 [/24 network]"
echo 1>&2 "Example: $0 192.168.1.0"
echo 1>&2 "Example will perform scan on network 192.168.1.0/24 and output file in output.txt file"

exit
fi

prefix=$(echo $1 | cut -d '.' -f 1-3)

for addr in $(seq 1 254); do
hping3 $prefix.$addr --icmp -c 1 >> handle.txt &
done
wait
grep len handle.txt | cut -d " " -f 2 | cut -d "-" -f 2 >> output.txt

rm handle.txt


The problem is the loop section is printing out the output.
I would greatly appreciate any help to fix this.



Thanks!

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...