From 2eb5f5e8419b00d6f1c688af7b2e5c61bfdc52f0 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 9 Dec 2015 12:20:09 +0100 Subject: [PATCH] Handling 'address already in use' for sqlmapapi server instance --- lib/utils/api.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/utils/api.py b/lib/utils/api.py index 07367b15c..8bcdd937e 100644 --- a/lib/utils/api.py +++ b/lib/utils/api.py @@ -10,6 +10,7 @@ import logging import os import re import shlex +import socket import sqlite3 import sys import tempfile @@ -654,7 +655,13 @@ def server(host="0.0.0.0", port=RESTAPI_SERVER_PORT): DataStore.current_db.init() # Run RESTful API - run(host=host, port=port, quiet=True, debug=False) + try: + run(host=host, port=port, quiet=True, debug=False) + except socket.error, ex: + if "already in use" in getSafeExString(ex): + logger.error("Address already in use ('%s:%s')" % (host, port)) + else: + raise def _client(url, options=None):