Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Added load-testing script (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsingh93 committed Nov 4, 2016
1 parent 211f512 commit 84b7a9d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
70 changes: 70 additions & 0 deletions extra/load-tester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env python2

import requests
import grequests
import json
import time

interval = 1
url = 'https://10.10.10.5'

verify = False

endpoints = [
'/index.php?p=game',
'/index.php?p=scoreboard&modal=scoreboard',
'/data/scores.php',
'/data/configuration.php',
'/data/country-data.php',
'/data/map-data.php',
'/data/teams.php',
'/data/command-line.php',
'/inc/gameboard/modules/announcements.php',
'/inc/gameboard/modules/filter.php',
'/inc/gameboard/modules/activity.php',
'/inc/gameboard/modules/teams.php',
'/inc/gameboard/modules/leaderboard.php',
'/inc/gameboard/modules/game-clock.php',
]

def check_ok(r, *args, **kwargs):
if r.status_code != 200:
print '[!] Received bad status code: ' + r.status_code

def exception(r, e):
print '[!] Request failed: ' + str(e)

def login():
s = requests.Session()
uri = url + '/index.php?ajax=true'
data = {
'action': 'login_team',
'team_id': '1',
'teamname': 'admin',
'password': 'password',
}
r = s.post(uri, data=data, verify=verify)
res = json.loads(r.content)
if res['result'] == 'OK':
print '[+] Logged in successfully'
else:
print '[!] Log in failed, exiting'
exit(1)

return s

def main():
s = login()

rs = [grequests.get(url + endpoint, callback=check_ok, session=s, verify=verify)
for endpoint in endpoints]
while True:
print '[+] Sending %d requests...' % len(rs)
start_time = time.time()
grequests.map(rs)
duration = time.time() - start_time
print '[+] done in %d seconds' % duration
time.sleep(interval)

if __name__ == '__main__':
main()
10 changes: 10 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

CSRF_TOKEN=$1
SESSION=$2
FLAG=${3:-a}
LEVEL_ID=${4:-1}

for i in {0..10}; do
curl 'https://10.10.10.5/index.php?p=game&ajax=true' -H "Cookie: Leaderboard=close; Announcements=close; Activity=close; Teams=close; Filter=close; Game Clock=close; FBCTF=$SESSION" -H 'Origin: https://10.10.10.5' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8,en-GB;q=0.6' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: */*' -H 'Connection: keep-alive' --data "action=answer_level&level_id=$LEVEL_ID&answer=$FLAG&csrf_token=$CSRF_TOKEN" --compressed --insecure &
done

0 comments on commit 84b7a9d

Please sign in to comment.