-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmIPBox.frm
340 lines (290 loc) · 8.07 KB
/
frmIPBox.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmIPBox
Caption = "IP BreakOut Box By Mike Down"
ClientHeight = 4455
ClientLeft = 60
ClientTop = 345
ClientWidth = 9855
LinkTopic = "Form1"
ScaleHeight = 4455
ScaleWidth = 9855
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command1
Caption = "CLS"
Height = 375
Left = 9390
TabIndex = 12
Top = 30
Width = 435
End
Begin MSWinsockLib.Winsock Inet2
Left = 3180
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.CommandButton cmdListen
Caption = "Listen"
Height = 375
Left = 8790
TabIndex = 11
Top = 30
Width = 585
End
Begin VB.TextBox txtLocalPort
Height = 285
Left = 3420
TabIndex = 8
Text = "23"
Top = 60
Width = 525
End
Begin VB.TextBox txtLocalIP
BackColor = &H00C0C0C0&
Height = 285
Left = 510
Locked = -1 'True
TabIndex = 7
Top = 60
Width = 2505
End
Begin VB.TextBox txtRemotePort
Height = 285
Left = 7500
TabIndex = 4
Text = "23"
Top = 60
Width = 525
End
Begin VB.OptionButton opUDP
Caption = "UDP"
Enabled = 0 'False
Height = 225
Left = 8070
TabIndex = 3
Top = 0
Width = 645
End
Begin VB.TextBox txtRemoteIP
Height = 285
Left = 4590
TabIndex = 1
Top = 60
Width = 2505
End
Begin VB.TextBox txtLog
BackColor = &H00000000&
BeginProperty Font
Name = "Courier New"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 4005
Left = 0
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 450
Width = 9435
End
Begin MSWinsockLib.Winsock Inet
Left = 1110
Top = 600
_ExtentX = 741
_ExtentY = 741
_Version = 393216
Protocol = 1
RemotePort = 53
LocalPort = 53
End
Begin VB.OptionButton opTCP
Caption = "TCP"
Height = 225
Left = 8070
TabIndex = 2
Top = 240
Value = -1 'True
Width = 645
End
Begin VB.Label Label4
Caption = "Local:"
Height = 225
Left = 30
TabIndex = 10
Top = 90
Width = 465
End
Begin VB.Label Label3
Caption = "Port:"
Height = 225
Left = 3060
TabIndex = 9
Top = 90
Width = 345
End
Begin VB.Label Label2
Caption = "Remote:"
Height = 225
Left = 3960
TabIndex = 6
Top = 90
Width = 615
End
Begin VB.Label Label1
Caption = "Port:"
Height = 225
Left = 7140
TabIndex = 5
Top = 90
Width = 345
End
End
Attribute VB_Name = "frmIPBox"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdListen_Click()
Select Case cmdListen.Caption
Case Is = "Listen"
If opTCP.Value Then
Inet.Protocol = sckTCPProtocol
Inet2.Protocol = sckTCPProtocol
Inet.LocalPort = CInt(txtLocalPort.Text)
Inet.RemoteHost = txtRemoteIP.Text
Inet.RemotePort = CInt(txtRemotePort.Text)
txtLocalPort.Enabled = False
txtRemoteIP.Enabled = False
txtRemotePort.Enabled = False
cmdListen.Caption = "Reset"
Inet.Close
Inet.Listen
log "I>Using TCP to Listin on " & Inet.LocalIP & ":" & Inet.LocalPort
Else
Inet.Close
Inet2.Close
Inet.Protocol = sckUDPProtocol
Inet2.Protocol = sckUDPProtocol
Inet.LocalPort = CInt(txtLocalPort.Text)
Inet2.RemoteHost = txtRemoteIP.Text
Inet2.RemotePort = CInt(txtRemotePort.Text)
txtLocalPort.Enabled = False
txtRemoteIP.Enabled = False
txtRemotePort.Enabled = False
cmdListen.Caption = "Reset"
Inet.Bind CInt(txtLocalPort.Text)
' Inet2.Bind CInt(txtRemotePort.Text)
log "I>Using UDP to Listin on " & Inet.LocalIP & ":" & Inet.LocalPort
End If
Case Is = "Reset"
Inet.Close
txtLocalPort.Enabled = True
txtRemoteIP.Enabled = True
txtRemotePort.Enabled = True
cmdListen.Caption = "Listen"
End Select
End Sub
Private Sub Command1_Click()
txtLog.Text = ""
End Sub
Private Sub Form_Load()
txtLocalIP.Text = Inet.LocalIP
End Sub
Private Sub Form_Resize()
If Not Me.WindowState = vbMinimized Then
txtLog.Width = Me.ScaleWidth
txtLog.Height = Me.Height - 850
End If
End Sub
Private Sub Inet_Close()
log "I>INET EVENT: CLOSED CONNECTION"
Inet2.Close
cmdListen_Click
cmdListen_Click
End Sub
Private Sub Inet_Connect()
log "I>INET EVENT: CONNECT"
End Sub
Private Sub Inet_ConnectionRequest(ByVal requestID As Long)
log "I>INET EVENT: CONNECTION REQUEST [ " & requestID & " ]"
If Inet.State <> sckClosed Then Inet.Close
log "I>CONNECTING 0 TO " & txtRemoteIP.Text & ":" & CInt(txtRemotePort.Text)
Inet2.Close
Inet2.Connect txtRemoteIP.Text, CInt(txtRemotePort.Text)
Do Until Inet2.State = sckConnected
DoEvents
Loop
Inet.Accept requestID
End Sub
Private Sub Inet_DataArrival(ByVal bytesTotal As Long)
'On Error GoTo erred
Dim sData As String
Dim bData() As Byte
If opTCP.Value Then
Inet.PeekData sData, vbString
Inet.GetData bData(), vbArray + vbByte
Inet2.SendData bData()
Else
Inet.GetData sData
Inet2.SendData sData
End If
log "I>" & sData
Exit Sub
erred:
Inet.Close
Inet2.Close
cmdListen_Click
cmdListen_Click
End Sub
Private Sub Inet_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
log "I>INET ERROR: " & Number & " = " & Description
End Sub
Public Sub log(Text As String)
On Error GoTo erred
txtLog.Text = txtLog.Text & Text & vbCrLf
txtLog.SelStart = Len(txtLog.Text)
Exit Sub
erred:
txtLog.Text = ""
txtLog.Text = txtLog.Text & Text & vbCrLf
txtLog.SelStart = Len(txtLog.Text)
End Sub
Private Sub Inet2_Close()
log "0>INET EVENT: CLOSED CONNECTION"
Inet.Close
cmdListen_Click
cmdListen_Click
End Sub
Private Sub Inet2_DataArrival(ByVal bytesTotal As Long)
On Error GoTo erred
Dim sData As String
Dim bData2() As Byte
If opTCP.Value Then
Inet2.PeekData sData, vbString
Inet2.GetData bData2(), vbArray + vbByte
Inet.SendData bData2()
Else
Inet2.GetData sData
Inet.SendData sData
End If
log "O>" & sData
Exit Sub
erred:
Inet.Close
Inet2.Close
cmdListen_Click
cmdListen_Click
End Sub
Private Sub Inet2_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
log "O>INET ERROR: " & Number & " = " & Description
End Sub
Private Sub txtLocalPort_Change()
txtRemotePort.Text = txtLocalPort.Text
End Sub