|
10 | 10 | import codecs |
11 | 11 | import copy |
12 | 12 | import ctypes |
| 13 | +import httplib |
13 | 14 | import inspect |
14 | 15 | import logging |
| 16 | +import ntpath |
15 | 17 | import os |
| 18 | +import pickle |
| 19 | +import posixpath |
16 | 20 | import random |
17 | 21 | import re |
18 | 22 | import socket |
19 | 23 | import string |
| 24 | +import struct |
20 | 25 | import sys |
21 | 26 | import time |
22 | 27 | import urlparse |
23 | | -import ntpath |
24 | | -import posixpath |
25 | | -import httplib |
26 | | -import struct |
27 | 28 | import unicodedata |
28 | 29 |
|
29 | 30 | from ConfigParser import DEFAULTSECT |
|
64 | 65 | from lib.core.exception import sqlmapMissingDependence |
65 | 66 | from lib.core.exception import sqlmapSyntaxException |
66 | 67 | from lib.core.optiondict import optDict |
| 68 | +from lib.core.settings import BIGARRAY_CHUNK_LENGTH |
67 | 69 | from lib.core.settings import INFERENCE_UNKNOWN_CHAR |
68 | 70 | from lib.core.settings import UNICODE_ENCODING |
69 | 71 | from lib.core.settings import DBMS_DICT |
@@ -194,6 +196,40 @@ def rewind(self): |
194 | 196 | self.index = 0 |
195 | 197 | self.adjust() |
196 | 198 |
|
| 199 | +class BigArray(list): |
| 200 | + """ |
| 201 | + List-like object used for storing large amounts of data (disk cached) |
| 202 | + """ |
| 203 | + |
| 204 | + def __init__(self): |
| 205 | + self.chunks = [[]] |
| 206 | + self.cache = None |
| 207 | + self.length = 0 |
| 208 | + |
| 209 | + def append(self, value): |
| 210 | + self.chunks[-1].append(value) |
| 211 | + if len(self.chunks[-1]) >= BIGARRAY_CHUNK_LENGTH: |
| 212 | + fp = tempfile.TemporaryFile() |
| 213 | + pickle.dump(self.chunks[-1], fp) |
| 214 | + del(self.chunks[-1][:]) |
| 215 | + self.chunks[-1] = fp |
| 216 | + self.chunks.append([]) |
| 217 | + |
| 218 | + def __getitem__(self, y): |
| 219 | + index = y / BIGARRAY_CHUNK_LENGTH |
| 220 | + offset = y % BIGARRAY_CHUNK_LENGTH |
| 221 | + chunk = self.chunks[index] |
| 222 | + if isinstance(chunk, list): |
| 223 | + return chunk[offset] |
| 224 | + else: |
| 225 | + if not (self.cache and self.cache[0] == index): |
| 226 | + chunk.seek(0) |
| 227 | + self.cache = (index, pickle.load(chunk)) |
| 228 | + return self.cache[1][offset] |
| 229 | + |
| 230 | + def __len__(self): |
| 231 | + return len(self.chunks[-1]) if len(self.chunks) == 1 else (len(self.chunks) - 1) * BIGARRAY_CHUNK_LENGTH + len(self.chunks[-1]) |
| 232 | + |
197 | 233 | class DynamicContentItem: |
198 | 234 | """ |
199 | 235 | Represents line in content page with dynamic properties (candidate |
|
0 commit comments