Tags: bash 

Rating:

This bash script evaluates to echo dont just run it, dummy # flag{...} where the flag is in the comments.

The comment won't be visible if you just execute the script. How can you mess with bash to get the value right before it executes?

Enjoy the intro misc chal.

Given file : cmd.sh.

when we run, we got output like this :
`dont just run it, dummy`

so we're trying to debug it.

`$ cat cmd.sh > debug.sh`

and add set -x at the start, set +x at the end of the code.

then when we trying to run it, we got a lot of junk + all the printf %s

```
...
...
] ${*} ${*} $(( ((-53#k+-3${!@}7"#"${*/;Qlu\"=}2)+${*/WgF^iKN3}1${@/^\`f~}6"#"2"4") )) ${*/fbim} ${*/X26C\)} $(( ((50#0*26#0)+8#25) )) ${*~} ${@} $[ ((-${*}49#"b"+4#10)+${*,,}2"0"${*/8.a\!}#${@##y\{5mY}i) ] ${*,,} $(( ((${!@}29${*##T07NyjoN}#"1"6-56#i)+3${*/k*s\!Cd\}/r7<&Rm}5"#""1") )) ${@~} $(( (-(-(${*/qQ<\(~\}/joR<\]g\`}2#1"${@//7\]*&}"00--7#11)+5"#"13)) )) ${@^^} $[ ((-30"#"l+"6"${*//8STR/\(>\"R}#$*0)+"${@/\[aTv77s/x\`Fhf}"2#1000"1"1) ] ${*//\)Dta1B6b/iem\)} ${*//Y^\]x;c0} $[ (("$@"5"6"#2*39#$*1)+"3"${!*}#11) ] ${*^^} $[ ((-"3""${@~~}"#1"0"*-${*}4${*}#1"1")+5"#""${@%%-1gVAj}"12) ] ${@##\)0\{\(S} $(( (("9"${*}#0*26#0)+4${@//\{hrT\[e7}#1) )) ${@#cvkgJ#} ${*//U~9f} $[ (-(-("3""7"#${*/*-Mxa_}2-"${@//UV>ejI/#\{\!\)\)Jq}"-"5""7""#""2")+2"#"11)) ] ${*/rPT<z8} ${*#V\"mmO} $(( ((${@%%ETMr$\{+\)}-"5""1"#l+"-"12#1"a")+${@%%->ho\]}4#"${@^}"10"1"0) )) "${@%%nHAMo}" "$@" $[ ((-"1"7${*~}#"${@%\[~Z$\{.px}"1*61#2)+8#${*/jd_$/d+1$|}17) ] "${@,}" "${@/\[-S\(;}" $[ ((${*^}3#10*28#${*#>6rK8}2)+22#e) ] ${!*}

**+++ printf %s f**

+++ for VS2R4y in $[ (-(-(3${*~~}#"1""${@/&=7I2ZJ}"1+"9""#"1)+${@~~}57#0)) ] ${@#-\(>G:=l} ${@##liW$} $[ ((-2#101-2"#""1""1"1)+"5"2"${@//H34o/\]6$=7u}"#${*,,}j) ] ${@,,} ${@^^} $[ ((2${*}#100*"-"${*~}4#"1"1)+${*^}18#22) ] ${!@} ${*,} $[ (-(-(23"#""f"--42#2)+7"#"12)) ] ${*//\]Kxy14./:D.-L\(} $[ ((4"#"${*}11-2"8"#0)+11"#""1"0) ] "${@%%J\)\)?7\(n}" "${@%%~\J2LrQ}" $(( (-(-("${@%8Yzpz@H}"-56#"1"-${*/C\oI,C:/~2^DZha}-6#11)+6${*##\!KW^\{}0${*//VEUHMT\}}#0)) )) ${@//,\)tNL} ${*} $(( (("-"2#1"1"*"2"7#2)+"5"0"#"e) )) ${@/rI%kSy/22\!9x*UR} "${@^^}" $[ (("
...
...
```

save it to a file, then grep "printf %s"

```
+++ printf %s f
+++ printf %s l
+++ printf %s a
+++ printf %s g
+++ printf %s '{'
+++ printf %s u
+++ printf %s s
+++ printf %s 3
+++ printf %s _
+++ printf %s z
+++ printf %s s
+++ printf %s h
+++ printf %s ,
+++ printf %s _
+++ printf %s d
+++ printf %s u
+++ printf %s m
+++ printf %s m
+++ printf %s y
+++ printf %s '}'
```

**flag{us3_zsh,_dummy}**