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

Skip to content

Commit ad3c425

Browse files
committed
quick fix
1 parent ac6ce47 commit ad3c425

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

lib/core/option.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import urllib2
3434
import urlparse
3535

36-
from ConfigParser import ConfigParser
36+
from ConfigParser import RawConfigParser
3737

3838
from lib.core.common import getConsoleWidth
3939
from lib.core.common import getFileType
@@ -76,6 +76,26 @@
7676
proxyHandler = urllib2.BaseHandler()
7777
redirectHandler = SmartRedirectHandler()
7878

79+
80+
class UnicodeRawConfigParser(RawConfigParser):
81+
def write(self, fp):
82+
"""Write an .ini-format representation of the configuration state."""
83+
if self._defaults:
84+
fp.write("[%s]\n" % DEFAULTSECT)
85+
for (key, value) in self._defaults.items():
86+
fp.write("%s = %s\n" % (key, unicode(value).replace('\n', '\n\t')))
87+
fp.write("\n")
88+
for section in self._sections:
89+
fp.write("[%s]\n" % section)
90+
for (key, value) in self._sections[section].items():
91+
if key != "__name__":
92+
if value is None:
93+
fp.write("%s\n" % (key))
94+
else:
95+
fp.write("%s = %s\n" %
96+
(key, unicode(value).replace('\n', '\n\t')))
97+
fp.write("\n")
98+
7999
def __urllib2Opener():
80100
"""
81101
This function creates the urllib2 OpenerDirector.
@@ -981,7 +1001,7 @@ def __saveCmdline():
9811001
debugMsg = "saving command line options on a sqlmap configuration INI file"
9821002
logger.debug(debugMsg)
9831003

984-
config = ConfigParser()
1004+
config = UnicodeRawConfigParser()
9851005
userOpts = {}
9861006

9871007
for family in optDict.keys():
@@ -1016,8 +1036,10 @@ def __saveCmdline():
10161036

10171037
config.set(family, option, value)
10181038

1019-
confFP = open(paths.SQLMAP_CONFIG, "wb")
1039+
print 11111
1040+
confFP = codecs.open(paths.SQLMAP_CONFIG, "wb", "UTF8")
10201041
config.write(confFP)
1042+
print 22222
10211043

10221044
infoMsg = "saved command line options on '%s' configuration file" % paths.SQLMAP_CONFIG
10231045
logger.info(infoMsg)

0 commit comments

Comments
 (0)