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

Skip to content

Commit e73e060

Browse files
committed
Minor code refactoring
1 parent 862cc9a commit e73e060

6 files changed

Lines changed: 16 additions & 11 deletions

File tree

lib/core/common.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def filePathToString(filePath):
404404
return strRepl
405405

406406
def dataToStdout(data, forceOutput=False):
407-
if conf.verbose > 0 or forceOutput:
407+
if forceOutput or conf.verbose > 0:
408408
try:
409409
sys.stdout.write(data)
410410
sys.stdout.flush()
@@ -569,10 +569,12 @@ def banner():
569569
This function prints sqlmap banner with its version
570570
"""
571571

572-
print """
572+
ban = """
573573
%s - %s
574-
%s
575-
""" % (VERSION_STRING, DESCRIPTION, SITE)
574+
%s\n
575+
""" % (VERSION_STRING, DESCRIPTION, SITE)
576+
577+
dataToStdout(ban, forceOutput=True)
576578

577579
def parsePasswordHash(password):
578580
blank = " " * 8

lib/core/update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
from subprocess import PIPE
2525
from subprocess import Popen as execute
2626

27-
from lib.core.common import getUnicode
2827
from lib.core.common import dataToStdout
28+
from lib.core.common import getUnicode
2929
from lib.core.common import pollProcess
3030
from lib.core.common import readInput
3131
from lib.core.data import conf
@@ -209,7 +209,7 @@ def notify(event_dict):
209209
return
210210

211211
if action.find('_completed') == -1:
212-
print "%s\t%s" % (prefix, event_dict['path'])
212+
dataToStdout("%s\t%s\n" % (prefix, event_dict['path']))
213213
else:
214214
revision = getUnicode(event_dict['revision'])
215215
index = revision.find('number ')

lib/takeover/abstraction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.common import dataToStdout
1011
from lib.core.common import readInput
1112
from lib.core.data import conf
1213
from lib.core.data import kb
@@ -76,7 +77,7 @@ def runCmd(self, cmd):
7677
if output:
7778
conf.dumper.string("command standard output", output)
7879
else:
79-
print "No output"
80+
dataToStdout("No output\n")
8081
else:
8182
self.execCmd(cmd, forgeCmd=True)
8283

lib/takeover/udf.py

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

1212
from lib.core.agent import agent
13+
from lib.core.common import dataToStdout
1314
from lib.core.common import readInput
1415
from lib.core.convert import urlencode
1516
from lib.core.data import conf
@@ -360,7 +361,7 @@ def udfInjectCustom(self):
360361
if output:
361362
conf.dumper.string("return value", output)
362363
else:
363-
print "No return value"
364+
dataToStdout("No return value\n")
364365
else:
365366
self.udfExecCmd(cmd, udfName=udfToCall, silent=True)
366367

plugins/generic/enumeration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1769,4 +1769,4 @@ def sqlShell(self):
17691769
pass
17701770

17711771
elif output != "Quit":
1772-
print "No output"
1772+
dataToStdout("No output\n")

sqlmap.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from lib.controller.controller import start
2727
from lib.core.common import banner
28+
from lib.core.common import dataToStdout
2829
from lib.core.common import getUnicode
2930
from lib.core.common import setPaths
3031
from lib.core.common import weAreFrozen
@@ -64,7 +65,7 @@ def main():
6465
banner()
6566
cmdLineOptions = cmdLineParser()
6667

67-
print "[*] starting at: %s\n" % time.strftime("%X")
68+
dataToStdout("[*] starting at: %s\n\n" % time.strftime("%X"), forceOutput=True)
6869

6970
try:
7071
init(cmdLineOptions)
@@ -112,7 +113,7 @@ def main():
112113
else:
113114
closeDumper(True)
114115

115-
print "\n[*] shutting down at: %s\n" % time.strftime("%X")
116+
dataToStdout("\n[*] shutting down at: %s\n\n" % time.strftime("%X"), forceOutput=True)
116117

117118
if __name__ == "__main__":
118119
main()

0 commit comments

Comments
 (0)