All Projects → Cisco-Talos → Pylocky_decryptor

Cisco-Talos / Pylocky_decryptor

Licence: apache-2.0

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pylocky decryptor

Homer
Homer, a text analyser in Python, can help make your text more clear, simple and useful for your readers.
Stars: ✭ 607 (+1024.07%)
Mutual labels:  python-script
Emspy
A collection of Python scripts to aide in mesoscale modelling using UEMS.
Stars: ✭ 7 (-87.04%)
Mutual labels:  python-script
Google Images Download
Python Script to download hundreds of images from 'Google Images'. It is a ready-to-run code!
Stars: ✭ 7,815 (+14372.22%)
Mutual labels:  python-script
Instagram Profilecrawl
📝 quickly crawl the information (e.g. followers, tags etc...) of an instagram profile.
Stars: ✭ 816 (+1411.11%)
Mutual labels:  python-script
Cti Stix Validator
OASIS TC Open Repository: Validator for STIX 2.0 JSON normative requirements and best practices
Stars: ✭ 24 (-55.56%)
Mutual labels:  python-script
Captain
command line python scripts for humans
Stars: ✭ 10 (-81.48%)
Mutual labels:  python-script
Multiscanner
Modular file scanning/analysis framework
Stars: ✭ 494 (+814.81%)
Mutual labels:  python-script
Asciipy
translate images, videos and text to Ascii arts easy
Stars: ✭ 52 (-3.7%)
Mutual labels:  python-script
Seo Analysis
A Python script to gain some insights from a domain and list of keywords.
Stars: ✭ 25 (-53.7%)
Mutual labels:  python-script
Youtubetospotify
A Python script to fetch tracks of music channels on Youtube, find them on Spotify and add them to a playlist
Stars: ✭ 33 (-38.89%)
Mutual labels:  python-script
Useful Scripts
Useful scripts I wrote to make my life easier
Stars: ✭ 5 (-90.74%)
Mutual labels:  python-script
Phpmyadmin sql backup
A Python script to automate SQL dumps via phpMyAdmin's web interface
Stars: ✭ 17 (-68.52%)
Mutual labels:  python-script
Pyfiling
Python script that organizes files in a folder or directory according to file type/extension.
Stars: ✭ 12 (-77.78%)
Mutual labels:  python-script
Learn python3 spider
python爬虫教程系列、从0到1学习python爬虫,包括浏览器抓包,手机APP抓包,如 fiddler、mitmproxy,各种爬虫涉及的模块的使用,如:requests、beautifulSoup、selenium、appium、scrapy等,以及IP代理,验证码识别,Mysql,MongoDB数据库的python使用,多线程多进程爬虫的使用,css 爬虫加密逆向破解,JS爬虫逆向,分布式爬虫,爬虫项目实战实例等
Stars: ✭ 8,525 (+15687.04%)
Mutual labels:  python-script
Genius Lyrics Search
Python script for searching Genius.com API
Stars: ✭ 49 (-9.26%)
Mutual labels:  python-script
You Are Pythonista
汇聚【Python应用】【Python实训】【Python技术分享】等等
Stars: ✭ 588 (+988.89%)
Mutual labels:  python-script
Elasticsearchjsonld
Generate JSON-LD @contexts from ElasticSearch JSON Mappings
Stars: ✭ 7 (-87.04%)
Mutual labels:  python-script
Gzipsimplehttpserver
A modification of the very useful SimpleHTTPServer python script to add gzip compression.
Stars: ✭ 52 (-3.7%)
Mutual labels:  python-script
Cti Taxii Server
OASIS TC Open Repository: TAXII 2 Server Library Written in Python
Stars: ✭ 50 (-7.41%)
Mutual labels:  python-script
Pyarmor
A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.
Stars: ✭ 886 (+1540.74%)
Mutual labels:  python-script

PyLocky Decryptor

This decryptor is intended to decrypt the files for those victims affected by the ransomware PyLocky.

This decryptor is built to be executed on Windows systems only and it does require a PCAP of the outbound connection attempt to the C&C servers. This connection is seen seconds after the infection occurs and it will contain, among other info, the Initialization Vector (IV) and a password (both generated randomly at runtime) used to encrypt the files. Without this PCAP containing these values, the decryption won't be possible.

The structure of the outbound connection contains an string like:

PCNAME=NAME&IV=KXyiJnifKQQ%3D%0A&GC=VGA+3D&PASSWORD=CVxAfel9ojCYJ9So&CPU=Intel%28R%29+Xeon%28R%29+CPU+E5-1660+v4+%40+3.20GHz&LANG=en_US&INSERT=1&UID=XXXXXXXXXXXXXXXX&RAM=4&OSV=10.0.16299+16299&MAC=00%3A00%3A00%3A00%3A45%3A6B&OS=Microsoft+Windows+10+Pro

The above string is contained in a POST request and is required to be inside an HTTP session saved in the PCAP passed as an argument to this decryptor.

Requirements to execute it

Usage

usage: pylocky_decryptor.exe [-h] [-p pylocky.pcap] [-r] [-d]

PyLocky decryptor

optional arguments:
  -h, --help            show this help message and exit
  -p pylocky.pcap, --pcap pylocky.pcap		Provide PyLocky C&C pcap
  -r, --remove          Remove encrypted files
  -d, --debug           Debug this program

Instructions

  1. Clone or download this repository to your computer (remember should be a PyLocky infected windows machine)
  2. Open a terminal: Start-> Run-> Type cmd and hit Enter
  3. In the command prompt, navigate to the folder location where the decryptor was downloaded (as in step 1), e.g: cd C:\Users\User\Desktop\pylocky_decryptor
  4. Specify the PCAP file with the -p (or --pcap) switch: pylocky_decryptor.exe -p pylocky.pcap
  5. Wait for the decryptor to complete the decryption process and verify the usability of your files and system

Output

If the program is enabled with debug output you will be able to see with detail how the PCAP file is being read, extracted both the IV and password and then what file is the decryptor reading, decrypting and restoring:

C:\Users\User\Desktop>pylocky_decryptor.exe -p pylock-fix.pcap -d -r
reading from file pylock-fix.pcap, link-type EN10MB (Ethernet)
Password to decrypt with: CVxAfel9ojCYJ9So
IV (base64 decoded) to decrypt with: )|ó&xƒ)
Opening fname: C:\Users\User\AppData\Local\Microsoft\Windows\Explorer\iconcache_48.db.lockedfile
Closed fname: C:\Users\User\AppData\Local\Microsoft\Windows\Explorer\iconcache_48.db.lockedfile
Before getting decryptor
...
Before decrypting data
Opening fname_w_e: C:\Users\User\MicrosoftEdgeBackups\backups\MicrosoftEdgeBackup20180914\MicrosoftEdgeFavoritesBackup.html
Closed fname_w_e: C:\Users\User\MicrosoftEdgeBackups\backups\MicrosoftEdgeBackup20180914\MicrosoftEdgeFavoritesBackup.html
File processed correctly: C:\Users\User\MicrosoftEdgeBackups\backups\MicrosoftEdgeBackup20180914\MicrosoftEdgeFavoritesBackup.html.lockedfile
File removed correctly: C:\Users\User\MicrosoftEdgeBackups\backups\MicrosoftEdgeBackup20180914\MicrosoftEdgeFavoritesBackup.html.lockedfile
Decryption complete! Please verify the content of your files and system

Also, if the remove flag was used along with the debugging flag, you will see a message like:

File removed correctly: C:\Users\User\Desktop\Tor Browser\Browser\browser\VisualElements\VisualElements_150.png.lockedfile

If there are no files with the .lockedfile extension OR all the files have been decrypted correctly and removed in a previous run, you'll simply get the following message:

No files with the ".lockedfile" extension were found. Please check again

Compiling the source code

If you need to modify the source code of the decryptor, you can do it using Python 2.7 and then use PyInstaller on Windows OS which can be installed using the auto-py-to-exe module. This module is a GUI that converts the Python script into a fully working exe file in a very easy way.

You can also use the command prompt, once you have auto-py-to-exe installed, with the following syntax:

C:\Users\User\Desktop>pyinstaller -y -F pylocky_decryptor.py

Note: if by any chance you get an import error stating: "No module named Queue" then just simply add --hidden-import=Queue to the pyinstaller arguments and the exe file should be generated correctly. You can find the exe file in a dist folder in the location you are currently working and with the same of the python script but with the exe extension.

Warning

During the development and testing of this decryptor it has been tested the succesfull recovery of 3 infected systems (with their corresponding PCAP file) and the only small issue found has been with very large files (more than 4 Gb) not able to be decrypted.

This tool is intended to be used in a live infected system, since it will loop over all the hard drives installed in the system and search for all the files containing the PyLocky encryption extension.

The debugging switch -d or --debug might provide a very verbose output but can be useful to understand what the decryptor is doing and any potential issues found. Is recommended to use it the first time the decryptor is executed.

Last but not least, using the switch -r or --remove will remove the copy of the encrypted files. Doing so will help to clean a bit the infection leftovers in the system however, if something goes wrong during the process and a file wasn't decrypted properly AND this option is enabled, the encrypted file will be deleted and then there will be no way to recover the content. Please be careful and use this option after an initial first recovery of the files, then in a second time running the decryptor there will be less the likelihood of losing the content. Cisco won't be responsible for a misuse of this tool.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].