예제 #1
0
def status_connections(root, which):
    connections = honeyd.status_connections(which.lower())

    if not len(connections):
        return "There are currently no active %s connections." % which.upper()

    for connection in connections:
        id = "%s,%s,%d,%s,%d" % (which.lower(), connection['src'],
                                 connection['sport'], connection['dst'],
                                 connection['dport'])
        connection['id'] = urllib.quote(id)

    template = TemplateManager().prepare(root +
                                         "/templates/status_connections.tmpl")
    tproc = TemplateProcessor(0)

    tproc.set("title", "Active %s Connections" % which.upper())
    tproc.set(
        "explanation",
        "This table shows the currently active %s connections" % which.upper())
    tproc.set("Connections", connections)

    content = tproc.process(template)

    return content
예제 #2
0
def stats_table(root):
    raw_stats = honeyd.stats_network()

    stats = []

    # Convert the dictionary into something that the template manager
    # can understand.
    for key in raw_stats.keys():
        minute = humanize(raw_stats[key][0], '/s')
        hour = humanize(raw_stats[key][1], '/s')
        day = humanize(raw_stats[key][2], '/s')

        stats.append({"name": key, "minute": minute, "hour": hour, "day": day})

    template = TemplateManager().prepare(root + "/templates/status_stats.tmpl")
    tproc = TemplateProcessor(0)

    tproc.set("title", "Honeyd Statistics")
    tproc.set("explanation", ("This table shows current statistics collected "
                              "by Honeyd."))
    tproc.set("Stats", stats)

    content = tproc.process(template)

    return content
예제 #3
0
파일: cfg.py 프로젝트: tomisilander/pydida
def tmpl(name, sid=None):
    if not name.endswith(".tmpl"):
        name = name + ".tmpl"

    name = os.path.join(tmpldir, name)

    template = TemplateManager().prepare(name)
    tproc = TemplateProcessor()

    if sid: tproc.set('sid', sid)
    tproc.set('css_path', css_path)

    return template, tproc
예제 #4
0
def config_ips(root):
    ips = honeyd.config_ips()

    template = TemplateManager().prepare(root + "/templates/config_ip.tmpl")
    tproc = TemplateProcessor(0)

    tproc.set("title", "Bound IP addresses")
    tproc.set(
        "explanation", "This table shows the IP addresses of the " +
        "currently configured virtual honeypots.")
    tproc.set("Ips", ips)

    content = tproc.process(template)

    return content
예제 #5
0
    def main(self):
        while True:
            while self.dataReady("channels-inbox"):
                data = self.recv("channels-inbox")
                self.channels.append(data)

            while self.dataReady("feeds-inbox"):
                data = self.recv("feeds-inbox")
                self.feeds.append(data)

            while self.dataReady("posts-inbox"):
                data = self.recv("posts-inbox")
                self.posts.append(data)

            while self.dataReady("config-inbox"):
                data = self.recv("config-inbox")
                self.config = data

            mustStop, providerFinished = self.checkControl()
            if mustStop:
                self.send(mustStop, "signal")
                return

            if providerFinished is not None and self.config is not None:
                tproc = TemplateProcessor(html_escape=0)
                template = self.prepareTemplate()
                yield 1

                self.fillTemplate(tproc)
                result = tproc.process(template)
                yield 1

                self.send(self.getOutputFileName(), 'create-output')
                yield 1

                self.send(result, "outbox")
                yield 1

                self.send(producerFinished(self), "signal")
                if self.VERBOSE:
                    print "File written %s" % self.getOutputFileName()
                return

            if not self.anyReady():
                self.pause()

            yield 1
예제 #6
0
    def __init__(self, template, debug=0):
        """ Constructor.             

            @header __init__(template, debug=0)
           
            @param template String containing template data.
            
            @param debug Enable or disable debugging messages.
            This optional parameter can be used to enable or disable debugging
            messages which are printed to stderr. By default debugging
            messages are disabled.
        """
        self._debug = debug
        self._classes = []
        self._functions = []
        self._class = {}
        self._template = TemplateCompiler().compile_string(template)
        self._tproc = TemplateProcessor(html_escape=0)
예제 #7
0
#!/usr/bin/env python

import sys
import gettext
import locale
sys.path.insert(0, "../..")
from htmltmpl import TemplateManager, TemplateProcessor

locale.setlocale(locale.LC_MESSAGES, "en_US")
gettext.bindtextdomain("test", "./locale")
gettext.textdomain("test")

man = TemplateManager(precompile = 0, gettext = 1, debug = 1)
tmpl = man.prepare("gettext.tmpl")
tproc = TemplateProcessor(debug = 1)
tproc.set("title", "Gettext test page")
print(tproc.process(tmpl))

