After sitting on Magic Banana's suggested executable script for the
near-forever four days, I found the
time and concentration to try it.
First, I stripped those trailing dots (which facilitated pasting nmap's
random 3rd & 4th octets) with the
sed script suggested by Magic Banana:
sed -i
Here's what I was trying to accomplish:
Starting with Magic Banana's script:
TMP=$(mktemp -u)
trap "rm $TMP 2>/dev/null" 0
mkfifo $TMP
awk '{ for (i = 0; ++i $TMP &
od -A n -t u1 -w2 -N $(expr 1024 \* $(wc -l <
"Prefixes.May2020.Slash16.txt")) /dev/urandom | tr -s ' ' . | paste -d ''
$TMP
Alas, I could not make Magic Banana's script for generating reandomized IPv4
addresses work;
most certainly by my failure to comprehend what's going on sufficiently. I
tried constructing
an od script, but the best I could do was to generate 3rd & 4th octets which
violate the 255
maxiumum of
About my playing with the end-of-line character (\n) ...
Applying nMap's grepable-output function, as in this script:
sort TestGrepOutnMapNine.txt |
sudo nmap -Pn -sn -T4 --max-retries 16 --script asn-query -iL '-' -oG - |
grep "Host:" '-' > TestGrepOutnMapNineGrep.txt
eliminates the blank lines
Alas, sed won't let me play with the end-parentheses character, even when I'm
using it
as a handle to select the immediately following newline character and to
select where
to position the substitute tab: [)n] to be replaced by [)t]. I haven't worked
out a
suitable adaptation of Magic
Magic Banana's magnificent script to fill out the listing of prefixes with
random octets looks like
this for a specific set of two-octet prefixes:
TMP=$(mktemp -u)
trap "rm $TMP 2>/dev/null" 0
mkfifo $TMP
awk '{ for (i = 0; ++i
xiferp=$(tail "-n $retnuoc" "SS.IPv4-NLU-January2020-26Prefixes.txt" | head
"-n 1")
26 prefixes - add them to an array first, then use foreach loop
https://linuxconfig.org/how-to-use-arrays-in-bash-script
Following Jaret's contribution, and also restructuring my script according to
this link:
https://www.linuxquestions.org/questions/programming-9/nested-while-loops-for-bash-novice-4175439318/
!/bin/bash
retnuoc=1
counter=1
for (( retnuoc ; retnuoc < 3 ; retnuoc++ )); do
for (( counter ; counter
/bin/sh is not bash
It doesn't understand bash's syntax (counter++)
/bin/bash is bash
in scripts use:
#!/bin/bash
Here is a script that is intended to generate a series of IPv4 addresses in
CIDR/16 address space:
counter=1
while [ $counter -le 4096 ]
do prefix=185.180; dd if=/dev/urandom bs=2 count=1 2>/dev/null | od -An -tu1
| tr -s ' ' . | sed s/^/$prefix/ >> Temp42120Works.txt
((counter++))
done
10 matches
Mail list logo