コード例 #1
0
ファイル: instructions.py プロジェクト: teambi0s/phpil
 def main():
     print Instruction(operation.Nop())
     print Instruction(operation.LoadInteger(1), False,
                       [variable.Variable(12)])
     print Instruction(operation.LoadFloat(1.1), False,
                       [variable.Variable(11)])
     print Instruction(operation.LoadString('aaaa'), False,
                       [variable.Variable(12)])
     print Instruction(operation.LoadBoolean(True), False,
                       [variable.Variable(12)])
     print Instruction(operation.LoadNull(), False, [variable.Variable(12)])
     print Instruction(
         operation.CreateArray(3),
         [variable.Variable(2),
          variable.Variable(3),
          variable.Variable(4)], [variable.Variable(12)])
     print Instruction(
         operation.CallFunction(2),
         [variable.Variable(1),
          variable.Variable(2),
          variable.Variable(3)], [variable.Variable(4)])
     #print Instruction(operation.CreateObject('blag', 3),[variable.Variable(1),variable.Variable(3),variable.Variable(2) ],[variable.Variable(12)]) //Error
     #print Instruction(operation.BeginFunction(),False,[variable.Variable(12)]) //NotCompleted
     #print Instruction(operation.EndFunction(),False,False) //NotCompleted
     print Instruction(operation.BeginIf(), [variable.Variable(1)], False)
     print Instruction(operation.BeginElse(), False, False)
     print Instruction(operation.EndIf(), False, False)
     print Instruction(
         operation.BeginWhile(">"),
         [variable.Variable(5), variable.Variable(0)], False)  # Error
     print Instruction(operation.EndWhile(), False, False)
     print Instruction(operation.BeginFor("++", "<"), [
         variable.Variable(1),
         variable.Variable(4),
         variable.Variable(10)
     ], False)
     print Instruction(operation.EndFor(), False, False)
     #print Instruction(operation.BeginForEach(),False,False) //NotCompleted
     #print Instruction(operation.EndForEach(),False,False) //NotCompleted
     print Instruction(operation.Return(), False, [variable.Variable(12)])
     print Instruction(operation.Break(), False, False)
     print Instruction(operation.Continue(), False, False)
     #print Instruction(operation.BeginTry(),False,False) //NotCompleted
     #print Instruction(operation.BeginCatch(),False,False) //NotCompleted
     #print Instruction(operation.EndTryCatch(),False,False) //NotCompleted
     #print Instruction(operation.BeginClass(),False,False) //NotMade
     #print Instruction(operation.EndClass(),False,False) //NotMade
     print Instruction(operation.UnaryOperation("++"),
                       [variable.Variable(11)], [variable.Variable(10)])
     print Instruction(operation.BinaryOperation("+"),
                       [variable.Variable(10),
                        variable.Variable(11)], [variable.Variable(10)])
     print Instruction(operation.Include(), [variable.Variable("module")],
                       False)
     print Instruction(operation.Eval('1'), [variable.Variable(11)], False)
     print Instruction(operation.Phi(), [variable.Variable(10)],
                       [variable.Variable(12)])
     print Instruction(operation.Copy(),
                       [variable.Variable(10),
                        variable.Variable(20)], False)
     print Instruction(operation.ThrowException(), [variable.Variable(10)],
                       False)
     print Instruction(operation.BeginTry(), False, False)
     print Instruction(operation.Copy(), False, [variable.Variable(20)])
     print Instruction(operation.Print(), [variable.Variable(10)], False)
     print Instruction(operation.BeginDoWhile(), False, False)
     print Instruction(
         operation.EndDoWhile(">"),
         [variable.Variable(1), variable.Variable(2)], False)
コード例 #2
0
ファイル: program_builder.py プロジェクト: teambi0s/phpil
 def callFunction(self, funcName, args):
     return self.perform(operation.CallFunction(len(args) + 1), [funcName] + args).getOutput()
コード例 #3
0
 def main():
     prog = program.Program([
         instructions.Instruction(operation.LoadInteger(1), False,
                                  [variable.Variable(0)]),
         instructions.Instruction(operation.LoadInteger(9), False,
                                  [variable.Variable(3)]),
         instructions.Instruction(operation.LoadString("thisisastring"),
                                  False, [variable.Variable(1)]),
         instructions.Instruction(operation.LoadInteger(True), False,
                                  [variable.Variable(4)]),
         instructions.Instruction(
             operation.BeginWhile(">"),
             [variable.Variable(0),
              variable.Variable(3)]),
         instructions.Instruction(operation.LoadInteger(1337), False,
                                  [variable.Variable(6)]),
         instructions.Instruction(operation.BeginIf(),
                                  [variable.Variable(2)]),
         instructions.Instruction(operation.LoadString("thisisastring"),
                                  False, [variable.Variable(9)]),
         instructions.Instruction(operation.EndIf()),
         instructions.Instruction(
             operation.BinaryOperation(">"),
             [variable.Variable(0),
              variable.Variable(3)], [variable.Variable(5)]),
         instructions.Instruction(operation.EndWhile()),
         instructions.Instruction(operation.LoadInteger(10), False,
                                  [variable.Variable(31337)]),
     ])
     prog = program.Program([
         instructions.Instruction(operation.LoadInteger(0), False,
                                  [variable.Variable(0)]),
         instructions.Instruction(operation.LoadInteger(1), False,
                                  [variable.Variable(1)]),
         instructions.Instruction(operation.LoadInteger(10), False,
                                  [variable.Variable(2)]),
         instructions.Instruction(operation.LoadInteger(10), False,
                                  [variable.Variable(3)]),
         instructions.Instruction(operation.LoadInteger(20), False,
                                  [variable.Variable(4)]),
         instructions.Instruction(operation.LoadInteger(5), False,
                                  [variable.Variable(5)]),
         instructions.Instruction(operation.Phi(), [variable.Variable(3)],
                                  [variable.Variable(6)]),
         instructions.Instruction(operation.Phi(), [variable.Variable(4)],
                                  [variable.Variable(7)]),
         instructions.Instruction(operation.BeginFor("++", "<"), [
             variable.Variable(0),
             variable.Variable(2),
             variable.Variable(8)
         ]),
         instructions.Instruction(
             operation.BinaryOperation("<"),
             [variable.Variable(8),
              variable.Variable(5)], [variable.Variable(6)]),
         instructions.Instruction(operation.BeginIf(),
                                  [variable.Variable(6)], False),
         instructions.Instruction(operation.LoadInteger(0), False,
                                  [variable.Variable(9)]),
         instructions.Instruction(
             operation.BeginWhile("<"),
             [variable.Variable(9),
              variable.Variable(5)], False),
         instructions.Instruction(
             operation.BinaryOperation("+"),
             [variable.Variable(6),
              variable.Variable(1)], [variable.Variable(10)]),
         instructions.Instruction(
             operation.Copy(),
             [variable.Variable(6),
              variable.Variable(10)]),
         instructions.Instruction(
             operation.BinaryOperation("+"),
             [variable.Variable(9),
              variable.Variable(1)], [variable.Variable(11)]),
         instructions.Instruction(
             operation.Copy(),
             [variable.Variable(6),
              variable.Variable(10)]),
         instructions.Instruction(
             operation.BeginFunction(
                 typesData.FunctionSignature(2, [variable.Variable(11)])),
             False, [variable.Variable(1)],
             [variable.Variable(10),
              variable.Variable(11)]),
         instructions.Instruction(
             operation.BinaryOperation("+"),
             [variable.Variable(10),
              variable.Variable(11)], [variable.Variable(2)]),
         instructions.Instruction(operation.LoadString("somestring"), False,
                                  [variable.Variable(3)]),
         instructions.Instruction(operation.Return(),
                                  [variable.Variable(2)]),
         instructions.Instruction(operation.EndFunction()),
         instructions.Instruction(operation.LoadInteger(1337), False,
                                  [variable.Variable(4)]),
         instructions.Instruction(operation.CallFunction(2), [
             variable.Variable(1),
             variable.Variable(4),
             variable.Variable(0)
         ], [variable.Variable(6)]),
         instructions.Instruction(operation.EndWhile(), False, False),
         instructions.Instruction(operation.BeginElse(), False, False),
         instructions.Instruction(operation.LoadInteger(0), False,
                                  [variable.Variable(9)]),
         instructions.Instruction(
             operation.BeginWhile("<"),
             [variable.Variable(9),
              variable.Variable(5)], False),
         instructions.Instruction(
             operation.BinaryOperation("+"),
             [variable.Variable(7),
              variable.Variable(1)], [variable.Variable(10)]),
         instructions.Instruction(
             operation.Copy(),
             [variable.Variable(7),
              variable.Variable(10)]),
         instructions.Instruction(
             operation.BinaryOperation("+"),
             [variable.Variable(9),
              variable.Variable(1)], [variable.Variable(11)]),
         instructions.Instruction(
             operation.Copy(),
             [variable.Variable(6),
              variable.Variable(10)]),
         instructions.Instruction(operation.EndWhile(), False, False),
         instructions.Instruction(operation.EndIf(), False, False),
         instructions.Instruction(operation.EndFor(), False, False),
         instructions.Instruction(operation.LoadInteger(1), False,
                                  [variable.Variable(90)]),
     ])
     program.Program([
         instructions.Instruction(operation.LoadInteger(1), False,
                                  [variable.Variable(0)]),
         instructions.Instruction(
             operation.BeginFunction(
                 typesData.FunctionSignature(2, [variable.Variable(11)])),
             False, [variable.Variable(1)],
             [variable.Variable(10),
              variable.Variable(11)]),
         instructions.Instruction(
             operation.BinaryOperation("+"),
             [variable.Variable(10),
              variable.Variable(11)], [variable.Variable(2)]),
         instructions.Instruction(operation.LoadString("somestring"), False,
                                  [variable.Variable(3)]),
         instructions.Instruction(operation.Return(),
                                  [variable.Variable(2)]),
         instructions.Instruction(operation.EndFunction()),
         instructions.Instruction(operation.LoadInteger(1337), False,
                                  [variable.Variable(4)]),
         instructions.Instruction(operation.CallFunction(2), [
             variable.Variable(1),
             variable.Variable(4),
             variable.Variable(0)
         ], [variable.Variable(6)]),
         instructions.Instruction(operation.LoadInteger(1337), False,
                                  [variable.Variable(7)]),
     ])
     print prog
     ctx = ContextAnalyzer(prog)
     ctx.doAnalyze()
コード例 #4
0
    Program()
    Program([
        instructions.Instruction(operation.LoadInteger(1), False,
                                 [variable.Variable(0)]),
        instructions.Instruction(
            operation.BeginFunction(typesData.FunctionSignature(2)), False,
            [variable.Variable(1)],
            [variable.Variable(10),
             variable.Variable(11)]),
        instructions.Instruction(
            operation.BinaryOperation("+"),
            [variable.Variable(10),
             variable.Variable(11)], [variable.Variable(2)]),
        instructions.Instruction(operation.LoadString("somestring"), False,
                                 [variable.Variable(3)]),
        instructions.Instruction(operation.Return(), [variable.Variable(3)]),
        instructions.Instruction(operation.EndFunction()),
        instructions.Instruction(operation.LoadInteger(1337), False,
                                 [variable.Variable(4)]),
        instructions.Instruction(
            operation.CallFunction(2),
            [variable.Variable(1),
             variable.Variable(4),
             variable.Variable(0)], [variable.Variable(6)]),
        instructions.Instruction(operation.LoadInteger(1337), False,
                                 [variable.Variable(7)]),
    ])

    # print Program([Instruction()])
コード例 #5
0
    def main():
        prog = program.Program([
            instructions.Instruction(operation.LoadInteger(10), False,
                                     [variable.Variable(0)]),
            instructions.Instruction(operation.LoadFloat(1.1), False,
                                     [variable.Variable(1)]),
            instructions.Instruction(operation.LoadBoolean(True), False,
                                     [variable.Variable(1)]),
            instructions.Instruction(operation.LoadString("qweqweqweqwe"),
                                     False, [variable.Variable(0)]),
            instructions.Instruction(operation.BeginIf(),
                                     [variable.Variable(2)]),
            instructions.Instruction(operation.BeginElse()),
            instructions.Instruction(operation.EndIf())
        ])

        prog = program.Program([
            instructions.Instruction(operation.LoadString("phar"), False,
                                     [variable.Variable(100)]),
            instructions.Instruction(operation.Include(),
                                     [variable.Variable(100)]),
            instructions.Instruction(operation.Include(),
                                     [variable.Variable(100)]),
            instructions.Instruction(operation.LoadInteger(1), False,
                                     [variable.Variable(0)]),
            instructions.Instruction(
                operation.BeginFunction(typesData.FunctionSignature(2)), False,
                [variable.Variable(1)],
                [variable.Variable(10),
                 variable.Variable(11)]),
            instructions.Instruction(
                operation.BinaryOperation("+"),
                [variable.Variable(10),
                 variable.Variable(11)], [variable.Variable(2)]),
            instructions.Instruction(operation.LoadString("somestring"), False,
                                     [variable.Variable(3)]),
            instructions.Instruction(operation.Return(),
                                     [variable.Variable(2)]),
            instructions.Instruction(operation.EndFunction()),
            instructions.Instruction(operation.LoadInteger(1337), False,
                                     [variable.Variable(4)]),
            instructions.Instruction(operation.CallFunction(2), [
                variable.Variable(1),
                variable.Variable(4),
                variable.Variable(0)
            ], [variable.Variable(6)]),
            instructions.Instruction(operation.LoadInteger(1337), False,
                                     [variable.Variable(7)]),
            instructions.Instruction(operation.Break()),
            instructions.Instruction(operation.Continue()),
            instructions.Instruction(operation.UnaryOperation("++"),
                                     [variable.Variable(0)],
                                     [variable.Variable(0)]),
        ])

        prog = program.Program([
            instructions.Instruction(operation.LoadString("phar"), False,
                                     [variable.Variable(100)]),
            instructions.Instruction(operation.Include(),
                                     [variable.Variable(100)]),
            instructions.Instruction(operation.Include(),
                                     [variable.Variable(100)]),
            instructions.Instruction(operation.LoadInteger(0), False,
                                     [variable.Variable(0)]),
            instructions.Instruction(operation.LoadInteger(1), False,
                                     [variable.Variable(1)]),
            instructions.Instruction(operation.LoadInteger(10), False,
                                     [variable.Variable(2)]),
            instructions.Instruction(operation.LoadInteger(10), False,
                                     [variable.Variable(3)]),
            instructions.Instruction(operation.LoadInteger(20), False,
                                     [variable.Variable(4)]),
            instructions.Instruction(operation.LoadInteger(5), False,
                                     [variable.Variable(5)]),
            instructions.Instruction(operation.LoadInteger(50), False,
                                     [variable.Variable(8)]),
            instructions.Instruction(operation.Phi(), [variable.Variable(3)],
                                     [variable.Variable(6)]),
            instructions.Instruction(operation.Phi(), [variable.Variable(4)],
                                     [variable.Variable(7)]),
            instructions.Instruction(operation.BeginFor("++", "<"), [
                variable.Variable(0),
                variable.Variable(2),
                variable.Variable(8)
            ], False, [variable.Variable(80)]),
            instructions.Instruction(
                operation.BinaryOperation("<"),
                [variable.Variable(8),
                 variable.Variable(5)], [variable.Variable(6)]),
            instructions.Instruction(operation.BeginIf(),
                                     [variable.Variable(6)], False),
            instructions.Instruction(operation.LoadInteger(0), False,
                                     [variable.Variable(9)]),
            instructions.Instruction(
                operation.BeginWhile("<"),
                [variable.Variable(9),
                 variable.Variable(5)], False),
            instructions.Instruction(
                operation.BinaryOperation("+"),
                [variable.Variable(6),
                 variable.Variable(1)], [variable.Variable(10)]),
            instructions.Instruction(
                operation.Copy(),
                [variable.Variable(6),
                 variable.Variable(10)]),
            instructions.Instruction(
                operation.BinaryOperation("+"),
                [variable.Variable(9),
                 variable.Variable(1)], [variable.Variable(11)]),
            instructions.Instruction(
                operation.Copy(),
                [variable.Variable(6),
                 variable.Variable(10)]),
            instructions.Instruction(operation.EndWhile(), False, False),
            instructions.Instruction(operation.BeginElse(), False, False),
            instructions.Instruction(operation.LoadInteger(0), False,
                                     [variable.Variable(9)]),
            instructions.Instruction(
                operation.BeginWhile("<"),
                [variable.Variable(9),
                 variable.Variable(5)], False),
            instructions.Instruction(
                operation.BinaryOperation("+"),
                [variable.Variable(7),
                 variable.Variable(1)], [variable.Variable(10)]),
            instructions.Instruction(
                operation.Copy(),
                [variable.Variable(7),
                 variable.Variable(10)]),
            instructions.Instruction(
                operation.BinaryOperation("+"),
                [variable.Variable(9),
                 variable.Variable(1)], [variable.Variable(11)]),
            instructions.Instruction(
                operation.Copy(),
                [variable.Variable(6),
                 variable.Variable(10)]),
            instructions.Instruction(operation.EndWhile(), False, False),
            instructions.Instruction(operation.EndIf(), False, False),
            instructions.Instruction(operation.EndFor(), False, False),
            instructions.Instruction(operation.LoadInteger(1), False,
                                     [variable.Variable(90)]),
        ])
        # print prog
        l = Lifter(prog)
        l.doLifting()
        print l.emitter