Now I have to replace #FF3200 #FF3200 #FF3200 by - and #FF3200 by .. Then remove every thing who is not -, . and >. Finaly replace > by a space.
1
grep "#FF3200" -C 1 hex.txt | awk '{ print $3 }' | awk '!NF{$0=">"}1' | xargs | sed 's/#FF3200 #FF3200 #FF3200 /-/g' | sed 's/#FF3200 /./g' | sed 's/#BC32D8//g' |sed 's/ //g'| sed 's/>/ /g'
Translate the morse
Now I have this string ----- ---.., there is one space between the 2 chars, I would add one space at the end and use sed to replace it by a letter. Like this
1 2
sed 's/----- /9/' sed 's/---.. /8/'
This is what I wanted to do at first but my space is removed in my script, I don’t know why. So I add this > at the end to have something like this: .- -... >
#!/bin/bash code=$1 code=$(echo$code | sed 's/\.- /A/g') code=$(echo$code | sed 's/-\.\.\. /B/g') code=$(echo$code | sed 's/-\.-\. /C/g') code=$(echo$code | sed 's/-\.\. /D/g') code=$(echo$code | sed 's/\. /E/g') code=$(echo$code | sed 's/\.\.-\. /F/g') code=$(echo$code | sed 's/--\. /G/g') code=$(echo$code | sed 's/\.\.\.\. /H/g') code=$(echo$code | sed 's/\.\. /I/g') code=$(echo$code | sed 's/\.--- /J/g') code=$(echo$code | sed 's/-\.- /K/g') code=$(echo$code | sed 's/\.-\.\. /L/g') code=$(echo$code | sed 's/-- /M/g') code=$(echo$code | sed 's/-\. /N/g') code=$(echo$code | sed 's/--- /O/g') code=$(echo$code | sed 's/\.-- /P/g') code=$(echo$code | sed 's/--\.- /Q/g') code=$(echo$code | sed 's/\.-\. /R/g') code=$(echo$code | sed 's/\.\.\. /S/g') code=$(echo$code | sed 's/- /T/g') code=$(echo$code | sed 's/\.\.- /U/g') code=$(echo$code | sed 's/\.\.\.- /V/g') code=$(echo$code | sed 's/\.-- /W/g') code=$(echo$code | sed 's/-\.\.- /X/g') code=$(echo$code | sed 's/-\.-- /Y/g') code=$(echo$code | sed 's/--\.\. /Z/g') code=$(echo$code | sed 's/\.---- /1/g') code=$(echo$code | sed 's/\.\.--- /2/g') code=$(echo$code | sed 's/\.\.\.-- /3/g') code=$(echo$code | sed 's/\.\.\.\.- /4/g') code=$(echo$code | sed 's/\.\.\.\.\. /5/g') code=$(echo$code | sed 's/-\.\.\. /6/g') code=$(echo$code | sed 's/--\.\.\. /7/g') code=$(echo$code | sed 's/---\.\. /8/g') code=$(echo$code | sed 's/----\. /9/g') code=$(echo$code | sed 's/----- /0/g') code=$(echo$code | sed 's/ >//g') echo$code
It’s ugly, there is no loop, no if and all that shiny stuffs, only the basics but it’s working. I can do it even smaller, with multiple sed in sed in sed etc… And then the output of this will be the password for the zip file. I have to assemble everything like a lego.
Assemble
In my script I have to do this:
1 2 3 4
# Get Morse # Translate # Unzip # repeat
Oh nooooooo !!! I just found a problem, it’s not the same hex value for every flag.png. There is 2 hex value every times, there is more background then foreground. To find the background:
Yup, the path is very long I’ve unziped more than 150 zip files, I should move the zip file every 150 files to be closer to the root directory. I’m not gonna create an another loop, I will just use the current one.