Is it possible to block Tor users?

后端 未结 14 2162
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 04:03

Would it be possible to block Tor users? (https://www.torproject.org/)

Due to the nature of the site I run I should do all I can to stop multiple accounts and block cert

14条回答
  •  别那么骄傲
    2021-01-30 04:48

    In .NET it's possible and simple. I have implemented it on my site.

    Let's say your site has an external IP address of 192.168.0.5 for argument's sake. Real TOR IP address at the time of posting: 95.215.44.97

    Imports System.Net
    Imports System.Net.Sockets
    Imports System.Web
    
    Private Function IsTorExitNode(sIP As String) As Boolean
    
        ' Reverse your IP (97.44.215.95) then pass to the string, I have just created it as one for this example
        Try
            Dim strTor As String = "97.44.215.95.80.5.0.168.192.ip-port.exitlist.torproject.org"
            Dim host As IPHostEntry = Dns.GetHostEntry(strTor)
    
            If host.AddressList.Length = 0 Then
                Return False
            Else
                If host.AddressList(0).ToString() = "127.0.0.2" Then
                    Return True
                Else
                    Return False
                End If
            End If
        Catch ex As SocketException
            Return False
        End Try
    End Function
    

    Breakdown

    Reversed IP address: 97.44.215.95
    Port: 80
    Reversed IP address: (your external site IP address)

    If the address is a TorExitNode it will return 127.0.0.2.

    In your Global.asax file, you can use the Application_Start to check if IP address returns true and then redirect them away from your site:

    If IsTorExitNode("97.44.215.95") = True Then Response.Redirect("http://www.google.co.uk")
    

    Now, as soon as they hit your site they are redirected away from it.

    TOR has a list of IP addresses, but obviously they change all the time so using my function would be the best way as it's always real-time.

提交回复
热议问题