FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlmap/lib/core/bigarray.py at master · codeinpeace/sqlmap · GitHub
codeinpeace
/
sqlmap
Public
forked from
sqlmapproject/sqlmap
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlmap
/
lib
/
core
/
bigarray.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
108 lines (90 loc) · 3.15 KB
Breadcrumbs
sqlmap
/
lib
/
core
/
bigarray.py
Copy path
File metadata and controls
108 lines (90 loc) · 3.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python
"""
Copyright (c) 2006-2012 sqlmap developers (http://www.sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
import
os
import
pickle
import
tempfile
from
lib
.
core
.
settings
import
BIGARRAY_CHUNK_LENGTH
class
Cache
:
"""
Auxiliary class used for storing cached chunks
"""
def
__init__
(
self
,
index
,
data
,
dirty
):
self
.
index
=
index
self
.
data
=
data
self
.
dirty
=
dirty
class
BigArray
(
list
):
"""
List-like class used for storing large amounts of data (disk cached)
"""
def
__init__
(
self
):
self
.
chunks
=
[[]]
self
.
cache
=
None
self
.
length
=
0
self
.
filenames
=
set
()
def
append
(
self
,
value
):
self
.
chunks
[
-
1
].
append
(
value
)
if
len
(
self
.
chunks
[
-
1
])
>=
BIGARRAY_CHUNK_LENGTH
:
filename
=
self
.
_dump
(
self
.
chunks
[
-
1
])
del
(
self
.
chunks
[
-
1
][:])
self
.
chunks
[
-
1
]
=
filename
self
.
chunks
.
append
([])
def
pop
(
self
):
if
len
(
self
.
chunks
[
-
1
])
<
1
:
self
.
chunks
.
pop
()
with
open
(
self
.
chunks
[
-
1
],
"rb"
)
as
fp
:
self
.
chunks
[
-
1
]
=
pickle
.
load
(
fp
)
return
self
.
chunks
[
-
1
].
pop
()
def
index
(
self
,
value
):
for
index
in
xrange
(
len
(
self
)):
if
self
[
index
]
==
value
:
return
index
return
ValueError
,
"%s is not in list"
%
value
def
_dump
(
self
,
value
):
handle
,
filename
=
tempfile
.
mkstemp
()
self
.
filenames
.
add
(
filename
)
os
.
close
(
handle
)
with
open
(
filename
,
"w+b"
)
as
fp
:
pickle
.
dump
(
value
,
fp
)
return
filename
def
_checkcache
(
self
,
index
):
if
(
self
.
cache
and
self
.
cache
.
index
!=
index
and
self
.
cache
.
dirty
):
filename
=
self
.
_dump
(
self
.
cache
.
data
)
self
.
chunks
[
self
.
cache
.
index
]
=
filename
if
not
(
self
.
cache
and
self
.
cache
.
index
==
index
):
with
open
(
self
.
chunks
[
index
],
"rb"
)
as
fp
:
self
.
cache
=
Cache
(
index
,
pickle
.
load
(
fp
),
False
)
def
__getitem__
(
self
,
y
):
index
=
y
/
BIGARRAY_CHUNK_LENGTH
offset
=
y
%
BIGARRAY_CHUNK_LENGTH
chunk
=
self
.
chunks
[
index
]
if
isinstance
(
chunk
,
list
):
return
chunk
[
offset
]
else
:
self
.
_checkcache
(
index
)
return
self
.
cache
.
data
[
offset
]
def
__setitem__
(
self
,
y
,
value
):
index
=
y
/
BIGARRAY_CHUNK_LENGTH
offset
=
y
%
BIGARRAY_CHUNK_LENGTH
chunk
=
self
.
chunks
[
index
]
if
isinstance
(
chunk
,
list
):
chunk
[
offset
]
=
value
else
:
self
.
_checkcache
(
index
)
self
.
cache
.
data
[
offset
]
=
value
self
.
cache
.
dirty
=
True
def
__repr__
(
self
):
return
"%s%s"
%
(
"..."
if
len
(
self
.
chunks
)
>
1
else
""
,
self
.
chunks
[
-
1
].
__repr__
())
def
__iter__
(
self
):
for
i
in
xrange
(
len
(
self
)):
yield
self
[
i
]
def
__len__
(
self
):
return
len
(
self
.
chunks
[
-
1
])
if
len
(
self
.
chunks
)
==
1
else
(
len
(
self
.
chunks
)
-
1
)
*
BIGARRAY_CHUNK_LENGTH
+
len
(
self
.
chunks
[
-
1
])
def
__del__
(
self
):
for
filename
in
self
.
filenames
:
try
:
os
.
remove
(
filename
)
except
OSError
:
pass
Back
|
FazBrowse Home
|
New Git URL