zoukankan      html  css  js  c++  java
  • IDA Python脚本

    16进制数据转10进制数据

    单个数据长度与B/W/D/Q 的关系

    1 2 4 8
    Byte Word Dword Qword

    提取要求为Dword

    dword_input[i] == / != dword_out[i]

    a=''
    for i in range(0x404020,0x404020+4*42,4):
        a+=str(Dword(i))+','
    print a
    

    0x404020 为数据段起始地址,42为数据总长度,4为单个数据长度。

    (注意:在ida中地址数据可能为000000404020,需要去掉404020前面的0,再加上0x)

    例子:2020全国信息安全大赛Reverse z3

    提取要求为Byte

    byte_input[i] == / != dword_out[i]

    #将Hex中的字符转换为Dec中对应的数字
    def Trans(NumHex):
        NumDec = 0
        if NumHex == 'a':
            NumDec = 10
        elif NumHex == 'b':
            NumDec = 11
        elif NumHex == 'c':
            NumDec = 12
        elif NumHex == 'd':
            NumDec = 13
        elif NumHex == 'e':
            NumDec = 14
        elif NumHex == 'f':
            NumDec =15
        else:
            NumDec = NumHex
        return NumDec
    
    a=''
    for i in range(0x404020,0x404020+4*42,4):
        a+=int(Trans(('0' + (hex(Dword(index))).replace('0x', '').replace('L', '')[-2:])[-1])) + 16 * int(Trans(('0' + (hex(Dword(index))).replace('0x', '').replace('L', '')[-2:])[-2]))
    print a
    

    long和str转换

    出现 TypeError: cannot concatenate 'str' and 'long' objects 错误且计算结果超过128

    a=''
    for i in range(数据长度):
      a += chr(b[i]%128)
    print a
    
  • 相关阅读:
    HTTP协议简介
    Web开发中B/S架构和C/S架构的区别
    软件测试作业三
    Java8 时间处理
    Java EE
    Java 中的 I/O 抽象
    Python 高级 I/O 多路复用
    SQL 与关系代数
    Python 协程与事件循环
    Java SE 5.0
  • 原文地址:https://www.cnblogs.com/b1ank/p/13554801.html
Copyright © 2011-2022 走看看