0

I exported:

export FMTSTR="%2\$n'printf "\xc0\xf2\x03\x42";'"

and I want to see the result:

env | grep FMTSTR
FMTSTR=%2$n'printf xc0xf2x03x42;'

but this is not what I want...The result must be :

‫‪FMTSTR=%2$nTB‬‬

Could you possibly tell me what the problem is? secondly can I use python instead of printf? like this:

export FMTSTR="%2\$n $(python -c 'print "\xc0\xf2\x03\x42"')"

when I use python the result is:

FMTSTR=%2$n ��B

why? please give me a help in these two questions.

thank you...

MLSC
  • 5,872
  • 8
  • 55
  • 89
  • Can you please show us an "ideal output"? What do you want it to equal in the end? – Goodies Jan 14 '14 at 06:00
  • I told friend.The result must be: ‫‪FMTSTR=%2$nTB‬‬ – MLSC Jan 14 '14 at 06:00
  • Why are you escaping the hex literals while setting the variable? – devnull Jan 14 '14 at 06:18
  • what do you mean? I didn't get it, pardon – MLSC Jan 14 '14 at 06:21
  • can you gime me an example? – MLSC Jan 14 '14 at 06:25
  • I tried `$printf "\xc0\xf2\x03\x42"` and got ��B. Also I tried `$python -c 'print "\xc0\xf2\x03\x42"'` and got the same: ��B. There is something with your terminal encoding (for me it is UTF8). Try playitng with this: $python -c 'print "\xc0\xf2\x03\x42".decode("cp1251").encode("utf8")' – akozin Jan 14 '14 at 06:38
  • my result is: FMTSTR=%2$n АтB...I think i'm getting closed...thank you..but 'A' char is extra... – MLSC Jan 14 '14 at 06:55
  • I don't see where the TB comes from. I see the \x42 'B' in ascii, but what are the 3 bytes before it? – Goodies Jan 14 '14 at 07:06

1 Answers1

1

This is not exactly correct (due to the nature of your question), but I feel you may have better luck using this:

export FMTSTR=`python -c 'print "%2$n\xc0\xf2\x03\x42"'`

Now, the \xc0\xf2\x03 has no ascii equivalent. I'm not sure how you're expecting the output TB.

Goodies
  • 4,439
  • 3
  • 31
  • 57