├── .gitignore ├── README.md ├── LICENSE └── burp-ext.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode 3 | .jython_cache 4 | .python-version 5 | burp/ 6 | dist/ 7 | build/ 8 | main.spec 9 | gqlutils.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auto GraphQL Scanner (aka Auto GQL) 2 | 3 | **Auto GQL** *(currently in Beta)* is a Burp Suite extension that automates the process of vulnerability hunting in GraphQL APIs. It does this using only the URL to the GraphQL endpoint (and option configurations) to make an Introspection Query, turn that into all possible API requests, find possible injection points for payloads, and handing them off to Active Scanner. Prior to this, Burp's Active Scanner did not know where to put payloads for GraphQL requests. It was a dog's breakfast. This plugin "teaches" it where to put the payloads, AND creates the requests for you, so you don't have to click around in the proxy to try and get every combination. 4 | ## Installation: 5 | ### Prerequisites 6 | 1. This plugin uses the Active Scanner, which is a Burp **Pro** feature. 7 | 2. Download Jython Standalone: https://www.jython.org/download.html 8 | 3. Open Burp > Extender > Options > Python Environment 9 | 4. Select the Jython jar 10 | ### Installation Steps 11 | 4. Open Burp > Extender > Extensions > Add 12 | 5. Extension Type: Python 13 | 6. Select file: burp-ext.py 14 | 15 | ## Usage: 16 | 1. Select the **Auto GQL** tab in Burp 17 | 2. Enter the URL for the GraphQL endpoint. 18 | - *Example:* For [DVGA](https://github.com/dolevf/Damn-Vulnerable-GraphQL-Application) the URL is `http://localhost:5013.com/graphql` 19 | 3. Add any custom headers that might be required to make queries to the target. 20 | - *Examples* 21 | - An *Authorization* header with bearer token 22 | - A browser *User-Agent* 23 | 4. Click the **Fetch Queries** button to run the Introspection query and automatically parse the schema into all possible queries. This can take up to a minute. 24 | - TODO: add a little progress/loading animation and an error message if the URL is unreachable or malformed. 25 | - For now just wait a few seconds. If it doesn't work after a minute, check that the URL is correct. 26 | - Ensure that "Intercept" is turned **off** on the proxy, because the query is run through the proxy so that you can keep a record of it in the logger. 27 | 5. Use the checkboxes to select the queries to include in the Active Scan. 28 | - The extension will automitcally preselect items that have insertion/injection points for the Active Scanner to add payloads to. 29 | - For the first run, I recommend deselecting any Mutations that will delete data. The scanner is not smart enough to sequence requests with creation first and deletion second, so it might try to run deletion requests multiple times consecutively. You'll get false negatives on some payloads because there wasn't actually any data in the API to try and delete after the first deletion request. 30 | 6. Click the **Run Scan** button to begin the Active Scan. 31 | 7. View the progress by going to the Dashboard tab in Burp and expanding the "Extension driven active audit" 32 | 33 | ## Debug: 34 | 1. Run Burp using the terminal. (Example is for MacOS) `java -jar -Xmx1g "/Applications/Burp Suite Professional.app/Contents/Resources/app/burpsuite_pro.jar"` 35 | 2. Add `pdb.set_trace()` anywhere you want a breakpoint. 36 | 3. Go to Burp > Extender > Add and select burp-ext.py 37 | 38 | ## To Do: 39 | 1. Separate into multiple files, and add build step to unify it back to one. (Burp requires that it be one file) 40 | 2. Search filter for queries. 41 | 3. Allow for user to manually alter injection points visually. 42 | 4. Allow for importing a Schema file as an alternative option to Introspection. 43 | 5. Allow for payload transformations (base64, etc.) 44 | 6. Maybe convert the whole thing to Java? I picked Python because Burp supports it, and I use it more regularly than Java. Plus all the Python libraries, right? Turns out this was not the best route. Burp *supports* Python, but is written in Java, so all Python support is due to Jython. This requires that the plugin be built in Python2, can't use external libraries (without some extra work from the end user), and has all sorts of fun data type issues that require detours to the Jython documentation. Not to mentinon that it all has to be in one file, which means having to write a Makefile or some other build step. Using Java would solve all those problems, plus the Burp documentation is all geared towards it. Let my toiling save you from your own. Write your Burp extension in Java. 45 | 46 | ## Acknowledgements 47 | 1. The transformation on Introspection response, into requests comes from the wonderful **inQL** extension for Burp. For this reason I have included their Apache license. My plan is to eventually implement my own version of this. Not because it isn't awesome, or because I'm afraid of losing street cred, but because I have some specific needs that will eventually require me to rewrite it. Plus it's fun to do it yourself! 48 | 2. Other Burp extensions were helpful references when trying to work out issues that have weak documentation. Some notable ones are **Autorize** and **Logger++**. 49 | 50 | ## Credits 51 | Author: Jared Meit (baron) 52 | - Email: j.meit@fwdsec.com 53 | - Twitter: @jaredmeit 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /burp-ext.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | import json 3 | 4 | from jarray import array 5 | 6 | from urlparse import urlparse 7 | 8 | ORDER = { 9 | u"scalar": 0, 10 | u"enum": 1, 11 | u"type": 2, 12 | u"input": 3, 13 | u"interface": 4, 14 | u"union": 5 15 | } 16 | MINUS_INFINITE = -10000 17 | 18 | 19 | def reverse_lookup_order(field, reverse_lookup): 20 | try: 21 | if field[u'required']: 22 | ret = 0 23 | else: 24 | ret = 10 25 | if field[u'array']: 26 | ret += 100 27 | if u'args' in field: 28 | ret += 1000 29 | ret += ORDER[reverse_lookup[field[u'type']]] 30 | return ret 31 | except KeyError: 32 | return 10000 33 | 34 | def recurse_fields(schema, reverse_lookup, t, max_nest=7, non_required_levels=1, dinput=None, 35 | params_replace=lambda schema, reverse_lookup, elem: elem, recursed=0): 36 | u""" 37 | Generates a JSON representation of the AST object representing a query 38 | 39 | :param schema: 40 | the output of a simplified schema 41 | 42 | :param reverse_lookup: 43 | a support hash that goes from typename to graphql type, useful to navigate the schema in O(1) 44 | 45 | :param t: 46 | type that you need to generate the AST for, since it is recursive it may be anything inside the graph 47 | 48 | :param max_nest: 49 | maximum number of recursive calls before returning the type name, this is needed in particularly broken cases 50 | where recurse_fields may not exit autonomously (EG. hackerone.com is using union to create sql or/and/not 51 | statements.) Consider that this will partially break params_replace calls. 52 | 53 | :param non_required_levels: 54 | expand up to non_required_levels levels automatically. 55 | 56 | :param dinput: 57 | the output object, it may even be provided from the outside. 58 | 59 | :param params_replace: 60 | a callback that takes (schema, reverse_lookup, elem) as parameter and returns a replacement for parameter. 61 | Needed in case you want to generate real parameters for queries. 62 | 63 | """ 64 | if max_nest == 0: 65 | return params_replace(schema, reverse_lookup, t) 66 | if t not in reverse_lookup: 67 | return params_replace(schema, reverse_lookup, t) 68 | 69 | if dinput is None: 70 | dinput = {} 71 | 72 | if reverse_lookup[t] in [u'type', u'interface', u'input']: 73 | for inner_t, v in sorted(schema[reverse_lookup[t]][t].items(), key=lambda kv: reverse_lookup_order(kv[1], reverse_lookup)): 74 | if inner_t == u'__implements': 75 | for iface in v.keys(): 76 | interface_recurse_fields = recurse_fields(schema, reverse_lookup, iface, max_nest=max_nest, 77 | non_required_levels=non_required_levels, 78 | params_replace=params_replace) 79 | dinput.update(interface_recurse_fields) 80 | continue 81 | # try to add at least one required inner, if you should not recurse anymore 82 | recurse = non_required_levels > 0 or (v[u'required'] and recursed <= 0) # required_only => v['required'] 83 | if recurse: 84 | dinput[inner_t] = recurse_fields(schema, reverse_lookup, v[u'type'], max_nest=max_nest - 1, 85 | non_required_levels=non_required_levels - 1, 86 | params_replace=params_replace) 87 | recursed += 1 88 | if recurse and u'args' in v: 89 | if inner_t not in dinput or type(dinput[inner_t]) is not dict: 90 | dinput[inner_t] = {} 91 | dinput[inner_t][u"args"] = {} 92 | for inner_a, inner_v in sorted(v[u'args'].items(), key=lambda kv: reverse_lookup_order(kv[1], reverse_lookup)): 93 | # try to add at least a parameter, even if there are no required parameters 94 | recurse_inner = non_required_levels > 0 or inner_v[u'required'] # required_only => v['required'] 95 | if recurse_inner: 96 | arg = recurse_fields(schema, reverse_lookup, inner_v[u'type'], max_nest=max_nest-1, recursed=MINUS_INFINITE, 97 | non_required_levels=non_required_levels-1, params_replace=params_replace) 98 | if u'array' in inner_v and inner_v[u'array']: 99 | if type(arg) is dict: 100 | arg = [arg] 101 | else: 102 | arg = u"[%s]" % arg 103 | if u'required' in inner_v and inner_v[u'required']: 104 | if type(arg) is not dict: 105 | arg = u"!%s" % arg 106 | else: 107 | pass # XXX: don't handle required array markers, this is a bug, but simplifies a lot the code 108 | dinput[inner_t][u'args'][inner_a] = arg 109 | if len(dinput[inner_t][u"args"]) == 0: 110 | del dinput[inner_t][u"args"] 111 | if len(dinput[inner_t]) == 0: 112 | del dinput[inner_t] 113 | 114 | if len(dinput) == 0 and (t not in reverse_lookup or reverse_lookup[t] not in [u'enum', u'scalar']): 115 | items = list(schema[reverse_lookup[t]][t].items()) 116 | if len(items) > 0: 117 | inner_t, v = items[0] 118 | dinput[inner_t] = recurse_fields(schema, reverse_lookup, v[u'type'], max_nest=max_nest - 1, 119 | non_required_levels=non_required_levels - 1, params_replace=params_replace) 120 | elif reverse_lookup[t] == u'union': 121 | # select the first type of the union 122 | for union in schema[u'union'][t].keys(): 123 | dinput[u"... on %s" % union] = recurse_fields(schema, reverse_lookup, union, max_nest=max_nest, 124 | non_required_levels=non_required_levels, 125 | params_replace=params_replace) 126 | elif reverse_lookup[t] in [u'enum', u'scalar']: 127 | # return the type since it is an enum 128 | return params_replace(schema, reverse_lookup, t) 129 | return dinput 130 | 131 | 132 | def dict_to_args(d): 133 | u""" 134 | Generates a string representing query arguments from an AST dict. 135 | 136 | :param d: AST dict 137 | """ 138 | args = [] 139 | for k, v in d.items(): 140 | args.append(u"%s:%s" % (k, json.dumps(v).replace(u'"', u'').replace(u"u'", u"").replace(u"'", u"").replace(u'@', u'"'))) 141 | if len(args) > 0: 142 | return u"(%s)" % u', '.join(args) 143 | else: 144 | return u"" 145 | 146 | 147 | def dict_to_qbody(d, prefix=u''): 148 | u""" 149 | Generates a string representing a query body from an AST dict. 150 | 151 | :param d: AST dict 152 | :param prefix: needed in case it will recurse 153 | """ 154 | if type(d) is not dict: 155 | return u'' 156 | s = u'' 157 | iprefix = prefix + u'\t' 158 | args = u'' 159 | for k, v in d.items(): 160 | if k == u'args': 161 | args = dict_to_args(v) 162 | elif type(v) is dict: 163 | s += u'\n' + iprefix + k + dict_to_qbody(v, prefix=iprefix) 164 | else: 165 | s += u'\n' + iprefix + k 166 | if len(s) > 0: 167 | return u"%s {%s\n%s}" % (args, s, prefix) 168 | else: 169 | return args 170 | 171 | 172 | def preplace(schema, reverse_lookup, t): 173 | u""" 174 | Replaces basic types and enums with default values. 175 | 176 | :param schema: 177 | the output of a simplified schema 178 | 179 | :param reverse_lookup: 180 | a support hash that goes from typename to graphql type, useful to navigate the schema in O(1) 181 | 182 | :param t: 183 | type that you need to generate the AST for, since it is recursive it may be anything inside the graph 184 | 185 | """ 186 | if t == u'String': 187 | return u'@code*@' 188 | elif t == u'Int': 189 | return 1334 190 | elif t == u'Boolean': 191 | return u'true' 192 | elif t == u'Float': 193 | return 0.1334 194 | elif t == u'ID': 195 | return 14 196 | elif reverse_lookup[t] == u'enum': 197 | return list(schema[u'enum'][t].keys())[0] 198 | elif reverse_lookup[t] == u'scalar': 199 | # scalar may be any type, so the AST can be anything as well 200 | # since the logic is custom implemented I have no generic way of replacing them 201 | # for this reason we return it back as they are 202 | return t 203 | else: 204 | return t 205 | 206 | 207 | def _recursive_name_get(obj): 208 | try: 209 | return obj[u'name'] or _recursive_name_get(obj[u'ofType']) 210 | except KeyError: 211 | return False 212 | 213 | 214 | def _recursive_kind_of(obj, target): 215 | try: 216 | return obj[u'kind'] == target or _recursive_kind_of(obj[u'ofType'], target) 217 | except KeyError: 218 | return False 219 | except TypeError: 220 | return False 221 | 222 | 223 | def simplify_introspection(data): 224 | u""" 225 | Generates a simplified introspection object based on an introspection query. 226 | This utility function is after used by many of the generators. 227 | 228 | # Parsing JSON response/file structure as follows 229 | # data 230 | # __schema 231 | # directives 232 | # mutationType 233 | # queryType 234 | # subscriptionType 235 | # types (kind, name, description) 236 | # name (RootQuery, RootMutation, Subscriptions, [custom] OBJECT) 237 | # fields 238 | # name (query names) 239 | # args 240 | # name (args names) 241 | # type 242 | # name (args types) 243 | 244 | :type data: an introspection query dict 245 | """ 246 | 247 | output = {} 248 | output[u'schema'] = {} 249 | schema = data[u'data'][u'__schema'] 250 | 251 | # Get the Root query type 252 | if schema[u'queryType'] and u'name' in schema[u'queryType']: 253 | output[u'schema'][u'query'] = { 254 | u"type": schema[u'queryType'][u'name'], 255 | u"array": False, 256 | u"required": False 257 | } 258 | 259 | # Get the Root subscription type 260 | if schema[u'subscriptionType'] and u'name' in schema[u'subscriptionType']: 261 | output[u'schema'][u'subscription'] = { 262 | u"type": schema[u'subscriptionType'][u'name'], 263 | u"array": False, 264 | u"required": False 265 | } 266 | 267 | # Get the Root mutation type 268 | if schema[u'mutationType'] and u'name' in schema[u'mutationType']: 269 | output[u'schema'][u'mutation'] = { 270 | u"type": schema[u'mutationType'][u'name'], 271 | u"array": False, 272 | u"required": False 273 | } 274 | 275 | # Go over all the fields and simplify the JSON 276 | output[u'type'] = {} 277 | for type in schema[u'types']: 278 | if type[u'name'][0:2] == u'__': continue 279 | if type[u'kind'] == u'OBJECT': 280 | output[u'type'][type[u'name']] = {} 281 | if type[u'fields']: 282 | for field in type[u'fields']: 283 | output[u'type'][type[u'name']][field[u'name']] = { 284 | u"type": _recursive_name_get(field[u'type']), 285 | u"required": field[u'type'][u'kind'] == u'NON_NULL', 286 | u"array": _recursive_kind_of(field[u'type'], u'LIST'), 287 | } 288 | if field[u'args']: 289 | output[u'type'][type[u'name']][field[u'name']][u"args"] = {} 290 | for arg in field[u'args']: 291 | output[u'type'][type[u'name']][field[u'name']][u'args'][arg[u'name']] = { 292 | u"type": _recursive_name_get(arg[u'type']), 293 | u"required": arg[u'type'][u'kind'] == u'NON_NULL', 294 | u"array": _recursive_kind_of(arg[u'type'], u'LIST'), 295 | } 296 | if arg[u'defaultValue'] != None: 297 | output[u'type'][type[u'name']][field[u'name']][u'args'][arg[u'name']][u'default'] = arg[ 298 | u'defaultValue'] 299 | if type[u'interfaces']: 300 | output[u'type'][type[u'name']][u'__implements'] = {} 301 | for iface in type[u'interfaces']: 302 | output[u'type'][type[u'name']][u'__implements'][iface[u'name']] = {} 303 | 304 | if u'type' not in output[u'type'][type[u'name']] and u'args' in output[u'type'][type[u'name']]: 305 | output[u'type'][type[u'name']][u"type"] = output[u'type'][type[u'name']][u"args"][u"type"] 306 | 307 | 308 | # Get all the Enums 309 | output[u'enum'] = {} 310 | for type in schema[u'types']: 311 | if type[u'name'][0:2] == u'__': continue 312 | if type[u'kind'] == u'ENUM': 313 | output[u'enum'][type[u'name']] = {} 314 | for v in type[u'enumValues']: 315 | output[u'enum'][type[u'name']][v[u'name']] = {} 316 | 317 | # Get all the Scalars 318 | output[u'scalar'] = {} 319 | for type in schema[u'types']: 320 | if type[u'name'][0:2] == u'__': continue 321 | if type[u'kind'] == u'SCALAR' and type[u'name'] not in [u'String', u'Int', u'Float', u'Boolean', u'ID']: 322 | output[u'scalar'][type[u'name']] = {} 323 | 324 | # Get all the inputs 325 | output[u'input'] = {} 326 | for type in schema[u'types']: 327 | if type[u'name'][0:2] == u'__': continue 328 | if type[u'kind'] == u'INPUT_OBJECT': 329 | output[u'input'][type[u'name']] = {} 330 | if type[u'inputFields']: 331 | for field in type[u'inputFields']: 332 | output[u'input'][type[u'name']][field[u'name']] = { 333 | u"type": _recursive_name_get(field[u'type']), 334 | u"required": field[u'type'][u'kind'] == u'NON_NULL', 335 | u"array": _recursive_kind_of(field[u'type'], u'LIST'), 336 | } 337 | 338 | # Get all the unions 339 | output[u'union'] = {} 340 | for type in schema[u'types']: 341 | if type[u'name'][0:2] == u'__': continue 342 | if type[u'kind'] == u'UNION': 343 | output[u'union'][type[u'name']] = {} 344 | for v in type[u'possibleTypes']: 345 | output[u'union'][type[u'name']][v[u'name']] = {} 346 | 347 | # Get all the interfaces 348 | output[u'interface'] = {} 349 | for type in schema[u'types']: 350 | if type[u'name'][0:2] == u'__': continue 351 | if type[u'kind'] == u'INTERFACE': 352 | output[u'interface'][type[u'name']] = {} 353 | if type[u'fields']: 354 | for field in type[u'fields']: 355 | output[u'interface'][type[u'name']][field[u'name']] = { 356 | u"type": _recursive_name_get(field[u'type']), 357 | u"required": field[u'type'][u'kind'] == u'NON_NULL', 358 | u"array": _recursive_kind_of(field[u'type'], u'LIST'), 359 | } 360 | if field[u'args']: 361 | output[u'interface'][type[u'name']][field[u'name']][u"args"] = {} 362 | for arg in field[u'args']: 363 | output[u'interface'][type[u'name']][field[u'name']][u'args'][arg[u'name']] = { 364 | u"type": _recursive_name_get(arg[u'type']), 365 | u"required": arg[u'type'][u'kind'] == u'NON_NULL', 366 | u"array": _recursive_kind_of(arg[u'type'], u'LIST'), 367 | } 368 | if arg[u'defaultValue'] != None: 369 | output[u'interface'][type[u'name']][field[u'name']][u'args'][arg[u'name']][u'default'] = arg[ 370 | u'defaultValue'] 371 | if u'type' not in output[u'interface'][type[u'name']] and u'args' in output[u'interface'][type[u'name']]: 372 | output[u'interface'][type[u'name']][u"type"] = output[u'interface'][type[u'name']][u"args"][u"type"] 373 | 374 | return output 375 | 376 | 377 | def generate(argument, detect=True): 378 | u""" 379 | Generate query templates 380 | 381 | :param argument: introspection query result 382 | :param qpath: 383 | directory template where to output the queries, first parameter is type of query and second is query name 384 | 385 | :param detect: 386 | retrieve placeholders according to arg type 387 | 388 | :param print: 389 | implements print in green 390 | 391 | :return: None 392 | """ 393 | queries = {} 394 | 395 | s = simplify_introspection(argument) 396 | 397 | rev = { 398 | u"String": u'scalar', 399 | u"Int": u'scalar', 400 | u"Float": u'scalar', 401 | u"Boolean": u'scalar', 402 | u"ID": u'scalar', 403 | } 404 | for t, v in s.items(): 405 | for k in v.keys(): 406 | rev[k] = t 407 | 408 | for qtype, qvalues in s[u'schema'].items(): 409 | if detect: 410 | rec = recurse_fields(s, rev, qvalues[u'type'], non_required_levels=2, params_replace=preplace) 411 | else: 412 | rec = recurse_fields(s, rev, qvalues[u'type'], non_required_levels=2) 413 | for qname, qval in rec.items(): 414 | body = u"%s {\n\t%s%s\n}" % (qtype, qname, dict_to_qbody(qval, prefix=u'\t')) 415 | if detect: 416 | body = body.replace(u'!', u'') 417 | query = {u"query": body} 418 | if qtype not in queries.keys(): 419 | queries[qtype] = {} 420 | queries[qtype][qname] = query 421 | 422 | return queries 423 | 424 | from burp import IBurpExtender, ITab, IMessageEditorController 425 | from java.util import ArrayList 426 | from javax.swing import JTabbedPane, JSplitPane, JScrollPane, JFrame, JTable, JLabel, JTextField, JButton, JTextArea, JSeparator 427 | from javax.swing.table import AbstractTableModel, TableRowSorter 428 | from java.lang import Boolean, String, Integer 429 | from java.awt import Font 430 | #from java.awt.event import FocusListener 431 | from urlparse import urlparse 432 | import sys 433 | import json 434 | import re 435 | from thread import start_new_thread 436 | from copy import copy 437 | 438 | #DEBUG 439 | import pdb 440 | #END DEBUG 441 | 442 | class BurpExtender( IBurpExtender, ITab, AbstractTableModel, IMessageEditorController ): 443 | 444 | # 445 | # implement IBurpExtender 446 | # 447 | 448 | def registerExtenderCallbacks(self, callbacks): 449 | 450 | # obtain an extension helpers object 451 | self._callbacks = callbacks 452 | self._helpers = callbacks.getHelpers() 453 | 454 | # set our extension name 455 | callbacks.setExtensionName( u"Auto GraphQL Scanner" ) 456 | 457 | #DEBUG 458 | sys.stdout = callbacks.getStdout() 459 | sys.stderr = callbacks.getStderr() 460 | #END DEBUG 461 | 462 | self.gqueries = ArrayList() 463 | 464 | self.gql_endpoint = u"" 465 | 466 | self.headers = [] 467 | self.headers_default = [ 468 | u'Accept: application/json', 469 | u'Content-Type: application/json', 470 | u'User-Agent: Auto GQL via Burp', 471 | u'Accept-Encoding: gzip, deflate', 472 | u'Accept-Language: en-US,en;q=0.9', 473 | u'Connection: close' 474 | ] 475 | self.headers_custom = [] 476 | self.headers_mandatory = [ 477 | u'POST @@path@@ HTTP/1.1', 478 | u'Host: @@netloc@@', 479 | u'Origin: @@url@@' 480 | ] 481 | 482 | self.addUI() 483 | 484 | return 485 | 486 | 487 | def addUI( self ): 488 | 489 | print( u"Loading UI..." ) 490 | 491 | callbacks = self._callbacks 492 | 493 | # Main split pane 494 | self._splitpane_main = JSplitPane( JSplitPane.HORIZONTAL_SPLIT ) 495 | 496 | # Top split pane with table and options 497 | self._splitpane_left = JSplitPane( JSplitPane.VERTICAL_SPLIT ) 498 | self._splitpane_main.setLeftComponent( self._splitpane_left ) 499 | 500 | # Queries Table - Top-Left 501 | gqueries_table = Table(self) 502 | # TODO: Disable until I fix the changeSelection to work with sorting 503 | #gqueries_table.setRowSorter( TableRowSorter(self) ) 504 | scroll_pane = JScrollPane( gqueries_table ) 505 | self._splitpane_left.setLeftComponent( scroll_pane ) 506 | 507 | # Options - Top-Right 508 | frame = JFrame() 509 | opts_pane = frame.getContentPane() 510 | opts_pane.setLayout( None ) 511 | 512 | opts_inner_y = 0 513 | 514 | label = JLabel("1.") 515 | y = 10 516 | h = 30 517 | opts_inner_y = y+h 518 | label.setBounds( 10, y, 30, h ) 519 | opts_pane.add( label ) 520 | 521 | hbar = JSeparator() 522 | hbar.setBounds( 40, y+h/2, 450, h ) 523 | opts_pane.add( hbar ) 524 | 525 | label = JLabel("GraphQL Endpoint URL:") 526 | y = opts_inner_y + 10 527 | h = 30 528 | opts_inner_y = y+h 529 | label.setBounds( 10, y, 150, h ) 530 | opts_pane.add( label ) 531 | 532 | placeholder_text = "http(s):///graphql" 533 | self.txt_input_gql_endpoint = JTextField( self.gql_endpoint if self.gql_endpoint != "" else placeholder_text ) 534 | self.txt_input_gql_endpoint.setBounds( 160, y, 300, h ) 535 | self.txt_input_gql_endpoint.setFont( Font( Font.MONOSPACED, Font.PLAIN, 14 ) ) 536 | callbacks.customizeUiComponent( self.txt_input_gql_endpoint ) 537 | opts_pane.add( self.txt_input_gql_endpoint ) 538 | 539 | label = JLabel("Custom Request Headers:") 540 | y = opts_inner_y + 10 541 | h = 30 542 | opts_inner_y = y+h 543 | label.setBounds( 10, y, 150, h ) 544 | opts_pane.add( label ) 545 | 546 | self.txt_input_headers = JTextArea( self.get_headers_text(), 5, 30 ) 547 | self.txt_input_headers.setWrapStyleWord(True) 548 | self.txt_input_headers.setLineWrap(True) 549 | scroll_txt_input_headers = JScrollPane( self.txt_input_headers ) 550 | scroll_txt_input_headers.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ) 551 | y = opts_inner_y + 10 552 | h = 150 553 | opts_inner_y = y+h 554 | scroll_txt_input_headers.setBounds( 10, y, 470, h ) 555 | callbacks.customizeUiComponent( self.txt_input_headers ) 556 | callbacks.customizeUiComponent( scroll_txt_input_headers ) 557 | opts_pane.add( scroll_txt_input_headers ) 558 | 559 | label = JLabel("2.") 560 | y = opts_inner_y + 10 561 | h = 30 562 | opts_inner_y = y+h 563 | label.setBounds( 10, y, 30, h ) 564 | opts_pane.add( label ) 565 | 566 | hbar = JSeparator() 567 | hbar.setBounds( 40, y+h/2, 450, h ) 568 | opts_pane.add( hbar ) 569 | 570 | btn_fetch_queries = JButton( "Fetch Queries", actionPerformed=self._pull_queries ) 571 | y = opts_inner_y + 10 572 | h = 30 573 | opts_inner_y = y+h 574 | btn_fetch_queries.setBounds( 10, y, 150, h ) 575 | callbacks.customizeUiComponent( btn_fetch_queries ) 576 | opts_pane.add( btn_fetch_queries ) 577 | 578 | label = JLabel("3.") 579 | y = opts_inner_y + 10 580 | h = 30 581 | opts_inner_y = y+h 582 | label.setBounds( 10, y, 30, h ) 583 | opts_pane.add( label ) 584 | 585 | hbar = JSeparator() 586 | hbar.setBounds( 40, y+h/2, 450, h ) 587 | opts_pane.add( hbar ) 588 | 589 | btn_fetch_queries = JButton( "Run Scan", actionPerformed=self._scan_queries ) 590 | y = opts_inner_y + 10 591 | h = 30 592 | opts_inner_y = y+h 593 | btn_fetch_queries.setBounds( 10, y, 150, h ) 594 | callbacks.customizeUiComponent( btn_fetch_queries ) 595 | opts_pane.add( btn_fetch_queries ) 596 | 597 | self._splitpane_main.setRightComponent( opts_pane ) 598 | 599 | # Request viewer - Bottom-Left 600 | tabs = JTabbedPane() 601 | self._requestViewer = callbacks.createMessageEditor( self, False ) 602 | tabs.addTab( "Request", self._requestViewer.getComponent() ) 603 | self._splitpane_left.setRightComponent( tabs ) 604 | 605 | # customize our UI components 606 | callbacks.customizeUiComponent( self._splitpane_main ) 607 | callbacks.customizeUiComponent( opts_pane ) 608 | callbacks.customizeUiComponent( gqueries_table ) 609 | callbacks.customizeUiComponent( scroll_pane ) 610 | callbacks.customizeUiComponent( tabs ) 611 | 612 | # add the custom tab to Burp's UI 613 | callbacks.addSuiteTab( self ) 614 | 615 | 616 | def get_headers_text( self ): 617 | 618 | if len( self.headers_custom ) == 0: 619 | self.headers_custom = copy( self.headers_default ) 620 | 621 | return "\r\n".join( self.headers_custom ) 622 | 623 | 624 | def draw_headers_text( self ): 625 | 626 | self.txt_input_headers.setText( self.get_headers_text() ) 627 | 628 | 629 | def set_headers( self ): 630 | 631 | headers_custom_text = self.txt_input_headers.getText() 632 | self.headers_custom = re.split( r'\r?\n', headers_custom_text ) 633 | 634 | re_token = r'@@([a-z]+)@@' 635 | url_parts = urlparse( self.gql_endpoint ) 636 | replacements = { 637 | "path": url_parts.path, 638 | "netloc": url_parts.netloc, 639 | "url": self.gql_endpoint 640 | } 641 | 642 | replaced_headers = [] 643 | for hdr in self.headers_mandatory: 644 | 645 | match = re.search( re_token, hdr ) 646 | hdr = re.sub( re_token, replacements[ match.group(1) ], hdr ) 647 | 648 | replaced_headers.append( hdr ) 649 | 650 | self.headers = replaced_headers + self.headers_custom 651 | 652 | 653 | def _pull_queries( self, event ): 654 | 655 | # TODO: (1) Validate URL 656 | # (2) Provide visual feedback that introspection is in progress 657 | self.gql_endpoint = self.txt_input_gql_endpoint.getText() 658 | self.set_headers() 659 | self.draw_headers_text() 660 | start_new_thread( self.pull_queries, (1,) ) 661 | 662 | def pull_queries( self, not_used ): 663 | 664 | self.introspection_to_queries( self.introspect() ) 665 | 666 | 667 | # 668 | # implement ITab 669 | # 670 | 671 | def getTabCaption(self): 672 | return "Auto GQL" 673 | 674 | def getUiComponent(self): 675 | return self._splitpane_main 676 | 677 | 678 | # 679 | # extend AbstractTableModel 680 | # 681 | 682 | def getColumnHeaders( self ): 683 | return [ 684 | "[ ]", 685 | "#", 686 | "Query Type", 687 | "Request Name", 688 | "Insertion Points", 689 | ] 690 | 691 | def getRowCount(self): 692 | try: 693 | return self.gqueries.size() 694 | except: 695 | return 0 696 | 697 | def getColumnCount(self): 698 | return len( self.getColumnHeaders() ) 699 | 700 | def getColumnName(self, column_index): 701 | cols = self.getColumnHeaders() 702 | 703 | if column_index < len(cols): 704 | return cols[ column_index ] 705 | 706 | return "" 707 | 708 | def getColumnClass( self, column_index ): 709 | 710 | if column_index == 0: 711 | return Boolean 712 | if column_index == 1 or column_index == 4: 713 | return Integer 714 | 715 | return String 716 | 717 | def getValueAt(self, row_index, column_index): 718 | gquery = self.gqueries.get( row_index ) 719 | 720 | cols = [ 721 | gquery['enabled'], # Checkbox 722 | row_index + 1, # Row number 723 | gquery[ 'type' ], #Query Type (Query, Mutation, or Subscription) 724 | gquery['name'], # Query Name 725 | len( gquery['insertion_points'] ) # Number of Insertion Points 726 | ] 727 | 728 | if column_index < len(cols): 729 | return cols[ column_index ] 730 | 731 | return "" 732 | 733 | 734 | # 735 | # Custom Methods 736 | # 737 | 738 | def _scan_queries( self, event ): 739 | 740 | # TODO: (1) Gray out button with info tooltip saying to fetch queries first 741 | # (2) Provide feedback that the scan has started 742 | if self.gqueries.size() > 0: 743 | start_new_thread( self.scan_queries, (1,) ) 744 | 745 | def scan_queries( self, not_used ): 746 | 747 | url_parts = urlparse( self.gql_endpoint ) 748 | 749 | for gquery in self.gqueries: 750 | 751 | if gquery['enabled'] == False: 752 | continue 753 | 754 | #callbacks.sendToIntruder( # Used to debug Insertion Points visually 755 | self._callbacks.doActiveScan( 756 | url_parts.hostname, 757 | self.web_port( self.gql_endpoint ), 758 | url_parts.scheme == 'https', 759 | gquery['query'], 760 | gquery['insertion_points'] 761 | ) 762 | 763 | 764 | def introspect( self ): 765 | 766 | introspection_query = u"query IntrospectionQuery{__schema{queryType{name}mutationType{name}subscriptionType{name}types{...FullType}directives{name description locations args{...InputValue}}}}fragment FullType on __Type{kind name description fields(includeDeprecated:true){name description args{...InputValue}type{...TypeRef}isDeprecated deprecationReason}inputFields{...InputValue}interfaces{...TypeRef}enumValues(includeDeprecated:true){name description isDeprecated deprecationReason}possibleTypes{...TypeRef}}fragment InputValue on __InputValue{name description type{...TypeRef}defaultValue}fragment TypeRef on __Type{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name}}}}}}}}" 767 | url_parts = urlparse( self.gql_endpoint ) 768 | 769 | request_bytes = self._helpers.buildHttpMessage( 770 | self.headers, 771 | self._helpers.stringToBytes( '{"query":"'+introspection_query+'"}' ) 772 | ) 773 | 774 | http_service = self._helpers.buildHttpService( 775 | url_parts.hostname, 776 | self.web_port( self.gql_endpoint ), 777 | url_parts.scheme 778 | ) 779 | 780 | print( u"Sending Introspection Query" ) 781 | 782 | intros_res = self._callbacks.makeHttpRequest( 783 | http_service, 784 | request_bytes 785 | ) 786 | 787 | gql_res = intros_res.getResponse() 788 | gql_res_info = self._helpers.analyzeResponse( gql_res ) 789 | body_offset = gql_res_info.getBodyOffset() 790 | introspection_result = self._helpers.bytesToString( gql_res )[body_offset:] 791 | 792 | return introspection_result 793 | 794 | 795 | def introspection_to_queries( self, introspection_result ): 796 | 797 | queries = generate( json.loads( introspection_result ) ) 798 | 799 | row_count = self.getRowCount() 800 | if row_count > 0: 801 | self.fireTableRowsDeleted( 0, row_count - 1 ) 802 | self.gqueries.clear() 803 | 804 | for qtype_nm, qtype in queries.items(): 805 | for qname,query in qtype.items(): 806 | 807 | query_s = json.dumps( query ) 808 | 809 | # Skip endpoints that remove data 810 | # TODO: Move to UI 811 | # if any(substring in query_s.lower() for substring in ['delete','remove','clear']): 812 | # continue 813 | 814 | request_bytes = self._helpers.buildHttpMessage( 815 | self.headers, 816 | self._helpers.stringToBytes( query_s ) 817 | ) 818 | 819 | insertion_points = self.getInsertionPoints( request_bytes ) 820 | 821 | self.gqueries.add( { 822 | "type": qtype_nm, 823 | "name": qname, 824 | "query": request_bytes, 825 | "insertion_points": insertion_points, 826 | "enabled": len( insertion_points ) > 0 827 | } ) 828 | 829 | # Update table view 830 | row = self.gqueries.size() - 1 831 | self.fireTableRowsInserted(row, row) 832 | 833 | return self.gqueries 834 | 835 | 836 | def getInsertionPoints( self, gql_req ): 837 | 838 | # retrieve the data parameter 839 | gql_req_info = self._helpers.analyzeRequest(gql_req) 840 | body_offset = gql_req_info.getBodyOffset() 841 | gql_body = self._helpers.bytesToString(gql_req)[body_offset:] 842 | 843 | if (gql_body is None): 844 | return None 845 | 846 | insertion_points = [] 847 | 848 | gql_req_obj = json.loads( gql_body ) 849 | 850 | json_token_query = u'"query": "' 851 | prefix_pad = body_offset + gql_body.find( json_token_query ) + len( json_token_query ) 852 | # The query appears with escape slashes in the HTTP request, but not in the deserialized object. Add them back in. 853 | query_w_slashes = re.sub( ur'([\n\t\r"])', ur'\\\1', gql_req_obj['query'] ) 854 | # TODO: Support all data types. Setting payload data types for Active Scanner is a necessity but doesn't seem to be an API option. 855 | # Phase 2 of this TODO is adding support for custom scalars 856 | #regex_all_data_types = ur'[^$]\w+:\s*[\\"]*([\w*]+)[\\"]*\s*[,)]' 857 | regex_strings_only = ur'(code\*)' 858 | for match in re.finditer( regex_strings_only, query_w_slashes ): 859 | insertion_points.append( array([ prefix_pad + match.start(1), prefix_pad + match.end(1) ], 'i') ) 860 | 861 | if u'variables' in gql_req_obj.keys(): 862 | json_token_query = u'"variables":{' 863 | prefix_pad = body_offset + gql_body.find( json_token_query ) + len( json_token_query ) - 2 # 2 because of { used for the token and 864 | #TODO replace regex with recursion through json object to find leaves, then find position of those leaves in the json string 865 | for match in re.finditer( regex_strings_only, json.dumps( gql_req_obj[u'variables'] ) ): 866 | insertion_points.append( array([ prefix_pad + match.start(1), prefix_pad + match.end(1) ], 'i') ) 867 | 868 | return insertion_points 869 | 870 | def create_insertion_point( self, re_match, base_request, prefix_pad = 0 ): 871 | 872 | return self._helpers.makeScannerInsertionPoint( 873 | u"InsertionPointName", 874 | base_request, 875 | prefix_pad + re_match.start(), 876 | prefix_pad + re_match.end() ) 877 | 878 | def web_port( self, url ): 879 | 880 | url_parts = urlparse( url ) 881 | 882 | if url_parts.port: 883 | return url_parts.port 884 | 885 | return 443 if url_parts.scheme.lower() == 'https' else 80 886 | 887 | # 888 | # extend JTable to handle cell selection 889 | # 890 | class Table( JTable ): 891 | def __init__(self, extender): 892 | self._extender = extender 893 | self.setModel(extender) 894 | 895 | def changeSelection(self, row, col, toggle, extend): 896 | 897 | gquery = self._extender.gqueries.get( row ) 898 | 899 | if col == 0: 900 | 901 | gquery['enabled'] = not gquery['enabled'] 902 | self._extender.gqueries.set( row, gquery ) 903 | self._extender.fireTableRowsUpdated( row, row ) 904 | return 905 | 906 | # Show the GQL Query for the selected row 907 | self._extender._requestViewer.setMessage( self._extender._helpers.bytesToString( gquery['query'] ), True ) 908 | 909 | JTable.changeSelection(self, row, col, toggle, extend) 910 | --------------------------------------------------------------------------------