[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

simple sample for block IP

Dear all,

I need simple code in vb.net to block certain IP from attack or use my resource web, database my network.
In addition, send him  a message that he is block or he is hacker.


Thanks
0
abdallah1973
Asked:
abdallah1973
  • 3
1 Solution
 
corneliu_newsCommented:
0
 
abdallah1973Author Commented:
This sample is good for if i have a web site.
but I have a list of IP I need to bock through an EXE application that will always block any IP that in the list
The same idea for that one but in vb.net application
1. I have the list of IP that I need to block.
2. Block the IP and if the port is open to close.
in simple way use vb.net
0
 
blandyukCommented:
I presume you already have code in place to detect these? If so, all you need to do is store the IP addresses and check them on page requests. If matches, Redirect to "banned.html" page. You can use the Cache() object to store the IPs and flush them to a database if you wish to keep them pernamently.
0
 
abdallah1973Author Commented:
if found this code in old vb6 code
private Declare Function AllocateAndGetTcpExTableFromStack Lib "iphlpapi.dll" (pTcpTableEx As Any, ByVal bOrder As Long, ByVal heap As Long, ByVal zero As Long, ByVal flags As Long) As Long
Private Declare Function SetTcpEntry Lib "iphlpapi.dll" (pTcpTableEx As MIB_TCPROW) As Long

 For t = 0 To frmFirewall.lstBlock.ListCount - 1
                        If UCase(frmFirewall.lstBlock.List(t)) = UCase(tempName) Then
                         
                            TerminateThisConnection nLocalAddr, nLocalPort, nRemoteAddr, nRemotePort
                            Exit For
                        Else
                        End If
                    Next t


Public Sub TerminateThisConnection(xLocalAddr As Long, xLocalPort As Long, xRemoteAddr As Long, xRemotePort As Long)
    udtRow.dwLocalAddr = xLocalAddr
    udtRow.dwLocalPort = xLocalPort
    udtRow.dwRemoteAddr = xRemoteAddr
    udtRow.dwRemotePort = xRemotePort
    udtRow.dwState = 12
    SetTcpEntry udtRow
End Sub

maybe will help us but not work in vb.net
0
 
abdallah1973Author Commented:
not met what I need
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now