⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmwebatk.frm

📁 全面网络扫描器VB源代码 很实用
💻 FRM
📖 第 1 页 / 共 3 页
字号:
    ElseIf session_procedure_type = "exploit" Then
        session_procedure_commands = plugin_procedure_exploit
    Else
        Call SetPluginSessionProcedure
    End If
    
    'Replace the ATK scripting language variants
    If InStrB(1, session_procedure_commands, "$DHOST", vbBinaryCompare) Then
        session_procedure_commands = Replace(session_procedure_commands, "$DHOST", target, , , vbBinaryCompare)
    End If
    
    If InStrB(1, session_procedure_commands, "$DPORT", vbBinaryCompare) Then
        session_procedure_commands = Replace(session_procedure_commands, "$DPORT", plugin_port, , , vbBinaryCompare)
    End If
    
    'Split the commands in the request apart
    Command = Split(session_procedure_commands, "|")
    
    'Count the commands of this check
    CommandCount = UBound(Command)
   
    'Start the attack timeout timer
   
   '{**************************
    'timTimeout.Interval = application_attack_timeout
    'timTimeout.Enabled = False
    'timTimeout.Enabled = True
   ' }

   For I = 0 To CommandCount
        'We need this if the timeout comes before a send command; I have to check this
        On Error Resume Next
        
        If Mid$(Command(I), 1, 4) = "open" Then
            Dim Try As Integer
            Dim OpenTarget As String
            
            'Check the target host
            If Len(Command(I)) > 4 Then
                OpenTarget = Mid$(Command(I), 6, Len(Command(I)))
            Else
                OpenTarget = target
            End If
            
             
            'Open a new connection using the target data
'            WriteLogEntry "Opening socket to " & OpenTarget & ":" & plugin_port, 6
            Winsock1.Close
            Winsock1.Connect OpenTarget, plugin_port
            'Winsock1.Connect OpenTarget, plugin_port
            
'            If IsFormVisible("frmAttackVisualizing") = True Then
'                Call frmAttackVisualizing.VisualizeOpenConnection
'            End If
           
            application_attack_timeout = CInt(txtdelay.Text)
            'Wait a few moments for a successful connection
            Do While Winsock1.State <> sckConnected
               Debug.Print Winsock1.State
                If Try < application_attack_timeout * 2 Then
                    Sleep 1
                    DoEvents
                    Try = Try + 1
                Else
                    Exit Do
                End If
            Loop
        
        ElseIf Mid$(Command(I), 1, 5) = "close" Then
            'If timTimeout.Enabled = True Then
                'Call to close the socket
                'Call Winsock1.Close
            'End If
            
            'If IsFormVisible("frmAttackVisualizing") = True Then
            '    Call frmAttackVisualizing.VisualizeCloseConnection
            'End If
        DoEvents
        ElseIf Mid$(Command(I), 1, 4) = "send" Then
            Dim DataToSend As String
             Debug.Print Winsock1.State
            
               
                If Len(Command(I)) > 5 Then
                    DataToSend = Replace(Mid$(Command(I), 6, Len(Command(I))), "\n", vbNewLine, , , vbBinaryCompare)
    
                    'Send the request with its needed command and linefeeds
                   Debug.Print DataToSend
                    
                   If Winsock1.RemotePort = 80 And targethost <> "" Then
                     Winsock1.SendData DataToSend + "Host: " + targethost + vbCrLf
                    ' MsgBox DataToSend + "Host: " + targethost + vbCrLf
                     

                   Else
                     Winsock1.SendData DataToSend
                   End If
                
                Else
                    'Send a "blank" request if the param1 is empty
                    DataToSend = vbNewLine
                    Winsock1.SendData DataToSend
                End If
                
'                WriteLogEntry "Sending data """ & Mid$(DataToSend, 1, 64) & """ ...", 6
            
'                If IsFormVisible("frmAttackVisualizing") = True Then
'                    Call frmAttackVisualizing.VisualizeSendData(DataToSend)
'                End If
           
        
        ElseIf Mid$(Command(I), 1, 5) = "sleep" Then
'            If timTimeout.Enabled = True Then
                Dim SleepTime As Integer    'Save the time wanted to sleep
            
                If Len(Command(I)) > 5 Then
                    'Sleep as long as requested
                    SleepTime = (Mid$(Command(I), 7, Len(Command(I))))
                Else
                    'Sleep default seconds if parameter is missing
                    SleepTime = application_sleep_time_default / 100
                End If
            
               ' If IsFormVisible("frmAttackVisualizing") = True Then
               '     Call frmAttackVisualizing.VisualizeSleep(SleepTime)
               ' End If
                
               ' WriteLogEntry "Sleeping for " & SleepTime & " seconds ...", 6
                Sleep (SleepTime)
'            End If
        ElseIf Mid$(Command(I), 1, 8) = "pattern_" Then
            'Dev note: We have to visualize the search for the pattern before we run the
            'routines for found or not found. This is because we want to keep the order of
            'the visualizing.
            l = 0
            Do Until Winsock1.State = 0 Or l = 100
               DoEvents
               Sleep 1
               l = l + 1
            Loop

            If Mid$(Command(I), 1, 14) = "pattern_exists" Then
                If Len(Command(I)) > 15 Then
                    session_triggers = Mid$(Command(I), 16, Len(Command(I)))
                    
                    'If IsFormVisible("frmAttackVisualizing") = True Then
                    '    Call frmAttackVisualizing.VisualizePatternExists(session_triggers)
                    'End If
                    
                    Call PatternExists(session_triggers)
                End If
            ElseIf Mid$(Command(I), 1, 18) = "pattern_not_exists" Then
                If Len(Command(I)) > 19 Then
                    session_triggers = Mid$(Command(I), 20, Len(Command(I)))
                    
                    'If IsFormVisible("frmAttackVisualizing") = True Then
                    '    Call frmAttackVisualizing.VisualizePatternExists(session_triggers)
                    'End If
                    
                    Call PatternNotExists(session_triggers)
                End If
            End If
        ElseIf Mid$(Command(I), 1, 10) = "icmp_alive" Then
            'Send ICMP ping
            Dim ECHO As ICMP_ECHO_REPLY
            
            'ping an ip address, passing the
            'address and the ECHO structure
            
'******            Call Ping(GetIPFromHostName(target), ECHO)
              
            'display the results from the ECHO structure
            If GetStatusCode(ECHO.Status) = 0 Then
                Call VulnerabilityNotFound
            Else
                Call VulnerabilityFound
            End If
        
        ElseIf Mid$(Command(I), 1, 3) = "run" Then
            Dim strRunCommand As String
            Dim strRunCommandFileName As String
        
            'get the selected command to run
            strRunCommand = (Mid$(Command(I), 5, Len(Command(I))))
            
            strRunCommandFileName = application_response_directory & target & "-runcommandresponse.txt"
            
            'run the selected command
            Shell Environ("Comspec") + " /C " & strRunCommand & " > " & strRunCommandFileName, vbMinimizedNoFocus
            
            'wait until the command is finished
            Sleep (application_sleep_time_default / 1000)
            
            'put the last response of the command run in the last response variant
            intFreeFile = FreeFile
            Open strRunCommandFileName For Input As #intFreeFile
                LastResponse = Input(LOF(intFreeFile), #intFreeFile)
            Close
            
'*************            Call LoadLatestResponse
        End If
        
        'Add for every command the progress bar
       ' If application_attack_mode = "SingleCheck" Then
'**********     '     SetProgress pbrProgress.Value + 100 / (CommandCount + 1)
       ' End If
        
    Next I
    
    'Finish the progress bar
'    If application_attack_mode = "SingleCheck" Then
'**********        SetProgress 100
'    End If
End Sub

' *********************************************************************
' * This routine is the "brain" of a pattern-based check. Here is the *
' * decision made, if the pattern can be found in the server response.*
' *********************************************************************

Private Sub PatternExists(ByRef strPattern As String)
    Dim I As Integer            'The integer for the OR counter
    Dim Patterns() As String    'The array for multiple patterns
    Dim PatternCount As Integer 'The count of the patterns
    
    'Split the multiple OR patterns
    Patterns = Split(strPattern, " OR ")
    
    PatternCount = UBound(Patterns)
    
    'Check for the existence of one of the patterns
    For I = 0 To PatternCount
        'Check if the string DOES exists in the response; also do a
        'regulary expression check. One of them should recognize the flaw.
        If InStr(1, LastResponse, Patterns(I)) <> 0 Or _
            LastResponse Like Patterns(I) Then
            
            'Call the VulnFound procedure if the pattern was found
            Call VulnerabilityFound
            
            'Write the new pattern. This is needed to check the pattern
            'in the response window and to show the found pattern in
            'the scan report.
            session_trigger_match = Patterns(I)
            
            'Exit the sub if the vulnerability was found
            Exit Sub
        End If
    Next I
    
    'Call the VulnNotFound procedure if the pattern was not found
    Call VulnerabilityNotFound
End Sub

Private Sub PatternNotExists(ByRef strPattern As String)
    Dim I As Integer            'The integer for the OR counter
    Dim Patterns() As String    'The array for multiple patterns
    Dim PatternCount As Integer 'The count of the patterns
    
    'Split the multiple OR patterns
    Patterns = Split(strPattern, " OR ")
    
    PatternCount = UBound(Patterns)
    
    'Check for the existence of one of the patterns
    For I = 0 To PatternCount
        'Check if the string DOES exists in the response; also do a
        'regulary expression check. One of them should recognize the flaw.
        
        If InStr(1, LastResponse, Patterns(I)) <> 0 Or _
            LastResponse Like Patterns(I) Then
            
            'Call the VulnFound procedure if the pattern was found
            Call VulnerabilityNotFound
            
            'Write the new pattern. This is needed to check the pattern
            'in the response window and to show the found pattern in
            'the scan report.
            session_trigger_match = Patterns(I)
            
            'Exit the sub if the vulnerability was found
            Exit Sub
        End If
    Next I
    
    'Call the VulnNotFound procedure if the pattern was not found
    Call VulnerabilityFound
End Sub

' **********************************************************************
' * This routine calls everything that is needed, if the vulnerability *
' * could be found with the used check.                                *
' **********************************************************************

Private Sub VulnerabilityFound()
    Dim strAlertingText As String
   sek = frmatkreport.ListView1.ListItems.Count
   frmatkreport.ListView1.ListItems(sek).SubItems(8) = "Found"
    frmatkreport.ListView1.ListItems(sek).ForeColor = vbRed
    
    strAlertingText = "The vulnerability " & plugin_name & _
        " was found on port " & plugin_protocol & "/" & plugin_port & _
        " of the host " & target & "."
    
    'Message if the vulnerability was found
    lblVulnerabilityState.Caption = strAlertingText
    lblVulnerabilityState.BackColor = &HC0C0FF
    'WriteLogEntry "Vulnerability found! Ready.", 5
    
    'Write the pluginname into the report
''    Call WritePluginNameToReportFile(plugin_filename & ";1;" & Date & ";" & Time)

    'If IsFormVisible("frmAttackVisualizing") = True Then
    '    Call frmAttackVisualizing.VisualizeVulnerabilityFound
    'End If

    'Show the alert message
    If application_vulnerability_found_alert_enable = True Then
        MsgBox strAlertingText, _
            vbExclamation, "Attack Tool Kit vulnerability found"
    End If

    'Speak the status that the vulnerability seems to be found
'    Call ReadText("Check is finished. The vulnerability was found.")
End Sub

' **********************************************************************
' * This routine calls everything that is needed, if the vulnerability *
' * could not be found with the used check.                            *
' **********************************************************************
Private Sub VulnerabilityNotFound()
    Dim strAlertingText As String
    
   sek = frmatkreport.ListView1.ListItems.Count
   frmatkreport.ListView1.ListItems(sek).SubItems(8) = "Not Found"
   
    strAlertingText = "The vulnerability " & plugin_name & _
        " was not found on port " & plugin_protocol & "/" & plugin_port & _
        " of the host " & target & "."
    
    'Message if the vulnerability was found
    lblVulnerabilityState.Caption = strAlertingText
    lblVulnerabilityState.BackColor = &HC0FFC0


'*********************    WriteLogEntry "Vulnerability not found. Ready.", 5

    'Write the pluginname into the report
'******    Call WritePluginNameToReportFile(plugin_filename & ";0;" & Date & ";" & Time)
    
'    If IsFormVisible("frmAttackVisualizing") = True Then
'        Call frmAttackVisualizing.VisualizeVulnerabilityNotFound
'    End If

    'Show the alert message
    If application_vulnerability_not_found_alert_enable = True Then
        MsgBox "The vulnerability " & plugin_name & vbNewLine & _
        " was not found on port " & plugin_protocol & "/" & plugin_port & " of the host " & target & ".", _
            vbInformation, "Attack Tool Kit vulnerability not found"
    End If
    
'***********    Call ReadText("Check is finished. The vulnerability was not found.")
End Sub






' ******************************************************************
' * This routine freezes the window, so the user can't give input. *
' * The main reason is to prevent unexpected behaviour during      *
' * checks or other long-term procedures.                          *
' ******************************************************************


Private Sub wsckClientudp_Error(Index As Integer, 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)

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -