Skip to content

Commit d9102e0

Browse files
committed
Moving binary to textual file openings
1 parent e62e8c6 commit d9102e0

File tree

10 files changed

+28
-27
lines changed

10 files changed

+28
-27
lines changed

data/txt/sha256sums.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,28 +168,28 @@ e376093d4f6e42ee38b050af329179df9c1c136b7667b2f1cb559f5d4b69ebd9 lib/controller
168168
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/controller/__init__.py
169169
2a96190ced25d8929861b13866101812fcadf5cac23dd1dd4b29b1a915918769 lib/core/agent.py
170170
1da4ec9cd9b67c8b54e4a3d314f8237d58778d8f3a00bc26a1e0540294dca30f lib/core/bigarray.py
171-
3324bcf3da983e8ca8d34fc1123b32706056e7158aaa2c274fa1560b1f377889 lib/core/common.py
171+
af24159b8ca5b8fe5e13cdfdedc2a758a2f4883361a601e0a550127cff368b3a lib/core/common.py
172172
a6397b10de7ae7c56ed6b0fa3b3c58eb7a9dbede61bf93d786e73258175c981e lib/core/compat.py
173173
a9997e97ebe88e0bf7efcf21e878bc5f62c72348e5aba18f64d6861390a4dcf2 lib/core/convert.py
174174
c03dc585f89642cfd81b087ac2723e3e1bb3bfa8c60e6f5fe58ef3b0113ebfe6 lib/core/data.py
175175
e396b7971d38896e0e20b973a3a6a3fbc3171d080a21bc6e66a65bee452fd69c lib/core/datatype.py
176176
e18c0c2c5a57924a623792a48bfd36e98d9bc085f6db61a95fc0dc8a3bcedc0c lib/core/decorators.py
177177
147823c37596bd6a56d677697781f34b8d1d1671d5a2518fbc9468d623c6d07d lib/core/defaults.py
178178
76756ce056dd2e5363e5e1d2b2b4c3f3b36ff8c8ac215e83ee3b8d535ea6b741 lib/core/dicts.py
179-
143f0b5b30e0f24b3527945879497de1542ba1aee9e6f0f98865e626c4c9317e lib/core/dump.py
179+
a033f92d136c707a25927c2383125ddb004d4283db62c004dcd67c3fc242bb1c lib/core/dump.py
180180
1abf1edeacb85eaf5cffd35fcbde4eee2da6f5fc722a8dc1f9287fb55d138418 lib/core/enums.py
181181
5387168e5dfedd94ae22af7bb255f27d6baaca50b24179c6b98f4f325f5cc7b4 lib/core/exception.py
182182
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/core/__init__.py
183183
914a13ee21fd610a6153a37cbe50830fcbd1324c7ebc1e7fc206d5e598b0f7ad lib/core/log.py
184184
02a2264324caa249154e024a01bcd7cc40dbca4d647d5d10a50654b4415a6d77 lib/core/optiondict.py
185-
6576d40a66fa7871d3498c193f4e1e50a9fa9a380005d019c5c2266c1dc31c21 lib/core/option.py
185+
4dc6383b5d9cfff5b1bf8ffa8b0b02a7dbd8df8624b76030f8925c2dbdee9bf9 lib/core/option.py
186186
8171f6ee33e7742f06bb3014a28324496374beddee7b378ace10a26414a97762 lib/core/patch.py
187187
49c0fa7e3814dfda610d665ee02b12df299b28bc0b6773815b4395514ddf8dec lib/core/profiling.py
188188
03db48f02c3d07a047ddb8fe33a757b6238867352d8ddda2a83e4fec09a98d04 lib/core/readlineng.py
189189
48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py
190190
3574639db4942d16a2dc0a2f04bb7c0913c40c3862b54d34c44075a760e0c194 lib/core/revision.py
191191
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
192-
9d05d48a24cf166f965ae95e63a57e92061bc84bb1fc2b3fe1c5ee985e17b453 lib/core/settings.py
192+
2503c9b9eca74ae3c2a6b245504046b623bf0e8a8f433105f41f61fa626aec48 lib/core/settings.py
193193
cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py
194194
bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py
195195
d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py
@@ -201,7 +201,7 @@ ec11fd5a3f4efd10a1cae288157ac6eb6fb75da4666d76d19f6adf74ac338b5a lib/core/wordl
201201
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/__init__.py
202202
54bfd31ebded3ffa5848df1c644f196eb704116517c7a3d860b5d081e984d821 lib/parse/banner.py
203203
a9f10a558684778bdb00d446cb88967fc1bfd413ae6a5f4bd582b3ea442baa87 lib/parse/cmdline.py
204-
cac08047db1168b24174496268af811cee555e7c3fdd528ef8d895ec49b91d36 lib/parse/configfile.py
204+
02d82e4069bd98c52755417f8b8e306d79945672656ac24f1a45e7a6eff4b158 lib/parse/configfile.py
205205
c5b258be7485089fac9d9cd179960e774fbd85e62836dc67cce76cc028bb6aeb lib/parse/handler.py
206206
97361d481a97b600a3086b7f228f54ffa68a78df8b63b76bfaa5495d66770b63 lib/parse/headers.py
207207
1ad9054cd8476a520d4e2c141085ae45d94519df5c66f25fac41fe7d552ab952 lib/parse/html.py
@@ -212,7 +212,7 @@ d2e771cdacef25ee3fdc0e0355b92e7cd1b68f5edc2756ffc19f75d183ba2c73 lib/parse/payl
212212
a1c638493ecdc5194db7186bbfed815c6eed2344f2607cac8c9fa50534824266 lib/request/basic.py
213213
bc61bc944b81a7670884f82231033a6ac703324b34b071c9834886a92e249d0e lib/request/chunkedhandler.py
214214
2daf0ce19eacda64687f441c90ef8da51714c3e8947c993ba08fb4ecdc4f5287 lib/request/comparison.py
215-
626bb6f3316a906a4629c0feb8ecbbcf473fb59e5bc532603c35b6b8f63f1deb lib/request/connect.py
215+
f83140c85be7f572f83c4ab4279fa1d8601243210cdfe4a44b2fc218befbcffd lib/request/connect.py
216216
8e06682280fce062eef6174351bfebcb6040e19976acff9dc7b3699779783498 lib/request/direct.py
217217
cf019248253a5d7edb7bc474aa020b9e8625d73008a463c56ba2b539d7f2d8ec lib/request/dns.py
218218
f56fc33251bd6214e3a6316c8f843eb192b2996aa84bd4c3e98790fdcf6e8cf0 lib/request/httpshandler.py
@@ -244,7 +244,7 @@ f552b6140d4069be6a44792a08f295da8adabc1c4bb6a5e100f222f87144ca9d lib/techniques
244244
a17c1d201bd084de0093254bcd303aa859399891de13a7259e8c200e98294efb lib/techniques/union/use.py
245245
67dff80a17503b91c8ff93788ccc037b6695aa18b0793894b42488cbb21c4c83 lib/utils/api.py
246246
ea5e14f8c9d74b0fb17026b14e3fb70ee90e4046e51ab2c16652d86b3ca9b949 lib/utils/brute.py
247-
3fa1b9fd57ff47c6a283e8381bf70259dce57bb2327f99d8cb56450f1acf2d46 lib/utils/crawler.py
247+
da5bcbcda3f667582adf5db8c1b5d511b469ac61b55d387cec66de35720ed718 lib/utils/crawler.py
248248
a94958be0ec3e9d28d8171813a6a90655a9ad7e6aa33c661e8d8ebbfcf208dbb lib/utils/deps.py
249249
51cfab194cd5b6b24d62706fb79db86c852b9e593f4c55c15b35f175e70c9d75 lib/utils/getch.py
250250
853c3595e1d2efc54b8bfb6ab12c55d1efc1603be266978e3a7d96d553d91a52 lib/utils/gui.py
@@ -255,7 +255,7 @@ dc68b7fdb2ae0e958f2a553984a94a06832d216a3209f632ad9ff53f17554524 lib/utils/http
255255
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/utils/__init__.py
256256
22ba65391b0a73b1925e5becf8ddab6ba73a196d86e351a2263509aad6676bd7 lib/utils/pivotdumptable.py
257257
c1dfc3bed0fed9b181f612d1d747955dd2b506dbe99bc9fd481495602371473a lib/utils/progress.py
258-
b0f777739420f7207e57d7073fd94c630a456e4c419d440b98ed6521143952dc lib/utils/purge.py
258+
27afe211030d06db28df85296bfbf698296c94440904c390cef0ff0c259dbbc5 lib/utils/purge.py
259259
c853aa08ab24a00a78969408d60684da0ccb33a2a6693492e0acb7c480ffbcd1 lib/utils/safe2bin.py
260260
2ee72e83500a1bf02fcd942564fca0053a0c46f736286f0c35dd6904e09f4734 lib/utils/search.py
261261
8258d0f54ad94e6101934971af4e55d5540f217c40ddcc594e2fba837b856d35 lib/utils/sgmllib.py
@@ -487,7 +487,7 @@ eb45fd711efa71ab9d91d815cc8abebc9abc4770311fbb827159008b000f4fc2 plugins/generi
487487
c6ad39bfd1810413402dedfc275fc805fa13f85fc490e236c1e725bde4e5100b sqlmapapi.py
488488
4e993cfe2889bf0f86ad0abafd9a6a25849580284ea279b2115e99707e14bb97 sqlmapapi.yaml
489489
a40607ce164eb2d21865288d24b863edb1c734b56db857e130ac1aef961c80b9 sqlmap.conf
490-
e9d3d52d4c0698b956cc0dc92c177d432b1f97c5918f750baa3e737de4ae574b sqlmap.py
490+
01457a41833b89b8bcdcae7b241a184bfcfdd8088575506154dd6ea1f4d71186 sqlmap.py
491491
eb37a88357522fd7ad00d90cdc5da6b57442b4fec49366aadb2944c4fbf8b804 tamper/0eunion.py
492492
a9785a4c111d6fee2e6d26466ba5efb3b229c00520b26e8024b041553b53efba tamper/apostrophemask.py
493493
cf26bc8006519bd25ce06d347f72770cd75b61575cf65e5812274e8ab9392eb4 tamper/apostrophenullencode.py

lib/core/common.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,7 +2465,7 @@ def getSQLSnippet(dbms, sfile, **variables):
24652465

24662466
return retVal
24672467

2468-
def readCachedFileContent(filename, mode="rb"):
2468+
def readCachedFileContent(filename, mode='r'):
24692469
"""
24702470
Cached reading of file content (avoiding multiple same file reading)
24712471
@@ -3609,7 +3609,7 @@ def saveConfig(conf, filename):
36093609

36103610
config.set(family, option, value)
36113611

3612-
with openFile(filename, "wb") as f:
3612+
with openFile(filename, 'w') as f:
36133613
try:
36143614
config.write(f)
36153615
except IOError as ex:
@@ -3815,6 +3815,7 @@ def openFile(filename, mode='r', encoding=UNICODE_ENCODING, errors="reversible",
38153815
# Reference: https://stackoverflow.com/a/37462452
38163816
if 'b' in mode:
38173817
buffering = 0
3818+
encoding = None
38183819

38193820
if filename == STDIN_PIPE_DASH:
38203821
if filename not in kb.cache.content:
@@ -4022,7 +4023,7 @@ def createGithubIssue(errMsg, excMsg):
40224023
logger.info(infoMsg)
40234024

40244025
try:
4025-
with openFile(paths.GITHUB_HISTORY, "a+b") as f:
4026+
with openFile(paths.GITHUB_HISTORY, "a+") as f:
40264027
f.write("%s\n" % key)
40274028
except:
40284029
pass
@@ -5103,7 +5104,7 @@ def resetCookieJar(cookieJar):
51035104
os.close(handle)
51045105

51055106
# Reference: http://www.hashbangcode.com/blog/netscape-http-cooke-file-parser-php-584.html
5106-
with openFile(filename, "w+b") as f:
5107+
with openFile(filename, "w+") as f:
51075108
f.write("%s\n" % NETSCAPE_FORMAT_HEADER_COOKIES)
51085109
for line in lines:
51095110
_ = line.split("\t")

lib/core/dump.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def setOutputFile(self):
110110

111111
self._outputFile = os.path.join(conf.outputPath, "log")
112112
try:
113-
self._outputFP = openFile(self._outputFile, "ab" if not conf.flushSession else "wb")
113+
self._outputFP = openFile(self._outputFile, 'a' if not conf.flushSession else 'w')
114114
except IOError as ex:
115115
errMsg = "error occurred while opening log file ('%s')" % getSafeExString(ex)
116116
raise SqlmapGenericException(errMsg)
@@ -453,7 +453,7 @@ def dbTableValues(self, tableValues):
453453
dumpFileName = conf.dumpFile or os.path.join(dumpDbPath, re.sub(r'[\\/]', UNSAFE_DUMP_FILEPATH_REPLACEMENT, "%s.%s" % (unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower())))
454454
if not checkFile(dumpFileName, False):
455455
try:
456-
openFile(dumpFileName, "w+b").close()
456+
openFile(dumpFileName, "w+").close()
457457
except SqlmapSystemException:
458458
raise
459459
except:
@@ -481,7 +481,7 @@ def dbTableValues(self, tableValues):
481481
else:
482482
count += 1
483483

484-
dumpFP = openFile(dumpFileName, "wb" if not appendToFile else "ab", buffering=DUMP_FILE_BUFFER_SIZE)
484+
dumpFP = openFile(dumpFileName, 'w' if not appendToFile else 'a', buffering=DUMP_FILE_BUFFER_SIZE)
485485

486486
count = int(tableValues["__infos__"]["count"])
487487
if count > TRIM_STDOUT_DUMP_SIZE:

lib/core/option.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def _listTamperingFunctions():
753753
logger.info(infoMsg)
754754

755755
for script in sorted(glob.glob(os.path.join(paths.SQLMAP_TAMPER_PATH, "*.py"))):
756-
content = openFile(script, "rb").read()
756+
content = openFile(script, 'r').read()
757757
match = re.search(r'(?s)__priority__.+"""(.+)"""', content)
758758
if match:
759759
comment = match.group(1).strip()
@@ -1015,8 +1015,8 @@ def _setPostprocessFunctions():
10151015
handle, filename = tempfile.mkstemp(prefix=MKSTEMP_PREFIX.PREPROCESS, suffix=".py")
10161016
os.close(handle)
10171017

1018-
openFile(filename, "w+b").write("#!/usr/bin/env\n\ndef postprocess(page, headers=None, code=None):\n return page, headers, code\n")
1019-
openFile(os.path.join(os.path.dirname(filename), "__init__.py"), "w+b").write("pass")
1018+
openFile(filename, "w+").write("#!/usr/bin/env\n\ndef postprocess(page, headers=None, code=None):\n return page, headers, code\n")
1019+
openFile(os.path.join(os.path.dirname(filename), "__init__.py"), "w+").write("pass")
10201020

10211021
errMsg = "function 'postprocess(page, headers=None, code=None)' "
10221022
errMsg += "in postprocess script '%s' " % script
@@ -1593,7 +1593,7 @@ def _createHomeDirectories():
15931593
os.makedirs(directory)
15941594

15951595
_ = os.path.join(directory, randomStr())
1596-
open(_, "w+b").close()
1596+
open(_, "w+").close()
15971597
os.remove(_)
15981598

15991599
if conf.get("outputDir") and context == "output":
@@ -1623,7 +1623,7 @@ def _createTemporaryDirectory():
16231623

16241624
_ = os.path.join(conf.tmpDir, randomStr())
16251625

1626-
open(_, "w+b").close()
1626+
open(_, "w+").close()
16271627
os.remove(_)
16281628

16291629
tempfile.tempdir = conf.tmpDir

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from thirdparty import six
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.10.1.51"
22+
VERSION = "1.10.1.52"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/parse/configfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def configFileParser(configFile):
6464
logger.debug(debugMsg)
6565

6666
checkFile(configFile)
67-
configFP = openFile(configFile, "rb")
67+
configFP = openFile(configFile, 'r')
6868

6969
try:
7070
config = UnicodeRawConfigParser()

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def getPage(**kwargs):
490490
headers = forgeHeaders(auxHeaders, headers)
491491

492492
if kb.headersFile:
493-
content = openFile(kb.headersFile, "rb").read()
493+
content = openFile(kb.headersFile, 'r').read()
494494
for line in content.split("\n"):
495495
line = getText(line.strip())
496496
if ':' in line:

lib/utils/crawler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def storeResultsToFile(results):
254254
infoMsg = "writing crawling results to a temporary file '%s' " % filename
255255
logger.info(infoMsg)
256256

257-
with openFile(filename, "w+b") as f:
257+
with openFile(filename, "w+") as f:
258258
if conf.forms:
259259
f.write("URL,POST\n")
260260

lib/utils/purge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def purge(directory):
5050
for filepath in filepaths:
5151
try:
5252
filesize = os.path.getsize(filepath)
53-
with openFile(filepath, "w+b") as f:
53+
with openFile(filepath, "w+") as f:
5454
f.write("".join(_unichr(random.randint(0, 255)) for _ in xrange(filesize)))
5555
except:
5656
pass

sqlmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def main():
593593

594594
if conf.get("harFile"):
595595
try:
596-
with openFile(conf.harFile, "w+b") as f:
596+
with openFile(conf.harFile, "w+") as f:
597597
json.dump(conf.httpCollector.obtain(), fp=f, indent=4, separators=(',', ': '))
598598
except SqlmapBaseException as ex:
599599
errMsg = getSafeExString(ex)

0 commit comments

Comments
 (0)