?----------------------------------------------------------------------------------------------------
做外掛的人都知道,目前有兩種辦法制作網(wǎng)絡(luò)游戲外掛。一種是封包式另外一種是內(nèi)存式!下面就給大家制作一個(gè)抓包器,來(lái)研究一下,網(wǎng)絡(luò)游戲的數(shù)據(jù)!
----------------------------------------------------------------------------------------------------
sub
=0
=1,,"源ip",2,,"源端口",3,,"目標(biāo)ip",4,,"目標(biāo)端口",5,,"協(xié)議",6,,"時(shí)間",1500
endsub
sub
calls
endsub
sub
dim
dim,
dim,=""'清除
dim
=then'如果控件沒(méi)有數(shù)值則提示錯(cuò)誤
exitsub
end
'將的值(即通過(guò)接收的數(shù)據(jù)包)轉(zhuǎn)換為一定格式并在控件下顯示出來(lái)
fori=
coun=coun+1
lenhexi=1then
sar="0"&hexi
else
sar=hexi
end
sar3=sar3&sar
ascchr"&h"&hexi
sar1="."
else
sar1=chr"&h"&hexi
end
sar2=sar2&=&sar&""
coun==&"|"&sar2&
coun=0
sar2=""
sar3=""
end
nexti
coun
=-coun*3+1
=r,chr32
=&&"|"&sar2
end
endsub
sub
=""
endsub
'程序開(kāi)始捕捉
sub
=""
ip,'開(kāi)始截取封包
endsub
sub
=true'停止截取封包
endsub
sub,,,
=+1
s,1
=truethen
calls
=
"退出",,"數(shù)據(jù)封包截取"
end
endsub
模塊:
'用來(lái)判斷所支持的版本,也就是初始化dll,其中第一個(gè)參數(shù)為你所想需要的版本!低字節(jié)為主版本,高字節(jié)為副版本!由于目前有兩個(gè)版本:1.1和2.2,因此該參數(shù)可以是或;第二個(gè)參數(shù)是一個(gè)結(jié)構(gòu),用于接收函數(shù)的返回信息!函數(shù)調(diào)用成功會(huì)返回0,否則返回非0值!
'用來(lái)關(guān)閉,與一起使用,即也可以看為啟動(dòng)
'用來(lái)返回一個(gè)關(guān)于主機(jī)信息的結(jié)構(gòu)的指針
lib"""",long
lib""""long
sublib"""",,
lib""""long
lib"""",long
lib""long
lib"",long
lib""long
lib""long
recvlib"",,,long
lib""long,,long
lib"",,,long
lib"",,,,,,,,long
lib""long
bindlib"",,
lib""
type
*255
*128
endtype
'sock地址結(jié)構(gòu)
type
*8
endtype
type
endtype
'ip頭結(jié)構(gòu)
type
endtype
'tcp頭結(jié)構(gòu)
type
endtype
'udp頭結(jié)構(gòu)
type
endtype
'icmp頭結(jié)構(gòu)
type
endtype
'常量
=2
=3
=2
=&h1
=
=&hc2
,
,為臨時(shí)變量,循環(huán)語(yǔ)句用,用來(lái)計(jì)算一共有多少個(gè)數(shù)據(jù)包
'存放數(shù)據(jù)包
'返回值,臨時(shí)變量
'退出標(biāo)識(shí)
'開(kāi)始
sub
dim
call,data'初始化為2.2
endsub
'結(jié)束
sub
call'關(guān)閉
s
endsub
'獲得當(dāng)前主機(jī)的
ip
dim
dim
dim
dim
host,,lenhost'將獲得的值放到host
pip,,4'將的值放到pip
uip,pip,4'將pip的值放到uip
=uip'將uip轉(zhuǎn)換為標(biāo)準(zhǔn)的ipv4格式
=s'去掉空格
cul=ss,s
='獲得ipv4格式的地址并將其放如
end
'獲得當(dāng)前機(jī)器的主機(jī)名
dim
dim
dim
host=255,0
=host,255'獲得當(dāng)前主機(jī)的主機(jī)名
=0then
=lefthost,1,host,-1
end
end
'連接
sub,
dim,,
buf=1
'初始化
=,,0'創(chuàng)建套接字,s是功能返回的文件描述符
calls
exitsub'如果創(chuàng)建失敗則退出
end='類(lèi)型
=ip'所用的ip地址
res=binds,sock,lensock'綁定端口
res
calls
exitsub'如果綁定失敗則退出
end
res=s,,buf,lenbuf,0,0,bufb,0,0'改變io模式,將其改為混亂模式,即接受與自己無(wú)關(guān)的數(shù)據(jù),則
res
calls
exitsub
end
res=s,,,'設(shè)置套接字處于阻塞方式或者非阻塞方式,消息發(fā)送的窗口是pic,即
res
calls
exitsub
end
endsub
'接收信息
sub,
=then
2000'重定義緩沖區(qū)大小為2000
res=recvs,0,2000,0&'接收信息
res>0then
'改變數(shù)組大小,并保留以前的數(shù)據(jù)
str=
=res
,0,len'將里面的數(shù)據(jù)復(fù)制到結(jié)構(gòu)里面
'根據(jù)ip頭結(jié)構(gòu)的標(biāo)識(shí)來(lái)獲得是什么類(lèi)型的數(shù)據(jù)包,并將從頭結(jié)構(gòu)中分離出來(lái)
=1then
="icmp"
hex,hex
end=6then
="tcp"
hex,hex
end=then
="udp"
hex,hex
end
end
loopres
end
endsub
'將進(jìn)制轉(zhuǎn)換為地址
dim
caselenlng
case1
lng=""&lng
case2
lng=""&lng
case3
lng=""&lng
case4
lng="0000"&lng
case5
lng="000"&lng
case6
lng="00"&lng
case7
lng="0"&lng
end
fori=1lenlngstep2
ips=ips&val"
百度搜“鄉(xiāng)村911”直達(dá)本站!