Friday, December 9, 2016

How to download Flash Files No Flash files in tmp

How to download Flash Files No Flash files in tmp


Firstly, we have our facebook page now, you will find a link to like this page in the right column, please like this page and keep yourself updated about new post(s) on Linux on Desktop.


First a disclaimer,it might be illegal to download flash file,it depends upon the websites TOS and I encourage you to go through them before attempting to download flash file, if it is illegal I will NOT recommend that you download flash file.


There are different ways to download flash file, there are plugins that you can install in firefox, there are scripts that allow you to do so, however,one of the better ways that I have used for years( at least more than a year) is copying FlashXXX files from /tmp and renaming them appropriately.

Whenever flash played any media file in the browser, it downloaded Flash file locally in /tmp and deleted it when you closed the page. This had many advantages, for instance if you find something interesting and have already watched it in browser, you do not have to download it again using some plugin, or for instance you could only play part of file by seeking it appropriately and the relevant section is only downloaded in /tmp.

However, I found after updating my system, I no longer had FlashXXX files stored in /tmp , I looked frantically on net to find out reasons for this and found that this has to do with Adobe Flash Player being updated, which no longer saves Files temporarily in /tmp. I further looked up different forums on the Internet and found Flash indeed saved file on the system locally, it was just bit more difficult to access them.

In this post I would try to demonstrate how to retrieve flash files stored locally in the system while it is being played in the web-browser when they are not saved in /tmp. This works with Mozilla Firefox, I havent tried this with other browsers, though it can work.

One approach to solve this problem would be to downgrade your flash to earlier version, but this is not recommended as updates fix many critical security vulnerabilities and further have performance improvements.

The key to finding flash is the fact that on POSIX based systems, or for instance GNU/Linux all the information about processes running on the system is stored in "/proc" directory were each running process is identified with Process ID and there is a directory corresponding to PID in /proc. Further, all the open File descriptors are maintained here i.e in a lyaman all the information about files opened by process is here.

So if we can find process ID corresponding to the instance of flash player and find the fd corresponding to opened flash file we can easily copy the file and this is the approach that is followed by this script ( I am not the original author of this script) :

Open your favorite text editor and copy the following script, and rename it to something like - findflash.sh

#!/usr/bin/env bash

for flashpid in $(pgrep -f flashplayer.so); do
cd "/proc/$flashpid/fd"
for video in $(file * | grep /tmp/Flash | sed s/(^[0-9]*).*/1/g); do
echo "/proc/$flashpid/fd/$video"
done
done
Now, open your favorite flash(ensure it is legal to copy) file in web-browser, and in terminal window execute this file by issuing command :

bash findflash.sh
This should print the fd corresponding to all the flash files currently playing, copy them using conventional UNIX command and rename it to meaningful name.

The screen shot below illustrates this -

We had opened a video in Firefox, then we executed findflash.sh script, which gave us file descriptors of opened flash video, we copied and renamed this to some meaningful file name and played it using mplayer.



Article Written by : Ambuj Varshney (blogambuj@gmail.com)
For Linux on Desktop Blog , http://linuxondesktop.blogspot.com
(C) 2011 , Ambuj Varshney


Available link for download