IsraelTorres

test_ldap.sh

Mar 12th, 2012
119
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. :<<israeltorres_comment_block
  3.  
  4.  ./test_ldap.sh
  5.  Israel Torres
  6.  Mon Mar 12 15:04:12 PDT 2012
  7.  run a few tests on potentional LDAP server on port 389
  8.  
  9.  Mac OS X 10.7.3 11D50b
  10.  Darwin Kernel Version 11.3.0
  11.  GNU bash, version 3.2.48(1)-release
  12.  
  13. israeltorres_comment_block
  14.  
  15. function use_netcat_a(){
  16. #required app check
  17. rqdapp='nc' # check netcat
  18. hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - returning"; return 1; }
  19. nc -z $TARGETADDRESS 389
  20. }
  21.  
  22. function use_netcat_b(){
  23. #required app check
  24. rqdapp='nc' # check netcat
  25. hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - returning"; return 1; }
  26. echo "1" | nc $TARGETADDRESS 389; if [ $? -eq 0 ]; then echo "[Connection Appears Good]"; else echo "[Unable to connect!]"; fi
  27. }
  28.  
  29. function use_nmap_a(){
  30. #required app check
  31. rqdapp='nmap' # check nmap
  32. hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - returning"; return 1; }
  33. nmap $TARGETADDRESS -p 389
  34. }
  35.  
  36. function use_ldapsearch(){
  37. TARGETADDRESS=$1
  38. #required app check
  39. rqdapp='ldapsearch' # check ldapsearch
  40. hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - returning"; return 1; }
  41. ldapsearch -x -h $TARGETADDRESS -b dc=test,dc=test
  42. }
  43.  
  44. if [ ! $# -lt 1 ]; then
  45.     TARGETADDRESS=$1
  46.     use_netcat_a $TARGETADDRESS
  47.     use_netcat_b $TARGETADDRESS
  48.     use_nmap_a  $TARGETADDRESS
  49.     use_ldapsearch $TARGETADDRESS
  50. else
  51.     echo "usage: $0 'TARGETADDRESS'"
  52.     echo "example: $0 192.168.1.1"
  53. fi
  54. #eof
RAW Paste Data