-- Leo's gemini proxy

-- Connecting to airmack.de:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

░█▀█░▀█▀░█▀▄░█▄█░█▀█░█▀▀░█░█░░░░█▀▄░█▀▀
░█▀█░░█░░█▀▄░█░█░█▀█░█░░░█▀▄░░░░█░█░█▀▀
░▀░▀░▀▀▀░▀░▀░▀░▀░▀░▀░▀▀▀░▀░▀░▀░░▀▀░░▀▀▀




Erster Eintrag


Aus der Kategorie Coding


Einmal den Kopf Hoch:


Das hier stellt den ersten Eintrag dar und zeigt den tollen Coden um diese statische Website zu generieren.


Code


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# VERSION: Freitag 7 Oktober 2011, 23:13

import hashlib
import io
import subprocess
import sys

import simplejson
from misc import isPatent, sortByTime, isSummary, isHidden

f = open("json/information.json", "r")
WEBSITE = simplejson.load(f)
f.close()


def readTemplate(filename):
  with io.open(filename, "r", encoding="utf-8") as f:
    return f.read()


def createheader(links): # links look like this: rel title href
  try:
    t = len(links)
  except TypeError:
    print("Oops! Links hat 0 Elemente... ")
    sys.exit(0)

  header = readTemplate("template/header.html")
  for i in range(0, t):
    header += (
      u'\t<link rel="'
      + links[i]["rel"]
      + u'" title="'
      + links[i]["title"]
      + u'" href="'
      + WEBSITE["URL"]
      + links[i]["href"]
      + u'" /> \n'
    )
  header += u"\n" + readTemplate("template/header1.html")
  return header


def createMOTD():
  f = open("json/motd.json", "r")
  j_obj = simplejson.load(f)
  f.close()
  MOTD = j_obj[0]["MOTD"]
  return MOTD


def createheaderbar(links): # links look like this: rel title href
  try:
    t = len(links)
  except TypeError:
    print("Oops! Links hat 0 Elemente... ")
    sys.exit(0)
  headerbar = u""
  with io.open("template/headerbar.html", "r", encoding="utf-8") as f:
    headerbar = f.read()
  # 	<link rel="contents" title="Inhaltsverzeichnis" href="show_categories.php">
  for i in range(0, t):
    headerbar += (
      u'\t\t\t<li><a href="'
      + WEBSITE["URL"]
      + links[i]["href"]
      + u'">'
      + links[i]["title"]
      + u"</a></li>\n"
    )
  with io.open("template/headerbar1.html", "r", encoding="utf-8") as f:
    headerbar += u"\n" + f.read()
  headerbar += (
    u"\n\t\t<h2><a href='https://www.airmack.de'>&#60;&#61;web@airmack.de: &#61;&#62;</a> echo \""
    + createMOTD()
    + u'" &#9647;</h2>\n\t\t<br />\n\t\n\t</div>\n<!-- end headerbar -->'
  )
  f.close()
  return headerbar


def createfooter(links): # links look like this: rel title href
  try:
    t = len(links)
  except TypeError:
    print("Oops! Links hat 0 Elemente... ")
    sys.exit(0)

  f = open("template/footer.html", "r")
  footer = f.read()
  f.close()

  for i in range(0, t):
    footer = (
      footer
      + u' <a href="'
      + WEBSITE["URL"]
      + links[i]["href"]
      + u'">'
      + links[i]["title"]
      + u"</a> \n"
    )
  f = open("template/footer1.html", "r")
  footer = footer + "\n" + f.read()
  f.close()
  return footer


def createleft(links, numberoflinks): # links look like this: rel title href
  try:
    t = len(links)
  except TypeError:
    print("Oops! Links hat 0 Elemente... ")
    sys.exit(0)
  # 	in case we should display more elements than we can reduce them
  if t < numberoflinks:
    numberoflinks = t

  f = open("template/left.html", "r")
  left = f.read()
  f.close()
  for i in range(0, numberoflinks):
    left = (
      left
      + u"\t\t<h3><a href ='"
      + WEBSITE["URL"]
      + u"single/"
      + links[i]["Hash"]
      + u".html'> \n \t\t\t "
      + links[i]["Titel"]
      + u"</a></h3><p class='category_date'> erstellt am "
      + links[i]["Datum"]
      + u"</p>\n \t\t\t"
    )
  f = open("template/left1.html", "r")
  left = left + u"\n" + f.read()
  f.close()
  return left


# links look like this: rel title href
def createoverview(links, Kategorien, header, headerbar, left, footer):
  try:
    t = len(Kategorien[0])
  except TypeError:
    print("Oops! Links hat 0 Elemente... ")
    sys.exit(0)
  # 	in case we should display more elements than we can reduce them
  f = open("template/uebersicht.html", "r")
  uebersicht = header + headerbar + left + f.read()
  f.close()

  for i in range(0, t):
    uebersicht = (
      uebersicht + u"\t<div class='category_row'><img class='category_icon' src='"
    )
    uebersicht = (
      uebersicht
      + Kategorien[2][i]
      + u"' alt=''/>\n\t\t<h2 style='float:left;' class='trigger'> \n \t\t<a href='javascript:void(0)'>"
      + Kategorien[0][i]
      + u" ("
      + str(Kategorien[1][i])
      + u" Artikel) </a></h2>\n \t\t\t<div class='toggle_container'><div class='block'>\n\t\t\t<ul style='list-style-type: none; margin-left: 10px;'><li>\n"
    )
    for j in range(0, len(links)):
      if Kategorien[0][i] == links[j]["Hauptkategorie"]:
        uebersicht = (
          uebersicht
          + u"\t\t\t\t<h3><a href='"
          + WEBSITE["URL"]
          + "single/"
          + str(links[j]["Hash"])
          + u".html'>"
          + links[j]["Titel"]
          + u"</a></h3>\n\t\t\t\t<p class='category_date'> erstellt am "
          + links[j]["Datum"]
          + u" </p> \n"
        )
    uebersicht = uebersicht + u"\t\t\t</li></ul>\n\t\t\t</div></div>\n\t</div> \n"

  f = open("template/uebersicht1.html", "r")
  uebersicht = uebersicht + "\n" + f.read() + footer
  f.close()

  f = open("single/uebersicht.html", "w")
  try:
    f.write(uebersicht.encode("UTF-8"))
  except TypeError:
    f.write(uebersicht)

  f.close()
  return uebersicht


def getcategories(articles):
  t = len(articles)
  f = open("json/kategorien.json", "r")
  k = simplejson.load(f)
  f.close()
  categories = []
  pictures = []
  number_of_elements = []
  for i in range(0, len(k)):
    categories.append(k[i]["Hauptkategorie"])
    pictures.append(WEBSITE["URL"] + k[i]["Bild"])
    number_of_elements.append(0)

  if not t:
    print("Oops! Links hat 0 Elemente... ")
    sys.exit(0)
  else:
    for i in range(0, t):
      if not len(categories):
        categories.append(articles[i]["Hauptkategorie"])
        number_of_elements.append(1)
      else:
        found = -1
        for j in range(0, len(categories)):
          if categories[j] == articles[i]["Hauptkategorie"]:
            number_of_elements[j] = number_of_elements[j] + 1
            found = j
            break
        if found == -1:
          categories.append(articles[i]["Hauptkategorie"])
          number_of_elements.append(1)
          pictures.append(WEBSITE["URL"] + "img/ka.png")
  return [categories, number_of_elements, pictures]


def createdisclaimer(header, headerbar, left, footer):
  f = open("json/information.json", "r")
  information = simplejson.load(f)
  f.close()
  f = open("template/impressum.html", "r")
  impres_header = f.read()
  f.close()
  disclaimer = (
    header
    + headerbar
    + left
    + impres_header
    + "\t\t<pre><code>"
    + information["Vorname"]
    + " "
    + information["Name"]
    + "\n"
    + information["Strasse"]
    + "\n"
    + information["Postleitzahl"]
    + " "
    + information["Stadt"]
    + "</code></pre>\n"
  )
  f = open("template/impressum1.html", "r")
  disclaimer = disclaimer + f.read() + information["Email"]
  f.close()
  f = open("template/impressum2.html", "r")
  disclaimer = (
    disclaimer
    + f.read()
    + "\t\t<pre><code>"
    + information["Vorname"]
    + " "
    + information["Name"]
    + "\n"
    + information["Strasse"]
    + "\n"
    + information["Postleitzahl"]
    + " "
    + information["Stadt"]
    + "</code></pre>\n"
  )
  f.close()

  f = open("template/impressum3.html", "r")
  disclaimer = disclaimer + f.read()
  disclaimer = disclaimer + footer
  f = open("single/impressum.html", "w")
  try:
    f.write(disclaimer.encode("UTF-8"))
  except TypeError:
    print("Fehler beim UTF8")
    f.write(disclaimer)
  f.close()


def createmain(header, headerbar, left, footer):
  f = open("json/articles.json", "r")
  information = simplejson.load(f)
  f.close()
  disclaimer = (
    header
    + headerbar
    + left
    + u"<div id='main'>\n\t<h2>"
    + information[0]["Titel"]
    + u"</h2>\n"
  )
  disclaimer += (
    u"\t<h3> aus der Kategorie " + information[0]["Hauptkategorie"] + " </h3>\n"
  )
  disclaimer += (
    u'\t<div id="article">'
    + parsearticle(information[0]["Inhalt"], information[0]["code"])
    + u"</div>\n"
  )
  disclaimer += (
    "\t<p class='category_date'> hzgf. am "
    + information[0]["Datum"]
    + u"</p>\n\t<br/>\n</div>\n<!-- end main division -->\n"
  )
  disclaimer += footer
  f = open("single/index.html", "w")
  try:
    f.write(disclaimer.encode("UTF-8"))
  except TypeError:
    print("Fehler beim UTF8")
    f.write(disclaimer)
  f.close()


def parsearticle(inhalt, code):
  # 	== == <h2> </h2> For headlines
  # 	=== === <h3> </h3>
  # 	<code> </code> Code
  #
  t = 0
  counter = 0
  while True:
    vorher = inhalt
    if counter == 0:
      inhalt = inhalt.replace("===", "<h3>", 1)
      counter = 1

    else:
      inhalt = inhalt.replace("===", "</h3>", 1)
      counter = 0
    if vorher == inhalt:
      break

  counter = 0
  while True:
    vorher = inhalt
    if counter == 0:
      inhalt = inhalt.replace("==", "<h4>", 1)
      counter = 1

    else:
      inhalt = inhalt.replace("==", "</h4>", 1)
      counter = 0
    if vorher == inhalt:
      break

  counter = 0
  if len(code) != 0:
    while True:
      anfang = inhalt.find("<code>")
      ende = inhalt.find("</code>")
      if len(code) <= counter:
        break
      dataname = code[counter]
      if anfang != -1 and ende != 1:
        t = [
          "/usr/bin/source-highlight",
          "-i",
          "code/" + dataname,
          "-o",
          "STDOUT",
          "--failsafe",
          "--out-format=html5",
        ]
        process = subprocess.check_output(t, shell=False).decode("utf-8")
        inhalt = inhalt.replace(inhalt[anfang : ende + 7], process, 1)
      else:
        break
      counter = counter + 1

  inhalt = inhalt.replace("#000000", "#00DD00")

  return inhalt


def createarticles(header, headerbar, left, footer):
  f = open("json/articles.json", "r")
  information = simplejson.load(f)
  f.close()
  for i in range(0, len(information)):

    disclaimer = (
      header
      + headerbar
      + left
      + "<div id='main'>\n\t<h2>"
      + information[i]["Titel"]
      + "</h2>\n"
    )
    disclaimer = (
      disclaimer
      + "\t<h3> aus der Kategorie "
      + information[i]["Hauptkategorie"]
      + " </h3>\n"
    )
    disclaimer = (
      disclaimer
      + '\t<div id="article">'
      + parsearticle(information[i]["Inhalt"], information[i]["code"])
      + "</div>\n"
    )
    disclaimer = (
      disclaimer
      + "\t<p class='category_date'> hzgf. am "
      + information[i]["Datum"]
      + "</p>\n\t<br/>\n</div>\n<!-- end main division -->\n"
    )
    disclaimer = disclaimer + footer
    f = open("single/" + str(information[i]["Hash"]) + ".html", "w")
    try:
      f.write(disclaimer.encode("UTF-8"))
    except TypeError:
      print("Fehler beim UTF8")
      f.write(disclaimer)

    f.close()


