Skip to content

Commit f2af886

Browse files
committed
Some more updates regarding #3140
1 parent 2895e5c commit f2af886

File tree

4 files changed

+292
-15
lines changed

4 files changed

+292
-15
lines changed

lib/core/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.2.11.8"
22+
VERSION = "1.2.11.9"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/utils/api.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -437,25 +437,30 @@ def option_list(taskid):
437437
@post("/option/<taskid>/get")
438438
def option_get(taskid):
439439
"""
440-
Get the value of an option (command line switch) for a certain task ID
440+
Get value of option(s) for a certain task ID
441441
"""
442442
if taskid not in DataStore.tasks:
443443
logger.warning("[%s] Invalid task ID provided to option_get()" % taskid)
444444
return jsonize({"success": False, "message": "Invalid task ID"})
445445

446-
option = request.json.get("option", "")
446+
options = request.json or []
447+
results = {}
447448

448-
if option in DataStore.tasks[taskid].options:
449-
logger.debug("[%s] Retrieved value for option %s" % (taskid, option))
450-
return jsonize({"success": True, option: DataStore.tasks[taskid].get_option(option)})
451-
else:
452-
logger.debug("[%s] Requested value for unknown option %s" % (taskid, option))
453-
return jsonize({"success": False, "message": "Unknown option", option: "not set"})
449+
for option in options:
450+
if option in DataStore.tasks[taskid].options:
451+
results[option] = DataStore.tasks[taskid].options[option]
452+
else:
453+
logger.debug("[%s] Requested value for unknown option '%s'" % (taskid, option))
454+
return jsonize({"success": False, "message": "Unknown option '%s'" % option})
455+
456+
logger.debug("[%s] Retrieved values for option(s) '%s'" % (taskid, ",".join(options)))
457+
458+
return jsonize({"success": True, "options": results})
454459

455460
@post("/option/<taskid>/set")
456461
def option_set(taskid):
457462
"""
458-
Set an option (command line switch) for a certain task ID
463+
Set value of option(s) for a certain task ID
459464
"""
460465

461466
if taskid not in DataStore.tasks:
@@ -775,11 +780,11 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non
775780
logger.error("No task ID in use")
776781
continue
777782
try:
778-
command, option = command.split(" ")
783+
command, option = command.split(" ", 1)
779784
except ValueError:
780785
raw = _client("%s/option/%s/list" % (addr, taskid))
781786
else:
782-
options = {"option": option}
787+
options = re.split(r"\s*,\s*", option.strip())
783788
raw = _client("%s/option/%s/get" % (addr, taskid), options)
784789
res = dejsonize(raw)
785790
if not res["success"]:

swagger.yaml

