idna與utf-8編碼漏洞


來自Black hat 2019
原理
什么是IDN?
國際化域名(Internationalized Domain Name,IDN)又名特殊字符域名,是指部分或完全使用特殊文字或字母組成的互聯網域名,包括中文、發育、阿拉伯語、希伯來語或拉丁字母等非英文字母,這些文字經過多字節萬國碼編碼而成。在域名系統中,國際化域名使用punycode轉寫並以ASCII字符串存儲。

什么是idna?
A library to support the Internationalised Domain Names in Applications (IDNA) protocol as specified in RFC 5891. This version of the protocol is often referred to as “IDNA2008” and can produce different results from the earlier standard from 2003.
>>> import idna
>>> print(idna.encode(u'ドメイン.テスト'))
結果:xn--eckwd4c7c.xn--zckzah
>>> print idna.decode('xn--eckwd4c7c.xn--zckzah')
結果:ドメイン.テスト

Demo:
℆這個字符,如果使用python3進行idna編碼的話
print('℆'.encode('idna'))
結果
b'c/u'
如果再使用utf-8進行解碼的話
print(b'c/u'.decode('utf-8'))
結果
c/u
通過這種方法可以繞過網站的一些過濾字符


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM