📄 main.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Main
BorderStyle = 3 'Fixed Dialog
Caption = "Trojan Defence v3.0"
ClientHeight = 5145
ClientLeft = 45
ClientTop = 615
ClientWidth = 5010
ControlBox = 0 'False
Icon = "Main.frx":0000
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5145
ScaleWidth = 5010
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 345
Left = 0
TabIndex = 11
Top = 4800
Width = 5010
_ExtentX = 8837
_ExtentY = 609
Style = 1
SimpleText = "Waiting..."
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.CommandButton cmdStopWatch
Caption = "&Stop"
Enabled = 0 'False
Height = 765
Left = 4125
Picture = "Main.frx":0442
Style = 1 'Graphical
TabIndex = 3
Top = 2850
Width = 615
End
Begin MSWinsockLib.Winsock wskPort
Index = 0
Left = 3375
Top = 4200
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.CommandButton cmdClearAll
Caption = "N&one"
Height = 765
Left = 4125
Picture = "Main.frx":074C
Style = 1 'Graphical
TabIndex = 1
Top = 1950
Width = 615
End
Begin VB.TextBox txtAddPort
Height = 315
Index = 1
Left = 1950
Locked = -1 'True
TabIndex = 9
TabStop = 0 'False
Top = 4275
Visible = 0 'False
Width = 1365
End
Begin VB.TextBox txtAddPort
Alignment = 1 'Right Justify
Height = 315
Index = 0
Left = 120
TabIndex = 8
Top = 4275
Width = 615
End
Begin VB.CommandButton cmdAddPort
Caption = "Add &port"
Enabled = 0 'False
Height = 315
Left = 825
TabIndex = 7
TabStop = 0 'False
Top = 4275
Width = 1065
End
Begin VB.CommandButton cmdSelectAll
Caption = "&All"
Height = 765
Left = 4125
Picture = "Main.frx":0B8E
Style = 1 'Graphical
TabIndex = 0
Top = 1050
Width = 615
End
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "E&xit"
Height = 765
Left = 4125
Picture = "Main.frx":0FD0
Style = 1 'Graphical
TabIndex = 4
Top = 3750
Width = 615
End
Begin VB.CommandButton cmdStartWatch
Caption = "&Watch"
Height = 765
Left = 4125
Picture = "Main.frx":111A
Style = 1 'Graphical
TabIndex = 2
Top = 150
Width = 615
End
Begin VB.ListBox lstPort
BackColor = &H80000004&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 162
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000001&
Height = 4110
ItemData = "Main.frx":1424
Left = 150
List = "Main.frx":142B
Sorted = -1 'True
Style = 1 'Checkbox
TabIndex = 5
TabStop = 0 'False
Top = 75
Width = 3690
End
Begin VB.Frame Frame1
Height = 4740
Left = 75
TabIndex = 6
Top = -75
Width = 3840
End
Begin VB.Frame Frame2
Height = 4740
Left = 3975
TabIndex = 10
Top = -75
Width = 915
End
Begin VB.Menu mnuDefence
Caption = "&Defence"
Begin VB.Menu mnuWatch
Caption = "&Watch"
End
Begin VB.Menu mnuExit
Caption = "E&xit"
End
End
Begin VB.Menu mnuHelp
Caption = "&Help"
Begin VB.Menu mnuAbout
Caption = "&About"
End
End
Begin VB.Menu mnuSystemTray
Caption = "SysTrayPopUp"
Visible = 0 'False
Begin VB.Menu mnuRestore
Caption = "Stop watching ports"
End
Begin VB.Menu mnuQuit
Caption = "Quit"
End
End
End
Attribute VB_Name = "Main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'Simple Wav Playing Declaration
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
'Boolean used to prevent Form_Activate running more than once
Private blnStartUp As Boolean
Private Sub ExitTrojanDefence()
'I'm not going to explain this
Unload Me
End Sub
Private Sub GoSystemTray()
'Put application in SysTray and wait for port attack
VBGTray.cbSize = Len(VBGTray)
VBGTray.hwnd = Me.hwnd
VBGTray.uId = vbNull
VBGTray.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
VBGTray.ucallbackMessage = WM_MOUSEMOVE
VBGTray.hIcon = Me.Icon
'tooltiptext
VBGTray.szTip = Me.Caption & vbNullChar
Call Shell_NotifyIcon(NIM_ADD, VBGTray)
'Hide the main form and enable the SysTray pop-up menu
Me.Hide
Me.mnuQuit.Enabled = True
Me.mnuRestore.Enabled = True
End Sub
Private Sub mnuQuit_Click()
'Selected from pop-up menu in SysTray
StopWatch
ExitTrojanDefence
End Sub
Private Sub mnuRestore_Click()
'Selected from pop-up menu in SysTray
'Restore from systray and stop watching ports
StopWatch
Me.Show
'Disable SysTray pop-up menu
Me.mnuQuit.Enabled = False
Me.mnuRestore.Enabled = False
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static lngMsg As Long
Static blnFlag As Boolean
Dim result As Long
lngMsg = X / Screen.TwipsPerPixelX
If blnFlag = False Then
blnFlag = True
Select Case lngMsg
'doubleclick
Case WM_LBUTTONDBLCLICK
'Restore from systray
StopWatch
Me.Show
'Disable SysTray pop-up menu
Me.mnuQuit.Enabled = False
Me.mnuRestore.Enabled = False
'right-click
Case WM_RBUTTONUP
result = SetForegroundWindow(Me.hwnd)
'This menu is on frmTrjDfc2, but hidden
Me.PopupMenu mnuSystemTray
End Select
blnFlag = False
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
VBGTray.cbSize = Len(VBGTray)
VBGTray.hwnd = Me.hwnd
VBGTray.uId = vbNull
Call Shell_NotifyIcon(NIM_DELETE, VBGTray)
End Sub
Private Sub EnableDisable(blnOnOff As Boolean)
'Enable or Disable controls on form
lstPort.Enabled = blnOnOff
txtAddPort(0).Enabled = blnOnOff
cmdAddPort.Enabled = blnOnOff
cmdClearAll.Enabled = blnOnOff
cmdExit.Enabled = blnOnOff
cmdSelectAll.Enabled = blnOnOff
cmdStartWatch.Enabled = blnOnOff
mnuDefence.Enabled = blnOnOff
mnuHelp.Enabled = blnOnOff
cmdStopWatch.Enabled = Not (blnOnOff)
End Sub
Private Sub AttackDetected(intIndex As Integer)
'Called from wskPort_ConnectionRequest
Me.Show
'Disable SysTray pop-up menu
Me.mnuQuit.Enabled = False
Me.mnuRestore.Enabled = False
'Display report of attack
frmAttackDetails.Show
'Populate text boxes on report form using index of winsock control
frmAttackDetails.txtPortAttacked = Left(lstPort.List(intIndex), 5)
frmAttackDetails.txtAttackingTrojan = Mid(lstPort.List(intIndex), 8)
frmAttackDetails.cmdGet.Value = True 'This button for Close your Net connection
frmAttackDetails.txtAttckrsIP = wskPort(intIndex).RemoteHostIP
frmAttackDetails.txtAttckrsPort = wskPort(intIndex).RemotePort
frmAttackDetails.Logs_save.Value = True 'For Attacker info logs Save
'Notify attack with sound
If Len(App.Path) = 3 Then
'Running in root directory
sndPlaySound App.Path & "connect.wav", &H1
Else
'Running in subfolder
sndPlaySound App.Path & "\connect.wav", &H1
End If
End Sub
Public Function ByteToString(bytString() As Byte) As String
Dim i As Integer
ByteToString = ""
i = 0
While bytString(i) = 0&
ByteToString = ByteToString & Chr(bytString(i))
i = i + 1
Wend
End Function
Private Sub StopWatch()
Dim intSelect As Integer
'Loop through all selected ports and close winsock
For intSelect = 0 To lstPort.ListCount - 1
If lstPort.Selected(intSelect) Then
wskPort(intSelect).Close
While wskPort(intSelect).State
DoEvents
Wend
'If winsock control was created at Runtime then unload it
If intSelect > 0 Then
Unload wskPort(intSelect)
End If
End If
Next intSelect
'Re-enable form's controls
EnableDisable True
End Sub
Private Sub StartWatch()
Dim intSelect As Integer
Dim wskNew As Winsock
Dim lngPortCount As Long
Dim blnNoWatch As Boolean
Dim strNoWatch As String
lngPortCount = 0
strNoWatch = ""
'Loop through all selected ports and create a new
'member of the winsock control array to watch that port
For intSelect = 0 To lstPort.ListCount - 1
If lstPort.Selected(intSelect) Then
'reset flag
blnNoWatch = False
'Create a new control if more than one port selected
If intSelect > 0 Then
Load wskPort(intSelect)
End If
wskPort(intSelect).Close
While wskPort(intSelect).State
DoEvents
Wend
'Set port to watch
wskPort(intSelect).LocalPort = CLng(Left(lstPort.List(intSelect), 5))
'The usual cause of an error here is that the
'port is already in use
On Error GoTo NoWatch
wskPort(intSelect).Listen
'If winsock control initiated ok then keep count
If Not (blnNoWatch) Then
lngPortCount = lngPortCount + 1
End If
End If
Next intSelect
'display a list of failed attempts to watch a port
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -