python Escaped String 和 Hex Stre

2019-10-25  本文已影响0人  黑小柴
Escaped_String=
"\x00\x1b\x1b\x82\x69\x1e\x08\x00\x06\x01\x00\x00\x08\x00\x45\x00" \
"\x00\x4b\x01\x7c\x40\x00\x3c\x06\xb3\x50\xc0\xa8\x04\x8d\xc0\xa8" \
"\x04\x03\x00\x66\xfe\x21\x10\x8f\x36\x83\x31\x2a\x46\x34\x50\x18" \
"\x0b\x68\x21\xf6\x00\x00\x03\x00\x00\x23\x02\xf0\x80\x32\x07\x00" \
"\x00\x05\x00\x00\x0c\x00\x06\x00\x01\x12\x08\x12\x84\x02\x03\x00" \
"\x00\x00\x00\xff\x09\x00\x02\x02\x00"

Hex_Stream='001b1b82691e08000601000008004500004b017c40003c06b350c0a8048dc0a804030066fe21108f3683312a463450180b6821f600000300002302f080320700000500000c0006000112081284020300000000ff0900020200'

import binascii


a='\x01\x01'

print a

b=binascii.hexlify(a)

print b

b1=binascii.unhexlify(b)

print b1

c=int (b,16)

print c
   
d=hex(c)

print d

e=d[2:]

print e

if(len(e)%2==1):
    e='0'+e

print e

结果

��
0101
��
257
0x101
101
0101

BitFlip任意字符串:

import binascii



a='\x03\xaa\xfc'
c=''
for i in range(len(a)):
    b=str(hex(255-int(binascii.hexlify(a[i]),16)))[2:]
    if(len(b)%2==1):
        b='0'+b
    print b
    c+=binascii.unhexlify(b)




if c=='\xfc\x55\x03':
    print True

参考资料:
https://www.baidu.com/s?ie=UTF-8&wd=bytes%E5%92%8CHexStr%E4%B9%8B%E9%97%B4%E7%9A%84%E8%BD%AC%E6%8D%A2%20python

http://www.cnblogs.com/japhasiac/p/7739846.html

https://blog.csdn.net/wjzhangcsu/article/details/74989927

上一篇下一篇

猜你喜欢

热点阅读