-
-
Save f0r34chb3t4/bb40d0c248d08b4514aece02bfa46852 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Quickly and dirtily get JBoss X-Powered-By header contents | |
from the Censys API. | |
Usage: python censys_jboss.py > censys_jboss.txt""" | |
import os | |
import sys | |
import json | |
import requests | |
API_URL = "https://www.censys.io/api/v1" | |
# get the following from https://censys.io/account | |
UID = os.environ['CENSYS_UID'] | |
SECRET = os.environ['CENSYS_SECRET'] | |
def go(): | |
pagenum = 1 | |
npages = 99999999 | |
while pagenum < npages: | |
payload = dict(query='80.http.get.headers.x_powered_by: JBoss', | |
fields=['80.http.get.headers.x_powered_by'], | |
page=pagenum) | |
res = requests.post(API_URL + "/search/ipv4", | |
auth=(UID, SECRET), | |
json=payload) | |
if res.status_code != 200: | |
print "error occurred: %d" % res.status_code | |
sys.exit(1) | |
j = res.json() | |
if pagenum == 1: | |
print '# %s' % j['metadata'] | |
npages = j['metadata']['pages'] | |
if j["status"] != "ok": | |
print "API query status is not 'ok': %s" % j["status"] | |
sys.exit(2) | |
for result in j["results"]: | |
print result['80.http.get.headers.x_powered_by'][0] | |
pagenum += 1 | |
if __name__ == '__main__': | |
go() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment