{"id":15663886,"url":"https://github.com/qnighy/ransomware-demo","last_synced_at":"2025-05-06T18:46:21.659Z","repository":{"id":66648205,"uuid":"63420901","full_name":"qnighy/ransomware-demo","owner":"qnighy","description":"A proof-of-concept for ransomware encryption","archived":false,"fork":false,"pushed_at":"2016-07-15T12:41:32.000Z","size":3,"stargazers_count":17,"open_issues_count":0,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T01:51:12.321Z","etag":null,"topics":["cryptography","demo","ransomware"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qnighy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-15T12:41:08.000Z","updated_at":"2023-04-21T15:56:20.000Z","dependencies_parsed_at":"2023-02-22T17:30:18.028Z","dependency_job_id":null,"html_url":"https://github.com/qnighy/ransomware-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qnighy%2Fransomware-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qnighy%2Fransomware-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qnighy%2Fransomware-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qnighy%2Fransomware-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qnighy","download_url":"https://codeload.github.com/qnighy/ransomware-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252748276,"owners_count":21798300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","demo","ransomware"],"created_at":"2024-10-03T13:40:19.155Z","updated_at":"2025-05-06T18:46:21.637Z","avatar_url":"https://github.com/qnighy.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ransomware demo\n\nThis is a simple demo of ransomware.\n\n## Disclaimer\n\n- Be careful when trying this demo. This demo is provided without warranty of any kind.\n- This demo is intended to help understanding how cryptography is used in ransomware. I don't expect it to be used in ransomwares \"in practice\". Creating ransomwares would be illegal. Moreover, this demo is not \"practical\", since it doesn't provide a way to ensure file erasure nor a way to pay and communicate keys.\n\n## How to try\n\n```\n~$ git clone https://github.com/qnighy/ransomware-demo.git\n~$ cd ransomware-demo\n```\n\n### Create a master key pair\n\nFirst, create a master key pair.\n\n```\n~/ransomware-demo$ ./genmaster.sh\n```\n\nAn RSA key pair `server/master.pem`/`client/master.pem` is created and it serves as a master key pair.\n\n- **The private key** `server/master.pem` is kept secret.\n- **The public key** `client/master.pem` is embedded in the ransomware.\n\n### Run ransomware\n\nSuppose the ransomware is distributed to victims and run. Let's simulate that.\n\n```\n~/ransomware-demo$ cd client\n~/ransomware-demo/client$ find documents\ndocuments\ndocuments/lipsum.txt\ndocuments/hello.txt\n~/ransomware-demo/client$ cat documents/hello.txt\nHello, world!\n~/ransomware-demo/client$ ./encrypt.sh\n~/ransomware-demo/client$ find documents\ndocuments\ndocuments/hello.txt.enc\ndocuments/hello.txt.iv\ndocuments/hello.txt.sha256\ndocuments/lipsum.txt.enc\ndocuments/lipsum.txt.iv\ndocuments/lipsum.txt.sha256\n```\n\nHere three things happen:\n\n- A device key is created.\n- The files are encrypted using the device key.\n- The device key is encrypted using the master key.\n\n### Pay something and recover the device key\n\nTo decrypt the files, you should pay for someone and have your device key recovered. Let's simulate that.\n\n```\n~/ransomware-demo/client$ ./decrypt.sh\ndevice_key.dat not found. First pay for us!\n~/ransomware-demo/client$ cp device_key_encrypted.dat ../server/\n~/ransomware-demo/client$ mv ../server/\n~/ransomware-demo/server$ ./decrypt-key.sh\n~/ransomware-demo/server$ cp device_key.dat ../client/\n~/ransomware-demo/server$ mv ../client/\n~/ransomware-demo/client$ ./decrypt.sh\n```\n\n### Decrypt files\n\nNow you can decrypt the files.\n\n```\n~/ransomware-demo/client$ ./decrypt.sh\n~/ransomware-demo/client$ find documents\ndocuments\ndocuments/lipsum.txt\ndocuments/hello.txt\n~/ransomware-demo/client$ cat documents/hello.txt\nHello, world!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqnighy%2Fransomware-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqnighy%2Fransomware-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqnighy%2Fransomware-demo/lists"}