13 Commits

Author SHA1 Message Date
Tommy Parnell
3faeb028e4 Merge pull request #2 from RonSijm/master
Fixed multible issues with models
2016-06-11 19:52:48 -04:00
Ron Sijm
177b86d997 Fixed multible issues with models:
- SearchHostResults missing "matches data attribute
 - Location areacode not being nullable
 - Banner having duplicate "ip" datamembers
 - Banner IP field being too small for the data
2016-06-12 01:26:08 +02:00
Tommy Parnell
8a2425abd1 really stoppign 2016-06-01 19:15:34 -04:00
Tommy Parnell
bbb863a5ea stopping for now 2016-06-01 19:15:11 -04:00
Tommy Parnell
1f85dfd096 add badge 2016-05-21 19:27:45 -04:00
Tommy Parnell
969b533e7d add appveyor yml 2016-05-21 19:25:11 -04:00
Tommy Parnell
08618aab83 Merge branch 'master' of github.com:tparnell8/Shodan.Net 2016-05-21 19:17:04 -04:00
Tommy Parnell
29241095a1 make test pass for now 2016-05-21 19:16:59 -04:00
Tommy Parnell
0378b52107 move up api docs 2016-05-21 18:28:41 -04:00
Tommy Parnell
ecc537eb46 you shouldnt need the standard lib for .net 4.5, just use framework targets 2016-05-21 14:36:25 -04:00
Tommy Parnell
2a2b388a39 minor readme fix 2016-05-21 14:32:40 -04:00
Tommy Parnell
0a6f61f590 fix doxyconf 2016-05-21 14:30:04 -04:00
Tommy Parnell
25fd53d3f5 minor docs fixes 2016-05-21 14:27:47 -04:00
16 changed files with 125 additions and 45 deletions

View File

@@ -1,9 +1,15 @@
[![Build status](https://ci.appveyor.com/api/projects/status/h0x5jv0s8p4ig078/branch/master?svg=true)](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
``` ```

View File

@@ -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
View 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\

View File

@@ -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.

View File

@@ -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()
);
}
}
}

View 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"));
}
}
}

View File

@@ -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": {

View File

@@ -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>

View 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; }
}
}

View File

@@ -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")]

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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