获取 monlist 命令结果源码,NTP时间服务器 monlist 命令

  • A+
所属分类:lcx
Option Explicit

Public Function HexToByte(ByVal Hex As String) As Byte()
    '将字符串形式的 Hex 值转换为 Byte 数组,例子:HexToByte("202020")
    Dim Tmp() As Byte, L As Long
    Hex = Trim(Replace(Hex, " ", ""))                                           '处理字符串
    L = Len(Hex)                                                                '获取字符串长度
    If (L And 1) Then                                                           '判断是否是奇数
        ReDim Tmp(0)
        MsgBox "Hex 字符串不能是奇数!", vbCritical, "警告"
    Else
        Dim I As Long
        ReDim Tmp(L / 2 - 1)
        For I = 1 To L Step 2                                                   '循环截取
            Tmp((I + 1) / 2 - 1) = Int("&H" & Mid(Hex, I, 2))
        Next I
    End If
    HexToByte = Tmp()
End Function

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim Data() As Byte, I As Long
    Winsock1.GetData Data()
    For I = 83 To UBound(Data()) Step 32
        Text1.Text = Text1.Text & Data(I + 5) & "." & Data(I + 6) & "." & Data(I + 7) & "." & Data(I + 8) & vbCrLf
    Next
End Sub

Private Sub Command1_Click()
    Dim Hex As String
    Hex = "1700022a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    Text1.Text = ""
    Winsock1.Close
    Winsock1.Protocol = sckUDPProtocol                                          'UDP 模式
    Winsock1.RemoteHost = ntp.Text                                              '远程地址(域名或IP)
    Winsock1.RemotePort = 123                                                   '远程端口
    Winsock1.Bind 9999                                                          '本地端口(可选,不指定则随机)
    Winsock1.SendData HexToByte(Hex)                                            '发送数据
End Sub

Exe 下载:

MonList.rar

相关内容:

【Python】获取NTP服务器最后活动的IP地址、monlist 命令

Using NTP to Enumerate Client IPs

Linux开启NTP服务会在本月遇到闰秒BUG导致服务器重启!

很少有人注意的一个细节,未来网络战争的严重安全隐患!

留言评论(旧系统):

dashige @ 2013-03-03 18:31:07

恕小菜眼拙,看不懂这是什么代码,难道是vb ?。。。

本站回复:

vb 不是一种语言,vb 是一种开发平台,采用的编程语言是 Basic。

文章来源于lcx.cc:获取 monlist 命令结果源码,NTP时间服务器 monlist 命令

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: