Minor code refactoring

This commit is contained in:
Bernardo Damele 2010-10-20 22:09:03 +00:00
parent 862cc9ac53
commit e73e06069b
6 changed files with 16 additions and 11 deletions

View File

@ -404,7 +404,7 @@ def filePathToString(filePath):
return strRepl
def dataToStdout(data, forceOutput=False):
if conf.verbose > 0 or forceOutput:
if forceOutput or conf.verbose > 0:
try:
sys.stdout.write(data)
sys.stdout.flush()
@ -569,10 +569,12 @@ def banner():
This function prints sqlmap banner with its version
"""
print """
ban = """
%s - %s
%s
""" % (VERSION_STRING, DESCRIPTION, SITE)
%s\n
""" % (VERSION_STRING, DESCRIPTION, SITE)
dataToStdout(ban, forceOutput=True)
def parsePasswordHash(password):
blank = " " * 8

View File

@ -24,8 +24,8 @@ from xml.dom.minidom import Document
from subprocess import PIPE
from subprocess import Popen as execute
from lib.core.common import getUnicode
from lib.core.common import dataToStdout
from lib.core.common import getUnicode
from lib.core.common import pollProcess
from lib.core.common import readInput
from lib.core.data import conf
@ -209,7 +209,7 @@ def __updateSqlmap():
return
if action.find('_completed') == -1:
print "%s\t%s" % (prefix, event_dict['path'])
dataToStdout("%s\t%s\n" % (prefix, event_dict['path']))
else:
revision = getUnicode(event_dict['revision'])
index = revision.find('number ')

View File

@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
See the file 'doc/COPYING' for copying permission
"""
from lib.core.common import dataToStdout
from lib.core.common import readInput
from lib.core.data import conf
from lib.core.data import kb
@ -76,7 +77,7 @@ class Abstraction(Web, UDF, xp_cmdshell):
if output:
conf.dumper.string("command standard output", output)
else:
print "No output"
dataToStdout("No output\n")
else:
self.execCmd(cmd, forgeCmd=True)

View File

@ -10,6 +10,7 @@ See the file 'doc/COPYING' for copying permission
import os
from lib.core.agent import agent
from lib.core.common import dataToStdout
from lib.core.common import readInput
from lib.core.convert import urlencode
from lib.core.data import conf
@ -360,7 +361,7 @@ class UDF:
if output:
conf.dumper.string("return value", output)
else:
print "No return value"
dataToStdout("No return value\n")
else:
self.udfExecCmd(cmd, udfName=udfToCall, silent=True)

View File

@ -1769,4 +1769,4 @@ class Enumeration:
pass
elif output != "Quit":
print "No output"
dataToStdout("No output\n")

View File

@ -25,6 +25,7 @@ except ImportError, _:
from lib.controller.controller import start
from lib.core.common import banner
from lib.core.common import dataToStdout
from lib.core.common import getUnicode
from lib.core.common import setPaths
from lib.core.common import weAreFrozen
@ -64,7 +65,7 @@ def main():
banner()
cmdLineOptions = cmdLineParser()
print "[*] starting at: %s\n" % time.strftime("%X")
dataToStdout("[*] starting at: %s\n\n" % time.strftime("%X"), forceOutput=True)
try:
init(cmdLineOptions)
@ -112,7 +113,7 @@ def main():
else:
closeDumper(True)
print "\n[*] shutting down at: %s\n" % time.strftime("%X")
dataToStdout("\n[*] shutting down at: %s\n\n" % time.strftime("%X"), forceOutput=True)
if __name__ == "__main__":
main()