6e1a9333ace951bc9be107e868b20d5abf871bc7
Hanno Böck initial commit

Hanno Böck authored 17 years ago

1) #!/usr/bin/python -tO
2) 
3) # freewvs 0.1 - the free web vulnerability scanner
4) #
5) # http://source.schokokeks.org/freewvs/
6) #
7) # Copyright 2007 Hanno Boeck, schokokeks.org <hanno@schokokeks.org>
8) #
9) # Contributions by
10) # Fabian Fingerle <fabian@datensalat.eu>
11) #
12) # This program is free software: you can redistribute it and/or modify
13) # it under the terms of the GNU General Public License as published by
14) # the Free Software Foundation, either version 3 of the License, or
15) # (at your option) any later version.
16) #
17) # This program is distributed in the hope that it will be useful,
18) # but WITHOUT ANY WARRANTY; without even the implied warranty of
Hanno Böck fix lot's of pylint issues...

Hanno Böck authored 16 years ago

19) # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
Hanno Böck initial commit

Hanno Böck authored 17 years ago

20) # GNU General Public License for more details.
21) #
22) # You should have received a copy of the GNU General Public License
Hanno Böck fix lot's of pylint issues...

Hanno Böck authored 16 years ago

23) # along with this program.    If not, see <http://www.gnu.org/licenses/>.
Hanno Böck initial commit

Hanno Böck authored 17 years ago

24) 
25) import ConfigParser, os, glob, pprint, re, optparse, sys
26) 
27) 
Hanno Böck fix lot's of pylint issues...

Hanno Böck authored 16 years ago

28) def versioncompare(safe_version, find_version):
29)     if safe_version == [""]:
30)         return True
31)     for i in range(min(len(find_version), len(safe_version))):
32)         if int(find_version[i])<int(safe_version[i]):
33)             return True
34)         if int(find_version[i])>int(safe_version[i]):
35)             return False
36)     return (len(find_version)<len(safe_version))
Hanno Böck initial commit

Hanno Böck authored 17 years ago

37) 
Hanno Böck fix lot's of pylint issues...

Hanno Böck authored 16 years ago

38) def vulnprint(appname, version, safeversion, vuln, vfilename, subdir):
39)     appdir = '/'.join(os.path.abspath(vfilename).split('/')[:-1-subdir])
40)     print "%(appname)s %(version)s (%(safeversion)s) %(vuln)s %(appdir)s" \
41)           % vars()
Hanno Böck initial commit

Hanno Böck authored 17 years ago

42) 
43) pp = pprint.PrettyPrinter(indent=4)
44) 
45) # Command-line options
46) parser = optparse.OptionParser()
47) parser.add_option("-a", "--all", action="store_true", dest="ALL",
48)                   help="Show all webapps found, not just vulnerable")
49) parser.add_option("-d", "--debug", action="store_true", dest="DEBUG",
Hanno Böck fix lot's of pylint issues...

Hanno Böck authored 16 years ago

50)                   help="Show lots of debugging output, mainly useful"+ \
51)                   "for development")
Hanno Böck initial commit

Hanno Böck authored 17 years ago

52) opts, args = parser.parse_args()
53) 
54) # Parse vulnerability database
55) config = ConfigParser.ConfigParser()
56) config.read(glob.glob('/usr/share/freewvs/*.freewvs'))
57) config.read(glob.glob('/usr/local/share/freewvs/*.freewvs'))
58) config.read(glob.glob(os.path.dirname(sys.argv[0])+'/freewvsdb/*.freewvs'))
59) 
60) vdb = []
61) for sect in config.sections():
Hanno Böck fix lot's of pylint issues...

Hanno Böck authored 16 years ago

62)     item = {}
63) 
64)     # base options
65)     item['name'] = sect
66)     item['safe'] = config.get(sect, 'safe')
67)     item['file'] = config.get(sect, 'file')
68)     item['vuln'] = config.get(sect, 'vuln')
69)     item['subdir'] = int(config.get(sect, 'subdir'))
70) 
71)     # match magic
72)     item['variable'] = []
73)     for var in config.get(sect,'variable').split(","):
74)         item['variable'].append(re.compile(re.escape(var)+
75)                                 r"[^0-9.]*[.]*([0-9.]*[0-9])[^0-9.]"))
76) 
77)     # optional options
78)     if config.has_option(sect,'extra_match'):
79)         item['extra_match'] = config.get(sect,'extra_match')
80)     else:
81)         item['extra_match'] = False
82)     if config.has_option(sect,'add_minor'):
83)         item['add_minor'] = config.get(sect,'add_minor')
84)     else:
85)         item['add_minor'] = False
86)     if config.has_option(sect,'old_safe'):
87)         item['old_safe'] = config.get(sect,'old_safe').split(",")
88)     else:
89)         item['old_safe'] = []
90) 
91)     vdb.append(item)
92) if opts.DEBUG:
93)     pp.pprint(vdb)
Hanno Böck initial commit

Hanno Böck authored 17 years ago

94) 
95) 
96) # start the search
97)