Skip to content

Instantly share code, notes, and snippets.

@FrancoisCapon
Last active December 16, 2023 09:33
Show Gist options
  • Save FrancoisCapon/7d18f79833f95510630a0fdf989156ad to your computer and use it in GitHub Desktop.
Save FrancoisCapon/7d18f79833f95510630a0fdf989156ad to your computer and use it in GitHub Desktop.
Capture CTF flags in files with strings tool

Capture flags in files with strings

#!/bin/bash

# Parameters example
# Disclaimer: any resemblance to actual exercices or CTF is purely coincidental ;-)
files_pattern='pcap_??.pcap'
flags_pattern='.{8}-.{4}-.{4}-.{4}-.{12}'

clear
echo
echo -e "\x1b[1;38;5;208m** Capture flags in files with strings **\n"
echo -e -n "\x1b[22m\x1b[38;5;220m"
echo "Warning: this method is absolutely not educational, you will not lean"
echo "         anything about the structure and content of the files to analyze!"
echo
echo -e "\x1b[22m\x1b[37mFiles pattern: \x1b[1;95m$files_pattern"
echo -e "\x1b[22m\x1b[37mFlags pattern: \x1b[1;95m$flags_pattern"
results=''
for file in $files_pattern
do
   results=$results"\n\x1b[1;96m* $file:\n"
   results=$results"\x1b[0;92m"
   results=$results$(strings --bytes=36 $file | egrep -o $flags_pattern | sort -u)
   results=$results"\n"
done
echo -e "$results"

📢 Warning: this method is absolutely not educational, you will not lean anything about the structure and content of the files to analyze!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment