|
45 | 45 | from lib.parse.banner import bannerParser |
46 | 46 | from lib.request import inject |
47 | 47 | from lib.request.connect import Connect as Request |
| 48 | +from lib.techniques.outband.stacked import stackedTest |
48 | 49 |
|
49 | 50 |
|
50 | 51 | class Enumeration: |
@@ -1053,24 +1054,36 @@ def sqlQuery(self, query): |
1053 | 1054 |
|
1054 | 1055 | break |
1055 | 1056 |
|
1056 | | - if sqlType: |
| 1057 | + if selectQuery == True: |
1057 | 1058 | infoMsg = "fetching %s query output: '%s'" % (sqlType, query) |
| 1059 | + logger.info(infoMsg) |
| 1060 | + |
| 1061 | + output = inject.getValue(query, fromUser=True) |
1058 | 1062 | else: |
1059 | | - infoMsg = "fetching SQL query output: '%s'" % query |
| 1063 | + if kb.stackedTest == None: |
| 1064 | + stackedTest() |
1060 | 1065 |
|
1061 | | - logger.info(infoMsg) |
| 1066 | + if kb.stackedTest == False: |
| 1067 | + warnMsg = "the web application does not support " |
| 1068 | + warnMsg += "stacked queries" |
| 1069 | + logger.warn(warnMsg) |
1062 | 1070 |
|
1063 | | - if selectQuery == False: |
1064 | | - # TODO: test if stacked queries are supported by the web |
1065 | | - # application before injecting |
1066 | | - inject.goStacked(query) |
1067 | | - else: |
1068 | | - output = inject.getValue(query, fromUser=True) |
| 1071 | + return None |
| 1072 | + else: |
| 1073 | + if sqlType: |
| 1074 | + infoMsg = "executing %s query: '%s'" % (sqlType, query) |
| 1075 | + else: |
| 1076 | + infoMsg = "executing unknown SQL type query: '%s'" % query |
| 1077 | + logger.info(infoMsg) |
1069 | 1078 |
|
1070 | | - if output == "Quit": |
1071 | | - return None |
1072 | | - else: |
1073 | | - return output |
| 1079 | + inject.goStacked(query) |
| 1080 | + |
| 1081 | + infoMsg = "done" |
| 1082 | + logger.info(infoMsg) |
| 1083 | + |
| 1084 | + output = False |
| 1085 | + |
| 1086 | + return output |
1074 | 1087 |
|
1075 | 1088 |
|
1076 | 1089 | def sqlShell(self): |
@@ -1105,5 +1118,9 @@ def sqlShell(self): |
1105 | 1118 |
|
1106 | 1119 | if output and output != "Quit": |
1107 | 1120 | dumper.string(query, output) |
| 1121 | + |
| 1122 | + elif output == False: |
| 1123 | + pass |
| 1124 | + |
1108 | 1125 | elif output != "Quit": |
1109 | 1126 | print "No output" |
0 commit comments