美文网首页
50行python过字符串静态处理

50行python过字符串静态处理

作者: 超哥__ | 来源:发表于2018-12-25 14:13 被阅读0次
      v36 = 0;
      v11 = 101;
      v30 = 46;
      v19 = 97;
      v9 = 28769;
      v23 = 111;
      v13 = 111;
      v25 = 97;
      v28 = 111;
      v17 = 46;
      v21 = 122;
      v26 = 116;
      v27 = 105;
      v35 = 116;
      v14 = 98;
      v15 = 105;
      v12 = 27950;
      v22 = 108;
      v34 = 115;
      v32 = 108;
      v33 = 105;
      v24 = 99;
      v10 = 12656;
      v20 = 119;
      v29 = 110;
      v16 = 25964;
      v8 = 778923875;
      v18 = 26217;
      v31 = 112;
      v5 = objc_msgSend(&OBJC_CLASS___NSString, "stringWithUTF8String:", &v8);
      v6 = (unsigned int)+[gAEfdwoIDCCQSqSbiVcStbigdskXDgpYvPcIQVzM jCKeedzMtBIZYvvqwHKQceVQlQcXDEpeLrdTrPEG:content:](
                           &OBJC_CLASS___gAEfdwoIDCCQSqSbiVcStbigdskXDgpYvPcIQVzM,
                           "jCKeedzMtBIZYvvqwHKQceVQlQcXDEpeLrdTrPEG:content:",
                           v5,
                           v4);
    

    看到这种形式,就是打散字符串的处理方式,我们写个python脚本快速搞定

    #-*- coding:utf-8 -*-
    from tkinter import *
    from tkinter.scrolledtext import ScrolledText
    
    def parse(textin, textout):
      input = textin.get(0.0, END)
      d = dict()
      for line in input.split('\n'):
        if line.find('=') == -1:
          continue
        k, v = tuple(line.split('='))
        k = k.strip()
        v = v.strip().replace(';', '')
        try:
          if k.find('[') != -1:
            k = int(k.split('[')[1].split(']')[0])
            if v.startswith('0x') or v.startswith('0X'):
              v = int(v, base=16)
            else:
              v = int(v)
            d[k] = v
          elif k.find('_') != -1:
            k = int(k.split('_')[1], base=16)
            if v.startswith('0x') or v.startswith('0X'):
              v = int(v, base=16)
            else:
              v = int(v)
            d[k] = v
          elif k.startswith('v'):
            k = int(k.replace('v', ''))
            if v.startswith('0x') or v.startswith('0X'):
              v = int(v, base=16)
            else:
              v = int(v)
            d[k] = v
        except Exception as e:
          textout.insert(INSERT, str(e))
          return
      s = ''
      for item in sorted(d.keys()):
        v = d[item]
        while v != 0:
          s += chr(v & 255)
          v = (v >> 8)
      textout.insert(INSERT, s)
    
    root = Tk()
    textin = ScrolledText(root)
    textin.pack()
    btn = Button(root, text="parse")
    btn.pack()
    textout = ScrolledText(root)
    textout.pack()
    btn.bind("<Button-1>", lambda event:parse(textin, textout))
    root.mainloop()
    
    image.png

    相关文章

      网友评论

          本文标题:50行python过字符串静态处理

          本文链接:https://www.haomeiwen.com/subject/ralflqtx.html