public string cryptSqf(string path) { string cName = RandomString(32) + ".parpg"; try { if (!File.Exists(path)) { throw new Exception("Die Datei im Pfad " + path + " existiert nicht. Bitte überprüfe ob die Datei existiert und ob sie richtig in der CfgFunctions definiert ist."); } string source = File.ReadAllText(path); string folder = Path.GetDirectoryName(path); string cPath = folder + "\\" + cName; File.Delete(path); while (File.Exists(cPath)) { cName = RandomString(32) + ".parpg"; cPath = folder + "\\" + cName; } File.WriteAllText(cPath, lCrypt(source)); return(cName); } catch (Exception ex) { OnSendDebug?.Invoke("[Crypter]: ", ex.Message, "0xff0000"); cName = null; } return(cName); }
public void Obfuscate(string file) { string fileName = Path.GetFileNameWithoutExtension(file); string fileExt = Path.GetExtension(file); string filePath = Path.GetDirectoryName(file); string workPath = filePath.Replace(missionName, obfuName); string workFile = workPath + "\\" + fileName + fileExt; OnSendDebug?.Invoke("Obfuscator", fileName + fileExt + " wird verarbeitet."); if (!Directory.Exists(workPath)) { Directory.CreateDirectory(workPath); } if (File.Exists(workFile)) { File.Delete(workFile); } if (fileExt.ToLower() == ".sqf") { SQF(file, workFile); OnSendDebug?.Invoke("Obfuscator", fileName + fileExt + " wurde sqfObfu"); } else { File.Copy(file, workFile); OnSendDebug?.Invoke("Obfuscator", fileName + fileExt + " wurde kopiert"); } }
public Crypt(string decryptPath) { cryptKey = RandomString(64); lcryptKey = toArray(cryptKey); OnSendDebug?.Invoke("[Crypter]: ", "CryptKey: " + cryptKey, "0x0000ff"); //string bakPath = Path.GetDirectoryName(decryptPath) + "\\" + Path.GetFileNameWithoutExtension(decryptPath) + ".bak"; //string bakPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\" + Path.GetFileNameWithoutExtension(decryptPath) + ".bak"; //if (File.Exists(bakPath)) //{ // File.Delete(bakPath); //} //File.Copy(decryptPath, bakPath); var resDecFile = Encoding.UTF8.GetString(Properties.Resources.fn_deCryptFiles); var regex = new Regex("private _key = .*;", RegexOptions.Multiline); string result = regex.Replace(resDecFile, "private _key = \"" + cryptKey + "\";"); string decryptFile = System.IO.Path.Combine(decryptPath, "fn_deCryptFiles.sqf"); File.WriteAllText(decryptFile, result); }