FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlmap/lib/parse/configfile.py at master · sql9/sqlmap · GitHub
sql9
/
sqlmap
Public
forked from
sqlmapproject/sqlmap
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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
/
parse
/
configfile.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
104 lines (84 loc) · 3.59 KB
Breadcrumbs
sqlmap
/
lib
/
parse
/
configfile.py
Copy path
File metadata and controls
104 lines (84 loc) · 3.59 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
#!/usr/bin/env python
"""
Copyright (c) 2006-2015 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
import
codecs
from
ConfigParser
import
MissingSectionHeaderError
from
ConfigParser
import
ParsingError
from
lib
.
core
.
common
import
checkFile
from
lib
.
core
.
common
import
getUnicode
from
lib
.
core
.
common
import
openFile
from
lib
.
core
.
common
import
unArrayizeValue
from
lib
.
core
.
common
import
UnicodeRawConfigParser
from
lib
.
core
.
data
import
conf
from
lib
.
core
.
data
import
logger
from
lib
.
core
.
exception
import
SqlmapMissingMandatoryOptionException
from
lib
.
core
.
exception
import
SqlmapSyntaxException
from
lib
.
core
.
optiondict
import
optDict
from
lib
.
core
.
settings
import
UNICODE_ENCODING
config
=
None
def
configFileProxy
(
section
,
option
,
boolean
=
False
,
integer
=
False
):
"""
Parse configuration file and save settings into the configuration
advanced dictionary.
"""
global
config
if
config
.
has_option
(
section
,
option
):
try
:
if
boolean
:
value
=
config
.
getboolean
(
section
,
option
)
if
config
.
get
(
section
,
option
)
else
False
elif
integer
:
value
=
config
.
getint
(
section
,
option
)
if
config
.
get
(
section
,
option
)
else
0
else
:
value
=
config
.
get
(
section
,
option
)
except
ValueError
,
ex
:
errMsg
=
"error occurred while processing the option "
errMsg
+=
"'%s' in provided configuration file ('%s')"
%
(
option
,
getUnicode
(
ex
))
raise
SqlmapSyntaxException
(
errMsg
)
if
value
:
conf
[
option
]
=
value
else
:
conf
[
option
]
=
None
else
:
debugMsg
=
"missing requested option '%s' (section "
%
option
debugMsg
+=
"'%s') into the configuration file, "
%
section
debugMsg
+=
"ignoring. Skipping to next."
logger
.
debug
(
debugMsg
)
def
configFileParser
(
configFile
):
"""
Parse configuration file and save settings into the configuration
advanced dictionary.
"""
global
config
debugMsg
=
"parsing configuration file"
logger
.
debug
(
debugMsg
)
checkFile
(
configFile
)
configFP
=
openFile
(
configFile
,
"rb"
)
try
:
config
=
UnicodeRawConfigParser
()
config
.
readfp
(
configFP
)
except
Exception
,
ex
:
errMsg
=
"you have provided an invalid and/or unreadable configuration file ('%s')"
%
getUnicode
(
ex
)
raise
SqlmapSyntaxException
(
errMsg
)
if
not
config
.
has_section
(
"Target"
):
errMsg
=
"missing a mandatory section 'Target' in the configuration file"
raise
SqlmapMissingMandatoryOptionException
(
errMsg
)
condition
=
not
config
.
has_option
(
"Target"
,
"direct"
)
condition
&=
not
config
.
has_option
(
"Target"
,
"url"
)
condition
&=
not
config
.
has_option
(
"Target"
,
"logFile"
)
condition
&=
not
config
.
has_option
(
"Target"
,
"bulkFile"
)
condition
&=
not
config
.
has_option
(
"Target"
,
"googleDork"
)
condition
&=
not
config
.
has_option
(
"Target"
,
"requestFile"
)
condition
&=
not
config
.
has_option
(
"Target"
,
"sitemapUrl"
)
condition
&=
not
config
.
has_option
(
"Target"
,
"wizard"
)
if
condition
:
errMsg
=
"missing a mandatory option in the configuration file "
errMsg
+=
"(direct, url, logFile, bulkFile, googleDork, requestFile, sitemapUrl or wizard)"
raise
SqlmapMissingMandatoryOptionException
(
errMsg
)
for
family
,
optionData
in
optDict
.
items
():
for
option
,
datatype
in
optionData
.
items
():
datatype
=
unArrayizeValue
(
datatype
)
boolean
=
datatype
==
"boolean"
integer
=
datatype
==
"integer"
configFileProxy
(
family
,
option
,
boolean
,
integer
)
Back
|
FazBrowse Home
|
New Git URL