Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c32ef9d

Browse files
committed
Major bug fix to avoid tracebacks when multiple targets are specified and one
of them is not reachable. Minor bug fix to make the --postfix work even if --prefix is not provided.
1 parent 2efb3ae commit c32ef9d

5 files changed

Lines changed: 36 additions & 6 deletions

File tree

doc/THANKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Jason Swan <[email protected]>
126126
Alessandro Tanasi <[email protected]>
127127
for extensively beta-testing sqlmap
128128
for suggesting many features and reporting some bugs
129+
for reviewing the documentation
129130

130131
Efrain Torres <[email protected]>
131132
for helping me out to improve the Metasploit Framework 3 sqlmap

lib/core/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def prefixQuery(self, string):
9393
if conf.prefix:
9494
query = conf.prefix
9595
else:
96-
if kb.injType == "numeric":
96+
if kb.injType == "numeric" or conf.postfix:
9797
pass
9898
elif kb.injType in ( "stringsingle", "likesingle" ):
9999
query = "'"

lib/core/common.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,40 @@ def parsePasswordHash(password):
493493

494494

495495
def cleanQuery(query):
496+
# SQL SELECT statement
496497
upperQuery = query.replace("select ", "SELECT ")
497498
upperQuery = upperQuery.replace(" from ", " FROM ")
499+
upperQuery = upperQuery.replace(" where ", " WHERE ")
500+
upperQuery = upperQuery.replace(" group by ", " GROUP BY ")
501+
upperQuery = upperQuery.replace(" order by ", " ORDER BY ")
502+
upperQuery = upperQuery.replace(" having ", " HAVING ")
498503
upperQuery = upperQuery.replace(" limit ", " LIMIT ")
499504
upperQuery = upperQuery.replace(" offset ", " OFFSET ")
500-
upperQuery = upperQuery.replace(" order by ", " ORDER BY ")
501-
upperQuery = upperQuery.replace(" group by ", " GROUP BY ")
502505
upperQuery = upperQuery.replace(" union all ", " UNION ALL ")
503506
upperQuery = upperQuery.replace(" rownum ", " ROWNUM ")
504507

508+
# SQL data definition
509+
upperQuery = upperQuery.replace(" create ", " CREATE ")
510+
upperQuery = upperQuery.replace(" drop ", " DROP ")
511+
upperQuery = upperQuery.replace(" truncate ", " TRUNCATE ")
512+
upperQuery = upperQuery.replace(" alter ", " ALTER ")
513+
514+
# SQL data manipulation
515+
upperQuery = upperQuery.replace(" insert ", " INSERT ")
516+
upperQuery = upperQuery.replace(" update ", " UPDATE ")
517+
upperQuery = upperQuery.replace(" delete ", " DELETE ")
518+
upperQuery = upperQuery.replace(" merge ", " MERGE ")
519+
520+
# SQL data control
521+
upperQuery = upperQuery.replace(" grant ", " GRANT ")
522+
523+
# SQL transaction control
524+
upperQuery = upperQuery.replace(" start transaction ", " START TRANSACTION ")
525+
upperQuery = upperQuery.replace(" begin work ", " BEGIN WORK ")
526+
upperQuery = upperQuery.replace(" begin transaction ", " BEGIN TRANSACTION ")
527+
upperQuery = upperQuery.replace(" commit ", " COMMIT ")
528+
upperQuery = upperQuery.replace(" rollback ", " ROLLBACK ")
529+
505530
return upperQuery
506531

507532

lib/request/connect.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def getPage(**kwargs):
9797
multipartOpener = urllib2.build_opener(multipartpost.MultipartPostHandler)
9898
conn = multipartOpener.open(url, multipart)
9999
page = conn.read()
100+
100101
return page
101102

102103
else:
@@ -197,7 +198,7 @@ def getPage(**kwargs):
197198
warnMsg += ", skipping to next url"
198199
logger.warn(warnMsg)
199200

200-
return None
201+
return None, None
201202

202203
if conf.retries < RETRIES:
203204
conf.retries += 1
@@ -206,6 +207,7 @@ def getPage(**kwargs):
206207
logger.warn(warnMsg)
207208

208209
time.sleep(1)
210+
209211
return Connect.__getPageProxy(get=get, post=post, cookie=cookie, ua=ua, direct=direct, multipart=multipart)
210212

211213
else:
@@ -268,5 +270,7 @@ def queryPage(value=None, place=None, content=False):
268270

269271
if content:
270272
return page
271-
else:
273+
elif page and headers:
272274
return comparison(page, headers, content)
275+
else:
276+
return False

plugins/dbms/mysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def osShell(self):
470470
"uploadDir": directory,
471471
}
472472
uploaderUrl = "%s/%s" % (baseUrl, uploaderName)
473-
page, _ = Request.getPage(url=uploaderUrl, multipart=multipartParams)
473+
page = Request.getPage(url=uploaderUrl, multipart=multipartParams)
474474

475475
if "Backdoor uploaded" not in page:
476476
warnMsg = "unable to upload the backdoor through "

0 commit comments

Comments
 (0)