Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- :<<israeltorres_comment_block
- ./test_ldap.sh
- Israel Torres
- Mon Mar 12 15:04:12 PDT 2012
- run a few tests on potentional LDAP server on port 389
- Mac OS X 10.7.3 11D50b
- Darwin Kernel Version 11.3.0
- GNU bash, version 3.2.48(1)-release
- israeltorres_comment_block
- function use_netcat_a(){
- #required app check
- rqdapp='nc' # check netcat
- hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - returning"; return 1; }
- nc -z $TARGETADDRESS 389
- }
- function use_netcat_b(){
- #required app check
- rqdapp='nc' # check netcat
- hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - returning"; return 1; }
- echo "1" | nc $TARGETADDRESS 389; if [ $? -eq 0 ]; then echo "[Connection Appears Good]"; else echo "[Unable to connect!]"; fi
- }
- function use_nmap_a(){
- #required app check
- rqdapp='nmap' # check nmap
- hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - returning"; return 1; }
- nmap $TARGETADDRESS -p 389
- }
- function use_ldapsearch(){
- TARGETADDRESS=$1
- #required app check
- rqdapp='ldapsearch' # check ldapsearch
- hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - returning"; return 1; }
- ldapsearch -x -h $TARGETADDRESS -b dc=test,dc=test
- }
- if [ ! $# -lt 1 ]; then
- TARGETADDRESS=$1
- use_netcat_a $TARGETADDRESS
- use_netcat_b $TARGETADDRESS
- use_nmap_a $TARGETADDRESS
- use_ldapsearch $TARGETADDRESS
- else
- echo "usage: $0 'TARGETADDRESS'"
- echo "example: $0 192.168.1.1"
- fi
- #eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement