2013-02-14 15:32:17 +04:00
|
|
|
#!/usr/bin/env python
|
2012-12-20 18:59:11 +04:00
|
|
|
|
|
|
|
"""
|
2013-01-18 18:07:51 +04:00
|
|
|
Copyright (c) 2006-2013 sqlmap developers (http://sqlmap.org/)
|
2012-12-20 18:59:11 +04:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
2012-12-20 19:29:23 +04:00
|
|
|
import optparse
|
2012-12-20 18:59:11 +04:00
|
|
|
|
2013-02-06 13:30:54 +04:00
|
|
|
from sqlmap import modulePath
|
2012-12-20 18:59:11 +04:00
|
|
|
from lib.core.common import setPaths
|
|
|
|
from lib.core.data import paths
|
|
|
|
from lib.core.data import logger
|
|
|
|
from lib.utils.api import client
|
|
|
|
from lib.utils.api import server
|
|
|
|
|
|
|
|
RESTAPI_SERVER_HOST = "127.0.0.1"
|
|
|
|
RESTAPI_SERVER_PORT = 8775
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
"""
|
|
|
|
REST-JSON API main function
|
|
|
|
"""
|
|
|
|
# Set default logging level to debug
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
2012-12-20 20:53:43 +04:00
|
|
|
# Initialize path variable
|
2012-12-20 18:59:11 +04:00
|
|
|
paths.SQLMAP_ROOT_PATH = modulePath()
|
|
|
|
setPaths()
|
|
|
|
|
2012-12-20 20:53:43 +04:00
|
|
|
# Parse command line options
|
2012-12-20 19:29:23 +04:00
|
|
|
apiparser = optparse.OptionParser()
|
2012-12-20 20:53:43 +04:00
|
|
|
apiparser.add_option("-s", "--server", help="Act as a REST-JSON API server", default=RESTAPI_SERVER_PORT, action="store_true")
|
2012-12-20 19:29:23 +04:00
|
|
|
apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_SERVER_PORT, action="store_true")
|
|
|
|
apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_SERVER_HOST, action="store")
|
|
|
|
apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_SERVER_PORT, type="int", action="store")
|
|
|
|
(args, _) = apiparser.parse_args()
|
2012-12-20 18:59:11 +04:00
|
|
|
|
2012-12-20 20:53:43 +04:00
|
|
|
# Start the client or the server
|
2012-12-20 18:59:11 +04:00
|
|
|
if args.server is True:
|
|
|
|
server(args.host, args.port)
|
|
|
|
elif args.client is True:
|
|
|
|
client(args.host, args.port)
|