#NoTrayIcon
Dim $Ipaddr,$prot,$const=1,$const2=1,$const3=1,$const4=1,$const5=1,$returns,$returns2,$file,$fileopen
Local $socker
While $const=1
$Ipaddr=""
$prot=""
$const=1
$const2=1
$const3=1
$const4=1
$const5=1
$socker=""
$returns=""
$returns2=""
$file=""
While $const2=1
$Ipaddr=InputBox("端口监听器","请输入IP地址:")
If $Ipaddr="" Then
MsgBox(0,"输入错误!","IP地址不能为空!")
Else
If $Ipaddr="exit" Then
Exit
Else
$const2=0
EndIf
EndIf
WEnd
While $const3=1
$prot=InputBox("端口监听器","请输入端口号:")
If $prot="" Then
MsgBox(0,"输入错误!","端口号不能为空!")
Else
If $prot<=65535 Then
If $prot="exit" Then
Exit
Else
$const3=0
EndIf
Else
MsgBox(0,"输入错误!","该端口号大于65535,不存在该端口!")
EndIf
EndIf
WEnd
While $const4=1
$file=InputBox("端口监听器","请输入监听日志路径:")
If $file="" Then
$file="D:\log.txt"
$const4=0
Else
If $file="exit" Then
Exit
Else
$const4=0
EndIf
EndIf
WEnd
While $const5=1
TCPStartup()
TCPConnect($Ipaddr,$prot)
$socker=TCPListen($Ipaddr,$prot,100)
$returns=TCPRecv($socker,2048,1)
If $returns<>"" Then
BinaryToString($returns)
$fileopen=FileOpen($file,1)
FileWrite($fileopen,$returns)
Else
$fileopen=FileOpen($file,1)
FileWrite($fileopen,"程序未在该端口上监听到任何数据!"&@CRLF)
EndIf
FileClose($fileopen)
TCPCloseSocket($socker)
TCPShutdown()
HotKeySet("{ESC}","ExitS")
WEnd
$returns2=MsgBox(1,"端口扫描器","是否退出?")
If $returns2=1 Then
Exit
EndIf
WEnd
Func ExitS()
$const5=0
EndFunc
|