adding the /api/map endpoint to retreive all endpoint possible

1.6
Tristan Dostaler 2016-05-18 18:23:02 -04:00
parent e43fb94634
commit 92b9d4d09e
1 changed files with 21 additions and 1 deletions

22
empire
View File

@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
import sqlite3, argparse, sys, argparse, logging, json, string, os, re, time, signal, copy, base64 import sqlite3, argparse, sys, argparse, logging, json, string, os, re, time, signal, copy, base64
from flask import Flask, request, jsonify, make_response, abort from flask import Flask, request, jsonify, make_response, abort, url_for
from time import localtime, strftime from time import localtime, strftime
from OpenSSL import SSL from OpenSSL import SSL
from Crypto.Random import random from Crypto.Random import random
@ -231,6 +231,25 @@ def start_restful_api(startEmpire=False, suppress=False, username=None, password
""" """
return jsonify({'version': empire.VERSION}) return jsonify({'version': empire.VERSION})
@app.route('/api/map', methods=['GET'])
def list_routes():
import urllib
output = []
for rule in app.url_map.iter_rules():
options = {}
for arg in rule.arguments:
options[arg] = "[{0}]".format(arg)
methods = ','.join(rule.methods)
url = url_for(rule.endpoint, **options)
line = urllib.unquote("[ { '" + rule.endpoint + "': [ { 'methods': '" + methods + "', 'url': '" + url + "' } ] } ]")
output.append(line)
res = ''
for line in sorted(output):
res = res + '\r\n' + line
return jsonify({'Routes':res})
@app.route('/api/config', methods=['GET']) @app.route('/api/config', methods=['GET'])
def get_config(): def get_config():
@ -1097,6 +1116,7 @@ def start_restful_api(startEmpire=False, suppress=False, username=None, password
shutdown_server() shutdown_server()
return jsonify({'success': True}) return jsonify({'success': True})
print app.route('/api/admin/shutdown')
if not os.path.exists('./data/empire.pem'): if not os.path.exists('./data/empire.pem'):
print "[!] Error: cannot find certificate ./data/empire.pem" print "[!] Error: cannot find certificate ./data/empire.pem"