You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bola1_locations.sh 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # Prompt the user to enter the value of HOSTNAME
  3. read -p "Enter the HOSTNAME: " HOSTNAME
  4. # Function to obtain access token for a given email and password
  5. get_access_token() {
  6. local email=$1
  7. local password=$2
  8. # Use curl to get the access token and jq to extract it
  9. local access_token=$(curl "http://$HOSTNAME/identity/api/auth/login" \
  10. -H 'Content-Type: application/json' \
  11. --data-raw '{"email":"'"$email"'","password":"'"$password"'"}' \
  12. --insecure -s | jq -j .token)
  13. echo "$access_token"
  14. }
  15. # Define the common password
  16. COMMON_PASSWORD='cRaPi2023!!!'
  17. # Define the email addresses
  18. emails=(
  19. 'apilab@akamai.com'
  20. 'apilab2@akamai.com'
  21. 'apilab3@akamai.com'
  22. 'apilab4@akamai.com'
  23. )
  24. for ((x=1; x<=10; x++)); do
  25. for ((i=0; i<${#emails[@]}; i++)); do
  26. # Generate access token
  27. access_token=$(get_access_token "${emails[i]}" "$COMMON_PASSWORD")
  28. # Get the corresponding UUID
  29. UUIDS=("b1804463-03be-4c51-88d3-e13b5b9a2331" "7e3633e8-f8e7-47a2-9076-705210dcc213" "2f3fd019-b89e-45dc-9d51-ee0aed14e550" "50e17ffb-3e81-4f93-8825-fd959310de6c")
  30. UUID=${UUIDS[i]}
  31. curl "http://$HOSTNAME/identity/api/v2/vehicle/$UUID/location" \
  32. -H "Accept: */*" \
  33. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  34. -H "Authorization: Bearer $access_token" \
  35. -H "Cache-Control: no-cache" \
  36. -H "Connection: keep-alive" \
  37. -H "Content-Type: application/json" \
  38. -H "DNT: 1" \
  39. -H "Origin: http://$HOSTNAME" \
  40. -H "Pragma: no-cache" \
  41. -H "Referer: http://$HOSTNAME/identity/api/v2/user/dashboard" \
  42. -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" \
  43. --compressed \
  44. --insecure | jq -j \
  45. # Check the esponse code
  46. if [ $? -ne 0 ]; then
  47. echo "Error: Request failed."
  48. fi
  49. done
  50. done