diff --git a/lib/core/common.py b/lib/core/common.py index 6a8afd535..971deb2b6 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -4895,3 +4895,50 @@ def firstNotNone(*args): break return retVal + +def generateChunkDdata(data): + """ + Convert post data to chunked format data. If the keyword is in a block, the keyword will be cut. + + >>> generateChunkDdata('select 1,2,3,4 from admin') + 4;AZdYz + sele + 2;fJS4D + ct + 5;qbCOT + 1,2, + 7;KItpi + 3,4 fro + 2;pFu1R + m + 5;uRoYZ + admin + 0 + + + """ + dl = len(data) + ret = "" + keywords = CHUNK_KEYWORDS + index = 0 + while index < dl: + chunk_size = random.randint(1, 9) + if index + chunk_size >= dl: + chunk_size = dl - index + salt = ''.join(random.sample(string.ascii_letters + string.digits, 5)) + while 1: + tmp_chunk = data[index:index + chunk_size] + tmp_bool = True + for k in keywords: + if k in tmp_chunk: + chunk_size -= 1 + tmp_bool = False + break + if tmp_bool: + break + index += chunk_size + ret += "%s;%s\r\n" % (hex(chunk_size)[2:], salt) + ret += "%s\r\n" % tmp_chunk + + ret += "0\r\n\r\n" + return ret diff --git a/lib/core/settings.py b/lib/core/settings.py index a638906af..4d1f78770 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -794,6 +794,9 @@ KB_CHARS_BOUNDARY_CHAR = 'q' # Letters of lower frequency used in kb.chars KB_CHARS_LOW_FREQUENCY_ALPHABET = "zqxjkvbp" +# Keywords that need to be cut in the chunked +CHUNKED_KEYWORDS = ['select', 'update', 'insert', 'from', 'load_file', 'sysdatabases', 'msysaccessobjects', 'msysqueries', 'sysmodules', 'information_schema'] + # CSS style used in HTML dump format HTML_DUMP_CSS_STYLE = """