Skip to content

Instantly share code, notes, and snippets.

@Crinfarr
Last active September 3, 2024 20:25
Show Gist options
  • Select an option

  • Save Crinfarr/dd38f44ec811befdf0a8a1f053a4a1c4 to your computer and use it in GitHub Desktop.

Select an option

Save Crinfarr/dd38f44ec811befdf0a8a1f053a4a1c4 to your computer and use it in GitHub Desktop.

Revisions

  1. Crinfarr revised this gist Sep 3, 2024. 1 changed file with 11 additions and 4 deletions.
    15 changes: 11 additions & 4 deletions masscanbannerparser.py
    Original file line number Diff line number Diff line change
    @@ -2,16 +2,23 @@
    hook = ""# YOUR CHANNEL HOOK HERE

    from discord_webhook import DiscordWebhook, DiscordEmbed
    import sys
    wh = DiscordWebhook(hook)

    for line in input():
    [_, tcudp, port, ip, ts, stype] = line.split(' ')
    for line in sys.stdin:
    if (line[0:6] != 'banner'): continue
    print(line)
    [_, tcudp, port, ip, ts, stype] = line.split(' ')[0:6]
    banner = ' '.join(line.split(' ')[6:])
    if stype == "X509":
    continue # All HTTPS servers send SSL -> X509 so we only care about one
    banner = ' '.join(line.split(' ')[6:])
    desc = f'{stype} server discovered '+\
    f'at {"http://" if stype == "http" else "https://" if stype=="SSL" else ""}{ip}:{port}\n'+\
    f'{"cert" if stype == "ssl" else "banner"}:```\n{banner}\n```'
    print(desc)
    embed = DiscordEmbed()
    embed.set_title(f'Discovered open {tcudp} port')
    embed.set_description(f'{stype} server discovered at {"http://" if stype == "http" else "https://" if stype=="SSL" else ""}{ip}:{port}. {"cert" if stype == "ssl" else "banner"}:```\n{banner}\n```')
    embed.set_description(desc)
    embed.set_timestamp(int(ts))
    wh.add_embed(embed)
    wh.execute(True)
  2. Crinfarr created this gist Sep 3, 2024.
    17 changes: 17 additions & 0 deletions masscanbannerparser.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/usr/bin/env python3
    hook = ""# YOUR CHANNEL HOOK HERE

    from discord_webhook import DiscordWebhook, DiscordEmbed
    wh = DiscordWebhook(hook)

    for line in input():
    [_, tcudp, port, ip, ts, stype] = line.split(' ')
    if stype == "X509":
    continue # All HTTPS servers send SSL -> X509 so we only care about one
    banner = ' '.join(line.split(' ')[6:])
    embed = DiscordEmbed()
    embed.set_title(f'Discovered open {tcudp} port')
    embed.set_description(f'{stype} server discovered at {"http://" if stype == "http" else "https://" if stype=="SSL" else ""}{ip}:{port}. {"cert" if stype == "ssl" else "banner"}:```\n{banner}\n```')
    embed.set_timestamp(int(ts))
    wh.add_embed(embed)
    wh.execute(True)