Skip to content

Commit 4299fbc

Browse files
Initial commit
0 parents  commit 4299fbc

File tree

15 files changed

+467
-0
lines changed

15 files changed

+467
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Using the Domain Reputation API web service
2+
3+
[Domain Reputation API](https://threatintelligenceplatform.com/threat-intelligence-apis/domain-reputation-api)
4+
provides you an opportunity to get a reputation score for any active domain name.
5+
6+
Here you'll find examples of querying the API implemented in multiple
7+
languages.
8+
9+
You'll need a
10+
[Threat Intelligence Platform account](https://threatintelligenceplatform.com/signup) to
11+
authenticate.
12+
13+
Please, refer to the
14+
[Domain Reputation API Guide](https://threatintelligenceplatform.com/threat-intelligence-api-docs/domain-reputation-api)
15+
for info on input parameters, request/response formats, authentication
16+
instructions and more.

java/domain-reputation-api-java.iml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
4+
<output url="file://$MODULE_DIR$/target/classes" />
5+
<output-test url="file://$MODULE_DIR$/target/test-classes" />
6+
<content url="file://$MODULE_DIR$">
7+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
9+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
10+
<excludeFolder url="file://$MODULE_DIR$/target" />
11+
</content>
12+
<orderEntry type="inheritedJdk" />
13+
<orderEntry type="sourceFolder" forTests="false" />
14+
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.2" level="project" />
15+
</component>
16+
</module>

java/pom.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.threatintelligenceplatform</groupId>
8+
<artifactId>domain-reputation-api</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
12+
<dependencies>
13+
<dependency>
14+
<groupId>com.google.code.gson</groupId>
15+
<artifactId>gson</artifactId>
16+
<version>2.8.2</version>
17+
</dependency>
18+
</dependencies>
19+
20+
<build>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.codehaus.mojo</groupId>
24+
<artifactId>exec-maven-plugin</artifactId>
25+
<version>1.6.0</version>
26+
<executions>
27+
<execution>
28+
<goals>
29+
<goal>java</goal>
30+
</goals>
31+
</execution>
32+
</executions>
33+
<configuration>
34+
<mainClass>DomainReputationApi</mainClass>
35+
</configuration>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
40+
</project>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import java.io.BufferedReader;
2+
import java.io.DataOutputStream;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
import java.net.URL;
6+
7+
import javax.net.ssl.HttpsURLConnection;
8+
9+
import com.google.gson.*;
10+
11+
12+
public class DomainReputationApi {
13+
14+
private String apiKey;
15+
16+
protected static final String BASE_URL =
17+
"https://api.threatintelligenceplatform.com/v1/reputation";
18+
19+
public DomainReputationApi(String apiKey) {
20+
this.apiKey = apiKey;
21+
}
22+
23+
24+
public static void main(String[] args) {
25+
DomainReputationApi rss = new DomainReputationApi("Your-API-key");
26+
27+
try {
28+
String response = rss.sendGet();
29+
System.out.println(rss.prettyJson(response));
30+
} catch (Exception e) {
31+
System.out.println(e.getMessage());
32+
}
33+
34+
}
35+
36+
public String sendGet() throws Exception
37+
{
38+
String userAgent = "Mozilla/5.0";
39+
String url = this.buildUrl("threatintelligenceplatform.com");
40+
41+
URL obj = new URL(url);
42+
43+
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
44+
45+
con.setRequestMethod("GET");
46+
con.setRequestProperty("User-Agent", userAgent);
47+
48+
BufferedReader in = new BufferedReader(
49+
new InputStreamReader(con.getInputStream()));
50+
51+
String inputLine;
52+
StringBuilder response = new StringBuilder();
53+
54+
while ((inputLine = in.readLine()) != null) {
55+
response.append(inputLine);
56+
}
57+
in.close();
58+
59+
return response.toString();
60+
}
61+
62+
protected String buildUrl(String domain) {
63+
StringBuffer url = new StringBuffer(DomainReputationApi.BASE_URL);
64+
url.append("?");
65+
url.append("apiKey=");
66+
url.append(this.apiKey);
67+
url.append("&domainName=");
68+
url.append(domain);
69+
url.append("&mode=full");
70+
71+
return url.toString();
72+
}
73+
74+
public void setApiKey(String apiKey)
75+
{
76+
this.apiKey = apiKey;
77+
}
78+
79+
protected String getApiKey()
80+
{
81+
return this.apiKey;
82+
}
83+
84+
private String prettyJson(String jsonString)
85+
{
86+
Gson gson = new GsonBuilder().setPrettyPrinting().create();
87+
88+
JsonParser jp = new JsonParser();
89+
JsonElement je = jp.parse(jsonString);
90+
String prettyJsonString = gson.toJson(je);
91+
92+
return prettyJsonString;
93+
}
94+
}

js/sample.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Domain Reputation Scoring API Sample</title>
5+
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
6+
<script type="text/javascript">
7+
var url = "https://api.threatintelligenceplatform.com/v1/reputation"
8+
+ "?domainName=threatintelligenceplatform.com"
9+
+ "&mode=fast&apiKey=Your-API-key";
10+
$(function() {
11+
$.get(
12+
url,
13+
function(data) {
14+
$("body").append(
15+
"<pre>" + JSON.stringify(data, null, 2) + "</pre>");
16+
}
17+
);
18+
});
19+
</script>
20+
</head>
21+
<body></body>
22+
</html>

net/DomainReputationApi.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.0.0
5+
MinimumVisualStudioVersion = 10.0.0.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainReputationApi", "DomainReputationApi/DomainReputationApi.csproj", "{538D27CF-DCA5-447B-AC70-C27325542E62}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{538D27CF-DCA5-447B-AC70-C27325542E62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{538D27CF-DCA5-447B-AC70-C27325542E62}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{538D27CF-DCA5-447B-AC70-C27325542E62}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{538D27CF-DCA5-447B-AC70-C27325542E62}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
3+
namespace DomainReputationApi
4+
{
5+
internal class DomainReputationApi
6+
{
7+
public static void Main(string[] args)
8+
{
9+
const string apiKey = "Your-API-key";
10+
const string domain = "threatintelligenceplatform.com";
11+
const string mode = "full";
12+
13+
var url =
14+
"https://api.threatintelligenceplatform.com/v1/reputation?"
15+
+ "apiKey=" + Uri.EscapeDataString(apiKey)
16+
+ "&domainName=" + Uri.EscapeDataString(domain)
17+
+ "&mode=" + Uri.EscapeDataString(mode);
18+
19+
dynamic result = new System.Net.WebClient().DownloadString(url);
20+
21+
Console.WriteLine(result);
22+
23+
// Prevent command window from automatically closing
24+
Console.WriteLine("Press any key to continue...");
25+
Console.ReadKey();
26+
}
27+
}
28+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{538D27CF-DCA5-447B-AC70-C27325542E62}</ProjectGuid>
8+
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>DomainReputationApi</RootNamespace>
12+
<AssemblyName>DomainReputationApi</AssemblyName>
13+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Microsoft.CSharp" />
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Xml" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Include="DomainReputationApi.cs" />
46+
<Compile Include="Properties\AssemblyInfo.cs" />
47+
</ItemGroup>
48+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
49+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
50+
Other similar extension points exist, see Microsoft.Common.targets.
51+
<Target Name="BeforeBuild">
52+
</Target>
53+
<Target Name="AfterBuild">
54+
</Target>
55+
-->
56+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("DomainReputationApi")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("DomainReputationApi")]
13+
[assembly: AssemblyCopyright("Copyright © 2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("538D27CF-DCA5-447B-AC70-C27325542E62")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

node/sample.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var https = require('https');
2+
3+
// Fill in your details
4+
var api_key = 'Your-api-key';
5+
var mode = "full";
6+
var domain = "threatintelligenceplatform.com";
7+
8+
var url = "https://api.threatintelligenceplatform.com/v1/reputation?"
9+
+ "domainName=" + domain
10+
+ "&mode=" + mode
11+
+ "&apiKey=" + api_key;
12+
13+
var req = https.get(url, function(res) {
14+
var str = '';
15+
res.on('data', function(chunk) {
16+
str += chunk;
17+
});
18+
res.on('end', function() {
19+
console.log(JSON.parse(str));
20+
});
21+
22+
});
23+
24+
// Handle errors
25+
req.on('error', function(e) {
26+
console.error(e);
27+
});

0 commit comments

Comments
 (0)