Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- __author__ = 'Irenicus09'
- __date__ = '10th June 2011'
- __license__ = 'GPL'
- __version__ = '1.0'
- ###############################################################################
- # #
- # FLASH GRAB Version 1.0 #
- # #
- # Flash Grab is a utility for Linux to access flash files cached by your #
- # browser. It can grab flash files regardless of the browser being used, #
- # also supports multiple instances of the same or different browser. #
- # It uses unique ID to keep track of different videos, so that multiple #
- # copies of the same video are not stored. #
- # #
- # Usage: ./FlashGrab.py [Destination Directory] #
- # #
- # For more info visit: #
- # http://irenicus09.wordpress.com/2011/06/10/flash-grab/ #
- # #
- ###############################################################################
- import subprocess, getpass, os, shutil, sys
- from time import sleep
- def Main():
- # Checking for invalid arguments
- if (len(sys.argv) != 2):
- print '[-] Usage: %s [Destination directory]' % sys.argv[0]
- sys.exit(1)
- elif (os.path.exists(sys.argv[1]) == False):
- print '[-] Destination path is not valid'
- sys.exit(1)
- # Edit Destination Directory if necessary [Hard Coding]
- absDestPath = sys.argv[1]
- # Get username
- usrname = getpass.getuser().strip()
- # Get base directories for searching
- cmd1 = subprocess.Popen('ps aux | grep "%s" | grep "flash"' % usrname, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- pid = (cmd1.communicate()[0].strip().split('\n'))
- # Declaring count to keep track of videos found
- count = 0
- for i in pid:
- srcPath = '/proc/%s/fd/' % (i.split()[1])
- try:
- os.chdir(srcPath)
- except (Exception):
- pass
- # Get List of valid Flash file names which are represented locally as numbers, such as 18, 32
- cmd4 = subprocess.Popen('ls -l | grep "Flash" | cut -f9 --delimiter=" "', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- srcFileName = (cmd4.communicate()[0].strip().split())
- # Parse individual Flash files and strip their unique ID for renaming
- cmd5 = subprocess.Popen('ls -l | grep "Flash" | cut -f11 --delimiter=" " | cut --delimiter="/" -f3', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- destFileName = (cmd5.communicate()[0].strip().split())
- # Individually copy all files into destination directory,
- # renaming them according to their unique Flash ID.
- if (len(srcFileName) != 0):
- for i in range(len(srcFileName)):
- try:
- absSrcPath = '%s%s' % (srcPath, srcFileName[i])
- shutil.copy(absSrcPath, absDestPath)
- os.chdir(absDestPath)
- os.rename(srcFileName[i], destFileName[i])
- count += 1
- print '[*] Found file %s, moved to %s' % (destFileName[i], absDestPath)
- sleep(0.3)
- except (Exception):
- pass
- if (count >= 1):
- print '[+] %d file(s) found and moved Successfully!' % count
- sys.exit(0)
- else:
- print '[-] No relevant process found'
- print '[?] Make sure you have browsers open'
- print '[*] Quitting'
- sys.exit(1)
- if __name__ == '__main__':
- Main()
Advertisement
Add Comment
Please, Sign In to add comment