Skip to content

Instantly share code, notes, and snippets.

@gwillem
Created November 10, 2017 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwillem/d57c61e735b09999792830f73b97b9b0 to your computer and use it in GitHub Desktop.
Save gwillem/d57c61e735b09999792830f73b97b9b0 to your computer and use it in GitHub Desktop.
censys coinhive query
#!/usr/bin/env python
import os
import censys.websites, censys.ipv4
UID = os.getenv('CENSYS_UID')
KEY = os.getenv('CENSYS_KEY')
NEEDLE='coinhive.min.js'
def websites():
api = censys.websites.CensysWebsites(api_id=UID, api_secret=KEY)
return api.search(NEEDLE)
def ipv4():
api = censys.ipv4.CensysIPv4(api_id=UID, api_secret=KEY)
return api.search(NEEDLE)
if __name__ == '__main__':
print("Nr of websites found: {}".format(len(list(websites()))))
print("Nr of IPv4 hits found: {}".format(len(list(ipv4()))))
@gwillem
Copy link
Author

gwillem commented Nov 10, 2017

Results:

Nr of websites found: 901
Nr of IPv4 hits found: 1588

And this is total sites (which includes lots of porn/torrent/stream/grey stuff), while I did study stores, which are in the legitimate domain.

@N0ur5
Copy link

N0ur5 commented Dec 26, 2017

Hello, I'm pretty new to Python and completely new to censys. I am to the point where I run this script with no errors but I want to review the actual list of results instead of just the number found. Is there an easy way for me to do that? For example, can I output the websites or IPV4 results to a txt or csv file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment