Skip to content

Commit 53b8a95

Browse files
committed
Fixes #5581
1 parent 6dd383f commit 53b8a95

File tree

3 files changed

+75
-55
lines changed

3 files changed

+75
-55
lines changed

lib/core/convert.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ def dejsonize(data):
135135

136136
return json.loads(data)
137137

138+
def rot13(data):
139+
"""
140+
Returns ROT13 encoded/decoded text
141+
142+
>>> rot13('foobar was here!!')
143+
'sbbone jnf urer!!'
144+
>>> rot13('sbbone jnf urer!!')
145+
'foobar was here!!'
146+
"""
147+
148+
# Reference: https://stackoverflow.com/a/62662878
149+
retVal = ""
150+
alphabit = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
151+
for char in data:
152+
retVal += alphabit[alphabit.index(char) + 13] if char in alphabit else char
153+
return retVal
154+
138155
def decodeHex(value, binary=True):
139156
"""
140157
Returns a decoded representation of provided hexadecimal value

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty.six import unichr as _unichr
2121

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

plugins/dbms/mssqlserver/filesystem.py

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from lib.core.compat import xrange
1919
from lib.core.convert import encodeBase64
2020
from lib.core.convert import encodeHex
21+
from lib.core.convert import rot13
2122
from lib.core.data import conf
2223
from lib.core.data import kb
2324
from lib.core.data import logger
@@ -278,60 +279,62 @@ def _stackedWriteFileVbs(self, tmpPath, localFileContent, remoteFile, fileType):
278279
randFile = "tmpf%s.txt" % randomStr(lowercase=True)
279280
randFilePath = "%s\\%s" % (tmpPath, randFile)
280281

281-
vbs = """Dim inputFilePath, outputFilePath
282-
inputFilePath = "%s"
283-
outputFilePath = "%s"
284-
Set fs = CreateObject("Scripting.FileSystemObject")
285-
Set file = fs.GetFile(inputFilePath)
286-
If file.Size Then
287-
Wscript.Echo "Loading from: " & inputFilePath
288-
Wscript.Echo
289-
Set fd = fs.OpenTextFile(inputFilePath, 1)
290-
data = fd.ReadAll
291-
fd.Close
292-
data = Replace(data, " ", "")
293-
data = Replace(data, vbCr, "")
294-
data = Replace(data, vbLf, "")
295-
Wscript.Echo "Fixed Input: "
296-
Wscript.Echo data
297-
Wscript.Echo
298-
decodedData = base64_decode(data)
299-
Wscript.Echo "Output: "
300-
Wscript.Echo decodedData
301-
Wscript.Echo
302-
Wscript.Echo "Writing output in: " & outputFilePath
303-
Wscript.Echo
304-
Set ofs = CreateObject("Scripting.FileSystemObject").OpenTextFile(outputFilePath, 2, True)
305-
ofs.Write decodedData
306-
ofs.close
307-
Else
308-
Wscript.Echo "The file is empty."
309-
End If
310-
Function base64_decode(byVal strIn)
311-
Dim w1, w2, w3, w4, n, strOut
312-
For n = 1 To Len(strIn) Step 4
313-
w1 = mimedecode(Mid(strIn, n, 1))
314-
w2 = mimedecode(Mid(strIn, n + 1, 1))
315-
w3 = mimedecode(Mid(strIn, n + 2, 1))
316-
w4 = mimedecode(Mid(strIn, n + 3, 1))
317-
If Not w2 Then _
318-
strOut = strOut + Chr(((w1 * 4 + Int(w2 / 16)) And 255))
319-
If Not w3 Then _
320-
strOut = strOut + Chr(((w2 * 16 + Int(w3 / 4)) And 255))
321-
If Not w4 Then _
322-
strOut = strOut + Chr(((w3 * 64 + w4) And 255))
323-
Next
324-
base64_decode = strOut
325-
End Function
326-
Function mimedecode(byVal strIn)
327-
Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
328-
If Len(strIn) = 0 Then
329-
mimedecode = -1 : Exit Function
330-
Else
331-
mimedecode = InStr(Base64Chars, strIn) - 1
332-
End If
333-
End Function""" % (randFilePath, remoteFile)
334-
282+
vbs = """Qvz vachgSvyrCngu, bhgchgSvyrCngu
283+
vachgSvyrCngu = "%f"
284+
bhgchgSvyrCngu = "%f"
285+
Frg sf = PerngrBowrpg("Fpevcgvat.SvyrFlfgrzBowrpg")
286+
Frg svyr = sf.TrgSvyr(vachgSvyrCngu)
287+
Vs svyr.Fvmr Gura
288+
Jfpevcg.Rpub "Ybnqvat sebz: " & vachgSvyrCngu
289+
Jfpevcg.Rpub
290+
Frg sq = sf.BcraGrkgSvyr(vachgSvyrCngu, 1)
291+
qngn = sq.ErnqNyy
292+
sq.Pybfr
293+
qngn = Ercynpr(qngn, " ", "")
294+
qngn = Ercynpr(qngn, ioPe, "")
295+
qngn = Ercynpr(qngn, ioYs, "")
296+
Jfpevcg.Rpub "Svkrq Vachg: "
297+
Jfpevcg.Rpub qngn
298+
Jfpevcg.Rpub
299+
qrpbqrqQngn = onfr64_qrpbqr(qngn)
300+
Jfpevcg.Rpub "Bhgchg: "
301+
Jfpevcg.Rpub qrpbqrqQngn
302+
Jfpevcg.Rpub
303+
Jfpevcg.Rpub "Jevgvat bhgchg va: " & bhgchgSvyrCngu
304+
Jfpevcg.Rpub
305+
Frg bsf = PerngrBowrpg("Fpevcgvat.SvyrFlfgrzBowrpg").BcraGrkgSvyr(bhgchgSvyrCngu, 2, Gehr)
306+
bsf.Jevgr qrpbqrqQngn
307+
bsf.pybfr
308+
Ryfr
309+
Jfpevcg.Rpub "Gur svyr vf rzcgl."
310+
Raq Vs
311+
Shapgvba onfr64_qrpbqr(olIny fgeVa)
312+
Qvz j1, j2, j3, j4, a, fgeBhg
313+
Sbe a = 1 Gb Yra(fgeVa) Fgrc 4
314+
j1 = zvzrqrpbqr(Zvq(fgeVa, a, 1))
315+
j2 = zvzrqrpbqr(Zvq(fgeVa, a + 1, 1))
316+
j3 = zvzrqrpbqr(Zvq(fgeVa, a + 2, 1))
317+
j4 = zvzrqrpbqr(Zvq(fgeVa, a + 3, 1))
318+
Vs Abg j2 Gura _
319+
fgeBhg = fgeBhg + Pue(((j1 * 4 + Vag(j2 / 16)) Naq 255))
320+
Vs Abg j3 Gura _
321+
fgeBhg = fgeBhg + Pue(((j2 * 16 + Vag(j3 / 4)) Naq 255))
322+
Vs Abg j4 Gura _
323+
fgeBhg = fgeBhg + Pue(((j3 * 64 + j4) Naq 255))
324+
Arkg
325+
onfr64_qrpbqr = fgeBhg
326+
Raq Shapgvba
327+
Shapgvba zvzrqrpbqr(olIny fgeVa)
328+
Onfr64Punef = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm0123456789+/"
329+
Vs Yra(fgeVa) = 0 Gura
330+
zvzrqrpbqr = -1 : Rkvg Shapgvba
331+
Ryfr
332+
zvzrqrpbqr = VaFge(Onfr64Punef, fgeVa) - 1
333+
Raq Vs
334+
Raq Shapgvba"""
335+
336+
# NOTE: https://github.com/sqlmapproject/sqlmap/issues/5581
337+
vbs = rot13(vbs)
335338
vbs = vbs.replace(" ", "")
336339
encodedFileContent = encodeBase64(localFileContent, binary=False)
337340

0 commit comments

Comments
 (0)