Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3faeb028e4 | ||
|
|
177b86d997 | ||
|
|
8a2425abd1 | ||
|
|
bbb863a5ea | ||
|
|
1f85dfd096 | ||
|
|
969b533e7d | ||
|
|
08618aab83 | ||
|
|
29241095a1 | ||
|
|
0378b52107 | ||
|
|
ecc537eb46 | ||
|
|
2a2b388a39 | ||
|
|
0a6f61f590 | ||
|
|
25fd53d3f5 |
@@ -1,9 +1,15 @@
|
|||||||
|
[](https://ci.appveyor.com/project/tparnell8/shodan-net/branch/master)
|
||||||
|
|
||||||
Visit the official Shodan API documentation at:
|
Visit the official Shodan API documentation at:
|
||||||
|
|
||||||
[https://developer.shodan.io](https://developer.shodan.io)
|
[https://developer.shodan.io](https://developer.shodan.io)
|
||||||
|
|
||||||
This is still in active development, error handling might not well handle well. Best bet when working with any libraries you didn't write..harden your calls!
|
This is still in active development, error handling might not well handle well. Best bet when working with any libraries you didn't write..harden your calls!
|
||||||
|
|
||||||
|
## APi Docs
|
||||||
|
|
||||||
|
You can find doxygen docs [here](http://shodan-csharp-docs.azurewebsites.net/)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
`install-package Shodan.Net`
|
`install-package Shodan.Net`
|
||||||
@@ -17,7 +23,7 @@ Create a shodan client. Note that ShodanClient inerhits from IDisposable, so you
|
|||||||
|
|
||||||
`var client = new Shodan.Net.ShodanClient("myapiKey");`
|
`var client = new Shodan.Net.ShodanClient("myapiKey");`
|
||||||
|
|
||||||
Now just query away.
|
Now just query away. You should be able to find all the actions [in the docs](http://shodan-csharp-docs.azurewebsites.net/class_shodan_1_1_net_1_1_shodan_client.html) or just through the docs in intellisense.
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
|
|
||||||
@@ -45,3 +51,4 @@ Searching shodan requires you to build up queries, and facets to make it easier
|
|||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ EndProject
|
|||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18A95621-2E1B-48F0-9D38-D7B3513F31D3}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18A95621-2E1B-48F0-9D38-D7B3513F31D3}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
|
appveyor.yml = appveyor.yml
|
||||||
global.json = global.json
|
global.json = global.json
|
||||||
LICENSE.txt = LICENSE.txt
|
LICENSE.txt = LICENSE.txt
|
||||||
Readme.md = Readme.md
|
Readme.md = Readme.md
|
||||||
|
|||||||
13
appveyor.yml
Normal file
13
appveyor.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
version: 1.0.{build}
|
||||||
|
configuration: Release
|
||||||
|
before_build:
|
||||||
|
- ps: >-
|
||||||
|
(new-object net.webclient).DownloadFile('https://download.microsoft.com/download/4/6/1/46116DFF-29F9-4FF8-94BF-F9BE05BE263B/packages/DotNetCore.1.0.0.RC2-SDK.Preview1-x64.exe','core.exe')
|
||||||
|
|
||||||
|
core.exe /install /quiet /norestart
|
||||||
|
|
||||||
|
dotnet restore
|
||||||
|
build:
|
||||||
|
verbosity: minimal
|
||||||
|
test_script:
|
||||||
|
- cmd: dotnet test .\src\Shodan.Net.UnitTests\
|
||||||
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
|
|||||||
# title of most generated pages and in a few other places.
|
# title of most generated pages and in a few other places.
|
||||||
# The default value is: My Project.
|
# The default value is: My Project.
|
||||||
|
|
||||||
PROJECT_NAME = "Showdan.Net"
|
PROJECT_NAME = "Shodan.Net"
|
||||||
|
|
||||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
@@ -933,7 +933,7 @@ USE_MDFILE_AS_MAINPAGE =
|
|||||||
# also VERBATIM_HEADERS is set to NO.
|
# also VERBATIM_HEADERS is set to NO.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
SOURCE_BROWSER = YES
|
SOURCE_BROWSER = NO
|
||||||
|
|
||||||
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
|
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
|
||||||
# classes and enums directly into the documentation.
|
# classes and enums directly into the documentation.
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace Shodan.Net.UnitTests
|
|
||||||
{
|
|
||||||
// This project can output the Class library as a NuGet Package.
|
|
||||||
// To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build".
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
[Fact]
|
|
||||||
public async Task privateGetsPorts()
|
|
||||||
|
|
||||||
{
|
|
||||||
var client = new ShodanClient("");
|
|
||||||
var ports = await client.SearchHosts(
|
|
||||||
query: a => a.Withcity("boston")
|
|
||||||
.Withcountry("usa")
|
|
||||||
.Before(DateTime.Now.AddDays(-5)),
|
|
||||||
facet: b => b.WithAsn()
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
25
src/Shodan.Net.UnitTests/Intergration/TestSuite.cs
Normal file
25
src/Shodan.Net.UnitTests/Intergration/TestSuite.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Shodan.Net.UnitTests.Intergration
|
||||||
|
{
|
||||||
|
public class TestSuite
|
||||||
|
{
|
||||||
|
private readonly ShodanClient shodanClient = new ShodanClient("9F0mxmNSaHbe0mYmefwoCZrChT2h0KzC");
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetHost()
|
||||||
|
{
|
||||||
|
var result = await shodanClient.GetHostAsync("41.21.249.170");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task PerformSearch()
|
||||||
|
{
|
||||||
|
var result = await shodanClient.SearchHosts(a => a.With_state("NY"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,8 @@
|
|||||||
"NETStandard.Library": "1.5.0-rc2-24027",
|
"NETStandard.Library": "1.5.0-rc2-24027",
|
||||||
"xunit": "2.1.0",
|
"xunit": "2.1.0",
|
||||||
"dotnet-test-xunit": "1.0.0-rc2-build10015",
|
"dotnet-test-xunit": "1.0.0-rc2-build10015",
|
||||||
"Shodan.Net": "1.0.0-*"
|
"Shodan.Net": "1.0.0-*",
|
||||||
|
"Newtonsoft.Json": "8.0.3"
|
||||||
},
|
},
|
||||||
|
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
|
|||||||
@@ -70,12 +70,12 @@ namespace Shodan.Net.Models
|
|||||||
/// The IP address of the host as an integer
|
/// The IP address of the host as an integer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataMember(Name = "ip")]
|
[DataMember(Name = "ip")]
|
||||||
public int? Ip { get; set; }
|
public long? Ip { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The IPv6 address of the host as a string. If this is present then the "ip" and "ip_str" fields wont be.
|
/// The IPv6 address of the host as a string. If this is present then the "ip" and "ip_str" fields wont be.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataMember(Name = "ip")]
|
[DataMember(Name = "ipv6")]
|
||||||
public string Ipv6 { get; set; }
|
public string Ipv6 { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
52
src/Shodan.Net/Models/Certificate.cs
Normal file
52
src/Shodan.Net/Models/Certificate.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Shodan.Net.Models
|
||||||
|
{
|
||||||
|
public class Certificate
|
||||||
|
{
|
||||||
|
[DataMember(Name = "sig_alg")]
|
||||||
|
public string SignatureAlgorithmm { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "issued")]
|
||||||
|
public string Issued { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "expires")]
|
||||||
|
public DateTime Expires { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "expired")]
|
||||||
|
public bool Expired { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "version")]
|
||||||
|
public int Version { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "fingerprint")]
|
||||||
|
public Fingerprint Fingerprint { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "subject")]
|
||||||
|
public dynamic Subject { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "pubkey")]
|
||||||
|
public dynamic PublicKey { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "issuer")]
|
||||||
|
public dynamic Issuer { get; set; }
|
||||||
|
|
||||||
|
[DataMember(Name = "ciper")]
|
||||||
|
public dynamic Ciper { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore()]
|
||||||
|
[DataMember(Name = "serial")]
|
||||||
|
public string Serial { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Fingerprint
|
||||||
|
{
|
||||||
|
public string sha256 { get; set; }
|
||||||
|
public string sha1 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,7 +36,6 @@ namespace Shodan.Net.Models
|
|||||||
[DataMember(Name = "country_code")]
|
[DataMember(Name = "country_code")]
|
||||||
public string CountryCode { get; set; }
|
public string CountryCode { get; set; }
|
||||||
|
|
||||||
[DataMember(Name = "data")]
|
|
||||||
public List<Banner> Data { get; set; }
|
public List<Banner> Data { get; set; }
|
||||||
|
|
||||||
[DataMember(Name = "city")]
|
[DataMember(Name = "city")]
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace Shodan.Net.Models
|
|||||||
/// The area code for the device's location. Only available for the US.
|
/// The area code for the device's location. Only available for the US.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataMember(Name = "area_code")]
|
[DataMember(Name = "area_code")]
|
||||||
public int AreaCode { get; set; }
|
public int? AreaCode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The designated market area code for the area where the device is located. Only available for the US.
|
/// The designated market area code for the area where the device is located. Only available for the US.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
@@ -13,7 +14,10 @@ namespace Shodan.Net.Models
|
|||||||
/// The parsed certificate properties that includes information such as when it was issued, the SSL extensions, the issuer, subject etc.
|
/// The parsed certificate properties that includes information such as when it was issued, the SSL extensions, the issuer, subject etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataMember(Name = "cert")]
|
[DataMember(Name = "cert")]
|
||||||
public dynamic Cert { get; set; }
|
public Certificate Cert { get; set; }
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public decimal[] Serial { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Preferred cipher for the SSL connection
|
/// Preferred cipher for the SSL connection
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Shodan.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RequestHandler : IRequstHandler
|
public class RequestHandler : IRequstHandler
|
||||||
{
|
{
|
||||||
private HttpClient client { get; set; }
|
private HttpClient client = new HttpClient();
|
||||||
|
|
||||||
public async Task<T> MakeRequestAsync<T>(Uri url, HttpContent content = null, RequestType requstType = RequestType.GET)
|
public async Task<T> MakeRequestAsync<T>(Uri url, HttpContent content = null, RequestType requstType = RequestType.GET)
|
||||||
where T : class
|
where T : class
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
/*! \mainpage Shodan.Net
|
/*! \mainpage Shodan.Net
|
||||||
* Shodan.net is a simple c# implementation of the shodan api
|
* Shodan.net is a simple c# implementation of the shodan api
|
||||||
* Shodan.net is missing the streams api, but it will come soon. Most of the action occurs in ShodanClient.cs
|
* Shodan.net is missing the streams api, but it will come soon. Most of the action occurs in Shodan.Net.ShodanClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Shodan.Net
|
|||||||
{
|
{
|
||||||
public class QueryGenerator
|
public class QueryGenerator
|
||||||
{
|
{
|
||||||
internal Dictionary<string, string> queryData { get; set; }
|
internal Dictionary<string, string> queryData = new Dictionary<string, string>();
|
||||||
private HashSet<string> CalledMethods = new HashSet<string>();
|
private HashSet<string> CalledMethods = new HashSet<string>();
|
||||||
private string searchText = string.Empty;
|
private string searchText = string.Empty;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"version": "0.1.0",
|
"version": "0.3.0",
|
||||||
"authors": [ "Tommy Parnell" ],
|
"authors": [ "Tommy Parnell" ],
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NETStandard.Library": "1.5.0-rc2-24027",
|
|
||||||
"Newtonsoft.Json": "8.0.3"
|
"Newtonsoft.Json": "8.0.3"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
@@ -11,10 +10,16 @@
|
|||||||
"imports": "dnxcore50",
|
"imports": "dnxcore50",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Dynamic.Runtime": "4.0.11-rc2-24027",
|
"System.Dynamic.Runtime": "4.0.11-rc2-24027",
|
||||||
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027"
|
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027",
|
||||||
|
"NETStandard.Library": "1.5.0-rc2-24027"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"net45": { "frameworkAssemblies": { "System.Runtime.Serialization": "4.0.0.0" } }
|
"net45": {
|
||||||
|
"frameworkAssemblies": {
|
||||||
|
"System.Runtime.Serialization": "4.0.0.0",
|
||||||
|
"System.Net.Http": "4.0.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"xmlDoc": false
|
"xmlDoc": false
|
||||||
|
|||||||
Reference in New Issue
Block a user