mirror of
				https://github.com/sqlmapproject/sqlmap.git
				synced 2025-11-04 09:57:38 +03:00 
			
		
		
		
	Minor bug fix with --sql-query/shell when providing a statement with DISTINCT
This commit is contained in:
		
							parent
							
								
									954a927cee
								
							
						
					
					
						commit
						80df1fdcf9
					
				| 
						 | 
					@ -502,6 +502,12 @@ class Agent:
 | 
				
			||||||
            if " ORDER BY " in limitedQuery:
 | 
					            if " ORDER BY " in limitedQuery:
 | 
				
			||||||
                limitedQuery = limitedQuery[:limitedQuery.index(" ORDER BY ")]
 | 
					                limitedQuery = limitedQuery[:limitedQuery.index(" ORDER BY ")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            notDistincts = re.findall("DISTINCT[\(\s+](.+?)\)*\s+", limitedQuery, re.I)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for notDistinct in notDistincts:
 | 
				
			||||||
 | 
					                limitedQuery = limitedQuery.replace("DISTINCT(%s)" % notDistinct, notDistinct)
 | 
				
			||||||
 | 
					                limitedQuery = limitedQuery.replace("DISTINCT %s" % notDistinct, notDistinct)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if limitedQuery.startswith("SELECT TOP ") or limitedQuery.startswith("TOP "):
 | 
					            if limitedQuery.startswith("SELECT TOP ") or limitedQuery.startswith("TOP "):
 | 
				
			||||||
                topNums         = re.search(queries[kb.dbms].limitregexp, limitedQuery, re.I)
 | 
					                topNums         = re.search(queries[kb.dbms].limitregexp, limitedQuery, re.I)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -518,10 +524,12 @@ class Agent:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if forgeNotIn:
 | 
					            if forgeNotIn:
 | 
				
			||||||
                limitedQuery = limitedQuery.replace("SELECT ", (limitStr % 1), 1)
 | 
					                limitedQuery = limitedQuery.replace("SELECT ", (limitStr % 1), 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if " WHERE " in limitedQuery:
 | 
					                if " WHERE " in limitedQuery:
 | 
				
			||||||
                    limitedQuery  = "%s AND %s " % (limitedQuery, field)
 | 
					                    limitedQuery  = "%s AND %s " % (limitedQuery, field)
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    limitedQuery  = "%s WHERE %s " % (limitedQuery, field)
 | 
					                    limitedQuery  = "%s WHERE %s " % (limitedQuery, field)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                limitedQuery += "NOT IN (%s" % (limitStr % num)
 | 
					                limitedQuery += "NOT IN (%s" % (limitStr % num)
 | 
				
			||||||
                limitedQuery += "%s %s)" % (field, fromFrom)
 | 
					                limitedQuery += "%s %s)" % (field, fromFrom)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,6 +74,7 @@ SQL_STATEMENTS     = {
 | 
				
			||||||
                             "select ",
 | 
					                             "select ",
 | 
				
			||||||
                             "show ",
 | 
					                             "show ",
 | 
				
			||||||
                             " top ",
 | 
					                             " top ",
 | 
				
			||||||
 | 
					                             " distinct ",
 | 
				
			||||||
                             " from ",
 | 
					                             " from ",
 | 
				
			||||||
                             " from dual",
 | 
					                             " from dual",
 | 
				
			||||||
                             " where ",
 | 
					                             " where ",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -350,6 +350,8 @@ def getValue(expression, blind=True, inband=True, fromUser=False, expected=None,
 | 
				
			||||||
    expression = expandAsteriskForColumns(expression)
 | 
					    expression = expandAsteriskForColumns(expression)
 | 
				
			||||||
    value      = None
 | 
					    value      = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    expression = expression.replace("DISTINCT ", "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if inband and kb.unionPosition:
 | 
					    if inband and kb.unionPosition:
 | 
				
			||||||
        if kb.dbms == "Oracle" and " ORDER BY " in expression:
 | 
					        if kb.dbms == "Oracle" and " ORDER BY " in expression:
 | 
				
			||||||
            expression = expression[:expression.index(" ORDER BY ")]
 | 
					            expression = expression[:expression.index(" ORDER BY ")]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user