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

Skip to content

Commit 291b491

Browse files
committed
Minor drei update
1 parent ff968c2 commit 291b491

9 files changed

Lines changed: 33 additions & 60 deletions

File tree

lib/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ def getFileType(filePath):
17581758
"""
17591759

17601760
try:
1761-
desc = magic.from_file(filePath) or ""
1761+
desc = getUnicode(magic.from_file(filePath) or "")
17621762
except:
17631763
return "unknown"
17641764

lib/core/convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def utf8decode(value):
145145
"""
146146
Returns UTF-8 representation of the supplied 8-bit string representation
147147
148-
>>> utf8decode(b'foobar')
149-
u'foobar'
148+
>>> utf8decode(b'foobar') == u'foobar'
149+
True
150150
"""
151151

152152
retVal = value

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from lib.core.enums import OS
1818

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

lib/utils/hash.py

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -269,56 +269,54 @@ def sha1_generic_passwd(password, uppercase=False):
269269

270270
def apache_sha1_passwd(password, **kwargs):
271271
"""
272-
>>> apache_sha1_passwd(password='testpass')
273-
'{SHA}IGyAQTualsExLMNGt9JRe4RGPt0='
272+
>>> apache_sha1_passwd(password='testpass') == '{SHA}IGyAQTualsExLMNGt9JRe4RGPt0='
273+
True
274274
"""
275275

276276
password = getBytes(password)
277277

278-
return "{SHA}%s" % base64.b64encode(sha1(password).digest())
278+
return "{SHA}%s" % getUnicode(base64.b64encode(sha1(password).digest()))
279279

280280
def ssha_passwd(password, salt, **kwargs):
281281
"""
282-
>>> ssha_passwd(password='testpass', salt='salt')
283-
'{SSHA}mU1HPTvnmoXOhE4ROHP6sWfbfoRzYWx0'
282+
>>> ssha_passwd(password='testpass', salt='salt') == '{SSHA}mU1HPTvnmoXOhE4ROHP6sWfbfoRzYWx0'
283+
True
284284
"""
285285

286286
password = getBytes(password)
287287
salt = getBytes(salt)
288288

289-
return "{SSHA}%s" % base64.b64encode(sha1(password + salt).digest() + salt)
289+
return "{SSHA}%s" % getUnicode(base64.b64encode(sha1(password + salt).digest() + salt))
290290

291291
def ssha256_passwd(password, salt, **kwargs):
292292
"""
293-
>>> ssha256_passwd(password='testpass', salt='salt')
294-
'{SSHA256}hhubsLrO/Aje9F/kJrgv5ZLE40UmTrVWvI7Dt6InP99zYWx0'
293+
>>> ssha256_passwd(password='testpass', salt='salt') == '{SSHA256}hhubsLrO/Aje9F/kJrgv5ZLE40UmTrVWvI7Dt6InP99zYWx0'
294+
True
295295
"""
296296

297297
password = getBytes(password)
298298
salt = getBytes(salt)
299299

300-
return "{SSHA256}%s" % base64.b64encode(sha256(password + salt).digest() + salt)
300+
return "{SSHA256}%s" % getUnicode(base64.b64encode(sha256(password + salt).digest() + salt))
301301

302302
def ssha512_passwd(password, salt, **kwargs):
303303
"""
304-
>>> ssha512_passwd(password='testpass', salt='salt')
305-
'{SSHA512}mCUSLfPMhXCQOJl9WHW/QMn9v9sjq7Ht/Wk7iVau8vLOfh+PeynkGMikqIE8sStFd0khdfcCD8xZmC6UyjTxsHNhbHQ='
304+
>>> ssha512_passwd(password='testpass', salt='salt') == '{SSHA512}mCUSLfPMhXCQOJl9WHW/QMn9v9sjq7Ht/Wk7iVau8vLOfh+PeynkGMikqIE8sStFd0khdfcCD8xZmC6UyjTxsHNhbHQ='
305+
True
306306
"""
307307

308308
password = getBytes(password)
309309
salt = getBytes(salt)
310310

311-
return "{SSHA512}%s" % base64.b64encode(sha512(password + salt).digest() + salt)
311+
return "{SSHA512}%s" % getUnicode(base64.b64encode(sha512(password + salt).digest() + salt))
312312

313313
def sha224_generic_passwd(password, uppercase=False):
314314
"""
315315
>>> sha224_generic_passwd(password='testpass', uppercase=False)
316316
'648db6019764b598f75ab6b7616d2e82563a00eb1531680e19ac4c6f'
317317
"""
318318

319-
password = getBytes(password)
320-
321-
retVal = sha224(password).hexdigest()
319+
retVal = sha224(getBytes(password)).hexdigest()
322320

323321
return retVal.upper() if uppercase else retVal.lower()
324322

@@ -328,9 +326,7 @@ def sha256_generic_passwd(password, uppercase=False):
328326
'13d249f2cb4127b40cfa757866850278793f814ded3c587fe5889e889a7a9f6c'
329327
"""
330328

331-
password = getBytes(password)
332-
333-
retVal = sha256(password).hexdigest()
329+
retVal = sha256(getBytes(password)).hexdigest()
334330

335331
return retVal.upper() if uppercase else retVal.lower()
336332

@@ -340,9 +336,7 @@ def sha384_generic_passwd(password, uppercase=False):
340336
'6823546e56adf46849343be991d4b1be9b432e42ed1b4bb90635a0e4b930e49b9ca007bc3e04bf0a4e0df6f1f82769bf'
341337
"""
342338

343-
password = getBytes(password)
344-
345-
retVal = sha384(password).hexdigest()
339+
retVal = sha384(getBytes(password)).hexdigest()
346340

347341
return retVal.upper() if uppercase else retVal.lower()
348342

@@ -352,9 +346,7 @@ def sha512_generic_passwd(password, uppercase=False):
352346
'78ddc8555bb1677ff5af75ba5fc02cb30bb592b0610277ae15055e189b77fe3fda496e5027a3d99ec85d54941adee1cc174b50438fdc21d82d0a79f85b58cf44'
353347
"""
354348

355-
password = getBytes(password)
356-
357-
retVal = sha512(password).hexdigest()
349+
retVal = sha512(getBytes(password)).hexdigest()
358350

359351
return retVal.upper() if uppercase else retVal.lower()
360352

@@ -366,13 +358,10 @@ def crypt_generic_passwd(password, salt, **kwargs):
366358
http://php.net/manual/en/function.crypt.php
367359
http://carey.geek.nz/code/python-fcrypt/
368360
369-
>>> crypt_generic_passwd(password='rasmuslerdorf', salt='rl', uppercase=False)
370-
'rl.3StKT.4T8M'
361+
>>> crypt_generic_passwd(password='rasmuslerdorf', salt='rl', uppercase=False) == 'rl.3StKT.4T8M'
362+
True
371363
"""
372364

373-
password = getBytes(password)
374-
salt = getBytes(salt)
375-
376365
return crypt(password, salt)
377366

378367
def unix_md5_passwd(password, salt, magic="$1$", **kwargs):
@@ -411,15 +400,15 @@ def _encode64(value, count):
411400
i = len(password)
412401
while i:
413402
if i & 1:
414-
ctx = ctx + chr(0) # if ($i & 1) { $ctx->add(pack("C", 0)); }
403+
ctx = ctx + b'\x00' # if ($i & 1) { $ctx->add(pack("C", 0)); }
415404
else:
416-
ctx = ctx + password[0]
405+
ctx = ctx + password[0:1]
417406
i = i >> 1
418407

419408
final = md5(ctx).digest()
420409

421410
for i in xrange(1000):
422-
ctx1 = ""
411+
ctx1 = b""
423412

424413
if i & 1:
425414
ctx1 = ctx1 + password
@@ -456,10 +445,7 @@ def joomla_passwd(password, salt, **kwargs):
456445
'e3d5794da74e917637332e0d21b76328:6GGlnaquVXI80b3HRmSyE3K1wEFFaBIf'
457446
"""
458447

459-
password = getBytes(password)
460-
salt = getBytes(salt)
461-
462-
return "%s:%s" % (md5("%s%s" % (password, salt)).hexdigest(), salt)
448+
return "%s:%s" % (md5(b"%s%s" % (getBytes(password), getBytes(salt))).hexdigest(), salt)
463449

464450
def django_md5_passwd(password, salt, **kwargs):
465451
"""
@@ -469,10 +455,7 @@ def django_md5_passwd(password, salt, **kwargs):
469455
'md5$salt$972141bcbcb6a0acc96e92309175b3c5'
470456
"""
471457

472-
password = getBytes(password)
473-
salt = getBytes(salt)
474-
475-
return "md5$%s$%s" % (salt, md5("%s%s" % (salt, password)).hexdigest())
458+
return "md5$%s$%s" % (salt, md5(b"%s%s" % (getBytes(salt), getBytes(password))).hexdigest())
476459

477460
def django_sha1_passwd(password, salt, **kwargs):
478461
"""
@@ -482,10 +465,7 @@ def django_sha1_passwd(password, salt, **kwargs):
482465
'sha1$salt$6ce0e522aba69d8baa873f01420fccd0250fc5b2'
483466
"""
484467

485-
password = getBytes(password)
486-
salt = getBytes(salt)
487-
488-
return "sha1$%s$%s" % (salt, sha1("%s%s" % (salt, password)).hexdigest())
468+
return "sha1$%s$%s" % (salt, sha1(b"%s%s" % (getBytes(salt), getBytes(password))).hexdigest())
489469

490470
def vbulletin_passwd(password, salt, **kwargs):
491471
"""
@@ -495,10 +475,7 @@ def vbulletin_passwd(password, salt, **kwargs):
495475
'85c4d8ea77ebef2236fb7e9d24ba9482:salt'
496476
"""
497477

498-
password = getBytes(password)
499-
salt = getBytes(salt)
500-
501-
return "%s:%s" % (md5("%s%s" % (md5(password).hexdigest(), salt)).hexdigest(), salt)
478+
return "%s:%s" % (md5(b"%s%s" % (binascii.hexlify(md5(getBytes(password)).digest()), getBytes(salt))).hexdigest(), salt)
502479

503480
def wordpress_passwd(password, salt, count, prefix, **kwargs):
504481
"""
@@ -515,12 +492,12 @@ def _encode64(input_, count):
515492
i = 0
516493

517494
while i < count:
518-
value = ord(input_[i])
495+
value = (input_[i] if isinstance(input_[i], int) else ord(input_[i]))
519496
i += 1
520497
output = output + ITOA64[value & 0x3f]
521498

522499
if i < count:
523-
value = value | (ord(input_[i]) << 8)
500+
value = value | ((input_[i] if isinstance(input_[i], int) else ord(input_[i])) << 8)
524501

525502
output = output + ITOA64[(value >> 6) & 0x3f]
526503

@@ -529,7 +506,7 @@ def _encode64(input_, count):
529506
break
530507

531508
if i < count:
532-
value = value | (ord(input_[i]) << 16)
509+
value = value | ((input_[i] if isinstance(input_[i], int) else ord(input_[i])) << 16)
533510

534511
output = output + ITOA64[(value >> 12) & 0x3f]
535512

@@ -542,6 +519,7 @@ def _encode64(input_, count):
542519
return output
543520

544521
password = getBytes(password)
522+
salt = getBytes(salt)
545523

546524
cipher = md5(salt)
547525
cipher.update(password)

plugins/dbms/h2/syntax.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from lib.core.common import getOrds
9-
from lib.core.compat import xrange
109
from plugins.generic.syntax import Syntax as GenericSyntax
1110

1211
class Syntax(GenericSyntax):

plugins/dbms/hsqldb/syntax.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from lib.core.common import getOrds
9-
from lib.core.compat import xrange
109
from plugins.generic.syntax import Syntax as GenericSyntax
1110

1211
class Syntax(GenericSyntax):

plugins/dbms/mssqlserver/syntax.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from lib.core.common import getOrds
9-
from lib.core.compat import xrange
109
from plugins.generic.syntax import Syntax as GenericSyntax
1110

1211
class Syntax(GenericSyntax):

plugins/dbms/oracle/syntax.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from lib.core.common import getOrds
9-
from lib.core.compat import xrange
109
from plugins.generic.syntax import Syntax as GenericSyntax
1110

1211
class Syntax(GenericSyntax):

plugins/dbms/sybase/syntax.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from lib.core.common import getOrds
9-
from lib.core.compat import xrange
109
from plugins.generic.syntax import Syntax as GenericSyntax
1110

1211
class Syntax(GenericSyntax):

0 commit comments

Comments
 (0)