怎樣寫遠程緩沖區溢出漏洞利用程序
在此,我們假設有一個有漏洞的服務器程序(vulnerable.c). 然後寫一個 eXPloit 來利用該漏洞,這樣將能得到一個遠程 shell。
一、理解有漏洞程序:
--------------------------------------- vulnerable.c ---------------------------------
#include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>
#define BUFFER_SIZE 1024
#define NAME_SIZE 2048
int handling(int c)
{
char buffer[BUFFER_SIZE], name[NAME_SIZE];
int bytes;
strcpy(buffer, "My name is: ");
bytes = send(c, buffer, strlen(buffer), 0);
if (bytes == -1)
return -1;
bytes = recv(c, name, sizeof(name), 0);
if (bytes == -1)
return -1;
name[bytes - 1] = ’