mirror of
				https://github.com/sqlmapproject/sqlmap.git
				synced 2025-11-04 09:57:38 +03:00 
			
		
		
		
	Avoid libmagic traceback on Windows.
WARNING: this release is a candidate, it only works on Linux/Unices for the moment!
This commit is contained in:
		
							parent
							
								
									8c0ac767f4
								
							
						
					
					
						commit
						aefa7ef988
					
				| 
						 | 
				
			
			@ -98,68 +98,69 @@ def from_buffer(buffer, mime=False):
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    libmagic = ctypes.CDLL(ctypes.util.find_library('magic'))
 | 
			
		||||
 | 
			
		||||
libmagic = ctypes.CDLL(ctypes.util.find_library('magic'))
 | 
			
		||||
    magic_t = ctypes.c_void_p
 | 
			
		||||
 | 
			
		||||
magic_t = ctypes.c_void_p
 | 
			
		||||
 | 
			
		||||
def errorcheck(result, func, args):
 | 
			
		||||
    def errorcheck(result, func, args):
 | 
			
		||||
        err = magic_error(args[0])
 | 
			
		||||
        if err is not None:
 | 
			
		||||
            raise MagicException(err)
 | 
			
		||||
        else:
 | 
			
		||||
            return result
 | 
			
		||||
 | 
			
		||||
magic_open = libmagic.magic_open
 | 
			
		||||
magic_open.restype = magic_t
 | 
			
		||||
magic_open.argtypes = [c_int]
 | 
			
		||||
    magic_open = libmagic.magic_open
 | 
			
		||||
    magic_open.restype = magic_t
 | 
			
		||||
    magic_open.argtypes = [c_int]
 | 
			
		||||
 | 
			
		||||
magic_close = libmagic.magic_close
 | 
			
		||||
magic_close.restype = None
 | 
			
		||||
magic_close.argtypes = [magic_t]
 | 
			
		||||
magic_close.errcheck = errorcheck
 | 
			
		||||
    magic_close = libmagic.magic_close
 | 
			
		||||
    magic_close.restype = None
 | 
			
		||||
    magic_close.argtypes = [magic_t]
 | 
			
		||||
    magic_close.errcheck = errorcheck
 | 
			
		||||
 | 
			
		||||
magic_error = libmagic.magic_error
 | 
			
		||||
magic_error.restype = c_char_p
 | 
			
		||||
magic_error.argtypes = [magic_t]
 | 
			
		||||
    magic_error = libmagic.magic_error
 | 
			
		||||
    magic_error.restype = c_char_p
 | 
			
		||||
    magic_error.argtypes = [magic_t]
 | 
			
		||||
 | 
			
		||||
magic_errno = libmagic.magic_errno
 | 
			
		||||
magic_errno.restype = c_int
 | 
			
		||||
magic_errno.argtypes = [magic_t]
 | 
			
		||||
    magic_errno = libmagic.magic_errno
 | 
			
		||||
    magic_errno.restype = c_int
 | 
			
		||||
    magic_errno.argtypes = [magic_t]
 | 
			
		||||
 | 
			
		||||
magic_file = libmagic.magic_file
 | 
			
		||||
magic_file.restype = c_char_p
 | 
			
		||||
magic_file.argtypes = [magic_t, c_char_p]
 | 
			
		||||
magic_file.errcheck = errorcheck
 | 
			
		||||
    magic_file = libmagic.magic_file
 | 
			
		||||
    magic_file.restype = c_char_p
 | 
			
		||||
    magic_file.argtypes = [magic_t, c_char_p]
 | 
			
		||||
    magic_file.errcheck = errorcheck
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
_magic_buffer = libmagic.magic_buffer
 | 
			
		||||
_magic_buffer.restype = c_char_p
 | 
			
		||||
_magic_buffer.argtypes = [magic_t, c_void_p, c_size_t]
 | 
			
		||||
_magic_buffer.errcheck = errorcheck
 | 
			
		||||
    _magic_buffer = libmagic.magic_buffer
 | 
			
		||||
    _magic_buffer.restype = c_char_p
 | 
			
		||||
    _magic_buffer.argtypes = [magic_t, c_void_p, c_size_t]
 | 
			
		||||
    _magic_buffer.errcheck = errorcheck
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def magic_buffer(cookie, buf):
 | 
			
		||||
    def magic_buffer(cookie, buf):
 | 
			
		||||
        return _magic_buffer(cookie, buf, len(buf))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
magic_load = libmagic.magic_load
 | 
			
		||||
magic_load.restype = c_int
 | 
			
		||||
magic_load.argtypes = [magic_t, c_char_p]
 | 
			
		||||
magic_load.errcheck = errorcheck
 | 
			
		||||
    magic_load = libmagic.magic_load
 | 
			
		||||
    magic_load.restype = c_int
 | 
			
		||||
    magic_load.argtypes = [magic_t, c_char_p]
 | 
			
		||||
    magic_load.errcheck = errorcheck
 | 
			
		||||
 | 
			
		||||
magic_setflags = libmagic.magic_setflags
 | 
			
		||||
magic_setflags.restype = c_int
 | 
			
		||||
magic_setflags.argtypes = [magic_t, c_int]
 | 
			
		||||
    magic_setflags = libmagic.magic_setflags
 | 
			
		||||
    magic_setflags.restype = c_int
 | 
			
		||||
    magic_setflags.argtypes = [magic_t, c_int]
 | 
			
		||||
 | 
			
		||||
magic_check = libmagic.magic_check
 | 
			
		||||
magic_check.restype = c_int
 | 
			
		||||
magic_check.argtypes = [magic_t, c_char_p]
 | 
			
		||||
 | 
			
		||||
magic_compile = libmagic.magic_compile
 | 
			
		||||
magic_compile.restype = c_int
 | 
			
		||||
magic_compile.argtypes = [magic_t, c_char_p]
 | 
			
		||||
    magic_check = libmagic.magic_check
 | 
			
		||||
    magic_check.restype = c_int
 | 
			
		||||
    magic_check.argtypes = [magic_t, c_char_p]
 | 
			
		||||
 | 
			
		||||
    magic_compile = libmagic.magic_compile
 | 
			
		||||
    magic_compile.restype = c_int
 | 
			
		||||
    magic_compile.argtypes = [magic_t, c_char_p]
 | 
			
		||||
except:
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
MAGIC_NONE = 0x000000 # No flags
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -742,7 +742,10 @@ def getRemoteIP():
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
def getFileType(filePath):
 | 
			
		||||
    try:
 | 
			
		||||
        magicFileType = magic.from_file(filePath)
 | 
			
		||||
    except:
 | 
			
		||||
        return "unknown"
 | 
			
		||||
 | 
			
		||||
    if "ASCII" in magicFileType or "text" in magicFileType:
 | 
			
		||||
        return "text"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										16
									
								
								sqlmap.conf
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								sqlmap.conf
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -2,21 +2,7 @@
 | 
			
		|||
 | 
			
		||||
# Target URL.
 | 
			
		||||
# Example: http://192.168.1.121/sqlmap/mysql/get_int.php?id=1&cat=2
 | 
			
		||||
# Windows Server 2003 Service Pack 2 virtual machine
 | 
			
		||||
#url = http://192.168.62.154/sqlmap/mysql/iis/get_int.asp?id=1
 | 
			
		||||
#url = http://192.168.62.154/sqlmap/mysql/iis/get_int.aspx?id=1
 | 
			
		||||
#url = http://192.168.62.154/sqlmap/mysql/iis/get_int_51.aspx?id=1
 | 
			
		||||
#url = http://192.168.62.154/sqlmap/pgsql/iis/get_int.asp?id=1
 | 
			
		||||
#url = http://192.168.62.154/sqlmap/pgsql/iis/get_int.aspx?id=1
 | 
			
		||||
#url = http://192.168.62.154/sqlmap/mssql/iis/get_str.asp?name=luther
 | 
			
		||||
url = http://192.168.62.154/sqlmap/mssql/iis/get_str2.asp?name=luther
 | 
			
		||||
#url = http://192.168.62.154/sqlmap/mssql/iis/get_str2_user.asp?name=luther
 | 
			
		||||
# Ubuntu 8.10 (Intrepid Ibex) virtual machine
 | 
			
		||||
#url = http://192.168.62.146/sqlmap/mysql/get_int.php?id=1
 | 
			
		||||
#url = http://192.168.62.146/sqlmap/mssql/get_int.php?id=1
 | 
			
		||||
#url = http://192.168.62.146/sqlmap/oracle/get_int.php?id=1
 | 
			
		||||
#url = http://10.0.0.58/sqlmap/pgsql/get_int.php?id=1
 | 
			
		||||
#url = http://192.168.62.146/sqlmap/pgsql/get_int_partialunion.php?id=1
 | 
			
		||||
url = 
 | 
			
		||||
 | 
			
		||||
# Parse targets from Burp or WebScarab logs
 | 
			
		||||
# Valid: Burp proxy (http://portswigger.net/suite/) requests log file path
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user