Advertisement
Guest User

Untitled

a guest
May 26th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Author: Wes Fitzpatrick
  4. #
  5. # This script will inject a list of ip addresses contained in a temporary
  6. # file or convert a list of hostnames to ip addresses for injecting.
  7. #
  8. # Change History:
  9. # 20110317 Created.
  10. # 20110511 Removed for loop, replaced with perl expression to consolidate hostnames and run only one query for all.
  11.  
  12. user="system"
  13. pass="system"
  14.  
  15. rm -f ips.tmp
  16. rm -f list2.tmp
  17.  
  18. clear
  19. echo ""
  20. echo "Looking up hostnames from list.tmp"
  21. echo ""
  22.  
  23. echo "Is this a list of Hostnames? (Yy/Nn): "
  24. read $ANS
  25.  
  26. if [ ${ANS} = Y -o ${ANS} = y ]; then
  27. perl -pe 's/\n/|/g' list.tmp > list2.tmp
  28. sed "s/|$//g" list2.tmp > list.tmp
  29. hostlist=`cat list.tmp | sort | uniq`
  30.  
  31. 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
  32. echo ""
  33.  
  34. else
  35. cat list.tmp > ips.tmp
  36. fi
  37.  
  38. sed -i "s/'//g" ips.tmp
  39. sed -i "s/\[//g" ips.tmp
  40. sed -i "s/\]//g" ips.tmp
  41. sed -i "s/, /\n/g" ips.tmp
  42.  
  43. echo "Start a scan for these endpoints? (Yy/Nn): "
  44. read SCAN
  45. if [ ${SCAN} = Y -o ${SCAN} = y ]; then
  46. echo "Injecting ip addresses into Tideway ......."
  47. /usr/tideway/bin/tw_injectip -u "$user" -p "$pass" --label="Injected IPs" --file ips.tmp
  48. echo "DONE !"
  49. fi
  50.  
  51. echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement