Skip to content

Commit 900a5da

Browse files
stamparmtanaydin
authored andcommitted
Minor update
1 parent 2592596 commit 900a5da

15 files changed

+112
-89
lines changed

data/txt/sha256sums.txt

Lines changed: 62 additions & 62 deletions
Large diffs are not rendered by default.

lib/core/common.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
from lib.core.convert import getUnicode
5959
from lib.core.convert import htmlUnescape
6060
from lib.core.convert import stdoutEncode
61-
from lib.core.data import cmdLineOptions
61+
from lib.core.data import cmdLineOptions, paths
6262
from lib.core.data import conf
6363
from lib.core.data import kb
6464
from lib.core.data import logger
@@ -2554,7 +2554,7 @@ def initCommonOutputs():
25542554
if line not in kb.commonOutputs[key]:
25552555
kb.commonOutputs[key].add(line)
25562556

2557-
def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, unique=False):
2557+
def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, unique=False, raiseOnError=True):
25582558
"""
25592559
Returns newline delimited items contained inside file
25602560
@@ -2567,7 +2567,7 @@ def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, un
25672567
if filename:
25682568
filename = filename.strip('"\'')
25692569

2570-
checkFile(filename)
2570+
checkFile(filename, raiseOnError=raiseOnError)
25712571

25722572
try:
25732573
with openFile(filename, 'r', errors="ignore") if unicoded else open(filename, 'r') as f:
@@ -5599,18 +5599,35 @@ def checkSums():
55995599

56005600
retVal = True
56015601

5602-
if paths.get("DIGEST_FILE"):
5603-
for entry in getFileItems(paths.DIGEST_FILE):
5604-
match = re.search(r"([0-9a-f]+)\s+([^\s]+)", entry)
5605-
if match:
5606-
expected, filename = match.groups()
5607-
filepath = os.path.join(paths.SQLMAP_ROOT_PATH, filename).replace('/', os.path.sep)
5608-
if not checkFile(filepath, False):
5609-
continue
5610-
with open(filepath, "rb") as f:
5611-
content = f.read()
5612-
if not hashlib.sha256(content).hexdigest() == expected:
5613-
retVal &= False
5614-
break
5602+
for entry in getFileItems(paths.DIGEST_FILE, raiseOnError=False):
5603+
file_data = entry.split()
5604+
if len(file_data) == 2 and len(file_data[0]) == 64:
5605+
filepath = os.path.join(paths.SQLMAP_ROOT_PATH, file_data[1]).replace('/', os.path.sep)
5606+
content = openFile(filepath, 'rb').read()
5607+
if not hashlib.sha256(content.encode('utf-8')).hexdigest() == file_data[0]:
5608+
retVal &= False
5609+
break
5610+
56155611

56165612
return retVal
5613+
5614+
5615+
def updateSums():
5616+
# Read existing entries to maintain file order
5617+
entries = []
5618+
for entry in getFileItems(paths.DIGEST_FILE):
5619+
file_data = entry.split()
5620+
if len(file_data) == 2 and len(file_data[0]) == 64:
5621+
filepath = os.path.join(paths.SQLMAP_ROOT_PATH, file_data[1]).replace('/', os.path.sep)
5622+
content = openFile(filepath, 'rb').read()
5623+
newline = b"%s %s\n" % (
5624+
hashlib.sha256(content.encode('utf-8')).hexdigest().encode('utf-8'),
5625+
file_data[1].encode('utf-8')
5626+
)
5627+
entries.append(newline)
5628+
5629+
# Write updated hashes back to file
5630+
if entries:
5631+
with open(paths.DIGEST_FILE, "wb") as f:
5632+
f.write(b"".join(entries))
5633+

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from thirdparty import six
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.9.2.8"
22+
VERSION = "1.9.2.9"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,9 @@ def cmdLineParser(argv=None):
796796
miscellaneous.add_argument("--wizard", dest="wizard", action="store_true",
797797
help="Simple wizard interface for beginner users")
798798

799+
miscellaneous.add_argument("--update-sums", dest="updateSums", action="store_true",
800+
help="Update SHA256 sums in digest file must run with --smoke")
801+
799802
# Hidden and/or experimental options
800803
parser.add_argument("--crack", dest="hashFile",
801804
help=SUPPRESS) # "Load and crack hashes from a file (standalone)"

sqlmap.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ def main():
179179
if not conf.updateAll:
180180
# Postponed imports (faster start)
181181
if conf.smokeTest:
182+
if conf.updateSums:
183+
from lib.core.common import updateSums
184+
updateSums()
182185
from lib.core.testing import smokeTest
183186
os._exitcode = 1 - (smokeTest() or 0)
184187
elif conf.vulnTest:

tamper/0eunion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def dependencies():
1616

1717
def tamper(payload, **kwargs):
1818
"""
19-
Replaces instances of <int> UNION with <int>e0UNION
19+
Replaces an integer followed by UNION with an integer followed by e0UNION
2020
2121
Requirement:
2222
* MySQL

tamper/apostrophemask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def dependencies():
1414

1515
def tamper(payload, **kwargs):
1616
"""
17-
Replaces apostrophe character (') with its UTF-8 full width counterpart (e.g. ' -> %EF%BC%87)
17+
Replaces single quotes (') with their UTF-8 full-width equivalents (e.g. ' -> %EF%BC%87)
1818
1919
References:
2020
* http://www.utf8-chartable.de/unicode-utf8-table.pl?start=65280&number=128

tamper/apostrophenullencode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def dependencies():
1414

1515
def tamper(payload, **kwargs):
1616
"""
17-
Replaces apostrophe character (') with its illegal double unicode counterpart (e.g. ' -> %00%27)
17+
Replaces single quotes (') with an illegal double Unicode encoding (e.g. ' -> %00%27)
1818
1919
>>> tamper("1 AND '1'='1")
2020
'1 AND %00%271%00%27=%00%271'

tamper/appendnullbyte.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def dependencies():
1818

1919
def tamper(payload, **kwargs):
2020
"""
21-
Appends (Access) NULL byte character (%00) at the end of payload
21+
Appends an (Access) NULL byte character (%00) at the end of payload
2222
2323
Requirement:
2424
* Microsoft Access

tamper/base64encode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def dependencies():
1515

1616
def tamper(payload, **kwargs):
1717
"""
18-
Base64-encodes all characters in a given payload
18+
Encodes the entire payload using Base64
1919
2020
>>> tamper("1' AND SLEEP(5)#")
2121
'MScgQU5EIFNMRUVQKDUpIw=='

0 commit comments

Comments
 (0)