Posts

Showing posts from April, 2014

Bash Script to Help With base64 and echo File Transfers

Image
Recently I had remote access to a Linux terminal with an extremely limited command set and I wanted to place a full featured web shell on the box. My usual methods of netcat and wget weren’t available but someone much smarter than I (Craig Swan at SensePost) suggested I use base64 to encode the shell (to avoid any issues with foreign characters) copy each line, and paste each line on the target box as part of an echo statement which builds a copy of the file on the target box. I thought the idea was great and it worked like a champ. I figured that this likely wasn’t the last time I would use this technique so I wrote a bash script to automate the process as much as possible. base64 $1 > based.tmp file_name=${1##*/} [ -f based_output.txt ] && rm based_output.txt prevar=’echo “‘ postvar='” >> ‘ cat based.tmp | while read line; do echo $prevar$line$postvar$file_name >> based_output.txt done The code takes an input file and prepare...