Skip to content

Commit

Permalink
Merge pull request #2 from dolevf/combined_detect_fingerprint
Browse files Browse the repository at this point in the history
Combined detect fingerprint
  • Loading branch information
dolevf authored Sep 12, 2021
2 parents 0d51ca0 + 6244322 commit 199c7c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
2 changes: 0 additions & 2 deletions graphw00f/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ def graph_query(self, url, operation='query', payload={}):
allow_redirects=self.follow_redirects,
json={operation:payload})
return response.json()
except GraphQLError:
return {}
except:
return {}

Expand Down
56 changes: 26 additions & 30 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


def main():
parser = OptionParser(usage='%prog -t http://example.com/graphql -f')
parser = OptionParser(usage='%prog -d -f -t http://example.com')
parser.add_option('-r', '--noredirect', action='store_false', dest='followredirect', default=True,

help='Do not follow redirections given by 3xx responses')
Expand Down Expand Up @@ -67,10 +67,9 @@ def main():
headers=conf.HEADERS,
cookies=conf.COOKIES)
url = options.url
url_path = urlparse(url).path
url_scheme = urlparse(url).scheme
url_netloc = urlparse(url).netloc

detected = False
print(draw_art())

if url_scheme not in ('http', 'https'):
Expand All @@ -88,35 +87,32 @@ def main():
try:
g.check(target)
print('[!] Found GraphQL at {}'.format(target))
print('[!] You can now try and fingerprint GraphQL using: {} -t {}'.format(sys.argv[0], target))
sys.exit(0)
url = target
detected = True

if not options.fingerprint:
sys.exit(0)

break
except GraphQLDetectionFailed:
continue
print('[x] Could not find GraphQL anywhere.')
sys.exit(1)

if not url_path:
print('[*] No URL path was provided.')
print('[*[ are you sure you want to fingerprint the server without a path? [y/n]')
choice = input().lower()
if not user_confirmed(choice):
print('_o/')
if not detected:
print('[x] Could not find GraphQL anywhere.')
sys.exit(1)
else:
print('[*] Checking if GraphQL is available at {url}...'.format(url=url))
fingerprint = None
try:
if g.check(url):
print('[!] Found GraphQL.')
except GraphQLDetectionFailed:
print(bcolors.FAIL + '[x] Could not determine the existence of GraphQL (Error: GraphQLDetectionFailed)' + bcolors.ENDC)
print('[*] Continue anyway? [y/n]'.format(url=url))
choice = input().lower()
if not user_confirmed(choice):
print('Quitting.')
sys.exit(1)

print('[*] Checking if GraphQL is available at {url}...'.format(url=url))

detected = None
try:
if g.check(url):
print('[!] Found GraphQL...')
except GraphQLDetectionFailed:
print(bcolors.FAIL + '[x] Could not determine existence of GraphQL (GraphQLDetectionFailed)' + bcolors.ENDC)
print('[*] Continue anyway? [y/n]'.format(url=url))
choice = input().lower()
if not user_confirmed(choice):
print('Quitting.')
sys.exit(1)

print('[*] Attempting to fingerprint...')
result = g.execute(url)

Expand All @@ -125,7 +121,7 @@ def main():
url = get_engines()[result]['url']
ref = get_engines()[result]['ref']
technologies = ', '.join(get_engines()[result]['technology'])
detected = name
fingerprint = name
print(bcolors.OKGREEN + '[*] Discovered GraphQL Engine: ({})'.format(name))
print('[!] Attack Surface Matrix: {}'.format(ref))
print('[!] Technologies: {}'.format(technologies))
Expand All @@ -136,7 +132,7 @@ def main():
if options.output_file:
f = open(options.output_file, 'w')
f.write('url,detected_engine,timestamp\n')
f.write('{},{},{}\n'.format(url_netloc, detected, get_time()))
f.write('{},{},{}\n'.format(url_netloc, fingerprint, get_time()))
f.close()

print(bcolors.ENDC + '[*] Completed.')
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.0.3'
VERSION = '1.0.4'

0 comments on commit 199c7c4

Please sign in to comment.