Writing a crude ransomware in under 40 lines

Writing ransomware in under 40 linesDISCLAMER:If you run this program without the if(text.txt) and change ../ to homedir, YOU WILL RUIN YOUR COMPUTER!We’re basically going to write a full ransomware program in 40 lines of Javascript!This example will a…


This content originally appeared on Level Up Coding - Medium and was authored by Nathan Leadill

Writing ransomware in under 40 lines

DISCLAMER:

If you run this program without the if(text.txt) and change ../ to homedir, YOU WILL RUIN YOUR COMPUTER!

We’re basically going to write a full ransomware program in 40 lines of Javascript!

This example will assume you already have knowledge of generator functions, basic cryptography.

Firstly we’re going to import everything we’re going to need. You won’t need to install any npm packages either this is all completely native.

Next we’re going to declare two variables an encryption key and an initialisation vector. These things should be random and in buffer form or you’ll get some nasty errors, i’ve included them in the format that they will work, plug and play as such.

Next it’s time to build an encryption function. So essentially we accept a param val that is encrypted using AES-256, then returning the encrypted data back from the function.

Next we’ll build a getFiles generator function that will essentially recursively loop through all the files and folders.

Finally we’ll build a function that will encrypt everything.

You can alternatively add an unlock file telling users how to unlock their files.

And there you have it, we’ve built a crude ransomware attack in nodejs in under 50 lines.

Imagine someone throwing this into an npm package crudely and you can see the devastating results something like this could have.


Writing a crude ransomware in under 40 lines was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Nathan Leadill


Print Share Comment Cite Upload Translate Updates
APA

Nathan Leadill | Sciencx (2021-08-16T15:58:12+00:00) Writing a crude ransomware in under 40 lines. Retrieved from https://www.scien.cx/2021/08/16/writing-a-crude-ransomware-in-under-40-lines/

MLA
" » Writing a crude ransomware in under 40 lines." Nathan Leadill | Sciencx - Monday August 16, 2021, https://www.scien.cx/2021/08/16/writing-a-crude-ransomware-in-under-40-lines/
HARVARD
Nathan Leadill | Sciencx Monday August 16, 2021 » Writing a crude ransomware in under 40 lines., viewed ,<https://www.scien.cx/2021/08/16/writing-a-crude-ransomware-in-under-40-lines/>
VANCOUVER
Nathan Leadill | Sciencx - » Writing a crude ransomware in under 40 lines. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/16/writing-a-crude-ransomware-in-under-40-lines/
CHICAGO
" » Writing a crude ransomware in under 40 lines." Nathan Leadill | Sciencx - Accessed . https://www.scien.cx/2021/08/16/writing-a-crude-ransomware-in-under-40-lines/
IEEE
" » Writing a crude ransomware in under 40 lines." Nathan Leadill | Sciencx [Online]. Available: https://www.scien.cx/2021/08/16/writing-a-crude-ransomware-in-under-40-lines/. [Accessed: ]
rf:citation
» Writing a crude ransomware in under 40 lines | Nathan Leadill | Sciencx | https://www.scien.cx/2021/08/16/writing-a-crude-ransomware-in-under-40-lines/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.