Bjoern Olausson

Scriptarchive

findflash.sh

nd cached Flash player files

Some versions ago the Adobe Flash player stored cached files in /tmp/.
Actually the latest player sill stores the cached files in /var/tmp/ but uses a trick to hide them from the user:

The file is marked as deleted, but the file handler and data on disc still exist.
So what to do if you cached a video and want to save it for later use?

Look up the PID of "libflashplayer.so" (use "ps") and find files which are used by this process (using "lsof").
You will find something like "/tmp/Flash*".
This file does not exist in /tmp/ but we will find the file handler in "/proc/${PID}/fd/".
Just list the content (ls -la) and grep for "Flash".
You will find something like:

lrwx------ 1 blub blub 64 Aug 18 07:53 15 -> /tmp/FlashXXsJu3NC (deleted)

Now you can play the file with "mplayer /proc/${PID}/fd/15" or copy it with "cp /proc/${PID}/fd/15 ~/Desktop/myfile.flv".

This little script will do all the above for you and find any cached file by the Flashplayer

findflash.sh

   {code brush: bash}

#!/bin/bash
#
#--------------------------------------------------------------------------------
#findflash.sh v2.0, Copyright Bjoern Olausson
#--------------------------------------------------------------------------------
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#To view the license visit
#http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#or write to
#Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
#
# This script finds cached Adobe Flash files open in any browser
#

 

FLASH_PREFIX="Flash"

 

PIDS=`lsof /tmp | sed -n "s|.* \(.*\) ${USER} .*\(${FLASH_PREFIX}.* \).*|\1|p" | uniq`
FILES=`lsof /tmp | sed -n "s|.* \(.*\) ${USER} .*\(${FLASH_PREFIX}.* \).*|\2|p" | uniq`

 

if [[ "$1" != "-c" ]] ; then
echo "Use -c to outpute a C&P ready line to copy the files to your Desktop."
echo -e "You can find your currently open Flash files here:\n"
else
echo -e "Use the following line(s) to copy the files to your desktop:\n"
fi
for PID in ${PIDS} ; do
for FILE in ${FILES} ; do
FD=`ls -lAh /proc/${PID}/fd | sed -n "s|.* \(.*\) -> .*${FILE}.*|\1|p"`
LINK="/proc/${PID}/fd/${FD}"
if [[ "$1" == "-c" ]] ; then
echo "cp ${LINK} /home/${USER}/Desktop/${FILE}.flv"
else
echo "${LINK}"
fi
done
done
echo "" {/code}

 

 

Add comment


Security code
Refresh

www. is deprecated

Play OGG

Qt Ambassador

Latest comments

Gixen