AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 42396
Accepted
Kjensen
Kjensen
Asked: 2009-07-18 16:29:52 +0800 CST2009-07-18 16:29:52 +0800 CST 2009-07-18 16:29:52 +0800 CST

防止 Microsoft FTP 服务器 (IIS6/7) 中的暴力攻击

  • 772

查看我的 ftp 服务器日志文件,我发现了很多暴力攻击,其中相同的 IP 地址尝试了 100 多个用户名/密码组合。

我能做些什么来让这些蛮力攻击者的生活更加艰难吗?如果有 y 次登录尝试失败,像 IP 之类的东西会被锁定 x 次?

服务器是 Microsoft Windows Server 2008。

windows-server-2008 ftp security iis brute-force-attacks
  • 3 3 个回答
  • 8820 Views

3 个回答

  • Voted
  1. Best Answer
    Jim B
    2009-07-18T18:09:08+08:002009-07-18T18:09:08+08:00

    请参阅IIS 新闻组中的这篇文章以获取一些解决问题的代码

    下面还有Chrissy Lemaire 的剧本

    '****************************************************************************
    ' This script created by Chrissy LeMaire ([email protected])
    ' Website: http://netnerds.net/
    '
    ' NO WARRANTIES, etc.
    '
    ' This script instantly bans IP addresses trying to login to FTP
    ' using the NT account "Administrator"
    '
    ' Run this script on the FTP server. It sits in the back and waits for an 
    ' event viewer "push" that lets it know someone failed FTP authentication.
    '
    ' This script has only been tested on Windows Server 2003. It assumes, as it 
    ' should, that there are no legitimate Administrator account FTP logins.
    '
    ' "What it does"
    ' 1. Sets an Async Event Sink to notify the script when someone fails MS-FTP auth
    ' 2. When alerted, the script parses the last day's FTP logs for all FTP sites (this
    '    is because the Event Viewer doesn't tell you which FTP site, if you have more than
    '    one, is the one getting hit)
    ' 3. Compiles the list of IPs to be banned and then bans them using IIS /and/
    '    IP level banning (thanks Spencer @ netortech.com for the idea)
    '*****************************************************************************
    
    ' Push Event Viewer Alert
        Set objWMIService = GetObject("winmgmts:{(security)}!root/cimv2")
        Set eventSink = wscript.CreateObject("WbemScripting.SWbemSink", "EVSINK_")
        strWQL = "Select * from __InstanceCreationEvent where TargetInstance isa  'Win32_NTLogEvent' and TargetInstance.SourceName = 'MSFTPSVC' and TargetInstance.EventCode = 100"
        objWMIService.ExecNotificationQueryAsync eventSink,strWQL
    
    ' Keep it going forever
    While (True)
        Wscript.Sleep(1000)
    Wend
    
    Sub EVSINK_OnObjectReady(objObject, objAsyncContext)
      If InStr(LCase(objObject.TargetInstance.Message),"administrator") > 0 Then 
        Set objFTPSVC = GetObject("IIS://localhost/MSFTPSVC")
        Set WshShell = CreateObject("WScript.Shell")
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objLog = CreateObject("MSWC.IISLog")
        Set objDictionary = CreateObject("Scripting.Dictionary")
        Set objFTPIPSec = objFTPSVC.IPSecurity
    
        'Get IP address of server so we can use it later to give the offending IP a bad route
        Set IPConfigSet = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")
        for each IPConfig in IPConfigSet
          if Not IsNull(IPConfig.DefaultIPGateway) then serverIP =  IPConfig.IPAddress(0)
        Next
        Set IPConfigSet = Nothing
    
        'Iterate through each FTP site. See #2 up above.
          For Each objSITE in objFTPSVC
            If lcase(objSITE.class) = "iisftpserver" Then
              ftpLogFilePath =  WshShell.ExpandEnvironmentStrings(objSITE.LogFileDirectory) & "\msftpsvc" & objSITE.Name
    
              Set objFolder = objFSO.GetFolder(ftpLogFilePath)
                Set objFiles = objFolder.Files
                  For Each fileName In objFiles
                    lastFile = fileName
                  Next
                strLogFile = lastFile
                Set file = Nothing
              Set objFolder = Nothing
    
              'Use the IIS log file parser provided by MSFT
              objLog.OpenLogFile strLogFile, 1, "MSFTPSVC", 1, 0 
                '(FileName,IOMode,ServiceName,ServiceInstance,OutputLogFileFormat) 
                ' 0 = NotApplicable, 1 = ForReading  
                While NOT objLog.AtEndOfLog
                  objLog.ReadLogRecord
                  If LCase(objLog.URIStem) = "administrator" Then
                    ClientIP = objLog.ClientIP
                      If objDictionary.Exists(ClientIP) = False Then
                          'Kill the route to the machine then add it to the array of banned IPs.
                          Set WshShell = WScript.CreateObject("WScript.Shell")
                        WshShell.Run "ROUTE ADD " & clientIP & " MASK 255.255.255.255 " & serverIP, 1, True
                        Set WshShell = Nothing
                        objDictionary.Add ClientIP, "255.255.255.255" '255 is just there for padding.
                      End If 
                  End If
                Wend  
              objLog.CloseLogFiles 1
            End If
          Next
    
          'Append the newly banned IPs to the currently banned IPs  
          If objDictionary.Count > 0 And objFTPIPSec.GrantByDefault = True Then 
            bannedIPArray = objFTPIPSec.IPDeny
              For i = 0 to ubound(bannedIPArray)
              clientIP = Left(bannedIPArray(i),InStr(bannedIPArray(i),",")-1)
                If objDictionary.Exists(ClientIP) = False Then
                  objDictionary.Add bannedIPArray(i), "255.255.255.255"
                End If 
              Next
    
            objFTPIPSec.IPDeny = objDictionary.Keys
            objFTPSVC.IPSecurity = objFTPIPSec
            objFTPSVC.SetInfo
          End If
    
        Set objFTPIPSec = Nothing
        Set objDictionary = Nothing
        Set objLog = Nothing
        Set objFSO = Nothing
        Set objFTPSVC = Nothing
      End If
      End Sub
    
    • 2
  2. mrdenny
    2009-07-18T16:44:15+08:002009-07-18T16:44:15+08:00

    只需阻止对该 IP 或子网的 FTP 服务器的访问。奇怪的是,IP 永远不需要合法访问您的 FTP 服务器。

    您可以在 IIS 中或通过防火墙/ACL 执行此操作。

    • 0
  3. Adam Brand
    2009-07-18T16:44:31+08:002009-07-18T16:44:31+08:00

    您可以更改 FTP 端口。

    1. 使用 Internet 服务管理器,将 FTP 属性设置为所需的端口。
    2. 应用更改并停止服务。
    3. 打开文件服务(位于 \System32\Drivers\Etc 目录中。
    4. 找到 ftp 21/tcp 行,并将其更改为反映新端口。
    5. 保存文件,然后运行位于 \System32 目录中的文件 Services.exe。
    6. 在 Internet 服务管理器中重新启动 FTP 服务。(来自这个线程)。

    ...或者,您可以安装CopSSH,将其指向高端口并使用 SFTP。

    如果您确实需要端口 21 上的 FTP,请查看FileZilla。它具有内置的反锤击功能。

    • 0

相关问题

  • IIS 优化

  • 有什么理由使用 Windows Server 2003 而不是 Server 2008?

  • 保护新的 Ubuntu 服务器 [关闭]

  • IIS 6.0 (Windows Server 2003) 备份的最佳实践?

  • 是否可以在单个 W2008 服务器上安装 Exchange Server?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve