Skip to content

Instantly share code, notes, and snippets.

@Demonslay335
Created December 19, 2018 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Demonslay335/3b2a7e71a69d7b69403bcdc0b9bfdd5e to your computer and use it in GitHub Desktop.
Save Demonslay335/3b2a7e71a69d7b69403bcdc0b9bfdd5e to your computer and use it in GitHub Desktop.
Keygen for Jemd Ransomware
import os, sys, argparse
# Charset used by Jemd ransomware
charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
# https://en.wikipedia.org/wiki/Linear_congruential_generator
def lcg(modulus, a, c, seed):
while True:
seed = (a * seed + c) % modulus
yield seed
# LCG using Delphi constants
def rand(s):
return lcg(2**32, 0x8088405, 1, s)
# Jemd keygen
def keygen(seed=0, length = 0xF):
key = ''
i = 0
cl = len(charset)
# Iterate generator
for c in rand(seed):
# Break at requested length
if i >= length:
break
# See Delphi LCGRandom(range)
key += charset[c * cl >> 32]
i += 1
return key
# Setup argument parts
parser = argparse.ArgumentParser(description='Keygen for Jemd ransomware.')
parser.add_argument('seed', help='seed', type=int)
# Parse arguments
args = parser.parse_args()
print keygen(args.seed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment