字符串轉十六進制繞過特征檢測SQL注入
Python中內置庫與出色第三方庫的學習
# 字符串轉十六進制
mystr = "hello world"
print(":".join("{:02x}".format(ord(c)) for c in mystr)) # format的參數化格式控制字符串 | join的用法
# str.join()區別於os.path.join()的使用
>>> src = '/var/www/'
>>> des = os.path.join(src,'/blog/html')
>>> des
'/blog/html'
>>> src
'/var/www/'
>>> des = os.path.join(src,'blog')
>>> des
'/var/www/blog'
# 字符串,十六進制流相互轉換
>>> data = b"<?php eval($GET['id'])?>"
>>> print(binascii.hexlify(data))
b'3c3f706870206576616c28244745545b276964275d293f3e'
>>> enc = b'3c3f706870206576616c28244745545b276964275d293f3e'
>>> print(binascii.unhexlify(enc))
b"<?php eval($GET['id'])?>"