mirror of
				https://github.com/sqlmapproject/sqlmap.git
				synced 2025-11-04 09:57:38 +03:00 
			
		
		
		
	First commit (and working one) for an Issue #287 (XML-RPC server)
This commit is contained in:
		
							parent
							
								
									b5884c7eda
								
							
						
					
					
						commit
						b9f6fc5f4e
					
				
							
								
								
									
										23
									
								
								_sqlmap.py
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								_sqlmap.py
									
									
									
									
									
								
							| 
						 | 
					@ -36,6 +36,7 @@ from lib.core.settings import LEGAL_DISCLAIMER
 | 
				
			||||||
from lib.core.testing import smokeTest
 | 
					from lib.core.testing import smokeTest
 | 
				
			||||||
from lib.core.testing import liveTest
 | 
					from lib.core.testing import liveTest
 | 
				
			||||||
from lib.parse.cmdline import cmdLineParser
 | 
					from lib.parse.cmdline import cmdLineParser
 | 
				
			||||||
 | 
					from lib.utils.xmlrpc import XMLRPCServer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def modulePath():
 | 
					def modulePath():
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
| 
						 | 
					@ -61,16 +62,20 @@ def main():
 | 
				
			||||||
        # Store original command line options for possible later restoration
 | 
					        # Store original command line options for possible later restoration
 | 
				
			||||||
        cmdLineOptions.update(cmdLineParser().__dict__)
 | 
					        cmdLineOptions.update(cmdLineParser().__dict__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        init(cmdLineOptions)
 | 
					        if cmdLineOptions.xmlRpc:
 | 
				
			||||||
 | 
					            server = XMLRPCServer()
 | 
				
			||||||
        if conf.profile:
 | 
					            server.serve()
 | 
				
			||||||
            profile()
 | 
					 | 
				
			||||||
        elif conf.smokeTest:
 | 
					 | 
				
			||||||
            smokeTest()
 | 
					 | 
				
			||||||
        elif conf.liveTest:
 | 
					 | 
				
			||||||
            liveTest()
 | 
					 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            start()
 | 
					            init(cmdLineOptions)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if conf.profile:
 | 
				
			||||||
 | 
					                profile()
 | 
				
			||||||
 | 
					            elif conf.smokeTest:
 | 
				
			||||||
 | 
					                smokeTest()
 | 
				
			||||||
 | 
					            elif conf.liveTest:
 | 
				
			||||||
 | 
					                liveTest()
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    except SqlmapUserQuitException:
 | 
					    except SqlmapUserQuitException:
 | 
				
			||||||
        errMsg = "user quit"
 | 
					        errMsg = "user quit"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -482,6 +482,9 @@ EVENTVALIDATION_REGEX = r'(?i)(?P<name>__EVENTVALIDATION[^"]*)[^>]+value="(?P<re
 | 
				
			||||||
# Number of rows to generate inside the full union test for limited output (mustn't be too large to prevent payload length problems)
 | 
					# Number of rows to generate inside the full union test for limited output (mustn't be too large to prevent payload length problems)
 | 
				
			||||||
LIMITED_ROWS_TEST_NUMBER = 15
 | 
					LIMITED_ROWS_TEST_NUMBER = 15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Default TCP port used for XML-RPC server instance
 | 
				
			||||||
 | 
					XML_RPC_SERVER_PORT = 8776
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Regular expression for SOAP-like POST data
 | 
					# Regular expression for SOAP-like POST data
 | 
				
			||||||
SOAP_RECOGNITION_REGEX = r"(?s)\A(<\?xml[^>]+>)?\s*<([^> ]+)( [^>]+)?>.+</\2.*>\s*\Z"
 | 
					SOAP_RECOGNITION_REGEX = r"(?s)\A(<\?xml[^>]+>)?\s*<([^> ]+)( [^>]+)?>.+</\2.*>\s*\Z"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -682,6 +682,9 @@ def cmdLineParser():
 | 
				
			||||||
        parser.add_option("--run-case", dest="runCase", type="int",
 | 
					        parser.add_option("--run-case", dest="runCase", type="int",
 | 
				
			||||||
                          help=SUPPRESS_HELP)
 | 
					                          help=SUPPRESS_HELP)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        parser.add_option("--xmlrpc", dest="xmlRpc", action="store_true",
 | 
				
			||||||
 | 
					                          help=SUPPRESS_HELP)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        parser.add_option_group(target)
 | 
					        parser.add_option_group(target)
 | 
				
			||||||
        parser.add_option_group(request)
 | 
					        parser.add_option_group(request)
 | 
				
			||||||
        parser.add_option_group(optimization)
 | 
					        parser.add_option_group(optimization)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										46
									
								
								lib/utils/xmlrpc.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								lib/utils/xmlrpc.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,46 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Copyright (c) 2006-2012 sqlmap developers (http://sqlmap.org/)
 | 
				
			||||||
 | 
					See the file 'doc/COPYING' for copying permission
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from SimpleXMLRPCServer import SimpleXMLRPCServer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from lib.controller.controller import start
 | 
				
			||||||
 | 
					from lib.core.datatype import AttribDict
 | 
				
			||||||
 | 
					from lib.core.data import cmdLineOptions
 | 
				
			||||||
 | 
					from lib.core.data import logger
 | 
				
			||||||
 | 
					from lib.core.option import init
 | 
				
			||||||
 | 
					from lib.core.settings import XML_RPC_SERVER_PORT
 | 
				
			||||||
 | 
					from lib.core.settings import UNICODE_ENCODING
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class XMLRPCServer:
 | 
				
			||||||
 | 
					    def __init__(self):
 | 
				
			||||||
 | 
					        self.reset()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def reset(self):
 | 
				
			||||||
 | 
					        self.options = AttribDict(cmdLineOptions)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def set_option(self, name, value):
 | 
				
			||||||
 | 
					        self.options[name] = value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_option(self, name):
 | 
				
			||||||
 | 
					        return self.options[name]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_option_names(self):
 | 
				
			||||||
 | 
					        return self.options.keys()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def run(self):
 | 
				
			||||||
 | 
					        init(self.options, True)
 | 
				
			||||||
 | 
					        return start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def serve(self):
 | 
				
			||||||
 | 
					        server = SimpleXMLRPCServer(addr=("", XML_RPC_SERVER_PORT), logRequests=False, allow_none=True, encoding=UNICODE_ENCODING)
 | 
				
			||||||
 | 
					        server.register_introspection_functions()
 | 
				
			||||||
 | 
					        server.register_function(self.reset)
 | 
				
			||||||
 | 
					        server.register_function(self.set_option)
 | 
				
			||||||
 | 
					        server.register_function(self.get_option)
 | 
				
			||||||
 | 
					        server.register_function(self.get_option_names)
 | 
				
			||||||
 | 
					        server.register_function(self.run)
 | 
				
			||||||
 | 
					        server.serve_forever()
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user