API功能描述
- API功能需要升级到2025.3.0之后的版本
- API功能用于通过http 接口操作任务、漏洞
- API功能的使用需要在配置里开启API服务,必须设置api token
- API接口的调用需要设置http头apitoken,API使用需要在已登录状态调用
- API服务开放端口为12306
API接口描述
健康监测接口
请求:http://127.0.0.1:12306/hi GET
请求头:{apitoken=[9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c]}
curl -X GET "http://127.0.0.1:12306/hi" -H "apitoken: 9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c"
任务列表接口
请求:http://127.0.0.1:12306/task/list GET
请求头:{apitoken=[9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c]}
curl -X GET "http://127.0.0.1:12306/task/list" -H "apitoken: 9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c"
任务详情
请求:http://127.0.0.1:12306/task/detail/330 GET
请求头:{apitoken=[9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c]}
curl -X GET "http://127.0.0.1:12306/task/detail/225" -H "apitoken: 9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c"
漏洞列表
请求:http://127.0.0.1:12306/vuln/list/330 GET
请求头:{apitoken=[9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c]}
curl -X GET "http://127.0.0.1:12306/vuln/list/227" -H "apitoken: 9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c"
漏洞详情
请求:http://127.0.0.1:12306/vuln/detail/330/1 GET
请求头:{apitoken=[9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c]}
curl -X GET "http://127.0.0.1:12306/vuln/detail/227/1" -H "apitoken: 9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c"
漏洞状态更新
请求:http://127.0.0.1:12306/vuln/updateStatus/330 POST
请求头:{apitoken=[9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c], Content-Type=[application/json]}
请求体:{"id":1,"status":"falsepositive"}
- 参数说明:url里的参数为任务id,请求体里的参数包括漏洞id、目标状态,支持4种状态falsepositive, repeate, awaitingprocess, vuln ,分别为误报 重复 待审计 漏洞
curl -X POST "http://127.0.0.1:12306/vuln/updateStatus/215" -H "apitoken: 9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c" -H "Content-Type: application/json" -d '{"id":1,"status":"falsepositive"}'
删除任务
请求:http://127.0.0.1:12306/task/delete/330 POST
请求头:{apitoken=[9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c], Content-Type=[application/json]}
请求体:null
- 参数说明:url里的参数为任务id,方法为POST,但请求体里无内容
curl -X POST "http://127.0.0.1:12306/task/delete/227" -H "apitoken: 9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c" -H "Content-Type: application/json"
创建扫描任务
请求:http://127.0.0.1:12306/task/createGitTask POST
请求头:{apitoken=[9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c], Content-Type=[application/json]}
请求体:{"taskName":"MCMS Task","gitUrl":"https://gitee.com/mingSoft/MCMS.git","branch":"master","gitAuthInfo":{"type":4,"token":"your-token-here","user":null,"password":null,"sshKeyPath":null}}
- 参数说明:请求体里的参数分别为 任务名称、git、分支、git认证信息
- git认证支持4种方式,通过type参数区分,1. sshkey 2. token 3.user/pass 4.no auth
- type参数设为1,表示sshkey认证,铲子自动从 ~/.ssh 目录读取sshkey,sshKeyPath参数为以后预留,无需设置
- type参数设为2,表示token认证,需要设置 user、token 参数
- type参数设为3, 表示password 认证,需要设置 user、password 参数
- type参数设为4, 表示git仓库无需认证
curl -X POST "http://127.0.0.1:12306/task/createGitTask" \
-H "apitoken: 9de4fcc4-0b9f-4fd4-9ff0-831cc0bbec9c" \
-H "Content-Type: application/json" \
-d '{
"taskName": "MCMS Task",
"gitUrl": "https://gitee.com/mingSoft/MCMS.git",
"branch": "master",
"gitAuthInfo": {
"type": 4,
"token": "your-token-here",
"user": null,
"password": null,
"sshKeyPath": null
}
}'
API服务注册
- API服务支持采用nacos作为注册中心,用于在调用方动态获取铲子扫描节点的IP地址
- 使用场景:1、铲子扫描节点的IP不固定 2、希望对多个扫描节点进行统一调度
- 使用方法:
- 需自行部署nacos服务器,单击模式部署即可,需开启nacos server的账号/密码认证
- 在铲子里开启nacos,设置nacos server的IP 端口 账号 密码,铲子会自动注册到注册中心
- 调用方从注册中心获取chanzisast服务的IP列表,然后进行按需调用
注意事项
- 请勿使用接口文档示例中的 apitoken,apitoken的值自行设置为具备一定复杂度的字符串