-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Expand file tree
/
Copy pathsqlmapapi.yaml
More file actions
893 lines (849 loc) · 26.6 KB
/
sqlmapapi.yaml
File metadata and controls
893 lines (849 loc) · 26.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
openapi: 3.0.3
info:
title: sqlmap REST-JSON API
version: "1.0.0"
description: |
OpenAPI/Swagger specification for sqlmapapi.py, the sqlmap REST-JSON API server.
This specification describes the API surface implemented by `lib/utils/api.py`.
The API is expected to be protected with HTTP Basic authentication when started
with `--username` and `--password`; hardened builds should require credentials
for server/client usage.
Notes for implementers:
* Most sqlmap options are represented as dynamic JSON object properties.
* API-level failures are commonly returned as HTTP 200 with `success: false`
and a `message` field, matching the current server behavior.
* The API starts scans by spawning sqlmap in a separate process and storing
logs/data in the configured IPC database.
license:
name: GPL-2.0-only or commercial
url: https://github.com/sqlmapproject/sqlmap/blob/master/LICENSE
contact:
name: sqlmap project
url: https://sqlmap.org
externalDocs:
description: sqlmap project repository
url: https://github.com/sqlmapproject/sqlmap
servers:
- url: http://127.0.0.1:8775
description: Default local sqlmapapi.py server
security:
- basicAuth: []
tags:
- name: Version
description: Server/version metadata
- name: Tasks
description: Task lifecycle management
- name: Options
description: Task option inspection and mutation
- name: Scans
description: Scan process lifecycle, status, logs, and results
- name: Admin
description: Task pool administration
- name: Files
description: Retrieval of output files
paths:
/version:
get:
tags: [Version]
operationId: getVersion
summary: Fetch server version
description: Returns the sqlmap version string reported by the API server.
responses:
"200":
description: Server version returned.
content:
application/json:
schema:
$ref: "#/components/schemas/VersionResponse"
examples:
success:
value:
success: true
version: "1.10.6.51#dev"
"401":
$ref: "#/components/responses/Unauthorized"
/task/new:
get:
tags: [Tasks]
operationId: createTask
summary: Create a new task
description: Creates an empty task and returns a 16-character hexadecimal task ID.
responses:
"200":
description: Task created.
content:
application/json:
schema:
$ref: "#/components/schemas/TaskNewResponse"
examples:
success:
value:
success: true
taskid: "fad44d6beef72285"
"401":
$ref: "#/components/responses/Unauthorized"
/task/{taskid}/delete:
get:
tags: [Tasks]
operationId: deleteTask
summary: Delete an existing task
description: Kills the task process, if still running, and removes the task from the in-memory task pool.
parameters:
- $ref: "#/components/parameters/TaskId"
responses:
"200":
description: Task deleted.
content:
application/json:
schema:
$ref: "#/components/schemas/SimpleSuccessResponse"
examples:
success:
value:
success: true
"401":
$ref: "#/components/responses/Unauthorized"
"404":
description: Non-existing task ID.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
notFound:
value:
success: false
message: Non-existing task ID
/admin/list:
get:
tags: [Admin]
operationId: listTasksForRemoteAddress
summary: List visible tasks
description: |
Lists task statuses visible to the caller. Without the admin token path variant,
the server returns tasks associated with the same remote address.
responses:
"200":
$ref: "#/components/responses/AdminList"
"401":
$ref: "#/components/responses/Unauthorized"
/admin/{token}/list:
get:
tags: [Admin]
operationId: listTasksWithAdminToken
summary: List all tasks with admin token
description: Lists all task statuses when the path token matches the server-generated admin token.
parameters:
- $ref: "#/components/parameters/AdminToken"
responses:
"200":
$ref: "#/components/responses/AdminList"
"401":
$ref: "#/components/responses/Unauthorized"
/admin/flush:
get:
tags: [Admin]
operationId: flushTasksForRemoteAddress
summary: Flush visible tasks
description: |
Kills and removes tasks visible to the caller. Without the admin token path variant,
the server flushes tasks associated with the same remote address.
responses:
"200":
description: Matching tasks flushed.
content:
application/json:
schema:
$ref: "#/components/schemas/SimpleSuccessResponse"
examples:
success:
value:
success: true
"401":
$ref: "#/components/responses/Unauthorized"
/admin/{token}/flush:
get:
tags: [Admin]
operationId: flushTasksWithAdminToken
summary: Flush all tasks with admin token
description: Kills and removes all tasks when the path token matches the server-generated admin token.
parameters:
- $ref: "#/components/parameters/AdminToken"
responses:
"200":
description: Matching tasks flushed.
content:
application/json:
schema:
$ref: "#/components/schemas/SimpleSuccessResponse"
examples:
success:
value:
success: true
"401":
$ref: "#/components/responses/Unauthorized"
/option/{taskid}/list:
get:
tags: [Options]
operationId: listOptions
summary: List task options
description: Returns the current option object for a task.
parameters:
- $ref: "#/components/parameters/TaskId"
responses:
"200":
description: Options returned, or an API-level failure envelope for an invalid task ID.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/OptionListResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
success:
value:
success: true
options:
url: "http://testasp.vulnweb.com/showforum.asp?id=1"
batch: true
threads: 1
invalidTask:
value:
success: false
message: Invalid task ID
"401":
$ref: "#/components/responses/Unauthorized"
/option/{taskid}/get:
post:
tags: [Options]
operationId: getOptions
summary: Get selected task options
description: Returns values for the requested option names.
parameters:
- $ref: "#/components/parameters/TaskId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/OptionGetRequest"
examples:
selectedOptions:
value: ["url", "cookie"]
responses:
"200":
description: Selected options returned, or an API-level failure envelope.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/OptionGetResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
success:
value:
success: true
options:
url: "http://testasp.vulnweb.com/showforum.asp?id=1"
cookie: "id=1"
unknownOption:
value:
success: false
message: "Unknown option 'doesNotExist'"
"401":
$ref: "#/components/responses/Unauthorized"
/option/{taskid}/set:
post:
tags: [Options]
operationId: setOptions
summary: Set task options
description: |
Sets one or more options on a task. Values are persisted in the task option
object and are used when the scan is started.
Hardened behavior: options listed in `x-sqlmap-unsupported-options` should be
rejected here with `success: false`, matching `/scan/{taskid}/start`.
x-sqlmap-unsupported-options:
- sqlShell
- wizard
- evalCode
- alert
parameters:
- $ref: "#/components/parameters/TaskId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SqlmapOptions"
examples:
setCookie:
value:
cookie: "id=1"
setTarget:
value:
url: "http://testasp.vulnweb.com/showforum.asp?id=1"
responses:
"200":
description: Options set, or an API-level failure envelope.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/SimpleSuccessResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
success:
value:
success: true
invalidJson:
value:
success: false
message: Invalid JSON options
unsupportedOption:
value:
success: false
message: "Unsupported option 'evalCode'"
"401":
$ref: "#/components/responses/Unauthorized"
/scan/{taskid}/start:
post:
tags: [Scans]
operationId: startScan
summary: Launch a scan
description: |
Applies the provided options to the task and starts sqlmap in a separate process.
The response contains the spawned engine process ID.
Current API behavior rejects options listed in `x-sqlmap-unsupported-options`
when they are supplied in this request body.
x-sqlmap-unsupported-options:
- sqlShell
- wizard
- evalCode
- alert
parameters:
- $ref: "#/components/parameters/TaskId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SqlmapOptions"
examples:
basicUrlScan:
value:
url: "http://testasp.vulnweb.com/showforum.asp?id=1"
responses:
"200":
description: Scan started, or an API-level failure envelope.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/ScanStartResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
success:
value:
success: true
engineid: 19720
unsupportedOption:
value:
success: false
message: "Unsupported option 'evalCode'"
invalidJson:
value:
success: false
message: Invalid JSON options
"401":
$ref: "#/components/responses/Unauthorized"
/scan/{taskid}/stop:
get:
tags: [Scans]
operationId: stopScan
summary: Stop a scan
description: Terminates the running scan process for the task and waits for process exit.
parameters:
- $ref: "#/components/parameters/TaskId"
responses:
"200":
$ref: "#/components/responses/ScanControl"
"401":
$ref: "#/components/responses/Unauthorized"
/scan/{taskid}/kill:
get:
tags: [Scans]
operationId: killScan
summary: Kill a scan
description: Force-kills the running scan process for the task and waits for process exit.
parameters:
- $ref: "#/components/parameters/TaskId"
responses:
"200":
$ref: "#/components/responses/ScanControl"
"401":
$ref: "#/components/responses/Unauthorized"
/scan/{taskid}/status:
get:
tags: [Scans]
operationId: getScanStatus
summary: Fetch scan status
description: Returns the process status and return code for the task.
parameters:
- $ref: "#/components/parameters/TaskId"
responses:
"200":
description: Scan status returned, or an API-level failure envelope.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/ScanStatusResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
running:
value:
success: true
status: running
returncode: null
terminated:
value:
success: true
status: terminated
returncode: 0
notRunning:
value:
success: true
status: not running
returncode: null
"401":
$ref: "#/components/responses/Unauthorized"
/scan/{taskid}/data:
get:
tags: [Scans]
operationId: getScanData
summary: Retrieve scan data
description: Returns structured scan output and recorded error messages for the task.
parameters:
- $ref: "#/components/parameters/TaskId"
responses:
"200":
description: Scan data returned, or an API-level failure envelope.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/ScanDataResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
success:
value:
success: true
data:
- status: 1
type: 0
value: []
error: []
"401":
$ref: "#/components/responses/Unauthorized"
/scan/{taskid}/log:
get:
tags: [Scans]
operationId: getScanLog
summary: Retrieve all scan log messages
description: Returns all recorded log messages for the task.
parameters:
- $ref: "#/components/parameters/TaskId"
responses:
"200":
$ref: "#/components/responses/ScanLog"
"401":
$ref: "#/components/responses/Unauthorized"
/scan/{taskid}/log/{start}/{end}:
get:
tags: [Scans]
operationId: getScanLogRange
summary: Retrieve a bounded scan log range
description: Returns log messages with database IDs from `start` through `end`, inclusive.
parameters:
- $ref: "#/components/parameters/TaskId"
- name: start
in: path
required: true
description: Inclusive starting log row ID. Must be a positive integer.
schema:
type: integer
minimum: 1
example: 1
- name: end
in: path
required: true
description: Inclusive ending log row ID. Must be greater than or equal to `start`.
schema:
type: integer
minimum: 1
example: 100
responses:
"200":
$ref: "#/components/responses/ScanLog"
"401":
$ref: "#/components/responses/Unauthorized"
/download/{taskid}/{target}/{filename}:
get:
tags: [Files]
operationId: downloadOutputFile
summary: Download an output file
description: |
Retrieves a file from sqlmap's output directory for the given task/target and
returns it as Base64 in JSON.
Implementation note: `filename` is a Bottle `:path` parameter and may contain
slash characters in the running server. Some OpenAPI tooling requires those
slashes to be URL-encoded or handled with a custom client.
x-bottle-path-parameter: filename
parameters:
- $ref: "#/components/parameters/TaskId"
- name: target
in: path
required: true
description: Target output-directory name.
schema:
type: string
example: testasp.vulnweb.com
- name: filename
in: path
required: true
description: Output file path relative to the target directory.
allowReserved: true
schema:
type: string
example: log
responses:
"200":
description: File returned, or an API-level failure envelope.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/DownloadResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
success:
value:
success: true
file: "SGVsbG8K"
forbidden:
value:
success: false
message: Forbidden path
missing:
value:
success: false
message: File does not exist
"401":
$ref: "#/components/responses/Unauthorized"
components:
securitySchemes:
basicAuth:
type: http
scheme: basic
description: |
HTTP Basic authentication using the `--username` and `--password` values
supplied to sqlmapapi.py. Hardened builds should require both values.
parameters:
TaskId:
name: taskid
in: path
required: true
description: 16-character hexadecimal scan task ID.
schema:
type: string
pattern: "^[0-9a-fA-F]{16}$"
example: fad44d6beef72285
AdminToken:
name: token
in: path
required: true
description: Server-generated admin token printed when sqlmapapi.py starts.
schema:
type: string
pattern: "^[0-9a-fA-F]{32}$"
example: "0123456789abcdef0123456789abcdef"
responses:
Unauthorized:
description: Missing or invalid HTTP Basic credentials. The response body is empty.
AdminList:
description: Task pool listing returned.
content:
application/json:
schema:
$ref: "#/components/schemas/AdminListResponse"
examples:
success:
value:
success: true
tasks:
fad44d6beef72285: running
c04d8c5c7582efb4: terminated
tasks_num: 2
ScanControl:
description: Scan control action completed, or an API-level failure envelope.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/SimpleSuccessResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
success:
value:
success: true
invalidTask:
value:
success: false
message: Invalid task ID
ScanLog:
description: Scan log returned, or an API-level failure envelope.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/ScanLogResponse"
- $ref: "#/components/schemas/ErrorResponse"
examples:
success:
value:
success: true
log:
- time: "12:34:56"
level: INFO
message: testing connection to the target URL
invalidRange:
value:
success: false
message: Invalid start or end value, must be digits
schemas:
SuccessFlag:
type: boolean
description: Indicates whether the API action succeeded.
ErrorResponse:
type: object
required: [success, message]
properties:
success:
type: boolean
enum: [false]
message:
type: string
additionalProperties: false
SimpleSuccessResponse:
type: object
required: [success]
properties:
success:
type: boolean
enum: [true]
additionalProperties: false
VersionResponse:
type: object
required: [success, version]
properties:
success:
type: boolean
enum: [true]
version:
type: string
description: sqlmap version string without the `sqlmap/` prefix.
example: "1.10.6.51#dev"
additionalProperties: false
TaskNewResponse:
type: object
required: [success, taskid]
properties:
success:
type: boolean
enum: [true]
taskid:
type: string
pattern: "^[0-9a-fA-F]{16}$"
example: fad44d6beef72285
additionalProperties: false
AdminListResponse:
type: object
required: [success, tasks, tasks_num]
properties:
success:
type: boolean
enum: [true]
tasks:
type: object
description: Object keyed by task ID, with current task status as the value.
additionalProperties:
$ref: "#/components/schemas/ScanStatus"
example:
fad44d6beef72285: running
tasks_num:
type: integer
minimum: 0
example: 1
additionalProperties: false
ScanStatus:
type: string
enum:
- not running
- running
- terminated
OptionValue:
description: Value accepted by sqlmap options. The exact type depends on the option.
nullable: true
oneOf:
- type: string
- type: boolean
- type: integer
- type: number
- type: array
items: {}
- type: object
additionalProperties: true
SqlmapOptions:
type: object
description: |
Dynamic object containing sqlmap option names and values. Option names map to
sqlmap's internal option dictionary. Unsupported REST API options should be
rejected by endpoints that accept this object.
additionalProperties:
$ref: "#/components/schemas/OptionValue"
example:
url: "http://testasp.vulnweb.com/showforum.asp?id=1"
cookie: "id=1"
batch: true
threads: 1
OptionListResponse:
type: object
required: [success, options]
properties:
success:
type: boolean
enum: [true]
options:
$ref: "#/components/schemas/SqlmapOptions"
additionalProperties: false
OptionGetRequest:
type: array
description: List of option names to return.
minItems: 1
items:
type: string
minLength: 1
example:
- url
- cookie
OptionGetResponse:
type: object
required: [success, options]
properties:
success:
type: boolean
enum: [true]
options:
$ref: "#/components/schemas/SqlmapOptions"
additionalProperties: false
ScanStartResponse:
type: object
required: [success, engineid]
properties:
success:
type: boolean
enum: [true]
engineid:
type: integer
description: Process ID of the spawned sqlmap engine.
example: 19720
additionalProperties: false
ScanStatusResponse:
type: object
required: [success, status, returncode]
properties:
success:
type: boolean
enum: [true]
status:
$ref: "#/components/schemas/ScanStatus"
returncode:
type: integer
nullable: true
description: Process return code, or null when no process is running or the process has not exited.
example: 0
additionalProperties: false
ScanDataItem:
type: object
required: [status, type, value]
properties:
status:
type: integer
description: Numeric content status stored by sqlmap.
example: 1
type:
type: integer
description: Numeric content type stored by sqlmap.
example: 0
value:
nullable: true
description: JSON-decoded scan output value. Shape depends on the content type.
additionalProperties: true
ScanDataResponse:
type: object
required: [success, data, error]
properties:
success:
type: boolean
enum: [true]
data:
type: array
items:
$ref: "#/components/schemas/ScanDataItem"
error:
type: array
items:
type: string
additionalProperties: false
LogEntry:
type: object
required: [time, level, message]
properties:
time:
type: string
description: Server-local time in HH:MM:SS format.
pattern: "^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$"
example: "12:34:56"
level:
type: string
description: Python logging level name.
example: INFO
message:
type: string
example: testing connection to the target URL
additionalProperties: false
ScanLogResponse:
type: object
required: [success, log]
properties:
success:
type: boolean
enum: [true]
log:
type: array
items:
$ref: "#/components/schemas/LogEntry"
additionalProperties: false
DownloadResponse:
type: object
required: [success, file]
properties:
success:
type: boolean
enum: [true]
file:
type: string
format: byte
description: Base64-encoded file content.
example: SGVsbG8K
additionalProperties: false