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

Skip to content

Commit c4215ce

Browse files
committed
Minor code refactoring
1 parent 26c7b74 commit c4215ce

6 files changed

Lines changed: 30 additions & 29 deletions

File tree

lib/core/optiondict.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@
2727
"Target": {
2828
"url": "string",
2929
"list": "string",
30+
"requestFile": "string",
3031
"googleDork": "string",
31-
"configFile": "string",
32-
"requestFile": "string"
32+
"configFile": "string"
3333
},
3434

3535
"Request": {
3636
"method": "string",
3737
"data": "string",
3838
"cookie": "string",
39+
"cookieUrlencode": "boolean",
3940
"dropSetCookie": "boolean",
4041
"referer": "string",
4142
"agent": "string",
@@ -62,7 +63,6 @@
6263
"regexp": "string",
6364
"eString": "string",
6465
"eRegexp": "string",
65-
"cookieUrlencode": "boolean"
6666
},
6767

6868
"Techniques": {

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import sys
2828

2929
# sqlmap version and site
30-
VERSION = "0.8-rc4"
30+
VERSION = "0.8-rc5"
3131
VERSION_STRING = "sqlmap/%s" % VERSION
3232
SITE = "http://sqlmap.sourceforge.net"
3333

lib/parse/cmdline.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ def cmdLineParser():
5353
target.add_option("-l", dest="list", help="Parse targets from Burp "
5454
"or WebScarab proxy logs")
5555

56+
target.add_option("-r", dest="requestFile",
57+
help="Load HTTP request from a file")
58+
5659
target.add_option("-g", dest="googleDork",
5760
help="Process Google dork results as target urls")
5861

5962
target.add_option("-c", dest="configFile",
6063
help="Load options from a configuration INI file")
61-
62-
target.add_option("-r", dest="requestFile",
63-
help="Load HTTP request from a file")
64-
64+
6565
# Request options
6666
request = OptionGroup(parser, "Request", "These options can be used "
6767
"to specify how to connect to the target url.")
@@ -75,7 +75,12 @@ def cmdLineParser():
7575
request.add_option("--cookie", dest="cookie",
7676
help="HTTP Cookie header")
7777

78-
request.add_option("--drop-set-cookie", dest="dropSetCookie", action="store_true",
78+
request.add_option("--cookie-urlencode", dest="cookieUrlencode",
79+
action="store_true",
80+
help="URL-encode generated cookie injections")
81+
82+
request.add_option("--drop-set-cookie", dest="dropSetCookie",
83+
action="store_true",
7984
help="Ignore Set-Cookie header from response")
8085

8186
request.add_option("--user-agent", dest="agent",
@@ -164,10 +169,6 @@ def cmdLineParser():
164169
help="Matches to be excluded before "
165170
"comparing page contents")
166171

167-
injection.add_option("--cookie-urlencode", dest="cookieUrlencode",
168-
action="store_true",
169-
help="URLEncode generated cookie injections")
170-
171172
# Techniques options
172173
techniques = OptionGroup(parser, "Techniques", "These options can "
173174
"be used to test for specific SQL injection "

lib/takeover/metasploit.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,15 +636,14 @@ def createMsfPayloadStager(self, initialize=True):
636636

637637
def uploadMsfPayloadStager(self, web=False):
638638
if web:
639-
self.exeFilePathRemote = "./%s" % os.path.basename(self.exeFilePathLocal)
639+
self.exeFilePathRemote = "%s/%s" % (self.webDirectory, os.path.basename(self.exeFilePathLocal))
640640
else:
641641
self.exeFilePathRemote = "%s/%s" % (conf.tmpPath, os.path.basename(self.exeFilePathLocal))
642642

643643
logger.info("uploading payload stager to '%s'" % self.exeFilePathRemote)
644644

645645
if web:
646-
for directory in self.webDirectories:
647-
self.webFileUpload(self.exeFilePathLocal, self.exeFilePathRemote, directory)
646+
self.webFileUpload(self.exeFilePathLocal, self.exeFilePathRemote, self.webDirectory)
648647
else:
649648
self.writeFile(self.exeFilePathLocal, self.exeFilePathRemote, "binary", False)
650649

lib/takeover/web.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self):
5151
self.webBaseUrl = None
5252
self.webBackdoorUrl = None
5353
self.webUploaderUrl = None
54-
self.webDirectories = set()
54+
self.webDirectory = None
5555

5656
def webBackdoorRunCmd(self, cmd):
5757
if self.webBackdoorUrl is None:
@@ -114,9 +114,9 @@ def webInit(self):
114114
self.checkDbmsOs()
115115

116116
kb.docRoot = getDocRoot()
117-
self.webDirectories = getDirs()
118-
self.webDirectories = list(self.webDirectories)
119-
self.webDirectories.sort()
117+
directories = getDirs()
118+
directories = list(directories)
119+
directories.sort()
120120

121121
infoMsg = "trying to upload the uploader agent"
122122
logger.info(infoMsg)
@@ -154,7 +154,7 @@ def webInit(self):
154154
uploaderName = "uploader.%s" % self.webApi
155155
uploaderStr = fileToStr(os.path.join(paths.SQLMAP_SHELL_PATH, uploaderName))
156156

157-
for directory in self.webDirectories:
157+
for directory in directories:
158158
# Upload the uploader agent
159159
outFile = os.path.normpath("%s/%s" % (directory, uploaderName))
160160
uplQuery = uploaderStr.replace("WRITABLE_DIR", directory)
@@ -184,6 +184,7 @@ def webInit(self):
184184

185185
self.webFileUpload(backdoorPath, backdoorName, directory)
186186
self.webBackdoorUrl = "%s/%s" % (self.webBaseUrl, backdoorName)
187+
self.webDirectory = directory
187188

188189
infoMsg = "the backdoor has probably been successfully "
189190
infoMsg += "uploaded on '%s', go with your browser " % directory

sqlmap.conf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ url =
1010
# 'conversations/' folder path
1111
list =
1212

13+
# Load HTTP request from a file
14+
# Example (file content): POST /login.jsp HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/4.0\n\nuserid=joe&password=guessme
15+
requestFile =
16+
1317
# Rather than providing a target url, let Google return target
1418
# hosts as result of your Google dork expression. For a list of Google
1519
# dorks see Johnny Long Google Hacking Database at
1620
# http://johnny.ihackstuff.com/ghdb.php.
1721
# Example: +ext:php +inurl:"&id=" +intext:"powered by "
1822
googleDork =
1923

20-
# Load HTTP request from a file
21-
# Example (file content): POST /login.jsp HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/4.0\n\nuserid=joe&password=guessme
22-
requestFile =
23-
2424
[Request]
2525

2626
# HTTP method to perform HTTP requests.
@@ -35,6 +35,10 @@ data =
3535
# HTTP Cookie header.
3636
cookie =
3737

38+
# URL-encode generated cookie injections.
39+
# Valid: True or False
40+
cookieUrlencode = False
41+
3842
# Ignore Set-Cookie header from response
3943
# Valid: True or False
4044
dropSetCookie = False
@@ -155,10 +159,6 @@ eString =
155159
# (http://www.python.org/doc/2.5.2/lib/re-syntax.html)
156160
eRegexp =
157161

158-
# URLEncode generated cookie injections.
159-
# Valid: True or False
160-
cookieUrlencode = False
161-
162162
[Techniques]
163163

164164
# Test for stacked queries (multiple statements) support.

0 commit comments

Comments
 (0)