' ==================================================================== ' 602TechSec List Management API - VB.NET Helper Class ' ==================================================================== ' This is a complete helper class for managing whitelist and blacklist ' entries via the 602TechSec API. ' ' USAGE: ' 1. Add this class to your VB.NET project ' 2. Reference System.Net.Http and Newtonsoft.Json packages ' 3. Create instance: Dim manager As New ListManagementHelper("your-api-key") ' 4. Use the methods below ' ==================================================================== Imports System.Net.Http Imports System.Text Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Public Class ListManagementHelper Private ReadOnly _apiKey As String Private ReadOnly _baseUrl As String Private ReadOnly _httpClient As HttpClient ''' ''' Initialize the List Management Helper ''' ''' Your 602TechSec API key ''' Base URL (default: https://sec.602.tech) Public Sub New(apiKey As String, Optional baseUrl As String = "https://sec.602.tech") _apiKey = apiKey _baseUrl = baseUrl.TrimEnd("/"c) _httpClient = New HttpClient() _httpClient.Timeout = TimeSpan.FromSeconds(30) End Sub ' ==================== IP Management Methods ==================== ''' ''' Add an IP address to whitelist or blacklist ''' ''' The IP address to add ''' The list type: "whitelist" or "blacklist" (default: "whitelist") ''' API response object or Nothing on error Public Function AddIp(ipAddress As String, Optional listType As String = "whitelist") As JObject Dim requestData As New With { .apiKey = _apiKey, .ipAddress = ipAddress, .listType = listType } Return PostRequest("/api/listmanagement/ip/add", requestData) End Function ''' ''' Remove an IP address from whitelist or blacklist ''' ''' The IP address to remove ''' The list type: "whitelist" or "blacklist" (default: "whitelist") ''' API response object or Nothing on error Public Function RemoveIp(ipAddress As String, Optional listType As String = "whitelist") As JObject Dim requestData As New With { .apiKey = _apiKey, .ipAddress = ipAddress, .listType = listType } Return PostRequest("/api/listmanagement/ip/remove", requestData) End Function ''' ''' List all IPs in whitelist or blacklist ''' ''' The list type: "whitelist" or "blacklist" (default: "whitelist") ''' Include global blocked IPs (default: False) ''' API response object with IP list or Nothing on error Public Function ListIps(Optional listType As String = "whitelist", Optional includeGlobal As Boolean = False) As JObject Dim url As String = $"{_baseUrl}/api/listmanagement/ip/list?apiKey={Uri.EscapeDataString(_apiKey)}&listType={Uri.EscapeDataString(listType)}&includeGlobal={includeGlobal.ToString().ToLower()}" Try Dim response As HttpResponseMessage = _httpClient.GetAsync(url).Result Dim content As String = response.Content.ReadAsStringAsync().Result If response.IsSuccessStatusCode Then Return JObject.Parse(content) Else Console.WriteLine($"Error: {response.StatusCode} - {content}") Return Nothing End If Catch ex As Exception Console.WriteLine($"Exception: {ex.Message}") Return Nothing End Try End Function ' ==================== Host Management Methods ==================== ''' ''' Add a host to whitelist or blacklist ''' ''' IMPORTANT: Whitelisting a host does NOT bypass all security checks. ''' The system will still validate against blocked IPs and restricted paths. ''' Whitelisting only exempts the host itself from host-based blocking. ''' ''' The host/domain to add (supports wildcards like *.example.com) ''' The list type: "whitelist" or "blacklist" (default: "blacklist") ''' API response object or Nothing on error Public Function AddHost(host As String, Optional listType As String = "blacklist") As JObject Dim requestData As New With { .apiKey = _apiKey, .host = host, .listType = listType } Return PostRequest("/api/listmanagement/host/add", requestData) End Function ''' ''' Remove a host from whitelist or blacklist ''' ''' The host/domain to remove ''' The list type: "whitelist" or "blacklist" (default: "blacklist") ''' API response object or Nothing on error Public Function RemoveHost(host As String, Optional listType As String = "blacklist") As JObject Dim requestData As New With { .apiKey = _apiKey, .host = host, .listType = listType } Return PostRequest("/api/listmanagement/host/remove", requestData) End Function ''' ''' List all hosts in whitelist or blacklist ''' ''' The list type: "whitelist" or "blacklist" (default: "blacklist") ''' Include global blocked hosts (default: False) ''' API response object with host list or Nothing on error Public Function ListHosts(Optional listType As String = "blacklist", Optional includeGlobal As Boolean = False) As JObject Dim url As String = $"{_baseUrl}/api/listmanagement/host/list?apiKey={Uri.EscapeDataString(_apiKey)}&listType={Uri.EscapeDataString(listType)}&includeGlobal={includeGlobal.ToString().ToLower()}" Try Dim response As HttpResponseMessage = _httpClient.GetAsync(url).Result Dim content As String = response.Content.ReadAsStringAsync().Result If response.IsSuccessStatusCode Then Return JObject.Parse(content) Else Console.WriteLine($"Error: {response.StatusCode} - {content}") Return Nothing End If Catch ex As Exception Console.WriteLine($"Exception: {ex.Message}") Return Nothing End Try End Function ' ==================== Path Management Methods ==================== ''' ''' Add a blocked path pattern ''' ''' The path pattern to block (e.g., /admin, *.php, /wp-*) ''' API response object or Nothing on error Public Function AddPath(path As String) As JObject Dim requestData As New With { .apiKey = _apiKey, .path = path } Return PostRequest("/api/listmanagement/path/add", requestData) End Function ''' ''' Remove a blocked path pattern ''' ''' The path pattern to unblock ''' API response object or Nothing on error Public Function RemovePath(path As String) As JObject Dim requestData As New With { .apiKey = _apiKey, .path = path } Return PostRequest("/api/listmanagement/path/remove", requestData) End Function ''' ''' List all blocked paths ''' ''' Include global blocked paths (default: False) ''' API response object with path list or Nothing on error Public Function ListPaths(Optional includeGlobal As Boolean = False) As JObject Dim url As String = $"{_baseUrl}/api/listmanagement/path/list?apiKey={Uri.EscapeDataString(_apiKey)}&includeGlobal={includeGlobal.ToString().ToLower()}" Try Dim response As HttpResponseMessage = _httpClient.GetAsync(url).Result Dim content As String = response.Content.ReadAsStringAsync().Result If response.IsSuccessStatusCode Then Return JObject.Parse(content) Else Console.WriteLine($"Error: {response.StatusCode} - {content}") Return Nothing End If Catch ex As Exception Console.WriteLine($"Exception: {ex.Message}") Return Nothing End Try End Function ' ==================== Helper Methods ==================== Private Function PostRequest(endpoint As String, data As Object) As JObject Try Dim json As String = JsonConvert.SerializeObject(data) Dim content As New StringContent(json, Encoding.UTF8, "application/json") Dim url As String = _baseUrl & endpoint Dim response As HttpResponseMessage = _httpClient.PostAsync(url, content).Result Dim responseContent As String = response.Content.ReadAsStringAsync().Result If response.IsSuccessStatusCode Then Return JObject.Parse(responseContent) Else Console.WriteLine($"Error: {response.StatusCode} - {responseContent}") Return Nothing End If Catch ex As Exception Console.WriteLine($"Exception: {ex.Message}") Return Nothing End Try End Function ''' ''' Dispose resources ''' Public Sub Dispose() If _httpClient IsNot Nothing Then _httpClient.Dispose() End If End Sub End Class