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

Skip to content

Commit 4846d85

Browse files
committed
Pre-fetching latest revision number in case of update
1 parent 3c439c3 commit 4846d85

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

lib/core/common.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,6 +3347,22 @@ def unhandledExceptionMessage():
33473347

33483348
return errMsg
33493349

3350+
def getLatestRevision():
3351+
"""
3352+
Retrieves latest revision from the offical repository
3353+
"""
3354+
3355+
retVal = None
3356+
req = urllib2.Request(url="https://raw.githubusercontent.com/sqlmapproject/sqlmap/master/lib/core/settings.py")
3357+
3358+
try:
3359+
content = urllib2.urlopen(req).read()
3360+
retVal = extractRegexResult(r"VERSION\s*=\s*[\"'](?P<result>[\d.]+)", content)
3361+
except:
3362+
pass
3363+
3364+
return retVal
3365+
33503366
def createGithubIssue(errMsg, excMsg):
33513367
"""
33523368
Automatically create a Github issue with unhandled exception information

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.2.7.14"
22+
VERSION = "1.2.7.15"
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/core/update.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from lib.core.common import dataToStdout
1919
from lib.core.common import getSafeExString
20+
from lib.core.common import getLatestRevision
2021
from lib.core.common import pollProcess
2122
from lib.core.common import readInput
2223
from lib.core.data import conf
@@ -25,6 +26,7 @@
2526
from lib.core.revision import getRevisionNumber
2627
from lib.core.settings import GIT_REPOSITORY
2728
from lib.core.settings import IS_WIN
29+
from lib.core.settings import VERSION
2830
from lib.core.settings import ZIPBALL_PAGE
2931
from lib.core.settings import UNICODE_ENCODING
3032

@@ -39,6 +41,10 @@ def update():
3941
warnMsg += "from GitHub (e.g. 'git clone --depth 1 %s sqlmap')" % GIT_REPOSITORY
4042
logger.warn(warnMsg)
4143

44+
if VERSION == getLatestRevision():
45+
logger.info("already at the latest revision '%s'" % getRevisionNumber())
46+
return
47+
4248
message = "do you want to try to fetch the latest 'zipball' from repository and extract it (experimental) ? [y/N]"
4349
if readInput(message, default='N', boolean=True):
4450
directory = os.path.abspath(paths.SQLMAP_ROOT_PATH)

txt/checksum.md5

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ c7443613a0a2505b1faec931cee2a6ef lib/controller/handler.py
2828
1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py
2929
0adf547455a76dc71e6a599e52da1ed9 lib/core/agent.py
3030
fd8f239e259afaf5f24bcf34a0ad187f lib/core/bigarray.py
31-
ab2f7ecb7d3dff9afd05675031942e8e lib/core/common.py
31+
5e498b6dd232bca7c698699cf5ceec03 lib/core/common.py
3232
0d082da16c388b3445e656e0760fb582 lib/core/convert.py
3333
9f87391b6a3395f7f50830b391264f27 lib/core/data.py
3434
72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py
@@ -48,14 +48,14 @@ c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4848
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
4949
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5050
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
51-
2c474df57ac9d142f8747701b70082a5 lib/core/settings.py
51+
5d09048bf6682159e784d762a2772137 lib/core/settings.py
5252
dd68a9d02fccb4fa1428b20e15b0db5d lib/core/shell.py
5353
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
5454
95f04c1c1d8c3998d86e1bdf0e12771c lib/core/target.py
5555
72d499ca8d792e90a1ebfb2ad2341a51 lib/core/testing.py
5656
de9922a29c71a235cb95a916ff925db2 lib/core/threads.py
5757
c40758411bb0bd68764d78e0bb72bd0f lib/core/unescaper.py
58-
9d395b143be295a143eb5c9b926f3569 lib/core/update.py
58+
b35636650cfe721f5cc47fb91737c061 lib/core/update.py
5959
e772deb63270375e685fa5a7b775c382 lib/core/wordlist.py
6060
1e5532ede194ac9c083891c2f02bca93 lib/__init__.py
6161
7620f1f4b8791e13c7184c06b5421754 lib/parse/banner.py

0 commit comments

Comments
 (0)