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

Skip to content

Commit 7cf4ba8

Browse files
committed
minor refactoring and comment update
1 parent 1821a00 commit 7cf4ba8

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

lib/core/settings.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,17 @@
211211
"rollback ", ),
212212
}
213213

214+
# Regular expressions used for parsing error messages (--parse-errors)
214215
ERROR_PARSING_REGEXES = (
215216
r"<b>[^<]*(fatal|error|warning|exception)[^<]*</b>:?\s*(?P<result>.+?)<br\s*/?\s*>",
216217
r"<li>Error Type:<br>(?P<result>.+?)</li>",
217218
r"error '[0-9a-f]{8}'((<[^>]+>)|\s)+(?P<result>[^<>]+)"
218219
)
219220

221+
# Regular expression used for parsing charset info from meta html headers
220222
META_CHARSET_REGEX = r'<meta http-equiv="?content-type"?[^>]+charset=(?P<result>[^">]+)'
221223

224+
# Regular expression used for parsing empty fields in tested form data
222225
EMPTY_FORM_FIELDS_REGEX = r'(?P<result>[^=]+=(&|\Z))'
223226

224227
# Reference: http://www.cs.ru.nl/bachelorscripties/2010/Martin_Devillers___0437999___Analyzing_password_strength.pdf
@@ -281,4 +284,8 @@
281284
# maximum length of urlencoded value after which failsafe procedure takes away
282285
URLENCODE_CHAR_LIMIT = 4000
283286

284-
DEFAULT_MSSQL_SCHEMA = 'dbo'
287+
# default schema for Microsoft SQL Server DBMS
288+
DEFAULT_MSSQL_SCHEMA = 'dbo'
289+
290+
# display hash attack info every mod number of items
291+
HASH_MOD_ITEM_DISPLAY = 1117

lib/utils/hash.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from lib.core.exception import sqlmapUserQuitException
4343
from lib.core.settings import COMMON_PASSWORD_SUFFIXES
4444
from lib.core.settings import DUMMY_USER_PREFIX
45+
from lib.core.settings import HASH_MOD_ITEM_DISPLAY
4546
from lib.core.settings import IS_WIN
4647
from lib.core.settings import LIST_EMAIL
4748
from lib.core.settings import UNICODE_ENCODING
@@ -422,11 +423,12 @@ def dictionaryAttack(attack_dict):
422423

423424
attack_info.remove(item)
424425

425-
elif count % 1117 == 0 or count == length or hash_regex in (HASH.ORACLE_OLD) or hash_regex == HASH.CRYPT_GENERIC and IS_WIN:
426+
elif count % HASH_MOD_ITEM_DISPLAY == 0 or count == length or hash_regex in (HASH.ORACLE_OLD) or hash_regex == HASH.CRYPT_GENERIC and IS_WIN:
426427
status = '%d/%d words (%d%s)' % (count, length, round(100.0*count/length), '%')
427428
dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status))
428429

429430
except KeyboardInterrupt:
431+
print
430432
warnMsg = "Ctrl+C detected in dictionary attack phase"
431433
logger.warn(warnMsg)
432434
return results
@@ -472,13 +474,14 @@ def dictionaryAttack(attack_dict):
472474

473475
found = True
474476
break
475-
elif count % 1117 == 0 or count == length or hash_regex in (HASH.ORACLE_OLD) or hash_regex == HASH.CRYPT_GENERIC and IS_WIN:
477+
elif count % HASH_MOD_ITEM_DISPLAY == 0 or count == length or hash_regex in (HASH.ORACLE_OLD) or hash_regex == HASH.CRYPT_GENERIC and IS_WIN:
476478
status = '%d/%d words (%d%s)' % (count, length, round(100.0*count/length), '%')
477479
if not user.startswith(DUMMY_USER_PREFIX):
478480
status += ' (user: %s)' % user
479481
dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status))
480482

481483
except KeyboardInterrupt:
484+
print
482485
warnMsg = "Ctrl+C detected in dictionary attack phase"
483486
logger.warn(warnMsg)
484487
return results

0 commit comments

Comments
 (0)