一个GraphQL枚举和提取工具
作者:Sec-Labs | 发布时间:
项目地址
https://github.com/cybervelia/graphicator
Graphicator
Graphicator 是一个 GraphQL“抓取器”/提取器。 该工具遍历目标 GraphQL 端点返回的内省文档,然后以内部形式重新构造架构,以便重新创建支持的查询。 创建此类查询时,使用它们将请求发送到端点并将返回的响应保存到文件中。
不保存错误的响应。 默认情况下,该工具会缓存正确的响应并缓存错误,因此当重新运行该工具时,它不会再次进入相同的查询。
明智地使用它并仅将其用于您有权与之交互的目标。
我们希望该工具能够将您自己的测试自动化,作为渗透测试人员,并为那些尚未进行 GraphQLing 测试的人员提供一些推动力。
要了解如何对 GraphQL 端点执行评估: https ://cybervelia.com/?p=736&preview=true
安装
在您的系统上安装
python3 install -r requirements.txt
改用容器
docker run --rm -it -p8005:80 cybervelia/graphicator --target http://the-target:port/graphql --verbose
任务完成后,它会压缩结果,此类压缩文件是通过服务于端口 8005 的网络服务器提供的。要终止容器,请提供 CTRL+C。 当容器停止时,数据也会被删除。 您也可以根据需要更改主机端口。
用法
python3 graphicator.py [args...]
设定目标
第一步是配置目标。 为此,您必须提供一个 --target 选项或一个使用 --file .
通过参数设置单个目标
python3 graphicator.py --target https://subdomain.domain:port/graphql
设置多个目标
python3 graphicator.py --target https://subdomain.domain:port/graphql --target https://target2.tld/graphql
通过文件设置目标
python3 graphicator.py --file file.txt
该文件每行应包含一个 URL,如下所示:
http://target1.tld/graphql
http://sub.target2.tld/graphql
http://subxyz.target3.tld:8080/graphql
使用代理
您可以将该工具与任何代理连接。
连接到默认的 burp 设置(端口 8080)
python3 graphicator.py --target target --default-burp-proxy
连接到您自己的代理
python3 graphicator.py --target target --use-proxy
通过 Tor 连接
python3 graphicator.py --target target --use-tor
使用标题
python3 graphicator.py --target target --header "x-api-key:60b725f10c9c85c70d97880dfe8191b3"
启用详细
python3 graphicator.py --target target --verbose
启用多线程
python3 graphicator.py --target target --multi
禁用不安全和自签名证书的警告
python3 graphicator.py --target target --insecure
避免使用缓存结果
python3 graphicator.py --target target --no-cache
例子
python3 graphicator.py --target http://localhost:8000/graphql --verbose --multi
_____ __ _ __
/ ___/____ ___ _ ___ / / (_)____ ___ _ / /_ ___ ____
/ (_ // __// _ `// _ \ / _ \ / // __// _ `// __// _ \ / __/
\___//_/ \_,_// .__//_//_//_/ \__/ \_,_/ \__/ \___//_/
/_/
By @fand0mas
[-] Targets: 1
[-] Headers: 'Content-Type', 'User-Agent'
[-] Verbose
[-] Using cache: True
************************************************************
0%| | 0/1 [00:00<?, ?it/s][*] Enumerating... http://localhost:8000/graphql
[*] Retrieving... => query {getArticles { id,title,views } }
[*] Retrieving... => query {getUsers { id,username,email,password,level } }
100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 35.78it/s]
$ cat reqcache/9652f1e7c02639d8f78d1c5263093072fb4fd06c.json
{
"data": {
"getUsers": [
{
"id": 1,
"username": "theo",
"email": "theo@example.com",
"password": "1234",
"level": 1
},
{
"id": 2,
"username": "john",
"email": "john@example.com",
"password": "5678",
"level": 1
}
]
}
}
$ cat reqcache-queries/9652f1e7c02639d8f78d1c5263093072fb4fd06c.query
query {getUsers { id,username,email,password,level } }
输出结构
创建了三个文件夹:
- reqcache:每个有效查询的响应以JSON格式存储
- reqcache-intro:所有内省查询都存储在该目录下的单独文件中
- reqcache-queries:所有查询都存储在该目录下的单独文件中。 每个查询的文件名将与保存查询响应的 reqcache 目录中的相应文件名相匹配。
文件名是考虑到查询和 url 的哈希值。
标签:工具分享, API安全, GraphQL