破坏和重构恶意url
defang的Python项目详细描述
破坏和重构恶意URL
用法
作为脚本:使用defang命令进行defang或“refang” 内容,支持 stdin/stdout流和磁盘上的文件的往返:
$ echo http://evil.example.com/malicious.php | defang hXXp://evil.example[.]com/malicious.php
作为库:
>>> from defang import defang >>> url = "http://evil.example.com/malicious.php" >>> defang(url) 'hXXp://evil.example[.]com/malicious.php'
我们添加了一些新的关键字参数选项:
>>> defang(url, colon=True) 'hXXp[:]//evil.example[.]com/malicious.php' >>> defang(url, all_dots=True) 'hXXp://evil[.]example[.]com/malicious.php' >>> defang(url, zero_width_replace=True) 'h\u200bt\u200bt\u200bp\u200b:\u200b/\u200b/\u200be\u200bv\u200bi\u200bl\u200b.\u200be\u200bx\u200ba\u200bm\u200bp\u200bl\u200be\u200b.\u200bc\u200bo\u200bm\u200b/\u200bm\u200ba\u200bl\u200bi\u200bc\u200bi\u200bo\u200bu\u200bs\u200b.\u200bp\u200bh\u200bp' # printed as 'http://evil.example.com/malicious.php'
释放量
- 0.5.3:
- 合并到可选功能中以拆分零宽度字符。
- 0.5.2:
- 在我的上一个补丁中留下了一条调试打印消息…删除了它。
- 0.5.1:
- 包装在冒号中的重构[:]
- 0.5.0:
- 为defang添加了新选项
- 所有点=真将把所有点变成[.],而不仅仅是tld之前的点
- 冒号=true将http://转换为http[:]//以及其他协议
- 0.4.0:
- 增加了对带有ipv4的uri的支持
- 0.3.0:
- 添加了一些正则表达式修复和任意协议损坏