Thursday, 29 December 2016

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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...