-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Expand file tree
/
Copy pathsqlmap.py
More file actions
executable file
·120 lines (96 loc) · 3.12 KB
/
sqlmap.py
File metadata and controls
executable file
·120 lines (96 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python
"""
$Id$
This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
Copyright (c) 2007-2010 Bernardo Damele A. G. <[email protected]>
Copyright (c) 2006 Daniele Bellucci <[email protected]>
sqlmap is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation version 2 of the License.
sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along
with sqlmap; if not, write to the Free Software Foundation, Inc., 51
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
import codecs
import os
import sys
import time
import traceback
import warnings
warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning)
# NOTE: This breaks SQL shell and OS shell history and TAB functionalities
#import locale
#sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
try:
import psyco
psyco.full()
psyco.profile()
except ImportError, _:
pass
from lib.controller.controller import start
from lib.core.common import banner
from lib.core.common import getUnicode
from lib.core.common import profile
from lib.core.common import setPaths
from lib.core.common import weAreFrozen
from lib.core.data import conf
from lib.core.data import logger
from lib.core.data import paths
from lib.core.exception import exceptionsTuple
from lib.core.exception import unhandledException
from lib.core.option import init
from lib.core.xmldump import closeDumper
from lib.parse.cmdline import cmdLineParser
def modulePath():
"""
This will get us the program's directory, even if we are frozen
using py2exe
"""
if weAreFrozen():
return os.path.dirname(getUnicode(sys.executable, sys.getfilesystemencoding()))
else:
return os.path.dirname(os.path.realpath(__file__))
def main():
"""
Main function of sqlmap when running from command line.
"""
paths.SQLMAP_ROOT_PATH = modulePath()
setPaths()
banner()
cmdLineOptions = cmdLineParser()
print "[*] starting at: %s\n" % time.strftime("%X")
try:
init(cmdLineOptions)
if conf.profile:
profile()
else:
start()
except exceptionsTuple, e:
e = getUnicode(e)
logger.error(e)
closeDumper(False, e)
except KeyboardInterrupt, _:
print
errMsg = "user aborted"
logger.error(errMsg)
closeDumper(False, errMsg)
except EOFError, _:
print
errMsg = "exit"
logger.error(errMsg)
closeDumper(False, errMsg)
except:
print
errMsg = unhandledException()
logger.error(errMsg)
traceback.print_exc()
closeDumper(False, errMsg)
else:
closeDumper(True)
print "\n[*] shutting down at: %s\n" % time.strftime("%X")
if __name__ == "__main__":
main()