Skip to content

Instantly share code, notes, and snippets.

@Crinfarr
Last active September 3, 2024 20:25
Show Gist options
  • Save Crinfarr/dd38f44ec811befdf0a8a1f053a4a1c4 to your computer and use it in GitHub Desktop.
Save Crinfarr/dd38f44ec811befdf0a8a1f053a4a1c4 to your computer and use it in GitHub Desktop.
Parses the output of masscan [...] -oL - --banners | grep banner
#!/usr/bin/env python3
hook = ""# YOUR CHANNEL HOOK HERE
from discord_webhook import DiscordWebhook, DiscordEmbed
import sys
wh = DiscordWebhook(hook)
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
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(desc)
embed.set_timestamp(int(ts))
wh.add_embed(embed)
wh.execute(True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment