- Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathPython_HTTP_Stress_Tester.py
More file actions
Latest commit
71 lines (62 loc) · 2.31 KB
/
Copy pathPython_HTTP_Stress_Tester.py
File metadata and controls
71 lines (62 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# I am not responsible for what you do with this application
# Yo no soy responsable de lo que haces con esta aplicación
# je ne suis pas responsable de ce que vous faites avec cette application.
# USE ON YOUR OWN RISK.
# WITH NO ANY EXPRESS OR IMPLIED WARRANTIES
# EMPLOI SUR VOS PROPRES RISQUES.
# SANS AUCUNE GARANTIE EXPLICITE OU IMPLICITE
# This is a simple http flooder to test YOUR server with multiples requests
# Copyright 2012 Arnaud Alies <mouu@hush.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
fromthreadingimportThread
fromurllibimporturlopen
fromatexitimportregister
fromosimport_exit
fromsysimportstdout, argv
defauto_send_request(server, number_of_requests=10):
forzinrange(number_of_requests):
try:
urlopen(server)
stdout.write(".")
exceptIOError:
stdout.write("E")
defflood(url, number_of_requests=1000, number_of_threads=50):
number_of_requests_per_thread=int(number_of_requests/number_of_threads)
try:
forxinrange(number_of_threads):
Thread(target=auto_send_request, args=(url, number_of_requests_per_thread)).start()
except:
stdout.write("\n[E]\n")
clean_exit()
print("\nDone %i requests on %s"% (number_of_requests, url))
defclean_exit():
print("\nQuitting...")
_exit(0)
defmain():
register(clean_exit)
try:
server=str(argv[1])
requests=int(argv[2])
exceptIndexError:
print("You can launch your script using: \npython filename.py http://server/ requests\nexample: python http://localhost/ 10000")
server=raw_input("Server: ")
requests=input("N° requests: ")
flood(server, requests)
if__name__=='__main__':
main()