资源简介
模糊测试作为发现漏洞的重要手段,为每个安全技术人员必须掌握。
本例子作为基础的应用层协议测试例子,代码简短精悍,注释完全,结构清晰,旨在揭示模糊测试原理,为初学者揭开其神秘面纱,对其不再感到困惑,当有抛砖引玉作用。
代码片段和文件信息
/*
* simple_http_fuzzer.c
*
*/
#include
#include
#include
#include
//maximum length to grow out url
#define MAX_NAME_LEN 2048
//max strlen of a valid IP address + null
#define MAX_IP_LEN 16
//static HTTP protocol content into which we insert fuzz string
char request[] = “GET %*s.html HTTP/1.1\r\nHost: %s\r\n\r\n“;
int main(int argc char **argv) {
//buffer to build out long request
char buf[MAX_NAME_LEN + sizeof(request) + MAX_IP_LEN];
//server address structure
struct sockaddr_in server;
int sock len req_len;
if (argc != 3) { //require IP address on the command line
fprintf(stderr “Missing server IP address\n“);
exit(1);
}
memset(&server 0 sizeof(server)); //clear the address info
server.sin_family = AF_INET; //building an IPV4 address
server.sin_port = htons(80); //connecting to port 80
//convert the dotted IP in argv[1] into network representation
if (inet_pton(AF_INET argv[1] &server.sin_addr) <= 0) {
fprintf(stderr “Invalid server IP address: %s\n“ argv[1]);
exit(1);
}
//This is the basic fuzzing loop. We loop growing the url by
//4 characters per pass until an error occurs or we reach MAX_NAME_LEN
for (len = 4; len < MAX_NAME_LEN; len += 4) {
//first we need to connect to the server create a socket...
sock = socket(AF_INET SOCK_STREAM 0);
if (sock == -1) {
fprintf(stderr “Could not create socket quitting\n“);
exit(1);
}
//and connect to port 80 on the web server
if (connect(sock (struct sockaddr*)&server sizeof(server))) {
fprintf(stderr “Failed connect to %s quitting\n“ argv[1]);
close(sock);
exit(1); //terminate if we can‘t connect
}
//build the request string. Request really only reserves space for
//the name field that we are fuzzing (using the * format specifier)
req_len = snprintf(buf sizeof(buf) request len “A“ argv[1]);
//this actually copies the growing number of A‘s into the request
memset(buf + 4 ‘A‘ len);
//now send the request to the server
send(sock buf req_len 0);
//try to read the server response for simplicity‘s sake let‘s assume
//that the remote side choked if no bytes are read or a recv error
//occurs
if (read(sock buf sizeof(buf) 0) <= 0) {
fprintf(stderr “Bad recv at len = %d\n“ len);
close(sock);
break; //a recv error occurred report it and stop looping
}
close(sock);
}
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2516 2013-08-19 14:41 simple_http_fuzzer.c
----------- --------- ---------- ----- ----
2516 1
- 上一篇:De Jong 测试函数及源代码
- 下一篇:GetAlibaba_Setup.rar
相关资源
- 生意参谋采集过程中的链接测试工具
- trainingDigits/testDigits
- BFM testbench PWM APB
- PC RS232 tool
- test2_DXF_cc.rar
- 全功能MODBUS-TCP从站仿真软件
- 力天电子AVR源代码
- DS18B20 资料原理图+test code
- annotation-reflect-test
- Fortran_C_NETCDF_MPI_tests.tar
- 3.4SIL_Test.zip
- test_InverterSPWM_10.psimsch
- 海伦约会-datingTestSet.txt
- OpenGLSETest.zip
- ICT(IN CIRCUIT TESTER)测试原理介绍
- SmartMonkey
- IPcamera Test
- 报文测试器v2.0(tcp/udp报文数据测试)
- TestStand视频教程(初级教程)
- 多线程下无同步和同步的简单对比
- testcomplete7.2企业版注册机
- 对GUI实现自动化 测试的工具
- ActiveX Control Test Container(免积分)
- i2c_master verilog代码+testbench
- ICT新手不得不看的小技巧
- 模糊控制,模糊pid源码
- 蓝牙测试软件.zip
- 吴恩达老师深度学习第二课第二周2
- wcftestClient.exe
- VHDL8位加法器含test_bench)
评论
共有 条评论