def givelink(name: str) -> None: """Show the link of the give binary or exe Arguments: name {str} -- Name of the file to give URL of """ exes = get_exe() if name in exes.keys(): url = colors(LOLURL + "/lolbas/{}".format(exes[name]), 94) elif name in get_bins(): url = colors(GTFOURL + "/gtfobins/{}".format(name), 94) else: print( colors("[!] Couldn't find any bin/exe with name {}".format(name), 91)) sys.exit(0) name = colors(name, 93, True) print("--> {n} \t{dash}>\t {link}".format( n=name, dash=colors( "-" * 20, 93, ), link=url, ))
def parse(data: dict) -> None: """Parse the data in the proper displaying format Arguments: data {dict} -- content that is to be displayed """ def form(val: str) -> str: """To format the "code" that is being printed The code section had `\n` which kinda breaks the flow when printed on terminal so we replace `\n` with `\n\t` Arguments: val {[str]} -- commands with \n Returns: [str] -- commands with \n\t """ return val.replace("\n", "\n\t") sections = data["functions"] for sec in sections: category = sections[sec] for cat in category: if "description" in cat: print("# " + colors(cat["description"], 93)) print("Code:\t" + colors(form(cat["code"]), 92)) print("Type:\t" + colors(sec, 91)) print("\n")
def lolbas(name: str) -> None: """Search binaries from LOLBAS within command line Arguments: name {[type]} -- Name of the exe to get info about Keyword Arguments: cmd {str} -- get only the code section (default: {False}) """ exes = get_exe() if name in exes.keys(): url = RAW_URL + exes[name] + ".md" r = requests.get(url).text data = list(yaml.load_all(r, Loader=yaml.SafeLoader))[0] parse(data) else: print(colors("[!] Binary not found on LOLBAS", 91)) # TODO: Match user input and make suggestion for search print(colors("[!] Make sure to provide name with proper extension", 91))
def parse(data: Dict) -> None: """Parse and print the commands The yml file contains the following fields: Description, Command, Category, Privileges, OperatingSystem, UseCase, MitreID, MItreLink. If any more data has to be printed then we can just do that. For easy reference see the following yml file: RAW_URL/Libraries/Ieadvpack.md Arguments: data {list} -- list of dictionary having everything a command yml file contains """ # TODO: Figure out a way to improve this printing cmd = data["Commands"] for c in cmd: print("# " + colors(c["Description"], 93) + "\n") print("CMD:\t\t" + colors(c["Command"], 92)) print("Category:\t" + colors(c["Category"], 91)) print("Privileges:\t" + colors(c["Privileges"], 91)) print("\n")
def gtfobins(bin_name: str) -> None: """Search binaries from GTFOBins within command line Arguments: bin_name {[type]} -- Name of the binary to get info about """ bins = get_bins() if bin_name in bins: r = requests.get(RAW_URL.format(bin_name)).text data = list(yaml.load_all(r, Loader=yaml.SafeLoader))[0] parse(data) else: print(colors("[!] Binary not found on GTFObins: ", 91))
def signal_handler() -> None: print(colors("\n\nYou pressed Ctrl+C!", 91)) sys.exit(0)