-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor, include curl verification commands, conslidate http clients
- Loading branch information
Showing
13 changed files
with
214 additions
and
157 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
"""Alias overloading tests.""" | ||
from lib.utils import graph_query | ||
from lib.utils import graph_query, curlify | ||
|
||
|
||
def alias_overloading(url, proxy, headers): | ||
"""Check for alias overloading.""" | ||
result = False | ||
res = { | ||
'result':False, | ||
'title':'Alias Overloading', | ||
'description':'Alias Overloading with 100+ aliases is allowed', | ||
'impact':'Denial of Service', | ||
'severity':'HIGH', | ||
'curl_verify':'' | ||
} | ||
aliases = '' | ||
|
||
for i in range(0, 101): | ||
aliases += 'alias{}:__typename \n'.format(i) | ||
|
||
gql_response = graph_query(url, proxies=proxy, headers=headers, payload='query { ' + aliases + ' }') | ||
|
||
|
||
res['curl_verify'] = curlify(gql_response) | ||
|
||
try: | ||
if gql_response['data']['alias100']: | ||
result = True | ||
if gql_response.json()['data']['alias100']: | ||
res['result'] = True | ||
except: | ||
pass | ||
|
||
return result | ||
return res |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
"""Batch tests.""" | ||
from lib.utils import graph_batch_query | ||
from lib.utils import graph_query, curlify | ||
|
||
|
||
def batch_query(url, proxy, headers): | ||
"""Check for batch queries.""" | ||
result = False | ||
|
||
gql_response = graph_batch_query(url, proxies=proxy, headers=headers, payload='query { __typename }') | ||
res = { | ||
'result':False, | ||
'title':'Array-based Query Batching', | ||
'description':'Batch queries allowed with 10+ simultaneous queries)', | ||
'impact':'Denial of Service', | ||
'severity':'HIGH', | ||
'curl_verify':'' | ||
} | ||
|
||
gql_response = graph_query(url, proxies=proxy, headers=headers, payload='query { __typename }', batch=True) | ||
|
||
res['curl_verify'] = curlify(gql_response) | ||
|
||
try: | ||
if len(gql_response) >= 10: | ||
result = True | ||
if len(gql_response.json()) >= 10: | ||
res['result'] = True | ||
except: | ||
pass | ||
|
||
return result | ||
return res |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
"""Directive overloading tests.""" | ||
from lib.utils import graph_query | ||
from lib.utils import graph_query, curlify | ||
|
||
|
||
def directive_overloading(url, proxy, headers): | ||
"""Check for directive overloading.""" | ||
result = False | ||
res = { | ||
'result':False, | ||
'title':'Directive Overloading', | ||
'description':'Multiple duplicated directives allowed in a query', | ||
'impact':'Denial of Service', | ||
'severity':'HIGH', | ||
'curl_verify':'' | ||
} | ||
|
||
q = 'query { __typename @aa@aa@aa@aa@aa@aa@aa@aa@aa@aa }' | ||
gql_response = graph_query(url, proxies=proxy, headers=headers, payload=q) | ||
|
||
res['curl_verify'] = curlify(gql_response) | ||
|
||
try: | ||
if len(gql_response['errors']) == 10: | ||
result = True | ||
if len(gql_response.json()['errors']) == 10: | ||
res['result'] = True | ||
except: | ||
pass | ||
|
||
return result | ||
return res |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
"""Field duplication tests.""" | ||
from lib.utils import graph_query | ||
from lib.utils import graph_query, curlify | ||
|
||
|
||
def field_duplication(url, proxy, headers): | ||
"""Check for field duplication.""" | ||
result = False | ||
res = { | ||
'result':False, | ||
'title':'Field Duplication', | ||
'description':'Queries are allowed with 500 of the same repeated field', | ||
'impact':'Denial of Service', | ||
'severity':'HIGH', | ||
'curl_verify':'' | ||
} | ||
|
||
duplicated_string = '__typename \n' * 500 | ||
q = 'query { ' + duplicated_string + '} ' | ||
gql_response = graph_query(url, proxies=proxy, headers=headers, payload=q) | ||
res['curl_verify'] = curlify(gql_response) | ||
|
||
try: | ||
if gql_response['data']['__typename']: | ||
result = True | ||
if gql_response.json()['data']['__typename']: | ||
res['result'] = True | ||
except: | ||
pass | ||
|
||
return result | ||
return res |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
"""Field suggestions tests.""" | ||
from lib.utils import graph_query, get_error | ||
from lib.utils import graph_query, get_error, curlify | ||
|
||
|
||
def field_suggestions(url, proxy, headers): | ||
"""Retrieve field suggestions.""" | ||
result = False | ||
res = { | ||
'result':False, | ||
'title':'Field Suggestions', | ||
'description':'Field Suggestions are Enabled', | ||
'impact':'Information Leakage', | ||
'severity':'LOW', | ||
'curl_verify':'' | ||
} | ||
|
||
q = 'query { __schema { directive } }' | ||
gql_response = graph_query(url, proxies=proxy, headers=headers, payload=q) | ||
res['curl_verify'] = curlify(gql_response) | ||
|
||
|
||
try: | ||
if 'Did you mean' in get_error(gql_response): | ||
result = True | ||
if 'Did you mean' in get_error(gql_response.json()): | ||
res['result'] = True | ||
except: | ||
pass | ||
|
||
return result | ||
return res |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
"""Collect all supported methods.""" | ||
from lib.utils import request_get | ||
from lib.utils import request_get, curlify | ||
|
||
|
||
def get_method_support(url, proxies, headers): | ||
"""Get the supported methods.""" | ||
result = False | ||
res = { | ||
'result':False, | ||
'title':'GET Method Query Support', | ||
'description':'GraphQL queries allowed using the GET method', | ||
'impact':'Possible Cross Site Request Forgery (CSRF)', | ||
'severity':'LOW', | ||
'curl_verify':'' | ||
} | ||
|
||
q = '{__typename}' | ||
|
||
response = request_get(url, proxies=proxies, headers=headers, params={'query':q}) | ||
|
||
res['curl_verify'] = curlify(response) | ||
|
||
try: | ||
if response and response.json()['data']['__typename']: | ||
result = True | ||
res['result'] = True | ||
except: | ||
pass | ||
|
||
return result | ||
return res |
Oops, something went wrong.