Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Author: Wes Fitzpatrick
- #
- # This script will inject a list of ip addresses contained in a temporary
- # file or convert a list of hostnames to ip addresses for injecting.
- #
- # Change History:
- # 20110317 Created.
- # 20110511 Removed for loop, replaced with perl expression to consolidate hostnames and run only one query for all.
- user="system"
- pass="system"
- rm -f ips.tmp
- rm -f list2.tmp
- clear
- echo ""
- echo "Looking up hostnames from list.tmp"
- echo ""
- echo "Is this a list of Hostnames? (Yy/Nn): "
- read $ANS
- if [ ${ANS} = Y -o ${ANS} = y ]; then
- perl -pe 's/\n/|/g' list.tmp > list2.tmp
- sed "s/|$//g" list2.tmp > list.tmp
- hostlist=`cat list.tmp | sort | uniq`
- tw_query --username $user --password $pass "search Host where name matches regex \"(${hostlist})\" traverse InferredElement:Inference:Associate:DiscoveryAccess where _last_marker show endpoint" | tail -n +7 > ips.tmp
- echo ""
- else
- cat list.tmp > ips.tmp
- fi
- sed -i "s/'//g" ips.tmp
- sed -i "s/\[//g" ips.tmp
- sed -i "s/\]//g" ips.tmp
- sed -i "s/, /\n/g" ips.tmp
- echo "Start a scan for these endpoints? (Yy/Nn): "
- read SCAN
- if [ ${SCAN} = Y -o ${SCAN} = y ]; then
- echo "Injecting ip addresses into Tideway ......."
- /usr/tideway/bin/tw_injectip -u "$user" -p "$pass" --label="Injected IPs" --file ips.tmp
- echo "DONE !"
- fi
- echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement