MCPcopy Create free account
hub / github.com/sqlmapproject/sqlmap / unix_md5_passwd

Function unix_md5_passwd

lib/utils/hash.py:369–440  ·  view source on GitHub ↗

Reference(s): http://www.sabren.net/code/python/crypt/md5crypt.py >>> unix_md5_passwd(password='testpass', salt='aD9ZLmkp') '$1$aD9ZLmkp$DRM5a7rRZGyuuOPOjTEk61'

(password, salt, magic="$1$", **kwargs)

Source from the content-addressed store, hash-verified

367 return getText(crypt(password, salt))
368
369def unix_md5_passwd(password, salt, magic="$1$", **kwargs):
370 """
371 Reference(s):
372 http://www.sabren.net/code/python/crypt/md5crypt.py
373
374 >>> unix_md5_passwd(password='testpass', salt='aD9ZLmkp')
375 '$1$aD9ZLmkp$DRM5a7rRZGyuuOPOjTEk61'
376 """
377
378 def _encode64(value, count):
379 output = ""
380
381 while (count - 1 >= 0):
382 count = count - 1
383 output += ITOA64[value & 0x3f]
384 value = value >> 6
385
386 return output
387
388 password = getBytes(password)
389 magic = getBytes(magic)
390 salt = getBytes(salt)
391
392 salt = salt[:8]
393 ctx = password + magic + salt
394 final = md5(password + salt + password).digest()
395
396 for pl in xrange(len(password), 0, -16):
397 if pl > 16:
398 ctx = ctx + final[:16]
399 else:
400 ctx = ctx + final[:pl]
401
402 i = len(password)
403 while i:
404 if i & 1:
405 ctx = ctx + b'\x00' # if ($i & 1) { $ctx->add(pack("C", 0)); }
406 else:
407 ctx = ctx + password[0:1]
408 i = i >> 1
409
410 final = md5(ctx).digest()
411
412 for i in xrange(1000):
413 ctx1 = b""
414
415 if i & 1:
416 ctx1 = ctx1 + password
417 else:
418 ctx1 = ctx1 + final[:16]
419
420 if i % 3:
421 ctx1 = ctx1 + salt
422
423 if i % 7:
424 ctx1 = ctx1 + password
425
426 if i & 1:

Callers

nothing calls this directly

Calls 4

getBytesFunction · 0.90
getTextFunction · 0.90
xrangeClass · 0.85
_encode64Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…