Skip to content

Commit

Permalink
Refactored some of the passive scanners to be configured through prop…
Browse files Browse the repository at this point in the history
…er channels.
  • Loading branch information
RoliSoft committed Jun 26, 2016
1 parent 260642b commit 232fe92
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 61 deletions.
15 changes: 15 additions & 0 deletions CensysScanner.cpp
Expand Up @@ -22,6 +22,21 @@ CensysScanner::CensysScanner(const string& auth)
{
}

void CensysScanner::SetKey(const string& key)
{
auth = key;
}

bool CensysScanner::HasKey()
{
return !auth.empty();
}

void CensysScanner::SetEndpoint(const string& uri)
{
endpoint = uri;
}

bool CensysScanner::IsPassive()
{
return true;
Expand Down
41 changes: 31 additions & 10 deletions CensysScanner.h
Expand Up @@ -10,16 +10,6 @@
class CensysScanner : public HostScanner
{
public:

/*!
* API username and password to use for the requests.
*/
std::string auth;

/*!
* API endpoint location.
*/
std::string endpoint = "https://censys.io/api/v1";

/*!
* Initializes a new instance of this class.
Expand All @@ -33,6 +23,27 @@ class CensysScanner : public HostScanner
*/
explicit CensysScanner(const std::string& auth);

/*!
* Sets the specified API key.
*
* \param key API key to set.
*/
void SetKey(const std::string& key);

/*!
* Value indicating whether an key was specified.
*
* \return true if key is present, otherwise false.
*/
bool HasKey();

/*!
* Sets the specified API endpoint location.
*
* \param uri API location to set.
*/
void SetEndpoint(const std::string& uri);

/*!
* Value indicating whether this instance is a passive scanner.
*
Expand Down Expand Up @@ -64,6 +75,16 @@ class CensysScanner : public HostScanner
~CensysScanner() override;

private:

/*!
* API username and password to use for the requests.
*/
std::string auth;

/*!
* API endpoint location.
*/
std::string endpoint = "https://censys.io/api/v1";

/*!
* Gets the information available on the API for the specified host.
Expand Down
15 changes: 15 additions & 0 deletions LooquerScanner.cpp
Expand Up @@ -18,6 +18,21 @@ LooquerScanner::LooquerScanner(const string& key)
{
}

void LooquerScanner::SetKey(const string& key)
{
this->key = key;
}

bool LooquerScanner::HasKey()
{
return !key.empty();
}

void LooquerScanner::SetEndpoint(const string& uri)
{
endpoint = uri;
}

bool LooquerScanner::IsPassive()
{
return true;
Expand Down
41 changes: 31 additions & 10 deletions LooquerScanner.h
Expand Up @@ -9,16 +9,6 @@
class LooquerScanner : public HostScanner
{
public:

/*!
* API key to use for the requests.
*/
std::string key;

/*!
* API endpoint location.
*/
std::string endpoint = "https://mrlooquer.com/api/v1";

/*!
* Initializes a new instance of this class.
Expand All @@ -32,6 +22,27 @@ class LooquerScanner : public HostScanner
*/
explicit LooquerScanner(const std::string& key);

/*!
* Sets the specified API key.
*
* \param key API key to set.
*/
void SetKey(const std::string& key);

/*!
* Value indicating whether an API key was specified.
*
* \return true if key is present, otherwise false.
*/
bool HasKey();

/*!
* Sets the specified API endpoint location.
*
* \param uri API location to set.
*/
void SetEndpoint(const std::string& uri);

/*!
* Value indicating whether this instance is a passive scanner.
*
Expand Down Expand Up @@ -63,6 +74,16 @@ class LooquerScanner : public HostScanner
~LooquerScanner() override;

private:

/*!
* API key to use for the requests.
*/
std::string key;

/*!
* API endpoint location.
*/
std::string endpoint = "https://mrlooquer.com/api/v1";

/*!
* Gets the information available on the API for the specified host.
Expand Down
51 changes: 48 additions & 3 deletions PassiveScanner.cpp
Expand Up @@ -11,6 +11,51 @@ PassiveScanner::PassiveScanner(const string& shodan_key, const string& censys_au
{
}

void PassiveScanner::SetShodanKey(const string& key)
{
shodan_key = key;
}

bool PassiveScanner::HasShodanKey()
{
return !shodan_key.empty();
}

void PassiveScanner::SetShodanEndpoint(const string& uri)
{
shodan_uri = uri;
}

void PassiveScanner::SetCensysKey(const string& key)
{
censys_auth = key;
}

bool PassiveScanner::HasCensysKey()
{
return !censys_auth.empty();
}

void PassiveScanner::SetCensysEndpoint(const string& uri)
{
censys_uri = uri;
}

void PassiveScanner::SetLooquerKey(const string& key)
{
looquer_key = key;
}

bool PassiveScanner::HasLooquerKey()
{
return !looquer_key.empty();
}

void PassiveScanner::SetLooquerEndpoint(const string& uri)
{
looquer_uri = uri;
}

bool PassiveScanner::IsPassive()
{
return true;
Expand All @@ -24,17 +69,17 @@ void PassiveScanner::Scan(Host* host)

if (!shodan_uri.empty())
{
ss.endpoint = shodan_uri;
ss.SetEndpoint(shodan_uri);
}

if (!censys_uri.empty())
{
cs.endpoint = censys_uri;
cs.SetEndpoint(censys_uri);
}

if (!looquer_uri.empty())
{
ls.endpoint = looquer_uri;
ls.SetEndpoint(looquer_uri);
}

auto shost = new Host(*host);
Expand Down
105 changes: 84 additions & 21 deletions PassiveScanner.h
Expand Up @@ -9,50 +9,83 @@
class PassiveScanner : public HostScanner
{
public:

/*!
* Shodan API key to use for the requests.
* Initializes a new instance of this class.
*/
std::string shodan_key;
PassiveScanner() = default;

/*!
* API endpoint location of Shodan.
* Initializes a new instance of this class.
*
* \param shodan_key Shodan API key to use for the requests.
* \param censys_auth Censys API username and password to use for the requests.
* \param looquer_key Mr Looquer API key to use for the requests.
*/
std::string shodan_uri;
PassiveScanner(const std::string& shodan_key, const std::string& censys_auth, const std::string& looquer_key);

/*!
* Censys API username and password to use for the requests.
* Sets the specified API key for the Shodan scanner.
*
* \param key API key to set.
*/
std::string censys_auth;
void SetShodanKey(const std::string& key);

/*!
* API endpoint location of Censys.
* Value indicating whether a Shodan API key was specified.
*
* \return true if key is present, otherwise false.
*/
std::string censys_uri;
bool HasShodanKey();

/*!
* Mr Looquer API key to use for the requests.
* Sets the specified API endpoint location for the Shodan scanner.
*
* \param uri API location to set.
*/
std::string looquer_key;
void SetShodanEndpoint(const std::string& uri);

/*!
* API endpoint location of Mr Looquer.
* Sets the specified API key for the Censys scanner.
*
* \param key API key to set.
*/
std::string looquer_uri;
void SetCensysKey(const std::string& key);

/*!
* Initializes a new instance of this class.
* Value indicating whether a Censys API key was specified.
*
* \return true if key is present, otherwise false.
*/
PassiveScanner() = default;
bool HasCensysKey();

/*!
* Initializes a new instance of this class.
* Sets the specified API endpoint location for the Censys scanner.
*
* \param shodan_key Shodan API key to use for the requests.
* \param censys_auth Censys API username and password to use for the requests.
* \param looquer_key Mr Looquer API key to use for the requests.
* \param uri API location to set.
*/
PassiveScanner(const std::string& shodan_key, const std::string& censys_auth, const std::string& looquer_key);
void SetCensysEndpoint(const std::string& uri);

/*!
* Sets the specified API key for the Looquer scanner.
*
* \param key API key to set.
*/
void SetLooquerKey(const std::string& key);

/*!
* Value indicating whether a Looquer API key was specified.
*
* \return true if key is present, otherwise false.
*/
bool HasLooquerKey();

/*!
* Sets the specified API endpoint location for the Looquer scanner.
*
* \param uri API location to set.
*/
void SetLooquerEndpoint(const std::string& uri);

/*!
* Value indicating whether this instance is a passive scanner.
Expand Down Expand Up @@ -85,6 +118,36 @@ class PassiveScanner : public HostScanner
~PassiveScanner() override;

private:

/*!
* Shodan API key to use for the requests.
*/
std::string shodan_key;

/*!
* API endpoint location of Shodan.
*/
std::string shodan_uri;

/*!
* Censys API username and password to use for the requests.
*/
std::string censys_auth;

/*!
* API endpoint location of Censys.
*/
std::string censys_uri;

/*!
* Mr Looquer API key to use for the requests.
*/
std::string looquer_key;

/*!
* API endpoint location of Mr Looquer.
*/
std::string looquer_uri;

/*!
* Merges two host results.
Expand Down

0 comments on commit 232fe92

Please sign in to comment.