ÈÐ Wïgê† Ðð† ñåmê

ïñ£ð§ê¢, ïñ£ðrmå†ïðñ §ê¢µr, Ðïgï†ål £ðrêñ§ï¢§, hå¢kïñg, §¥§†êm åÐmïñ阮rå†ïðñ, lïñµx ßlðg


I am often on the go, and sometimes I only have a few hours to do something.  A scenario came up where I have a few hours of time and I wanted to do a quick pentest of a few sites during that time.  I had a long list of domains to audit, and during the previous two days I had started at the top of the list and worked my way down.  I had made it through about 13 domains, but had 150+ left to go.  So its during these brief periods where I could perform the bulk scan of a few domains that could help me stay on track to get this job completed on time.  Except, I didn’t have a way to really select 5 or 6 domains from the list without doing it manually.

I came up with an idea, what if I could randomly select a few hosts from the list, then keep track of the hosts I had audited this way….eventually I would get through the entire list.  The following script is what I came up with…

[codesyntax lang=”bash” title=”randomize_hosts.sh”]

#!/bin/bash

# By Ed Wiget
# This script takes a list of items you provide, randomizes it, and then saves the number of entries you select to a file
# originally written to randomly audit a list of domain names from a master list of domains
# limiting the number to 5

echo -e "Enter the full path to the file to be randomized\n\n\ti.e. if you have a list of domain names 1 per line\n\n\t/path/to/list/to-audit.txt"
read LONG_LIST

echo -e "Enter the path to save the output file\n\n\ti.e. /home/user/mylist-`date +%Y%m%d`.txt"
read OUT_FILE

echo -e "Enter a numeric value of items to be included in the output file\n\n\ti.e. if you want 10 items, enter 10"
read LIST_VALUE

for i in `cat ${LONG_LIST}`; do echo "${RANDOM} ${i}"; done | sort | sed -r 's/^[0-9]+ //' | head -${LIST_VALUE} > ${OUT_FILE}

[/codesyntax]


Leave a Reply