Exemple #1
0
    async def writeup(self, ctx, room_code):
        if not sanitize_check(room_code):
            return

        # Request to the API.
        data = await api_fetch(c_api_url["room"].format(room_code))

        # If the specified code is wrong.
        if data[room_code]["success"] == False:
            botMsg = await ctx.send(s_room["code_not_found"].format(room_code))

            await asyncio.sleep(5)
            await botMsg.delete()
            await ctx.message.delete()

            return

        # If there is no writeup.
        if len(data[room_code]["writeups"]) == 0:
            await ctx.send(s_room["writeup_not_found"])
            return

        # Set up embed.
        img = data[room_code]["image"]
        title = data[room_code]["title"]
        link = c_url_room + room_code

        embed = officialEmbed(title, link)
        embed.set_image(url=img)

        for item in data[room_code]["writeups"]:
            embed.add_field(name="By: " + item["username"], value=item["link"])

        # Send messages.
        await ctx.send(embed=embed)
    async def rank(self, ctx, user=None):
        is_id = False

        # Empty arg, so we retrieve sender's id.
        if user == None:
            await self.rank_from_id(ctx, ctx.author.id)
            return

        # Contains a user.
        ## Is it a mention or THM username?
        ### Mentions.
        if "<@!" in user:
            is_id = True
            user = user[3:len(user) - 1]
        elif "<@" in user:
            is_id = True
            user = user[2:len(user) - 1]

        # THM Username.
        if sanitize_check(user) == False:
            await ctx.send(s_not_sanitized)
            return
        if is_id:
            await self.rank_from_id(ctx, user)
        else:
            await self.send_rank(ctx, user)
Exemple #3
0
def __check_sanitized__(args):
    """Checks that every arg in args is sanitized correctly."""

    for arg in args:
        print("Doing: "+str(arg))
        if isinstance(arg, tuple) or isinstance(arg, list):
            __check_sanitized__(arg)
        else:
            if not utils.sanitize_check(arg):
                raise Exception(s_cmd["not_sanitized"])
    async def rule(self, ctx, ruleNb):

        if not sanitize_check(ruleNb):
            await ctx.send(config.get_string("not_sanitized"))
            return

        message = "Rule " + ruleNb + " does not exist."

        ruleNb = int(ruleNb)

        if ruleNb >= 1 and ruleNb <= len(rules):
            message = "**__Rule " + str(ruleNb) + ":__** " + rules[ruleNb-1]

        await ctx.send(message)
Exemple #5
0
    async def gtfobins(self, ctx, search_term=""):
        if sanitize_check(search_term) == False:
            await ctx.send(s_not_sanitized)

        gtfobins_file = json.loads(open(c_file_gtfobins, "r").read())

        # If user is searching for something.
        if search_term != "":
            try:
                # Getting data.
                data = gtfobins_file[search_term]
                result = "".join(["- " + item[1:-1] + "\n" for item in data])

                # Generating the embed.
                response = officialEmbed(
                    s_gfto["result_title"].format(search_term), color=0xcc0000)

                response.set_thumbnail(url=s_gfto["logo"])
                response.add_field(name=s_gfto["search_terms"],
                                   value=search_term)
                response.add_field(name=s_gfto["vulnerability"], value=result)
                response.add_field(
                    name=s_gfto["url"],
                    value="https://gtfobins.github.io/gtfobins/" + search_term)

                await ctx.send(embed=response)
            except Exception as e:
                await ctx.send(s_gfto["not_found"].format(search_term))

        # Otherwise display a list of possibilities.
        else:
            try:
                result = ""
                for key, value in gtfobins_file.items():
                    result += "- " + key
                    result += "\n"

                response = discord.Embed(title=s_gfto["binaries"],
                                         color=0xcc0000)
                response.set_thumbnail(url=s_gfto["logo"])
                response.add_field(name=s_gfto["binaries_list"], value=result)
                response.add_field(name="How to?", value=s_gfto["howto"])

                await ctx.send(s_gfto["sending_list"])
                await ctx.send(embed=response)
            except Exception as e:
                await ctx.send(s_gfto["error"])