Last active
February 28, 2019 14:09
-
-
Save mertsalik/d846edab91c692f6a348f029d26f384b to your computer and use it in GitHub Desktop.
abuse endpoints
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 requests | |
class Abuzer(object): | |
def __init__(self, base_url, login_path): | |
self.base_url = base_url | |
self._login_path = login_path | |
self._session = requests.session() | |
def send_request(self, path, request_params): | |
request_url = "{}{}".format(self.base_url, path) | |
print("req: {}".format(request_url)) | |
response = self._session.post(request_url, headers={ | |
'HTTP_REFERER': "https://test-domain.net" | |
}, json=request_params) | |
print(response.json()) | |
print("resp: {}".format(response.status_code)) | |
def login(self): | |
self._session = requests.session() | |
login_url = "{}{}".format(self.base_url, self._login_path) | |
response = self._session.post(url=login_url, json={ | |
"username": "[email protected]", | |
"password": "123456" | |
}) | |
print("login resp: {}".format(response.status_code)) | |
def logout(self): | |
self._session = requests.session() | |
if __name__ == '__main__': | |
abuser = Abuzer(base_url="https://test-domain.net", | |
login_path="/users/login") | |
abuser.logout() | |
# send sms | |
for x in range(10): | |
abuser.send_request(path="/some-app/send-verify-sms", request_params={ | |
"phone_number": "05443332211" | |
}) | |
abuser.login() | |
for x in range(10): | |
abuser.send_request(path="/some-app/send-verify-sms", request_params={ | |
"phone_number": "05443332211" | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment