Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $# -eq 0 ]
- then
- echo "No arguments supplied. Expecting a file with a list of ILO-IPs/DNS names to connect to. E.g. run ./ilocheck.sh /tmp/ilo-list"
- exit 1
- fi
- echo "Enter FULL AD-Account DN (required for ILO1/2) or local account name: (EX: CN=adminuser,OU=departmen1,OU=top,DC=domain,DC=local)"
- read -e userdn
- userdn64=$( echo -n $userdn | base64 -w 0 )
- echo "Enter password:"
- read -es pw
- pw64=$( echo -n $pw | base64 -w 0 )
- cat $@ | sort | while read ilo
- do
- ilourl="https://$ilo"
- echo -e "\nChecking ILO Interface on $ilourl..."
- curl -ks "$ilourl" | if grep -Pq "HP Integrated Lights-Out( 2)? Login"
- then
- echo "$ilourl is an ILO2 or ILO1 System"
- curl -ks "$ilourl/login.htm" | grep -A1 "sessionkey=" | grep -Po '\w[^\"]+' > /tmp/ilotemp
- sessionkey=$( awk 'FNR == 2 {print}' /tmp/ilotemp )
- sessionindex=$( awk 'FNR == 4 {print}' /tmp/ilotemp )
- curl -ks "$ilourl/index.htm" --header "Cookie: hp-iLO-Login=$sessionindex:$userdn64:$pw64:$sessionkey" --header "Referer: $ilourl/login.htm" | if grep -q "has detected a failed login attempt"
- then
- echo "Login on $ilourl NOT successful."
- else
- echo "Login on $ilourl successful."
- fi
- else
- curl -ks "$ilourl" | if grep -Pq "iLO [34]"
- then
- echo "$ilourl is an ILO3 or ILO4 System"
- curl -ks "$ilourl/json/login_session" -X POST --data "{\"method\":\"login\",\"user_login\":\"$userdn\",\"password\":\"$pw\"}" | if grep -q "JS_ERR_NO_PRIV"
- then
- echo "Login on $ilourl NOT successful."
- else
- echo "Login on $ilourl successful."
- fi
- else
- echo "ILO Interface of $ilourl unreachable or not found"
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement