' ====================================================================
' 602TechSec List Management API - VB.NET Quick Start Example
' ====================================================================
' This example demonstrates the most common operations for the
' List Management API. Copy and modify this code for your needs.
'
' REQUIREMENTS:
' - .NET Framework 4.5+ or .NET Core 3.1+
' - Newtonsoft.Json (Install via NuGet: Install-Package Newtonsoft.Json)
'
' SETUP:
' 1. Replace "your-api-key-here" with your actual API key
' 2. Run the example to see the API in action
' ====================================================================
Imports System.Net.Http
Imports System.Text
Imports Newtonsoft.Json
Module QuickStartExample
Private Const ApiKey As String = "your-api-key-here"
Private Const BaseUrl As String = "https://sec.602.tech"
Async Function Main() As Task
Console.WriteLine("602TechSec List Management API - Quick Start")
Console.WriteLine("=" & New String("="c, 50))
Console.WriteLine()
Try
' Example 1: Add an IP to whitelist
Console.WriteLine("1. Adding IP to whitelist...")
Await AddIpToWhitelist("192.168.1.100")
' Example 2: Add a host to blacklist
Console.WriteLine(vbCrLf & "2. Adding host to blacklist...")
Await AddHostToBlacklist("malicious.com")
' Example 3: Bulk add multiple IPs
Console.WriteLine(vbCrLf & "3. Bulk adding IPs...")
Dim ips = New List(Of String) From {
"10.0.0.1",
"10.0.0.2",
"10.0.0.3"
}
Await BulkAddIps(ips)
' Example 4: Check if IP is in whitelist
Console.WriteLine(vbCrLf & "4. Checking if IP is whitelisted...")
Dim isWhitelisted = Await CheckIpWhitelisted("192.168.1.100")
Console.WriteLine($" IP is whitelisted: {isWhitelisted}")
' Example 5: Get all lists
Console.WriteLine(vbCrLf & "5. Retrieving all lists...")
Await GetAllLists()
' Example 6: Remove IP from whitelist
Console.WriteLine(vbCrLf & "6. Removing IP from whitelist...")
Await RemoveIpFromWhitelist("192.168.1.100")
Console.WriteLine(vbCrLf & "All examples completed successfully!")
Catch ex As Exception
Console.WriteLine($"ERROR: {ex.Message}")
End Try
Console.WriteLine(vbCrLf & "Press any key to exit...")
Console.ReadKey()
End Function
'''
''' Example 1: Add an IP address to whitelist
'''
Async Function AddIpToWhitelist(ipAddress As String) As Task
Using client As New HttpClient()
Dim request = New With {
.apiKey = ApiKey,
.ipAddress = ipAddress,
.listType = "whitelist"
}
Dim json = JsonConvert.SerializeObject(request)
Dim content = New StringContent(json, Encoding.UTF8, "application/json")
Dim response = Await client.PostAsync($"{BaseUrl}/api/listmanagement/ip/add", content)
Dim resultJson = Await response.Content.ReadAsStringAsync()
Dim result = JsonConvert.DeserializeObject(Of ApiResponse)(resultJson)
Console.WriteLine($" Success: {result.Success}")
Console.WriteLine($" Message: {result.Message}")
End Using
End Function
'''
''' Example 2: Add a host to blacklist
'''
Async Function AddHostToBlacklist(host As String) As Task
Using client As New HttpClient()
Dim request = New With {
.apiKey = ApiKey,
.host = host,
.listType = "blacklist"
}
Dim json = JsonConvert.SerializeObject(request)
Dim content = New StringContent(json, Encoding.UTF8, "application/json")
Dim response = Await client.PostAsync($"{BaseUrl}/api/listmanagement/host/add", content)
Dim resultJson = Await response.Content.ReadAsStringAsync()
Dim result = JsonConvert.DeserializeObject(Of ApiResponse)(resultJson)
Console.WriteLine($" Success: {result.Success}")
Console.WriteLine($" Message: {result.Message}")
End Using
End Function
'''
''' Example 3: Bulk add multiple IP addresses
'''
Async Function BulkAddIps(ipAddresses As List(Of String)) As Task
Using client As New HttpClient()
Dim request = New With {
.apiKey = ApiKey,
.entries = ipAddresses,
.entryType = "ip",
.listType = "whitelist"
}
Dim json = JsonConvert.SerializeObject(request)
Dim content = New StringContent(json, Encoding.UTF8, "application/json")
Dim response = Await client.PostAsync($"{BaseUrl}/api/listmanagement/bulk/add", content)
Dim resultJson = Await response.Content.ReadAsStringAsync()
Dim result = JsonConvert.DeserializeObject(Of BulkApiResponse)(resultJson)
Console.WriteLine($" Success Count: {result.SuccessCount}")
Console.WriteLine($" Failure Count: {result.FailureCount}")
If result.FailedEntries?.Count > 0 Then
Console.WriteLine($" Failed Entries: {String.Join(", ", result.FailedEntries)}")
End If
End Using
End Function
'''
''' Example 4: Check if IP is in whitelist
'''
Async Function CheckIpWhitelisted(ipAddress As String) As Task(Of Boolean)
Using client As New HttpClient()
Dim request = New With {
.apiKey = ApiKey,
.entry = ipAddress,
.entryType = "ip"
}
Dim json = JsonConvert.SerializeObject(request)
Dim content = New StringContent(json, Encoding.UTF8, "application/json")
Dim response = Await client.PostAsync($"{BaseUrl}/api/listmanagement/check", content)
Dim resultJson = Await response.Content.ReadAsStringAsync()
Dim result = JsonConvert.DeserializeObject(Of CheckEntryResponse)(resultJson)
Return result.InWhitelist
End Using
End Function
'''
''' Example 5: Get all lists
'''
Async Function GetAllLists() As Task
Using client As New HttpClient()
Dim response = Await client.GetAsync($"{BaseUrl}/api/listmanagement/lists?apiKey={ApiKey}")
Dim resultJson = Await response.Content.ReadAsStringAsync()
Dim result = JsonConvert.DeserializeObject(Of ListContentsResponse)(resultJson)
Console.WriteLine($" IP Whitelist: {result.IpWhitelist?.Count ?? 0} entries")
If result.IpWhitelist IsNot Nothing Then
For Each ip In result.IpWhitelist
Console.WriteLine($" - {ip}")
Next
End If
Console.WriteLine($" IP Blacklist: {result.IpBlacklist?.Count ?? 0} entries")
If result.IpBlacklist IsNot Nothing Then
For Each ip In result.IpBlacklist
Console.WriteLine($" - {ip}")
Next
End If
Console.WriteLine($" Host Whitelist: {result.HostWhitelist?.Count ?? 0} entries")
Console.WriteLine($" Host Blacklist: {result.HostBlacklist?.Count ?? 0} entries")
End Using
End Function
'''
''' Example 6: Remove IP from whitelist
'''
Async Function RemoveIpFromWhitelist(ipAddress As String) As Task
Using client As New HttpClient()
Dim request = New With {
.apiKey = ApiKey,
.ipAddress = ipAddress,
.listType = "whitelist"
}
Dim json = JsonConvert.SerializeObject(request)
Dim content = New StringContent(json, Encoding.UTF8, "application/json")
Dim response = Await client.PostAsync($"{BaseUrl}/api/listmanagement/ip/remove", content)
Dim resultJson = Await response.Content.ReadAsStringAsync()
Dim result = JsonConvert.DeserializeObject(Of ApiResponse)(resultJson)
Console.WriteLine($" Success: {result.Success}")
Console.WriteLine($" Message: {result.Message}")
End Using
End Function
#Region "Response Models"
Public Class ApiResponse
Public Property Success As Boolean
Public Property Message As String
Public Property Entry As String
Public Property ListType As String
Public Property Timestamp As DateTime
End Class
Public Class BulkApiResponse
Public Property Success As Boolean
Public Property Message As String
Public Property SuccessCount As Integer
Public Property FailureCount As Integer
Public Property FailedEntries As List(Of String)
Public Property Timestamp As DateTime
End Class
Public Class CheckEntryResponse
Public Property Success As Boolean
Public Property Entry As String
Public Property InWhitelist As Boolean
Public Property InBlacklist As Boolean
Public Property Message As String
Public Property Timestamp As DateTime
End Class
Public Class ListContentsResponse
Public Property Success As Boolean
Public Property IpWhitelist As List(Of String)
Public Property IpBlacklist As List(Of String)
Public Property HostWhitelist As List(Of String)
Public Property HostBlacklist As List(Of String)
Public Property TotalWhitelistCount As Integer
Public Property TotalBlacklistCount As Integer
Public Property Timestamp As DateTime
End Class
#End Region
End Module