Created
June 28, 2023 09:50
-
-
Save Ashex/c8512ffe9bf7259e6e4488a565981acc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import requests | |
import json | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
'token', type=str, help='Bearer token, grab it from the browser or something idk') | |
parser.add_argument( | |
'user', type=str, help='the username without the domain') | |
args = parser.parse_args() | |
user_id = lookup_user(args.user, args.token) | |
reset_password(user_id, args.token) | |
# https://calckey.social/api-doc#operation/users/search | |
def lookup_user(username, token): | |
headers = { | |
'Content-Type': 'application/json', | |
'Origin': 'https://wibblur.social', | |
'authorization': f'Bearer {token}' | |
} | |
payload = { | |
'query': username, | |
'offset': 0, | |
'limit': 1, | |
'origin': 'local', | |
'detail': True | |
} | |
r = requests.post('https://wibblur.social/api/users/search', headers=headers, data=json.dumps(payload)) | |
return r.json()[0]['id'] | |
# https://calckey.social/api-doc#operation/admin/reset-password | |
def reset_password(user_id, token): | |
headers = { | |
'Content-Type': 'application/json', | |
'Origin': 'https://wibblur.social', | |
'authorization': f'Bearer {token}' | |
} | |
payload = { | |
'userId': user_id | |
} | |
r = requests.post('https://wibblur.social/api/admin/reset-password', headers=headers, data=json.dumps(payload)) | |
password = r.json()['password'] | |
print(f'Password reset to: {password}') | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment