Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 667e4d0

Browse files
committed
Fixes #4204
1 parent 788dcbf commit 667e4d0

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.4.5.25"
21+
VERSION = "1.4.5.26"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from lib.core.settings import RESTAPI_DEFAULT_ADAPTER
5050
from lib.core.settings import RESTAPI_DEFAULT_ADDRESS
5151
from lib.core.settings import RESTAPI_DEFAULT_PORT
52+
from lib.core.settings import VERSION_STRING
5253
from lib.core.shell import autoCompletion
5354
from lib.core.subprocessng import Popen
5455
from lib.parse.cmdline import cmdLineParser
@@ -657,6 +658,15 @@ def download(taskid, target, filename):
657658
logger.warning("[%s] File does not exist %s" % (taskid, target))
658659
return jsonize({"success": False, "message": "File does not exist"})
659660

661+
@get("/version")
662+
def version(token=None):
663+
"""
664+
Fetch server version
665+
"""
666+
667+
logger.debug("Fetched version (%s)" % ("admin" if is_admin(token) else request.remote_addr))
668+
return jsonize({"success": True, "version": VERSION_STRING.split('/')[-1]})
669+
660670
def server(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, adapter=RESTAPI_DEFAULT_ADAPTER, username=None, password=None):
661671
"""
662672
REST-JSON API server
@@ -760,7 +770,7 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non
760770
logger.critical(errMsg)
761771
return
762772

763-
commands = ("help", "new", "use", "data", "log", "status", "option", "stop", "kill", "list", "flush", "exit", "bye", "quit")
773+
commands = ("help", "new", "use", "data", "log", "status", "option", "stop", "kill", "list", "flush", "version", "exit", "bye", "quit")
764774
autoCompletion(AUTOCOMPLETE_TYPE.API, commands=commands)
765775

766776
taskid = None
@@ -849,6 +859,13 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non
849859
continue
850860
logger.info("Switching to task ID '%s' " % taskid)
851861

862+
elif command in ("version",):
863+
raw = _client("%s/%s" % (addr, command))
864+
res = dejsonize(raw)
865+
if not res["success"]:
866+
logger.error("Failed to execute command %s" % command)
867+
dataToStdout("%s\n" % raw)
868+
852869
elif command in ("list", "flush"):
853870
raw = _client("%s/admin/%s" % (addr, command))
854871
res = dejsonize(raw)
@@ -873,6 +890,7 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non
873890
msg += "stop Stop current task\n"
874891
msg += "kill Kill current task\n"
875892
msg += "list Display all tasks\n"
893+
msg += "version Fetch server version\n"
876894
msg += "flush Flush tasks (delete all tasks)\n"
877895
msg += "exit Exit this client\n"
878896

0 commit comments

Comments
 (0)