예제 #8
0
파일: omtest.py 프로젝트: cria/openmodeller
def summarize():
    global success_counter, failure_counter, blow_counter, skip_counter
    global cur_name
    global report_entry_set, map_stats_entry_set

    print
    print 'Test Script: %s' % cur_name
    print 'Succeeded: %d' % success_counter
    print 'Failed:    %d (%d blew exceptions)' \
          % (failure_counter+blow_counter, blow_counter)
    print 'Skipped:   %d' % skip_counter
    print

    # find whether we are in test root dir or one level up
    if os.path.exists(os.path.join("..", "SummaryReport.tmpl")):
        os.chdir("..")

    elif not os.path.exists("SummaryReport.tmpl"):
        raise "Could not find HTML template files."

    # Compile or load already precompiled template.
    template = TemplateManager().prepare("SummaryReport.tmpl")
    tproc = TemplateProcessor()

    # Set the title.
    mod = om.OpenModeller()
    tproc.set("om_version", mod.getVersion())
    tproc.set("om_num_algs", mod.numAvailableAlgorithms())

    # htmltmpl requires var name starting with uppercase (!?!)
    Entries = report_entry_set
    tproc.set("Entries", Entries)

    # get list of algorithms
    Algorithms = []
    algList = mod.availableAlgorithms()
    for i in range(0, len(algList)):
        alg = {}
        alg["class"] = "a"
        alg["id"] = algList[i].id
        alg["name"] = algList[i].name
        Algorithms.append(alg)

    tproc.set("Algorithms", Algorithms)

    # write the processed template to disk
    summary_file = file("index.html", "w")
    summary_file.write(tproc.process(template))
    summary_file.close()

    # Compile or load already precompiled template.
    template = TemplateManager().prepare("MapReport.tmpl")
    tproc = TemplateProcessor()

    # htmltmpl requires var name starting with uppercase (!?!)
    Mapstats = map_stats_entry_set
    tproc.set("Mapstats", Mapstats)

    # write the processed template to disk
    map_file = file("MapReport.html", "w")
    map_file.write(tproc.process(template))
    map_file.close()
예제 #9
0
import honeyd
import time
import support
from htmltmpl import TemplateManager, TemplateProcessor

global counter

self.send_response(200)
self.send_header("Content-Type", "text/html")
self.send_nocache()
self.end_headers()

# Compile or load already precompiled template.
template = TemplateManager().prepare(self.root+"/templates/index.tmpl")
tproc = TemplateProcessor(0)

# Process commands given to us
message = support.parse_query(self.query)

# Set the title.
tproc.set("title", "Honeyd Administration Interface")

# Test
try:
    counter += 1
except:
    counter = 1

greeting = ("Welcome to the Honeyd Administration Interface."
            "You are visitor %d.<p>") % counter
예제 #10
0
# 生成文档的title和最新更新时间列表
for file_path, category in article_category.items():
    fd = open(file_path)
    fd.seek(0)
    title = fd.readline()
    keyword = fd.readline()
    uuid = fd.readline()
    fd.close()
    article_title[file_path] = title
    article_keyword[file_path] = keyword
    article_uuid[file_path] = uuid
    article_lastmodify[file_path] = "%d" % os.stat(file_path).st_mtime

#============ 生成首页 =============#
template = TemplateManager().prepare(index_html_template)
tproc = TemplateProcessor(html_escape=0)

# Create the 'Menuitem' loop.
Menuitems = []
for category, cn_name in site_category.items():
    if category in article_category.values():
        menuitem = {}
        menuitem["menu_href"] = "/%s/index.html" % (category)
        menuitem["menu_name"] = cn_name
        Menuitems.append(menuitem)

# 首页显示最新的一篇文章内容
index_article = []
# create new article list
Newarticles = []
article_lastmodify_sort = sorted(article_lastmodify.items(),
예제 #11
0
#!/usr/bin/env python

TEST = "compiled"

import sys
import os
sys.path.insert(0, "..")

from htmltmpl import TemplateManager, TemplateProcessor

man = TemplateManager(precompile = 1, debug = "debug" in sys.argv)
template = man.prepare(TEST + ".tmpl")
tproc = TemplateProcessor(debug = "debug" in sys.argv)

#######################################################

def fill(tproc):
    tproc.set("title", "Template world.")
    tproc.set("greeting", "Hello !")
    tproc.set("Boys", [
        { "name" : "Tomas",  "age" : 19 },
        { "name" : "Pavel",  "age" : 34 },
        { "name" : "Janek",  "age" : 67 },
        { "name" : "Martin", "age" : 43 },
        { "name" : "Viktor", "age" : 78 },
        { "name" : "Marian", "age" : 90 },
        { "name" : "Prokop", "age" : 23 },
        { "name" : "Honzik", "age" : 46 },
        { "name" : "Brudra", "age" : 64 },
        { "name" : "Marek",  "age" : 54 },
        { "name" : "Peter",  "age" : 42 },