+273-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
# Note: written with Swagger Editor (https://editor.swagger.io/)
12
swagger: "2.0"
23
info:
34
description: ""
45
version: "1.2"
5-
title: "sqlmap API (REST-JSON)"
6+
title: "sqlmap API"
67
contact:
78
89
license:
@@ -183,6 +184,277 @@ paths:
183184
success:
184185
type: boolean
185186
enum: [true]
187+
/option/{taskid}/list:
188+
get:
189+
tags:
190+
- "option"
191+
summary: "List task options"
192+
description: ""
193+
operationId: "optionList"
194+
produces:
195+
- "application/json"
196+
parameters:
197+
- name: "taskid"
198+
in: "path"
199+
description: "ID of an existing task to list it's options"
200+
required: true
201+
type: "string"
202+
responses:
203+
200:
204+
description: "Task options successfully listed"
205+
schema:
206+
type: object
207+
properties:
208+
success:
209+
type: boolean
210+
enum: [true]
211+
options:
212+
type: object
213+
additionalProperties:
214+
type: string
215+
example:
216+
crawlDepth: null
217+
osShell: false
218+
getUsers: false
219+
getPasswordHashes: false
220+
excludeSysDbs: false
221+
ignoreTimeouts: false
222+
regData: null
223+
fileDest: null
224+
prefix: null
225+
code: null
226+
googlePage: 1
227+
skip: null
228+
query: null
229+
randomAgent: false
230+
osPwn: false
231+
authType: null
232+
safeUrl: null
233+
requestFile: null
234+
predictOutput: false
235+
wizard: false
236+
stopFail: false
237+
forms: false
238+
uChar: null
239+
secondReq: null
240+
taskid: d977b0e5f091370e
241+
pivotColumn: null
242+
dropSetCookie: false
243+
smart: false
244+
paramExclude: null
245+
risk: 1
246+
sqlFile: null
247+
rParam: null
248+
getCurrentUser: false
249+
notString: null
250+
getRoles: false
251+
getPrivileges: false
252+
testParameter: null
253+
tbl: null
254+
charset: null
255+
trafficFile: null
256+
osSmb: false
257+
level: 1
258+
dnsDomain: null
259+
outputDir: null
260+
encoding: null
261+
skipWaf: false
262+
timeout: 30
263+
firstChar: null
264+
torPort: null
265+
getComments: false
266+
binaryFields: null
267+
checkTor: false
268+
commonTables: false
269+
direct: null
270+
tmpPath: null
271+
titles: false
272+
getSchema: false
273+
identifyWaf: false
274+
paramDel: null
275+
safeReqFile: null
276+
regKey: null
277+
murphyRate: null
278+
limitStart: null
279+
crawlExclude: null
280+
flushSession: false
281+
loadCookies: null
282+
csvDel:
283+
offline: false
284+
method: null
285+
tmpDir: null
286+
fileWrite: null
287+
disablePrecon: false
288+
osBof: false
289+
testSkip: null
290+
invalidLogical: false
291+
getCurrentDb: false
292+
hexConvert: false
293+
proxyFile: null
294+
answers: null
295+
host: null
296+
dependencies: false
297+
cookie: null
298+
proxy: null
299+
regType: null
300+
optimize: false
301+
limitStop: null
302+
search: false
303+
uFrom: null
304+
noCast: false
305+
testFilter: null
306+
ignoreCode: null
307+
eta: false
308+
csrfToken: null
309+
threads: 1
310+
logFile: null
311+
os: null
312+
col: null
313+
skipStatic: false
314+
proxyCred: null
315+
verbose: 1
316+
isDba: false
317+
updateAll: false
318+
privEsc: false
319+
forceDns: false
320+
getAll: false
321+
api: true
322+
url: http://www.test.com/index.php?id=1
323+
invalidBignum: false
324+
regexp: null
325+
getDbs: false
326+
freshQueries: false
327+
uCols: null
328+
smokeTest: false
329+
udfInject: false
330+
invalidString: false
331+
tor: false
332+
forceSSL: false
333+
beep: false
334+
noEscape: false
335+
configFile: null
336+
scope: null
337+
authFile: null
338+
torType: SOCKS5
339+
regVal: null
340+
dummy: false
341+
checkInternet: false
342+
safePost: null
343+
safeFreq: null
344+
skipUrlEncode: false
345+
referer: null
346+
liveTest: false
347+
retries: 3
348+
extensiveFp: false
349+
dumpTable: false
350+
getColumns: false
351+
batch: true
352+
purge: false
353+
headers: null
354+
authCred: null
355+
osCmd: null
356+
suffix: null
357+
dbmsCred: null
358+
regDel: false
359+
shLib: null
360+
sitemapUrl: null
361+
timeSec: 5
362+
msfPath: null
363+
dumpAll: false
364+
fileRead: null
365+
getHostname: false
366+
sessionFile: null
367+
disableColoring: true
368+
getTables: false
369+
listTampers: false
370+
agent: null
371+
webRoot: null
372+
exclude: null
373+
lastChar: null
374+
string: null
375+
dbms: null
376+
dumpWhere: null
377+
tamper: null
378+
ignoreRedirects: false
379+
hpp: false
380+
runCase: null
381+
delay: 0
382+
evalCode: null
383+
cleanup: false
384+
csrfUrl: null
385+
secondUrl: null
386+
getBanner: true
387+
profile: false
388+
regRead: false
389+
bulkFile: null
390+
db: null
391+
dumpFormat: CSV
392+
alert: null
393+
harFile: null
394+
nullConnection: false
395+
user: null
396+
parseErrors: false
397+
getCount: false
398+
data: null
399+
regAdd: false
400+
ignoreProxy: false
401+
database: /tmp/sqlmapipc-jGw6ZY
402+
mobile: false
403+
googleDork: null
404+
saveConfig: null
405+
sqlShell: false
406+
tech: BEUSTQ
407+
textOnly: false
408+
cookieDel: null
409+
commonColumns: false
410+
keepAlive: false
411+
/option/{taskid}/get:
412+
post:
413+
tags:
414+
- "option"
415+
summary: "Get task option value(s)"
416+
description: ""
417+
operationId: "optionGet"
418+
consumes:
419+
- "application/json"
420+
produces:
421+
- "application/json"
422+
parameters:
423+
- name: "taskid"
424+
in: "path"
425+
description: "ID of an existing task"
426+
required: true
427+
type: "string"
428+
- in: body
429+
name: options
430+
description: ""
431+
schema:
432+
type: array
433+
items:
434+
type: string
435+
example: ["url", "timeout"]
436+
responses:
437+
200:
438+
description: "Task option value successfully retrieved"
439+
schema:
440+
type: object
441+
properties:
442+
success:
443+
type: boolean
444+
options:
445+
type: array
446+
items:
447+
type: object
448+
properties:
449+
name:
450+
type: string
451+
value:
452+
type: string
453+
example:
454+
- success: true
455+
options:
456+
url: http://www.test.com/index.php?id=1
457+
timeout: 30
186458
externalDocs:
187459
description: "Find out more about sqlmap API (REST-JSON)"
188460
url: "https://github.com/sqlmapproject/sqlmap/wiki/Usage#api-rest-json"

txt/checksum.md5

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4949
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
5050
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5151
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
52-
f6c316b9de14838f5a70072e514c5974 lib/core/settings.py
52+
b7d7300f745050d9a29bcf30a1ddcc5e lib/core/settings.py
5353
a971ce157d04de96ba6e710d3d38a9a8 lib/core/shell.py
5454
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
5555
721198b5be72c8015a02acb116532a1f lib/core/target.py
@@ -101,7 +101,7 @@ db208ab47de010836c6bf044e2357861 lib/techniques/blind/inference.py
101101
1e5532ede194ac9c083891c2f02bca93 lib/techniques/union/__init__.py
102102
f7813cdee00df8f98d6f811475e520a1 lib/techniques/union/test.py
103103
7361338240ecd9d01d1d10ec76bce069 lib/techniques/union/use.py
104-
dfea8e2ca23c5160b2f57732d8d49023 lib/utils/api.py
104+
038ec99105c59acc2b1c6cb90e9e4043 lib/utils/api.py
105105
37dfb641358669f62c2acedff241348b lib/utils/brute.py
106106
31b1e7eb489eac837db6a2bc1dcb7da7 lib/utils/crawler.py
107107
f9867bbfcd6d31916ca73e72e95fd881 lib/utils/deps.py

0 commit comments

Comments
 (0)