def createBio(header, headerbar, left, footer):
  f = open("template/bio.html", "r")
  uebersicht = header + headerbar + left + f.read()
  f.close()

  f = open("json/information.json", "r")
  information = simplejson.load(f)

  uebersicht += (
    '<img style="float: right" src="../img/RC3/RC3_orig_256_256.png" alt="Eat, Sleep, PWN, Repeat"/>\n\t\t<h2>Basic Information:</h2>'
    #    + '<a href="https://www.credly.com/badges/a3d845e1-7528-4a41-97d4-bf5fb7e5d8c9/public_url"><img style="float: right" src="../img/cissp.png" alt="Certified Information Systems Security Professional (CISSP)"/></a>\n\t\t'
    + information["Vorname"]
    + " "
    + information["Name"]
    + "\n"
    "<br/>\n"
  )
  f.close()

  for f in [open("json/bio.json", "r"), open("json/patents.json", "r")]:
    information = simplejson.load(f)
    patentTrue = isPatent(information)
    if patentTrue:
      information = [{"Data": sortByTime(information), "Name": "Patents"}]
    for i in information:
      summaryTrue = isSummary(i)
      if summaryTrue:
        continue
      uebersicht += " <br/>\n<h2> " + i["Name"] + " </h2>\n \t\t\t<table>"
      for j in i["Data"]:
        if isHidden(j):
          continue
        if not patentTrue:
          uebersicht += "<tr>\n"
          uebersicht += '<td class="lefty"> ' + j["From"] + "</td>\n"
          uebersicht += '<td class="righty"> ' + j["What"] + "</td>\n"
          uebersicht += "</tr>\n"
          uebersicht += "<tr><td><br/></td></tr>\n"
        else:
          uebersicht += "<tr>\n"
          uebersicht += (
            '<td class="lefty"> '
            + j["From"]
            + "<br/> <a href='javascript:void(0)' role='button'>"
            + j["ID"]
            + "</a> </td>\n"
          )
          uebersicht += (
            '<td class="righty"> <a href="'
            + j["link"]
            + '"> '
            + j["Title"]
            + "</a>"
          )
          uebersicht += "<div class='toggle_container'><div class='block'>\n\t\t\t<ul style='list-style-type: none; margin-left: 10px;'><li>"
          uebersicht += j["What"] + "\n"
          uebersicht += (
            u"\t\t\t</li></ul>\n\t\t\t</div></div>\n\t</div> </td>\n"
          )
          uebersicht += "</tr>\n"
          uebersicht += "<tr><td><br/></td></tr>\n"

      uebersicht += "</table>\n\n"
    f.close()

  uebersicht += "</div>\r\n" + footer
  f = open("single/bio.html", "w")
  try:
    f.write(uebersicht.encode("UTF-8"))
  except TypeError:
    print("Fehler beim UTF8")
    f.write(uebersicht)

  f.close()


def CreateHashForArtcile():
  f = open("json/articles.json", "r")
  j_obj = simplejson.load(f)
  f.close()
  m = hashlib.sha256()

  for i in range(0, len(j_obj)):
    if "Hash" in j_obj[i]:
      continue
    m.update(j_obj[i]["Inhalt"].encode("UTF-8"))
    j_obj[i]["Hash"] = m.hexdigest()
    print(m.hexdigest())
  f = open("json/articles.json", "w")
  simplejson.dump(j_obj, f, sort_keys=True, indent=4 * " ")
  f.close()


def main(argv=None):
  CreateHashForArtcile()
  f = open("json/up.json", "r")
  j_obj = simplejson.load(f)
  header = createheader(j_obj)
  headerbar = createheaderbar(j_obj)
  f.close()
  f = open("json/down.json", "r")
  footer = createfooter(simplejson.load(f))
  f.close()
  f = open("json/articles.json", "r")
  j_obj = simplejson.load(f)
  categories = getcategories(j_obj)
  left = createleft(j_obj, 7)
  createoverview(j_obj, categories, header, headerbar, left, footer)
  f.close()

  createdisclaimer(header, headerbar, left, footer)
  createmain(header, headerbar, left, footer)
  createarticles(header, headerbar, left, footer)
  createBio(header, headerbar, left, footer)


if __name__ == "__main__":
  main()




Latest article



Fix for zfs-dkms-git in arch for kernel 5.15.7 erstellt am 11. December 2021


Project gemini erstellt am 13. Februar 2021


Eat Sleep PWN Repeat erstellt am 07. Dezember 2020


Physico-chemically motivated parameterization and modelling of real-time capable lithium-ion battery models: a case study on the Tesla Model S battery erstellt am 06. Dezember 2020


Breaking out of cisco anyconnect no local network restriction erstellt am 8. April 2018


Insomni Hack 2015(Lost In Memories) writeup erstellt am 23. Maerz 2014


ruCTF 2014(Pidometer) writeup erstellt am 21. Dezember 2014


Footer



Hauptseite


Impressum


Übersicht


Bio

-- Response ended

-- Page fetched on Fri May 17 06:29:48 2024