' ==================================================================== ' 602TechSec List Management API - VB.NET Usage Examples ' ==================================================================== ' This file demonstrates how to use the ListManagementHelper class ' to manage whitelist and blacklist entries. ' ' PREREQUISITES: ' - Add ListManagementHelper.vb to your project ' - Install NuGet packages: System.Net.Http, Newtonsoft.Json ' - Replace "your-api-key-here" with your actual API key ' ==================================================================== Imports System Imports Newtonsoft.Json.Linq Module ListManagementClient Sub Main() ' Initialize the helper with your API key Dim manager As New ListManagementHelper("your-api-key-here", "https://sec.602.tech") Console.WriteLine("602TechSec List Management Examples") Console.WriteLine("====================================") Console.WriteLine() ' ==================== IP Management Examples ==================== Console.WriteLine("IP Management Examples:") Console.WriteLine("-----------------------") ' Add IP to whitelist Console.WriteLine("1. Adding IP to whitelist...") Dim addIpResult As JObject = manager.AddIp("192.168.1.100", "whitelist") If addIpResult IsNot Nothing Then Console.WriteLine($" Success: {addIpResult("message")}") End If Console.WriteLine() ' Add IP to blacklist Console.WriteLine("2. Adding IP to blacklist...") Dim blockIpResult As JObject = manager.AddIp("10.0.0.50", "blacklist") If blockIpResult IsNot Nothing Then Console.WriteLine($" Success: {blockIpResult("message")}") End If Console.WriteLine() ' List whitelisted IPs (API key-specific only) Console.WriteLine("3. Listing whitelisted IPs (API key-specific)...") Dim whitelistResult As JObject = manager.ListIps("whitelist", False) If whitelistResult IsNot Nothing Then Dim count As Integer = CInt(whitelistResult("count")) Console.WriteLine($" Found {count} whitelisted IPs") Dim ips As JArray = CType(whitelistResult("ips"), JArray) For Each ip As String In ips Console.WriteLine($" - {ip}") Next End If Console.WriteLine() ' List blacklisted IPs (API key-specific only) Console.WriteLine("4. Listing blacklisted IPs (API key-specific)...") Dim blacklistResult As JObject = manager.ListIps("blacklist", False) If blacklistResult IsNot Nothing Then Dim count As Integer = CInt(blacklistResult("count")) Console.WriteLine($" Found {count} blacklisted IPs") Dim ips As JArray = CType(blacklistResult("ips"), JArray) For Each ip As String In ips Console.WriteLine($" - {ip}") Next End If Console.WriteLine() ' List blacklisted IPs including global blocked IPs Console.WriteLine("5. Listing blacklisted IPs (with global)...") Dim globalBlacklistResult As JObject = manager.ListIps("blacklist", True) If globalBlacklistResult IsNot Nothing Then Dim count As Integer = CInt(globalBlacklistResult("count")) Console.WriteLine($" Found {count} total blacklisted IPs (API key + global)") Dim ips As JArray = CType(globalBlacklistResult("ips"), JArray) For Each ip As String In ips Console.WriteLine($" - {ip}") Next End If Console.WriteLine() ' Remove IP from whitelist Console.WriteLine("6. Removing IP from whitelist...") Dim removeIpResult As JObject = manager.RemoveIp("192.168.1.100", "whitelist") If removeIpResult IsNot Nothing Then Console.WriteLine($" Success: {removeIpResult("message")}") End If Console.WriteLine() ' ==================== Host Management Examples ==================== Console.WriteLine("Host Management Examples:") Console.WriteLine("-------------------------") ' Add host to blacklist Console.WriteLine("7. Adding host to blacklist...") Dim addHostResult As JObject = manager.AddHost("malicious.com", "blacklist") If addHostResult IsNot Nothing Then Console.WriteLine($" Success: {addHostResult("message")}") End If Console.WriteLine() ' Add wildcard host to blacklist Console.WriteLine("8. Adding wildcard host to blacklist...") Dim addWildcardResult As JObject = manager.AddHost("*.spam.com", "blacklist") If addWildcardResult IsNot Nothing Then Console.WriteLine($" Success: {addWildcardResult("message")}") End If Console.WriteLine() ' List blacklisted hosts Console.WriteLine("9. Listing blacklisted hosts...") Dim hostsResult As JObject = manager.ListHosts("blacklist", False) If hostsResult IsNot Nothing Then Dim count As Integer = CInt(hostsResult("count")) Console.WriteLine($" Found {count} blacklisted hosts") Dim hosts As JArray = CType(hostsResult("hosts"), JArray) For Each host As String In hosts Console.WriteLine($" - {host}") Next End If Console.WriteLine() ' Add host to whitelist (with important note) Console.WriteLine("10. Adding host to whitelist...") Console.WriteLine(" NOTE: Whitelisting a host does NOT bypass IP or path blocking!") Dim whitelistHostResult As JObject = manager.AddHost("trusted.example.com", "whitelist") If whitelistHostResult IsNot Nothing Then Console.WriteLine($" Success: {whitelistHostResult("message")}") End If Console.WriteLine() ' Remove host from blacklist Console.WriteLine("11. Removing host from blacklist...") Dim removeHostResult As JObject = manager.RemoveHost("malicious.com", "blacklist") If removeHostResult IsNot Nothing Then Console.WriteLine($" Success: {removeHostResult("message")}") End If Console.WriteLine() ' ==================== Path Management Examples ==================== Console.WriteLine("Path Management Examples:") Console.WriteLine("-------------------------") ' Add blocked path Console.WriteLine("12. Adding blocked path...") Dim addPathResult As JObject = manager.AddPath("/admin/*") If addPathResult IsNot Nothing Then Console.WriteLine($" Success: {addPathResult("message")}") End If Console.WriteLine() ' Add multiple blocked paths Console.WriteLine("13. Adding multiple blocked paths...") Dim pathsToBlock As String() = {"*.php", "/wp-admin/*", "/phpmyadmin/*", "/.env"} For Each pathPattern As String In pathsToBlock Dim result As JObject = manager.AddPath(pathPattern) If result IsNot Nothing Then Console.WriteLine($" Blocked: {pathPattern}") End If Next Console.WriteLine() ' List blocked paths Console.WriteLine("14. Listing blocked paths...") Dim pathsResult As JObject = manager.ListPaths(False) If pathsResult IsNot Nothing Then Dim count As Integer = CInt(pathsResult("count")) Console.WriteLine($" Found {count} blocked paths") Dim paths As JArray = CType(pathsResult("paths"), JArray) For Each path As String In paths Console.WriteLine($" - {path}") Next End If Console.WriteLine() ' List blocked paths including global Console.WriteLine("15. Listing blocked paths (with global)...") Dim globalPathsResult As JObject = manager.ListPaths(True) If globalPathsResult IsNot Nothing Then Dim count As Integer = CInt(globalPathsResult("count")) Console.WriteLine($" Found {count} total blocked paths (API key + global)") Dim paths As JArray = CType(globalPathsResult("paths"), JArray) For Each path As String In paths Console.WriteLine($" - {path}") Next End If Console.WriteLine() ' Remove blocked path Console.WriteLine("16. Removing blocked path...") Dim removePathResult As JObject = manager.RemovePath("/admin/*") If removePathResult IsNot Nothing Then Console.WriteLine($" Success: {removePathResult("message")}") End If Console.WriteLine() ' ==================== Advanced Examples ==================== Console.WriteLine("Advanced Examples:") Console.WriteLine("------------------") ' Bulk IP blocking Console.WriteLine("17. Bulk IP blocking...") Dim suspiciousIps As String() = { "123.45.67.89", "98.76.54.32", "111.222.333.444" } Dim blockedCount As Integer = 0 For Each ip As String In suspiciousIps Dim result As JObject = manager.AddIp(ip, "blacklist") If result IsNot Nothing Then blockedCount += 1 End If Next Console.WriteLine($" Successfully blocked {blockedCount} IPs") Console.WriteLine() ' Check if specific IP is in blacklist Console.WriteLine("18. Checking if IP is blacklisted...") Dim checkIp As String = "123.45.67.89" Dim allBlocked As JObject = manager.ListIps("blacklist", False) If allBlocked IsNot Nothing Then Dim blockedIps As JArray = CType(allBlocked("ips"), JArray) Dim isBlocked As Boolean = blockedIps.Any(Function(ip) ip.ToString() = checkIp) Console.WriteLine($" IP {checkIp} is {If(isBlocked, "BLOCKED", "NOT BLOCKED")}") End If Console.WriteLine() ' Cleanup: Dispose the manager manager.Dispose() Console.WriteLine("Examples completed!") Console.WriteLine() Console.WriteLine("Press any key to exit...") Console.ReadKey() End Sub End Module