sqlmap/plugins/generic/fingerprint.py

59 lines
1.7 KiB
Python
Raw Normal View History

#!/usr/bin/env python
2008-10-15 19:38:22 +04:00
"""
2019-01-05 23:38:52 +03:00
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
2017-10-11 15:50:46 +03:00
See the file 'LICENSE' for copying permission
2008-10-15 19:38:22 +04:00
"""
from lib.core.common import Backend
2011-01-16 02:54:03 +03:00
from lib.core.common import readInput
from lib.core.data import logger
from lib.core.enums import OS
from lib.core.exception import SqlmapUndefinedMethod
2008-10-15 19:38:22 +04:00
class Fingerprint:
"""
This class defines generic fingerprint functionalities for plugins.
"""
def __init__(self, dbms):
Backend.forceDbms(dbms)
2008-10-15 19:38:22 +04:00
def getFingerprint(self):
2011-04-30 17:20:05 +04:00
errMsg = "'getFingerprint' method must be defined "
2008-10-15 19:38:22 +04:00
errMsg += "into the specific DBMS plugin"
raise SqlmapUndefinedMethod(errMsg)
2008-10-15 19:38:22 +04:00
def checkDbms(self):
2011-04-30 17:20:05 +04:00
errMsg = "'checkDbms' method must be defined "
2008-10-15 19:38:22 +04:00
errMsg += "into the specific DBMS plugin"
raise SqlmapUndefinedMethod(errMsg)
def checkDbmsOs(self, detailed=False):
2011-04-30 17:20:05 +04:00
errMsg = "'checkDbmsOs' method must be defined "
errMsg += "into the specific DBMS plugin"
raise SqlmapUndefinedMethod(errMsg)
def forceDbmsEnum(self):
pass
2011-01-16 02:54:03 +03:00
def userChooseDbmsOs(self):
warnMsg = "for some reason sqlmap was unable to fingerprint "
warnMsg += "the back-end DBMS operating system"
logger.warn(warnMsg)
msg = "do you want to provide the OS? [(W)indows/(l)inux]"
while True:
2017-04-19 15:46:27 +03:00
os = readInput(msg, default='W').upper()
2011-01-16 02:54:03 +03:00
2017-04-19 15:46:27 +03:00
if os == 'W':
Backend.setOs(OS.WINDOWS)
2011-01-16 02:54:03 +03:00
break
2017-04-19 15:46:27 +03:00
elif os == 'L':
Backend.setOs(OS.LINUX)
2011-01-16 02:54:03 +03:00
break
else:
warnMsg = "invalid value"
logger.warn(warnMsg)