Take the 2-minute tour ×

Okay so like 10 minutes ago i put this .py file on my Desktop, chmod it to make it executable and when i double clicked it it openned up and all my files on my desktop were gone and it made a folder called "key-database". Does anyone know how to get my stuff back? Thanks

#!/usr/bin/env python

import os
import sys
import time
import shutil
import commands
from PyQt4 import QtGui,QtCore

def initialize():
    'Set Working directory'
    if 'core' in os.listdir(os.getcwd()):
        variable = sys.argv[0]
        direc = variable.replace('execute.py',"")
        if direc:

def restore_files():
    '''Fern 1.2 update algorithm fails to update the new version files
        therefore this piece of code corrects that defect when running
        the program after an update from 1.2'''

    update_directory = '/tmp/Fern-Wifi-Cracker/'

    for old_file in os.listdir(os.getcwd()):
        if os.path.isfile(os.getcwd() + os.sep + old_file) and old_file != '.font_settings.dat':
            os.remove(os.getcwd() + os.sep + old_file)
                                                                    # Delete all old directories except the "key-database" directory
    for old_directory in os.listdir(os.getcwd()):
        if os.path.isdir(os.getcwd() + os.sep + old_directory) and old_directory != 'key-database':
            shutil.rmtree(os.getcwd() + os.sep + old_directory)

    for update_file in os.listdir('/tmp/Fern-Wifi-Cracker'):        # Copy New update files to working directory
        if os.path.isfile(update_directory + update_file):
            shutil.copyfile(update_directory + update_file,os.getcwd() + os.sep + update_file)
            shutil.copytree(update_directory + update_file,os.getcwd() + os.sep + update_file)

def create_directory():
    'Create directories and database'

    if not os.path.exists('fern-settings'):
        os.mkdir('fern-settings')                               # Create permanent settings directory
    if not os.path.exists('key-database'):                      # Create Database directory if it does not exist

def cleanup():
    'Kill all running processes'
    commands.getstatusoutput('killall airodump-ng')
    commands.getstatusoutput('killall aircrack-ng')
    commands.getstatusoutput('killall airmon-ng')
    commands.getstatusoutput('killall aireplay-ng')


if 'core' not in os.listdir(os.getcwd()):

from core import *
from gui import *

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    run = fern.mainwindow()

    pixmap = QtGui.QPixmap("%s/resources/screen_splash.png" % (os.getcwd()))
    screen_splash = QtGui.QSplashScreen(pixmap,QtCore.Qt.WindowStaysOnTopHint)



share|improve this question
Where did you get the .py file from? Can we see the contents of the .py file? (right click, open in gedit)? –  searchfgold6789 Jul 8 '13 at 1:20
It was in fern-wifi-cracker called execute.py and this is what's inside it; –  Jester Jul 8 '13 at 1:25
I posted it as an answer –  Jester Jul 8 '13 at 1:27
You should edit you question to include new information and methods you have used. Thanks –  BiggJJ Jul 8 '13 at 1:37
possible duplicate of How to recover deleted files? (or some other questions in the data-recovery tag) –  Eliah Kagan Sep 9 '13 at 17:21
add comment

closed as unclear what you're asking by psusi, vasa1, hexafraction, hbdgaf, Kevin Bowen Jul 8 '13 at 3:16


1 Answer

up vote 3 down vote accepted
for old_directory in os.listdir(os.getcwd()):
    shutil.rmtree(os.getcwd() + os.sep + old_directory)

That is the culprit my friend.

share|improve this answer
What do i do with that? Sorry i'm kind of new to all this stuff :/ –  Jester Jul 8 '13 at 1:37
All I can tell you is that it effectively deleted everything that was in the directory with the rm command, there is no retrieval. Mind you, I am not discounting the possibility I am wrong either. –  Kaobear Jul 8 '13 at 1:41
@Jester Indeed recovery is difficult or impossible now. –  hexafraction Jul 8 '13 at 2:17
@Jester My apologies mate. –  Kaobear Jul 8 '13 at 2:20
add comment
