Rewrite chack Maxming GeoIP
Posted: 2020-03-22 16:12
Hi,
I'm looking to update this script :
https://www.hmailserver.com/forum/viewt ... 9&start=60
But, Maxmind now use mmdb format.
Do you know how to use it trought vbs script ?
Here is my old script :
The goal is to disconnect client from non-autorised country before IPDB checking.
Can you help me ?
An other way to do something similar is to import GeoLite2-Country-Blocks-IPv4.csv , GeoLite2-Country-Blocks-IPv6.csv and GeoLite2-Country-Locations-fr.csv (in FR for me
) to mysql database and find a way to use it trough vbs...
But again, i don't know to do this.
I'm looking to update this script :
https://www.hmailserver.com/forum/viewt ... 9&start=60
But, Maxmind now use mmdb format.
Do you know how to use it trought vbs script ?
Here is my old script :
Code: Select all
' Sub OnClientConnect(oClient)
Function ListedInAbuseIPDB(strIP) : ListedInAbuseIPDB = false
With CreateObject("AbuseIPDBComponent.AbuseIPDBRestClient")
.SetApiKey("MY_API_KEY")
.SetMaxConfidenceScore(50)
.SetMaxAgeInDays(30)
On Error Resume Next
ListedInAbuseIPDB = .BlockEndpoint(strIP)
If (ListedInAbuseIPDB) then
EventLog.Write("AbuseIPDB Score:" & .GetConfidenceScore(strIP))
End If
If Err.Number <> 0 Then
EventLog.Write("AbuseIPDB Error: " & Err.Description)
End If
On Error Goto 0
End With
End Function
Sub OnClientConnect(oClient)
' GeoIP
Dim geoip
Result.Value = 0
set geoip = CreateObject("GeoIPCOMEx.GeoIPEx")
geoip.set_db_path("D:\geoip\")
geoip.find_by_addr(oClient.IPAddress)
country = geoip.country_code
Select Case country
Case "RU","CN","PA","ID","AR","VN","TR","NC","RO","GR","EG","NP"
Result.Value = 1
EventLog.Write("Geo-IP rejected:"+Chr(34)+vbTab+oClient.IPAddress+vbTab+Chr(34)+geoip.country_code+" "+geoip.country_name)
Case Else
If ListedInAbuseIPDB(oClient.IPAddress) Then
EventLog.Write("INFO: AbuseIPDB: " & oClient.IPAddress & ":" & oClient.Port & " " & country & " " & geoip.country_name)
Result.Value = 1
Exit Sub
End If
End Select
End Sub
' End Sub
Can you help me ?
An other way to do something similar is to import GeoLite2-Country-Blocks-IPv4.csv , GeoLite2-Country-Blocks-IPv6.csv and GeoLite2-Country-Locations-fr.csv (in FR for me

But again, i don't know to do this.