make code compatible with python 3
Hanno Böck

Hanno Böck commited on 2014-02-24 17:14:27
Zeige 2 geänderte Dateien mit 11 Einfügungen und 6 Löschungen.

... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/python2 -tO
1
+#!/usr/bin/python -tO
2 2
 
3 3
 # freewvs 0.1 - the free web vulnerability scanner
4 4
 #
... ...
@@ -23,7 +23,12 @@
23 23
 # return your changes to the public. We would be especially happy if you tell
24 24
 # us what you're going to do with this code.
25 25
 
26
-import ConfigParser, os, glob, pprint, re, optparse, sys, gettext
26
+try: # python3
27
+	import configparser
28
+except ImportError: # python2
29
+	import ConfigParser as configparser
30
+
31
+import os, glob, pprint, re, optparse, sys, gettext
27 32
 from xml.sax.saxutils import escape
28 33
 
29 34
 gettext.textdomain('freewvs')
... ...
@@ -60,7 +65,7 @@ def vulnprint(appname, version, safeversion, vuln, vfilename, subdir, style = No
60 65
                 print (vuln)
61 66
         else:
62 67
             print (_("%(appname)s %(version)s found." ) % vars())
63
-        print
68
+        print ("")
64 69
     elif style=='xml':
65 70
         state = 'vulnerable'
66 71
         if safeversion == 'ok':
... ...
@@ -91,7 +96,7 @@ parser.add_option("-x", "--xml", action="store_const", dest="OUTPUT", const="xml
91 96
 opts, args = parser.parse_args()
92 97
 
93 98
 # Parse vulnerability database
94
-config = ConfigParser.ConfigParser()
99
+config = configparser.ConfigParser()
95 100
 config.read(glob.glob('/usr/share/freewvs/*.freewvs'))
96 101
 config.read(glob.glob('/usr/local/share/freewvs/*.freewvs'))
97 102
 config.read(glob.glob(os.path.dirname(sys.argv[0])+'/freewvsdb/*.freewvs'))
... ...
@@ -144,7 +149,7 @@ for fdir in args:
144 149
                 if filename == item['file']:
145 150
                     mfile = os.path.join(root, filename)
146 151
                     try:
147
-                      file = open(mfile)
152
+                      file = open(mfile,encoding="iso-8859-15")
148 153
                     except:
149 154
                       continue
150 155
                     filestr = file.read()
... ...
@@ -124,7 +124,7 @@ subdir=2
124 124
 [MODX-2.x]
125 125
 url=http://www.modxcms.com/
126 126
 safe=2.2.11
127
-vuln=http://modx.com/blog/2014/01/21/revolution-2.2.11%E2%80%94security-fixes-and-prevent-change-loss/
127
+vuln=http://modx.com/blog/2014/01/21/revolution-2.2.11%%E2%%80%%94security-fixes-and-prevent-change-loss/
128 128
 file=changelog.txt
129 129
 variable=MODX Revolution
130 130
 subdir=2
131 131