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

Skip to content

Commit 15ef0f8

Browse files
committed
Minor refactoring
1 parent 10be8a1 commit 15ef0f8

5 files changed

Lines changed: 10 additions & 7 deletions

File tree

lib/core/revision.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import subprocess
1111

1212
from lib.core.common import getText
13+
from lib.core.common import openFile
1314

1415
def getRevisionNumber():
1516
"""
@@ -36,7 +37,7 @@ def getRevisionNumber():
3637

3738
while True:
3839
if filePath and os.path.isfile(filePath):
39-
with open(filePath, "r") as f:
40+
with openFile(filePath, "r") as f:
4041
content = f.read()
4142
filePath = None
4243
if content.startswith("ref: "):

lib/core/settings.py

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

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

lib/core/update.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from lib.core.common import getSafeExString
1919
from lib.core.common import getLatestRevision
2020
from lib.core.common import getText
21+
from lib.core.common import openFile
2122
from lib.core.common import pollProcess
2223
from lib.core.common import readInput
2324
from lib.core.data import conf
@@ -82,7 +83,7 @@ def update():
8283

8384
filepath = os.path.join(paths.SQLMAP_ROOT_PATH, "lib", "core", "settings.py")
8485
if os.path.isfile(filepath):
85-
with open(filepath, "rb") as f:
86+
with openFile(filepath, "rb") as f:
8687
version = re.search(r"(?m)^VERSION\s*=\s*['\"]([^'\"]+)", f.read()).group(1)
8788
logger.info("updated to the latest version '%s#dev'" % version)
8889
success = True

lib/utils/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from lib.core.common import dataToStdout
2323
from lib.core.common import getSafeExString
24+
from lib.core.common import openFile
2425
from lib.core.common import saveConfig
2526
from lib.core.common import unArrayizeValue
2627
from lib.core.compat import xrange
@@ -648,9 +649,8 @@ def download(taskid, target, filename):
648649

649650
if os.path.isfile(path):
650651
logger.debug("(%s) Retrieved content of file %s" % (taskid, target))
651-
with open(path, 'rb') as inf:
652-
file_content = inf.read()
653-
return jsonize({"success": True, "file": encodeBase64(file_content, binary=False)})
652+
content = openFile(path, "rb").read()
653+
return jsonize({"success": True, "file": encodeBase64(content, binary=False)})
654654
else:
655655
logger.warning("[%s] File does not exist %s" % (taskid, target))
656656
return jsonize({"success": False, "message": "File does not exist"})

lib/utils/hash.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
from lib.core.common import hashDBRetrieve
5757
from lib.core.common import hashDBWrite
5858
from lib.core.common import normalizeUnicode
59+
from lib.core.common import openFile
5960
from lib.core.common import paths
6061
from lib.core.common import readInput
6162
from lib.core.common import singleTimeLogMessage
@@ -597,7 +598,7 @@ def storeHashesToFile(attack_dict):
597598
infoMsg = "writing hashes to a temporary file '%s' " % filename
598599
logger.info(infoMsg)
599600

600-
with open(filename, "w+") as f:
601+
with openFile(filename, "w+") as f:
601602
for item in items:
602603
f.write(item)
603604

0 commit comments

Comments
 (0)