Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the atack generation of graphql queries and mutations #122

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove new line, tab and cr after removing comments
  • Loading branch information
bandronic committed May 22, 2023
commit 674ef46933248667eed1a09a00e076717914a138
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ After building InQL as described above, you can prepare your development environ
Begin by setting up a virtual environment with Python 2.7 for Jython compatibility. Note that necessary headers are required to build libraries with pip. For instance, using virtualenv:

```bash
$ sudo apt install -y python2.7 python2.7-dev python2-setuptools-whl python2-pip-whl python3-virtualenv
$ sudo apt install -y python2.7 python2.7-dev python2-setuptools-whl python2-pip-whl python3-virtualenv libssl-dev
$ virtualenv -p python2.7 ./venv/
```

Expand Down
9 changes: 5 additions & 4 deletions python/inql/attacker/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_attack_request(self):
info = helpers.analyzeRequest(self.editor.request)
headers = info.getHeaders()
raw = helpers.bytesToString(self.editor.request[info.getBodyOffset():])
body = str(raw).replace('\\r', '').replace('\\n', ' ').replace('\\t', '')
body = str(raw) #.replace('\\r', '').replace('\\n', ' ').replace('\\t', '')
parsed = json.loads(body)
if isinstance(parsed, list):
parsed = parsed[0]
Expand All @@ -47,6 +47,7 @@ def generate_attack_request(self):
actionMatch = re.search('([^{]*?){(.+)}([^}]*?)', query, re.DOTALL)
action, query, tmp = actionMatch.groups()
query = self.stripComments(query)
query = re.sub(r'\n|\r|\t', '', query)
prefix, suffix, exploit = "", "", ""
while True:
# FIXME: whitespace inbetween will break the regex!
Expand Down Expand Up @@ -79,7 +80,7 @@ def generate_attack_request(self):
# $[INT:first:last]
start, end = args
for n, item in enumerate(range(int(start), int(end)+1)):
exploit +='op%s: %s%s%s%s{%s}%s\n' % (n+1, prefix, lead, item, rest, query, suffix)
exploit +='op%s: %s%s%s%s{%s}%s' % (n+1, prefix, lead, item, rest, query, suffix)
if verb == 'FILE':
# $[FILE:path] and $[FILE:path:first:last]
path = args[0]
Expand All @@ -91,11 +92,11 @@ def generate_attack_request(self):
start, end = 1, len(items)

for n, item in enumerate(items[start-1: end]):
exploit +='op%s: %s%s%s%s{%s}%s\n' % (n+1, prefix, lead, item, rest, query, suffix)
exploit +='op%s: %s%s%s%s{%s}%s' % (n+1, prefix, lead, item, rest, query, suffix)

#build the query
# attack = prefix + exploit + suffix\
attack = action + "{\n" + exploit + "}"
attack = action + "{" + exploit + "}"

log.debug("attack query: %s" % attack)
body = json.dumps({'query': attack})
Expand Down