MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / htmlParser

Function htmlParser

lib/parse/html.py:61–99  ·  view source on GitHub ↗

This function calls a class that parses the input HTML page to fingerprint the back-end database management system >>> from lib.core.enums import DBMS >>> htmlParser("Warning: mysql_fetch_array() expects parameter 1 to be resource") == DBMS.MYSQL True >>> threadData = getCu

(page)

Source from the content-addressed store, hash-verified

59 kb.forkNote = kb.forkNote or attrs.get("fork")
60
61def htmlParser(page):
62 """
63 This function calls a class that parses the input HTML page to
64 fingerprint the back-end database management system
65
66 >>> from lib.core.enums import DBMS
67 >>> htmlParser("Warning: mysql_fetch_array() expects parameter 1 to be resource") == DBMS.MYSQL
68 True
69 >>> threadData = getCurrentThreadData()
70 >>> threadData.lastErrorPage = None
71 """
72
73 page = page[:HEURISTIC_PAGE_SIZE_THRESHOLD]
74
75 xmlfile = paths.ERRORS_XML
76 handler = HTMLHandler(page)
77 key = hash(page)
78
79 # generic SQL warning/error messages
80 if re.search(r"SQL (warning|error|syntax)", page, re.I):
81 handler._markAsErrorPage()
82
83 if key in kb.cache.parsedDbms:
84 retVal = kb.cache.parsedDbms[key]
85 if retVal:
86 handler._markAsErrorPage()
87 return retVal
88
89 parseXmlFile(xmlfile, handler)
90
91 if handler.dbms and handler.dbms not in kb.htmlFp:
92 kb.lastParserStatus = handler.dbms
93 kb.htmlFp.append(handler.dbms)
94 else:
95 kb.lastParserStatus = None
96
97 kb.cache.parsedDbms[key] = handler.dbms
98
99 return handler.dbms

Callers 1

parseResponseFunction · 0.90

Calls 5

_markAsErrorPageMethod · 0.95
parseXmlFileFunction · 0.90
HTMLHandlerClass · 0.85
searchMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…