|
33 | 33 | import urllib2 |
34 | 34 | import urlparse |
35 | 35 |
|
36 | | -from ConfigParser import ConfigParser |
| 36 | +from ConfigParser import RawConfigParser |
37 | 37 |
|
38 | 38 | from lib.core.common import getConsoleWidth |
39 | 39 | from lib.core.common import getFileType |
|
76 | 76 | proxyHandler = urllib2.BaseHandler() |
77 | 77 | redirectHandler = SmartRedirectHandler() |
78 | 78 |
|
| 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 | + |
79 | 99 | def __urllib2Opener(): |
80 | 100 | """ |
81 | 101 | This function creates the urllib2 OpenerDirector. |
@@ -981,7 +1001,7 @@ def __saveCmdline(): |
981 | 1001 | debugMsg = "saving command line options on a sqlmap configuration INI file" |
982 | 1002 | logger.debug(debugMsg) |
983 | 1003 |
|
984 | | - config = ConfigParser() |
| 1004 | + config = UnicodeRawConfigParser() |
985 | 1005 | userOpts = {} |
986 | 1006 |
|
987 | 1007 | for family in optDict.keys(): |
@@ -1016,8 +1036,10 @@ def __saveCmdline(): |
1016 | 1036 |
|
1017 | 1037 | config.set(family, option, value) |
1018 | 1038 |
|
1019 | | - confFP = open(paths.SQLMAP_CONFIG, "wb") |
| 1039 | + print 11111 |
| 1040 | + confFP = codecs.open(paths.SQLMAP_CONFIG, "wb", "UTF8") |
1020 | 1041 | config.write(confFP) |
| 1042 | + print 22222 |
1021 | 1043 |
|
1022 | 1044 | infoMsg = "saved command line options on '%s' configuration file" % paths.SQLMAP_CONFIG |
1023 | 1045 | logger.info(infoMsg) |
|
0 commit comments