Skip to content

Commit

Permalink
Added graphql parsing library
Browse files Browse the repository at this point in the history
  • Loading branch information
bandronic committed May 24, 2023
1 parent 674ef46 commit c99e676
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = lib/GQLSpection
url = ../GQLSpection.git
branch = dev
[submodule "lib/graphql-py"]
path = lib/graphql-py
url = https://github.com/ivelum/graphql-py
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sourceSets {
srcDir 'kotlin'
}
resources {
srcDirs = ['python', 'lib/GQLSpection/src']
srcDirs = ['python', 'lib/GQLSpection/src', 'lib/graphql-py/graphql']
}
}
}
Expand Down
1 change: 1 addition & 0 deletions graphql-py
Submodule graphql-py added at 9859df
1 change: 1 addition & 0 deletions lib/graphql-py
Submodule graphql-py added at 9859df
10 changes: 9 additions & 1 deletion python/inql/attacker/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from threading import Thread
from urlparse import urlparse

from graphql.parser import GraphQLParser

from burp import IMessageEditorController

from java.awt import BorderLayout
Expand Down Expand Up @@ -44,10 +46,13 @@ def generate_attack_request(self):
parsed = parsed[0]
query = parsed['query']

ast = parser.parse(query)
print('ast: ', ast)

actionMatch = re.search('([^{]*?){(.+)}([^}]*?)', query, re.DOTALL)
action, query, tmp = actionMatch.groups()
query = self.stripComments(query)
query = re.sub(r'\n|\r|\t', '', query)
query = "{" + re.sub(r'\n|\r|\t', '', query) + "}"
prefix, suffix, exploit = "", "", ""
while True:
# FIXME: whitespace inbetween will break the regex!
Expand All @@ -57,6 +62,8 @@ def generate_attack_request(self):
if not match:
break
pfx, query, sfx = match.groups()
print('match pfx ', pfx)
print('match query ', query)

# look for a placeholder
match = (
Expand All @@ -74,6 +81,7 @@ def generate_attack_request(self):
lead, verb, args, rest = match.groups()
args = args.split(':')
log.debug("lead: %s, verb: %s, args: %s, rest: %s" % (lead, verb, args, rest))
print("lead: %s, verb: %s, args: %s, rest: %s" % (lead, verb, args, rest))

exploit = ""
if verb == 'INT':
Expand Down

0 comments on commit c99e676

Please sign in to comment.