|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +""" |
| 4 | +Copyright (c) 2006-2012 sqlmap developers (http://sqlmap.org/) |
| 5 | +See the file 'doc/COPYING' for copying permission |
| 6 | +""" |
| 7 | + |
| 8 | +import argparse |
| 9 | +import logging |
| 10 | + |
| 11 | +from _sqlmap import modulePath |
| 12 | +from lib.core.common import setPaths |
| 13 | +from lib.core.data import paths |
| 14 | +from lib.core.data import logger |
| 15 | +from lib.utils.api import client |
| 16 | +from lib.utils.api import server |
| 17 | + |
| 18 | +RESTAPI_SERVER_HOST = "127.0.0.1" |
| 19 | +RESTAPI_SERVER_PORT = 8775 |
| 20 | + |
| 21 | +if __name__ == "__main__": |
| 22 | + """ |
| 23 | + REST-JSON API main function |
| 24 | + """ |
| 25 | + # Set default logging level to debug |
| 26 | + logger.setLevel(logging.DEBUG) |
| 27 | + |
| 28 | + paths.SQLMAP_ROOT_PATH = modulePath() |
| 29 | + setPaths() |
| 30 | + |
| 31 | + parser = argparse.ArgumentParser() |
| 32 | + parser.add_argument("-s", "--server", help="Act as a REST-JSON API server", default=RESTAPI_SERVER_PORT, action="store_true") |
| 33 | + parser.add_argument("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_SERVER_PORT, action="store_true") |
| 34 | + parser.add_argument("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_SERVER_HOST, action="store") |
| 35 | + parser.add_argument("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_SERVER_PORT, action="store") |
| 36 | + args = parser.parse_args() |
| 37 | + |
| 38 | + if args.server is True: |
| 39 | + server(args.host, args.port) |
| 40 | + elif args.client is True: |
| 41 | + client(args.host, args.port) |
0 commit comments