Arthur Clune wrote:
The attached script will build a basic honeywall setup that can be
booted as a xen host.
Drop all three files in a directory and edit he constants at the top of
the build_xen_image.sh script. If you use the defaults you'll need a
directory called /opt/vms. The host needs the kernel-xen and xen-*
packages installed and must be running CentOS (or maybe Fedora, but I
haven't tried that).
# sh build_xen_image.sh
# xm create -c honeywall
This is only proof of concept stuff (*). If anyone is interested, I'll
develop it further, if not, I won't. I'd like some feedback on what
further customisation is necessary to get it to work properly. This only
installs. The details of how to set the networking up are something I'd
like to know, and if anyone looks at it, I'll document it on the wiki.
On first boot, there's be some errors, but these can mostly be ignored
as they are fixed by a script that runs in rc.local. It's mostly stuff
that needs randomness which doesn't install correctly in the chroot as
there is no decent source of randomness, so it must be fixed up on boot.
There is an error with postfix which I haven't bothered to fix yet. Also
if anyone can work out why the normal install doesn't set the root
password correctly, that'd also be good :)
Arthur
(*) For starters, we'd build a proper yumgroups.xml file in the repo
rather than scraping the list of rpms as I am here.
--Arthur Clune UK Honeynet Project [EMAIL PROTECTED]
www.ukhoneynet.org
------------------------------------------------------------------------
# Copyright Arthur Clune 2008
# License GPLv2
# Get list of rpms in Honeywall
# This whole script is a bodge that will be replaced with yumgroups.xml if we
go with this
import re
import os
import urllib2
import sgmllib
import sys
from rpmtools import *
class MyParser(sgmllib.SGMLParser):
"A simple parser class from
http://www.boddie.org.uk/python/downloads/HTML1.py"
def parse(self, s):
"Parse the given string 's'."
self.feed(s)
self.close()
def __init__(self, verbose=0):
"Initialise an object, passing 'verbose' to the superclass."
sgmllib.SGMLParser.__init__(self, verbose)
self.hyperlinks = []
def start_a(self, attributes):
"Process a hyperlink and its 'attributes'."
for name, value in attributes:
if name == "href":
self.hyperlinks.append(value)
def get_hyperlinks(self):
"Return the list of hyperlinks."
return self.hyperlinks
if __name__=='__main__':
f = urllib2.urlopen('http://www.honeynet.org/tools/cdrom/roo/repo-1.3')
s = f.read()
f.close()
myparser = MyParser()
myparser.parse(s)
results = []
for link in myparser.get_hyperlinks():
if link[-4:] == '.rpm':
name, ver = get_name_version(link)
if name != 'roo-base':
results.append("%s" % name)
results.sort()
print "%s roo-base" % ' '.join(results)
------------------------------------------------------------------------
# rpm tools
#
# Code from http://people.redhat.com/laroche/pyrpm/download/pyrpm.py
#
# Authors: Paul Nasrat, Florian La Roche, Phil Knirsch, Thomas Woerner, Florian
Festi
# License: GPL v2
import re
# locale independend string methods
def _xisalpha(c):
return (c >= "a" and c <= "z") or (c >= "A" and c <= "Z")
def _xisdigit(c):
return c >= "0" and c <= "9"
def _xisalnum(c):
return ((c >= "a" and c <= "z") or (c >= "A" and c <= "Z")
or (c >= "0" and c <= "9"))
# compare two strings, rpm/lib/rpmver.c:rpmvercmp()
def stringCompare(str1, str2):
""" Loop through each version segment (alpha or numeric) of
str1 and str2 and compare them. """
if str1 == str2:
return 0
lenstr1 = len(str1)
lenstr2 = len(str2)
i1 = 0
i2 = 0
while i1 < lenstr1 and i2 < lenstr2:
# remove leading separators
while i1 < lenstr1 and not _xisalnum(str1[i1]):
i1 += 1
while i2 < lenstr2 and not _xisalnum(str2[i2]):
i2 += 1
if i1 == lenstr1 or i2 == lenstr2: # bz 178798
break
# start of the comparison data, search digits or alpha chars
j1 = i1
j2 = i2
if j1 < lenstr1 and _xisdigit(str1[j1]):
while j1 < lenstr1 and _xisdigit(str1[j1]):
j1 += 1
while j2 < lenstr2 and _xisdigit(str2[j2]):
j2 += 1
isnum = 1
else:
while j1 < lenstr1 and _xisalpha(str1[j1]):
j1 += 1
while j2 < lenstr2 and _xisalpha(str2[j2]):
j2 += 1
isnum = 0
# check if we already hit the end
if j1 == i1:
return -1
if j2 == i2:
if isnum:
return 1
return -1
if isnum:
# ignore leading "0" for numbers (1.01 == 1.000001)
while i1 < j1 and str1[i1] == "0":
i1 += 1
while i2 < j2 and str2[i2] == "0":
i2 += 1
# longer size of digits wins
if j1 - i1 > j2 - i2:
return 1
if j2 - i2 > j1 - i1:
return -1
x = cmp(str1[i1:j1], str2[i2:j2])
if x:
return x
# move to next comparison start
i1 = j1
i2 = j2
if i1 == lenstr1:
if i2 == lenstr2:
return 0
return -1
return 1
# EVR compare: uses stringCompare to compare epoch/version/release
def labelCompare(e1, e2):
# remove comparison of the release string if one of them is missing
r = stringCompare(e1[0], e2[0])
if r == 0:
r = stringCompare(e1[1], e2[1])
if r == 0 and e1[2] != "" and e2[2] != "":
r = stringCompare(e1[2], e2[2])
return r
def get_name_version(filename):
"""return version string given a filename"""
name = ""
version = ""
found_ver = False
for part in filename.split('-'):
if re.match('\d', part):
found_ver = True
if found_ver:
version += '-' + part
else:
name += '-' + part
version = '.'.join(version.split('.')[:-2])
return name[1:], version[1:]
------------------------------------------------------------------------
_______________________________________________
Honeywall mailing list
[email protected]
https://public.honeynet.org/mailman/listinfo/honeywall
Many thanks Arthur. I will test it as soon as possible ...
--
CL Martinez
carlopmart {at} gmail {d0t} com
_______________________________________________
Honeywall mailing list
[email protected]
https://public.honeynet.org/mailman/listinfo/honeywall