Commands to solve picoCTF ‘Mob psycho’ challenge:
Search for hex strings 16+ characters long
find mobpsycho -type f -exec strings {} \; | grep -oE '[0-9a-fA-F]{16,}'here:
-type- this is a find option for filtering by object type.f- “file” (regular file); other options:-type d(directories),-type l(symbolic links)-exec- execute command for each found file. Everything between-execand\;is the command that will be executed:-exec command arguments \;strings {}- here{}is a placeholder that find replaces with the full path to the found file. For example:# find finds: mobpsycho/classes.dex # command becomes: strings mobpsycho/classes.dex\;- escapes;from bash shell and ends the command for-execgrep -oE '[0-9a-fA-F]{16,}'- find hex strings 16+ characters,-E- extended regular expressions,-o- print only lines that match the regular expression
with sorting
find mobpsycho -type f -exec strings {} \; | grep -oE '[0-9a-fA-F]{16,}' | sort -uhere:
sort- sorts lines, A→Z, 1→9 by default-u --unique- removes duplicates
Search and decode potential flag
find mobpsycho -type f -exec strings {} \; | grep -oE '[0-9a-fA-F]{50,}' | while read hex; do
echo "Hex: $hex"
echo "Decoded: $(echo $hex | xxd -r -p 2>/dev/null || echo 'decode failed')"
echo "---"
doneadditional method for simultaneous search and decoding
find mobpsycho -type f -exec strings {} \; | grep -oE '[0-9a-fA-F]{60,}' | xargs -I {} sh -c 'echo "Hex: {}"; echo "Decoded: $(echo {} | xxd -r -p)"; echo "---"'here:
find→ finds filesstrings→ extracts text from filesgrep→ filters only hex stringsxargs→ receives hex strings and PASSES THEM to script (sh -ccannot directly receive data from pipe){}- placeholder/container for hex string variablesh -c- starts the scriptxxd -r -p- takes hex values in pairs, converts to raw bytes and then presents as plain text
Data flow diagram:
📁 files → 📄 text → 🔢 hex-strings → 💾 arguments → 🔤 decoded text
↓ ↓ ↓ ↓ ↓
find strings grep xargs xxd -r -p