Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) AbuseIPDB Check EndpointThe check endpoint accepts a single IP address (v4 or v6). Optionally you may set the maxAgeInDays parameter to only return reports within the last x amount of days. For more information, see https://docs.abuseipdb.com/?shell#check-endpoint
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @http int -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Implements the following CURL command: -- curl -G https://api.abuseipdb.com/api/v2/check \ -- --data-urlencode "ipAddress=118.25.6.39" \ -- -d maxAgeInDays=90 \ -- -d verbose \ -- -H "Key: $YOUR_API_KEY" \ -- -H "Accept: application/json" -- Use the following online tool to generate HTTP code from a CURL command -- Convert a cURL Command to HTTP Source Code DECLARE @req int -- Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @req OUT EXEC sp_OASetProperty @req, 'HttpVerb', 'GET' EXEC sp_OASetProperty @req, 'Path', '/api/v2/check' EXEC sp_OASetProperty @req, 'ContentType', 'application/x-www-form-urlencoded' EXEC sp_OAMethod @req, 'AddParam', NULL, 'maxAgeInDays', '90' EXEC sp_OAMethod @req, 'AddParam', NULL, 'verbose', '' EXEC sp_OAMethod @req, 'AddParam', NULL, 'ipAddress', '118.25.6.39' EXEC sp_OAMethod @req, 'AddHeader', NULL, 'Key', '$YOUR_API_KEY' EXEC sp_OAMethod @req, 'AddHeader', NULL, 'Accept', 'application/json' DECLARE @resp int EXEC sp_OAMethod @http, 'SynchronousRequest', @resp OUT, 'api.abuseipdb.com', 443, 1, @req EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 = 0 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @req RETURN END DECLARE @jResp int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT EXEC sp_OAMethod @jResp, 'Load', @success OUT, @sTmp0 EXEC sp_OASetProperty @jResp, 'EmitCompact', 0 PRINT 'Response Body:' EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT PRINT @sTmp0 DECLARE @respStatusCode int EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT PRINT 'Response Status Code = ' + @respStatusCode IF @respStatusCode >= 400 BEGIN PRINT 'Response Header:' EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT PRINT @sTmp0 PRINT 'Failed.' EXEC @hr = sp_OADestroy @resp EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @req EXEC @hr = sp_OADestroy @jResp RETURN END EXEC @hr = sp_OADestroy @resp -- Sample JSON response: -- (Sample code for parsing the JSON response is shown below) -- { -- "data": { -- "ipAddress": "118.25.6.39", -- "isPublic": true, -- "ipVersion": 4, -- "isWhitelisted": false, -- "abuseConfidenceScore": 1, -- "countryCode": "CN", -- "usageType": "Data Center\/Web Hosting\/Transit", -- "isp": "Tencent Cloud Computing (Beijing) Co. Ltd", -- "domain": "tencent.com", -- "hostnames": [ -- ], -- "countryName": "China", -- "totalReports": 2, -- "numDistinctUsers": 1, -- "lastReportedAt": "2021-04-03T18:55:00+00:00", -- "reports": [ -- { -- "reportedAt": "2021-03-10T10:07:53+00:00", -- "comment": "SSH login attempts with user root.", -- "categories": [ -- 18, -- 22 -- ], -- "reporterId": 54484, -- "reporterCountryCode": "CN", -- "reporterCountryName": "China" -- }, -- { -- "reportedAt": "2021-03-09T09:47:57+00:00", -- "comment": "SSH login attempts with user root.", -- "categories": [ -- 18, -- 22 -- ], -- "reporterId": 54484, -- "reporterCountryCode": "CN", -- "reporterCountryName": "China" -- } -- ] -- } -- } -- Sample code for parsing the JSON response... -- Use the following online tool to generate parsing code from sample JSON: -- Generate Parsing Code from JSON DECLARE @reportedAt nvarchar(4000) DECLARE @comment nvarchar(4000) DECLARE @reporterId int DECLARE @reporterCountryCode nvarchar(4000) DECLARE @reporterCountryName nvarchar(4000) DECLARE @j int DECLARE @count_j int DECLARE @intVal int DECLARE @dataIpAddress nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @dataIpAddress OUT, 'data.ipAddress' DECLARE @dataIsPublic int EXEC sp_OAMethod @jResp, 'BoolOf', @dataIsPublic OUT, 'data.isPublic' DECLARE @dataIpVersion int EXEC sp_OAMethod @jResp, 'IntOf', @dataIpVersion OUT, 'data.ipVersion' DECLARE @dataIsWhitelisted int EXEC sp_OAMethod @jResp, 'BoolOf', @dataIsWhitelisted OUT, 'data.isWhitelisted' DECLARE @dataAbuseConfidenceScore int EXEC sp_OAMethod @jResp, 'IntOf', @dataAbuseConfidenceScore OUT, 'data.abuseConfidenceScore' DECLARE @dataCountryCode nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @dataCountryCode OUT, 'data.countryCode' DECLARE @dataUsageType nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @dataUsageType OUT, 'data.usageType' DECLARE @dataIsp nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @dataIsp OUT, 'data.isp' DECLARE @dataDomain nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @dataDomain OUT, 'data.domain' DECLARE @dataCountryName nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @dataCountryName OUT, 'data.countryName' DECLARE @dataTotalReports int EXEC sp_OAMethod @jResp, 'IntOf', @dataTotalReports OUT, 'data.totalReports' DECLARE @dataNumDistinctUsers int EXEC sp_OAMethod @jResp, 'IntOf', @dataNumDistinctUsers OUT, 'data.numDistinctUsers' DECLARE @dataLastReportedAt nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @dataLastReportedAt OUT, 'data.lastReportedAt' DECLARE @i int SELECT @i = 0 DECLARE @count_i int EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'data.hostnames' WHILE @i < @count_i BEGIN EXEC sp_OASetProperty @jResp, 'I', @i SELECT @i = @i + 1 END SELECT @i = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'data.reports' WHILE @i < @count_i BEGIN EXEC sp_OASetProperty @jResp, 'I', @i EXEC sp_OAMethod @jResp, 'StringOf', @reportedAt OUT, 'data.reports[i].reportedAt' EXEC sp_OAMethod @jResp, 'StringOf', @comment OUT, 'data.reports[i].comment' EXEC sp_OAMethod @jResp, 'IntOf', @reporterId OUT, 'data.reports[i].reporterId' EXEC sp_OAMethod @jResp, 'StringOf', @reporterCountryCode OUT, 'data.reports[i].reporterCountryCode' EXEC sp_OAMethod @jResp, 'StringOf', @reporterCountryName OUT, 'data.reports[i].reporterCountryName' SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'data.reports[i].categories' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j EXEC sp_OAMethod @jResp, 'IntOf', @intVal OUT, 'data.reports[i].categories[j]' SELECT @j = @j + 1 END SELECT @i = @i + 1 END EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @req EXEC @hr = sp_OADestroy @jResp END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.