Skip to content

Instantly share code, notes, and snippets.

@TheZoc
Created May 24, 2018 02:23
Show Gist options
  • Save TheZoc/f356cb74958d148b252f7d466baeb84f to your computer and use it in GitHub Desktop.
Save TheZoc/f356cb74958d148b252f7d466baeb84f to your computer and use it in GitHub Desktop.
A small script to help revert the damage caused by crab ransomware
#!/usr/bin/python3
#
# .crab file fixer
# This small script was created to help a friend who got attacked by a ransomware
# I hope this helps someone else out there :)
#
import os
from glob import glob
# Config
target_path = os.getcwd() # You can change the target directory here; By default, it uses the current directory
evil_extension = '.crab'
# Rename the files
evil_files = glob(target_path + '/**/*' + evil_extension, recursive=True)
print('Found {} evil "{}" files. Attempting to fix:\n'.format(len(evil_files), evil_extension))
for evil in evil_files:
good = evil[:-len(evil_extension)]
print(good)
os.rename(evil, good)
print('\nDone!\n')
input('Press Enter to exit...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment