コード例 #1
0
def ebpf_xadd_(obj, sz, dreg, sreg, off, imm):
    size = {0: 32, 1: 16, 2: 8, 3: 64}[sz]
    if (size < 32) or imm != 0:
        raise InstructionError(obj)
    dst = env.mem(env.R[dreg] + off.int(-1), size)
    src = env.R[sreg][0:size]
    obj.operands = [dst, src]
    obj.type = type_data_processing
コード例 #2
0
def ebpf_ld_(obj, sz, dreg, sreg, off, imm, _abs):
    size = {0: 32, 1: 16, 2: 8, 3: 64}[sz]
    dst = env.R[0]
    adr = env.reg("#skb", 64)
    if not _abs:
        adr += env.R[sreg]
    src = env.mem(adr, size, disp=imm.int(-1))
    obj.operands = [dst, src]
    obj.type = type_data_processing
コード例 #3
0
def ebpf_ldx_(obj, sz, dreg, sreg, off, imm):
    size = {0: 32, 1: 16, 2: 8, 3: 64}[sz]
    if imm != 0:
        raise InstructionError(obj)
    dst = env.R[dreg]
    src = env.R[sreg]
    src = env.mem(src + off.int(-1), size)
    obj.operands = [dst, src]
    obj.type = type_data_processing
コード例 #4
0
def ebpf_ld_(obj,sz,dreg,sreg,off,imm,_abs):
    size = {0:32,1:16,2:8,3:64}[sz]
    dst = env.R[0]
    adr = env.reg('#skb',64)
    if not _abs: adr += env.R[sreg]
    src = env.mem(adr,size,disp=imm.int(-1))
    obj.operands = [dst,src]
    obj.mnemonic += {8:'b',16:'h',32:'w',64:'dw'}[size]
    obj.type = type_data_processing
コード例 #5
0
ファイル: spec_bpf.py プロジェクト: xorpse/amoco
def bpf_ld_(obj, sz, md, jt, jf, k):
    if sz == 3:
        raise InstructionError(obj)
    size = 32 >> sz
    dst = env.A
    adr = env.skb()
    if md == 0:  # IMM
        src = env.cst(k.int(-1), 32)
    elif md == 1:  # ABS
        src = env.mem(adr, size, disp=k.int(-1))
    elif md == 2:  # IND
        src = env.mem(adr + env.X + k.int(-1), size)
    elif md == 3 and k.int() < 16:  # MEM
        src = env.M[k.int()]
    elif md == 4:  # LEN
        src = env.skb("len")
    else:
        raise InstructionError(obj)
    obj.operands = [dst, src]
    obj.type = type_data_processing
コード例 #6
0
def ebpf_st_(obj, sz, dreg, sreg, off, imm):
    size = {0: 32, 1: 16, 2: 8, 3: 64}[sz]
    dst = env.mem(env.R[dreg] + off.int(-1), size)
    if obj.mnemonic == "stx":
        src = env.R[sreg]
        if imm != 0:
            raise InstructionError(obj)
    else:
        src = env.cst(imm.int(-1), 32).zeroextend(64)
    src = src[0:size]
    obj.operands = [dst, src]
    obj.type = type_data_processing
コード例 #7
0
def bpf_ldx_(obj,sz,md,jt,jf,k):
    if sz==3: raise InstructionError(obj)
    size = 32>>sz
    dst = env.X
    adr = env.skb()
    if   md==0 and size==32: #IMM
        src = env.cst(k.int(-1),32)
    elif md==3 and size==32 and k.int()<16: #MEM
        src = env.M[k.int()]
    elif md==6 and size==8: #MSH
        src = env.mem(adr,size,disp=k.int(-1))*4
    else:
        raise InstructionError(obj)
    obj.operands = [dst,src]
    obj.type = type_data_processing