[COFF] Useful Shell Scripts Network Connections , Logins and Block hacking attempts
Ralph Corderoy
ralph at inputplus.co.uk
Thu May 11 19:18:57 AEST 2023
Hi,
>From a quick skim, these seem poorly written. They might do what's
required some of the time but are no better than a quickly knocked-up
attempt I'd do myself.
> Use the awk command to display only the data in column 5, and then
> display the information of the IP address in column 1
...
> netstat -atn | awk '{print $5}' | awk '{print $1}' | sort -nr | uniq -c
The second awk does nothing, even though it's documented.
> find $dir -type f|xargs md5sum > /tmp/md5_a.txt
> ssh $b_ip "find $dir -type f|xargs md5sum > /tmp/md5_b.txt"
> scp $b_ip:/tmp/md5_b.txt /tmp
> #Compare file names as traversal objects one by one
> for f in `awk '{print 2} /tmp/md5_a.txt'`
Looks like that ‘print 2’ should be $2. Presumably it was corrupted on
its long journey of cut-and-pastes and renderings. The '' quoting is
also adrift as what's there lumps the AWK with the input's path.
> if grep -qw "$f" /tmp/md5_b.txt
This checks if an A file is present in B. There is nothing to spot new
files in B not in A.
> then
> md5_a=`grep -w "$f" /tmp/md5_a.txt|awk '{print 1}'`
> md5_b=`grep -w "$f" /tmp/md5_b.txt|awk '{print 1}'`
Both 1 should be $1 to get the MD5 for the path. And grep's -w isn't
the right way to pick out the line.
$ md5sum * | grep -w foo
d41d8cd98f00b204e9800998ecf8427e foo
d41d8cd98f00b204e9800998ecf8427e foo extra
$
I didn't read further.
--
Cheers, Ralph.
More information about the COFF
mailing list