コード例 #1
0
    def __init__(self, *blocks, **kwargs):
        self.arch   = kwargs.get('arch')
        self.os     = kwargs.get('os')
        self.blocks = []

        for b in pwn.concat_all(list(blocks)):
            if isinstance(b, AssemblerBlock):
                if self.os   == None: self.os   = b.os
                if self.arch == None: self.arch = b.arch

                if self.os != b.os and b.os != None:
                    pwn.die('Trying to combine assembler blocks with different os: ' + self.os + ' and ' + b.os)

                if self.arch != b.arch and b.arch != None:
                    pwn.die('Trying to combine assembler blocks with different archs: ' + self.arch + ' and ' + b.arch)

            if isinstance(b, AssemblerContainer):
                self.blocks.extend(b.blocks)
            elif isinstance(b, AssemblerBlock):
                self.blocks.append(b)
            elif isinstance(b, str):
                cast = kwargs.get('cast', 'blob')
                if cast == 'text':
                    self.blocks.append(AssemblerText(b, **kwargs))
                elif cast == 'blob':
                    self.blocks.append(AssemblerBlob(b, **kwargs))
                else:
                    die('Invalid cast for AssemblerContainer')
            else:
                pwn.die('Trying to force something of type ' + str(type(b)) + ' into an assembler block. Its value is:\n' + repr(b)[:100])
コード例 #2
0
ファイル: clookup.py プロジェクト: yudevan/pwntools
def clookup(*consts, **kwargs):
    consts = pwn.concat_all(consts)
    eval   = kwargs.get('eval', False)
    arch   = kwargs.get('arch', None)
    os     = kwargs.get('os', None)

    if os == None or arch == None:
        return consts

    return _clookup(consts, eval, arch, os)
コード例 #3
0
ファイル: blocks.py プロジェクト: Haabb/pwntools
 def __init__(self, content = None, wordsize = 4, name = None):
     self._content = []
     self.wordsize = wordsize
     self.parent = None
     if name:
         self.name = name
     else:
         self.name = "block%d" % Block._block_count
         Block._block_count += 1
     if self.name in Block._roots:
         pwn.die('A root block with the name "%s" already exicsts' % self.name)
     Block._roots[self.name] = self
     for o in pwn.concat_all([content]) if content != None else []:
         self._add(o)
コード例 #4
0
 def __init__(self, content=None, wordsize=4, name=None):
     self._content = []
     self.wordsize = wordsize
     self.parent = None
     if name:
         self.name = name
     else:
         self.name = "block%d" % Block._block_count
         Block._block_count += 1
     if self.name in Block._roots:
         pwn.die('A root block with the name "%s" already exicsts' %
                 self.name)
     Block._roots[self.name] = self
     for o in pwn.concat_all([content]) if content != None else []:
         self._add(o)
コード例 #5
0
 def __iadd__(self, other):
     for o in pwn.concat_all([other]):
         if isinstance(o, _Later):
             o._block = self
         self._entries.append(o)
     return self
コード例 #6
0
ファイル: blocks.py プロジェクト: Haabb/pwntools
    def __iadd__(self, other):
        for o in pwn.concat_all([other]):
            self._content.append(o)

        return self
コード例 #7
0
    def __iadd__(self, other):
        for o in pwn.concat_all([other]):
            self._content.append(o)

        return self