INNER CODE UNIT · Python
bh_query
idnahacks/GoodHound · goodhound/ghresults.py:87
def bh_query(path):
"""Generate a replayable query for each finding for Bloodhound visualisation."""
query = """match p=(({name:'%s'})""" %path["nodeLabels"][0]
n=1
for r in path["relLabels"]:
nextstring = "-[:%s]->({name:'%s'})" %(r, path["nodeLabels"][n])
query = query + nextstring
n += 1
finalstring = ") return p"
query = query + finalstring
return query
def grandtotals(totaluniqueuserswithpath, totalenablednonadminusers, totalpaths, new_path, seen_before, weakest_links, top_results):
total_users_percentage = round(((totaluniqueuserswithpath/totalenablednonadminusers)*100),1)
grandtotals = [{"Total Non-Admins with a Path":totaluniqueuserswithpath, "Percentage of Total Enabled Non-Admins":total_users_percentage, "Total Paths":totalpaths, "% of Paths Seen Before":seen_before/totalpaths*100, "New Paths":new_path}]
grandtotalsdf = pd.DataFrame(grandtotals)
weakest_linkdf = pd.DataFrame(weakest_links, columns=["Weakest Link", "Number of Paths it appears in", "% of Total Paths", "Bloodhound Query"])
busiestpathsdf = pd.DataFrame(top_results, columns=["Starting Node", "Number of Enabled Non-Admins with Path", "Percent of Total Enabled Non-Admins with Path", "Number of Hops", "Exploit Cost", "Risk Score", "Path", "Bloodhound Query", "UID"])