Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ We are excited to share with the world a chat bot that we affectionately call Cy
!whois \<domain> - WHOIS Query (ex: cylance[.]com)
!nslookup \<FQDN|IP> - DNS forward/reverse Query (ex: www[.]cylance[.]com)
!geoip \<FQDN|IP> - Perform GeoIP lookup of host (ex: www[.]cylance[.]com)
!censys \<IP> - Return Censys information on host (ex: 1.2.3.4)
!unshorten \<shortened URL> - Unshortens URLs (ex: goo[.]gl/IGL1lE)
!screenshot <defanged URL> - Takes a screenshot of a website and returns the .png - Accepts defanged [()] URLs
!linkextractor \<FQDN|IP> - Extracts links from a site and safely displays them (ex: hxxps://www[.]google[.]com)
Expand Down
9 changes: 9 additions & 0 deletions plugins/censys/censys.plug
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Core]
Name = censys
Module = censts

[Documentation]
Description = This plugin queries Censys.io for information about an IP address.

[Python]
Version = 2+
41 changes: 41 additions & 0 deletions plugins/censys/censys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# !censys is used for Querying the censys.io API

import os, requests, json, re
from errbot import BotPlugin, botcmd, arg_botcmd

base_url = "https://www.censys.io/api/v1"
api_id = "changeme"
api_secret = "changeme"


class censys(BotPlugin):
@arg_botcmd("query", type=str) # flags a command
def censys(self, msg, query=None):
query = re.sub("[\[()\]]", "", query)
uri = "view/ipv4/{}".format(query)
api_creds = (api_id, api_secret)
response = requests.get(base_url + uri, auth=api_creds)
json_resp = response.json()

if json_resp.get("error", False):
answer = 'Error: ' + json_resp["error"] + "\r\n"
else:
answer = "IP: {0}\r\n".format(ip)
answer += "Tags: {0}\r\n".format(", ".join(json_resp["tags"]))
answer += "Protocols: {0}\r\n".format(", ".join(json_resp["protocols"]))
if (80) in json_resp["ports"]:
try:
answer += "Web page title (80/http): {0}\r\n".format(
json_resp["80"]["http"]["get"]["title"]
)
except KeyError:
pass
if (443) in json_resp["ports"]:
try:
answer += "Web page title (443/https): {0}\r\n".format(
json_resp["443"]["https"]["get"]["title"]
)
except KeyError:
pass
answer += "Updated at: {0}\r\n".format(json_resp["updated_at"])
return answer