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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
httpscan.log
12 changes: 12 additions & 0 deletions definitions/ilo3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "ilo3",
"meta": {
"vendor": "HP"
},
"rules": {
"headers": {
"server": ["Allegro-Software-RomPager"]
}
},
"plugins": ["ilo3"]
}
13 changes: 13 additions & 0 deletions definitions/ilo4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "ilo4",
"meta": {
"vendor": "HP",
"class": "iLO 4"
},
"rules": {
"headers": {
"server": ["HP-iLO-Server", "HPE-iLO-Server"]
}
},
"plugins": ["ilo4"]
}
16 changes: 8 additions & 8 deletions httpscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
parser.add_argument('--fast', help='Change timeout settings for the scanner in order to scan faster (T5).', default=False, action='store_true')
parser.add_argument('--definitions-create', help='Create a definition for a given host', default=False, action='store_true')
parser.add_argument('--port', help='Port to be scanned (default: 80)', type=str, default=PORT)
parser.add_argument('--allow-redirects', dest='allow_redirects', action='store_true')
parser.add_argument('--no-allow-redirects', dest='allow_redirects', action='store_false')
parser.set_defaults(allow_redirects=True)
parser.add_argument('--debug', help='Show additionalinformation in the logs', action='store_true', default=False)
args = parser.parse_args()

Expand All @@ -54,9 +57,9 @@
if args.definitions_create:
url = 'http://{host}:{port}/'.format(host=args.hosts, port=args.port)
try:
response = requests.get(url, timeout=5, verify=False)
response = requests.get(url, timeout=5, verify=False, allow_redirects=args.allow_redirects)
except (requests.exceptions.RequestException, requests.exceptions.SSLError) as e:
log.debug('{url} request error: {exc}'.format(url=url, exc=e))
log.debug('{url} request error: {ename} {eargs!r}'.format(url=url, ename=type(e).__name__, eargs=e.args))
exit()

valid_charcters = string.ascii_lowercase + string.digits
Expand Down Expand Up @@ -120,12 +123,9 @@
# Make HTTP request
url = 'http://{host}:{port}/'.format(host=host, port=port)
try:
response = requests.get(url, timeout=5, verify=False)
response = requests.get(url, timeout=5, verify=False, allow_redirects=args.allow_redirects)
except (requests.exceptions.RequestException, requests.exceptions.SSLError) as e:
log.debug('{url} request error: {exc}'.format(
url=url,
exc=e
))
log.debug('{url} request error: {ename} {eargs!r}'.format(url=url, ename=type(e).__name__, eargs=e.args))
continue

identity = None
Expand Down Expand Up @@ -177,4 +177,4 @@
definition_name=identity.get('name'),
definition_meta=identity.get('meta')
)
)
)
17 changes: 17 additions & 0 deletions plugins/ilo3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import subprocess
import json

def run(host, port, definition, response):
url = 'https://{host}:{port}/json/login_session'.format(host=host, port=443)
# using curl because requests.get barfs with a SSLError (sslv3 alert handshake failure)
try:
r = subprocess.check_output(['curl', '--silent', '-k', url], stderr=None);
jsond = json.loads(r)
if jsond:
definition[u'meta'][u'class'] = 'iLO 3'
definition[u'meta'][u'ilo-version'] = jsond["version"]
except (Exception) as e:
# print('{url} request error: {ename} {eargs!r}'.format(url=url, ename=type(e).__name__, eargs=e.args))
pass

return definition
17 changes: 17 additions & 0 deletions plugins/ilo4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import requests
import json

def run(host, port, definition, response):
url = 'https://{host}:{port}/rest/v1'.format(host=host, port=443)
try:
r = requests.get(url, timeout=5, verify=False, allow_redirects=False)
if r.status_code == 200:
jsond = json.loads(r.text)
if jsond:
definition[u'meta'][u'class'] = jsond["Oem"]["Hp"]["Manager"][0]["ManagerType"]
definition[u'meta'][u'ilo-version'] = jsond["Oem"]["Hp"]["Manager"][0]["ManagerFirmwareVersion"]
except (Exception) as e:
# print('{url} request error: {ename} {eargs!r}'.format(url=url, ename=type(e).__name__, eargs=e.args))
pass

return definition