public void NoExist() { var task = new RenameTask(_doesntExist, _renameTo, new DotNetPath()); var o = task.VerifyCanRun(); Assert.IsTrue(o.ContainsError()); }
public void OriginalFileNoLongerExists() { var task = new RenameTask(_sourceFile, _renameTo, new DotNetPath()); task.Execute(); Assert.IsFalse(File.Exists(_sourceFile)); }
public void RenameFileWorks() { var task = new RenameTask(_sourceFile, _renameTo, new DotNetPath()); task.Execute(); Assert.IsTrue(File.Exists(_renameTo)); }
public override void RegisterRealTasks(PhysicalServer site) { string target = PathConverter.Convert(site, _target); string newName = PathConverter.Convert(site, _newName); var o = new RenameTask(target, newName, new DotNetPath()); site.AddTask(o); }
public override void RegisterRealTasks(PhysicalServer site) { string target = _target; string newName = _newName; target = RemotePathHelper.Convert(site, target); var o = new RenameTask(target, newName, new DotNetPath()); site.AddTask(o); }
public override void RegisterRealTasks(PhysicalServer site) { string target = site.MapPath(_target); string newName = site.MapPath(_newName); if (!Path.IsPathRooted(_newName)) newName = site.MapPath(Path.Combine(Path.GetDirectoryName(_target), _newName)); var o = new RenameTask(target, newName, new FileSystem.DotNetPath(), _deleteDestination); site.AddTask(o); }
public static string Process(Context ctx, LogInfo info, LogWarn war, LogErr err) { try { string startobf = "Starting "; ModuleDefMD module = ModuleDefMD.Load(ctx.FileName); module.GlobalType.FindOrCreateStaticConstructor(); foreach (TaskID task in ctx.TasksList) { switch (task) { case AntiDebugTask.ID: { info(startobf + "Anti-Debug Task..."); AntiDebugTask.Execute(module); } break; case StringEncodingTask.ID: { info(startobf + "String encoding Task..."); StringEncodingTask.Execute(module); } break; case ControlFlowTask.ID: { info(startobf + "Control Flow Task..."); ControlFlowTask.Execute(module); } break; case InvalidMDTask.ID: { info(startobf + "Invalid Metadata Task..."); InvalidMDTask.Execute(module); } break; case RenameTask.ID: RenameTask.IsObfuscationActive = true; break; } } info(startobf + "Rename Task..." + Environment.NewLine); RenameTask.Execute(module); module.Write(ctx.NewPath, new ModuleWriterOptions() { Listener = NETUtils.listener }); return(ctx.NewPath); } catch (Exception ex) { err(ex.Message); return(""); } }
public static Dictionary <MethodDef, Tuple <int[], int[]> > CreateMethods(ModuleDef loadedMod) { DynamicCode code = new DynamicCode(3); int[] modules = new int[4]; for (int i = 0; i < modules.Length; i++) { modules[i] = rand.Next(2, 25); } Instruction[,] methods = new Instruction[4, 10]; for (int i = 0; i < 4; i++) { Instruction[] methodBody = code.Create(); for (int y = 0; y < methodBody.Length; y++) { methods[i, y] = methodBody[y]; } } List <Tuple <Instruction[], Tuple <int, Tuple <int[], int[]> > > > InstrToInt = new List <Tuple <Instruction[], Tuple <int, Tuple <int[], int[]> > > >(); for (int i = 0; i < 4; i++) { List <Instruction> instr = new List <Instruction>(); int[] numbersTrue = new int[5]; int[] numbersFalse = new int[5]; for (int y = 0; y < 10; y++) { instr.Add(methods[i, y]); } for (int y = 0; y < 5; y++) { numbersTrue[y] = code.RandomNumberInModule(instr.ToArray(), modules[i], true); } for (int y = 0; y < 5; y++) { numbersFalse[y] = code.RandomNumberInModule(instr.ToArray(), modules[i], false); } InstrToInt.Add(Tuple.Create(instr.ToArray(), Tuple.Create(modules[i], Tuple.Create(numbersTrue, numbersFalse)))); } Dictionary <MethodDef, Tuple <int[], int[]> > final = new Dictionary <MethodDef, Tuple <int[], int[]> >(); MethodAttributes methFlags = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig | MethodAttributes.ReuseSlot; MethodImplAttributes methImplFlags = MethodImplAttributes.IL | MethodImplAttributes.Managed; for (int i = 0; i < 4; i++) { MethodDef methodDefs1 = new MethodDefUser( "", MethodSig.CreateStatic(loadedMod.CorLibTypes.Boolean, loadedMod.CorLibTypes.Int32), methImplFlags, methFlags); RenameTask.Rename(methodDefs1); methodDefs1.Body = new CilBody(); methodDefs1.ParamDefs.Add(new ParamDefUser("lol", 0)); List <Instruction> preInstr = new List <Instruction>(InstrToInt[i].Item1); int module = InstrToInt[i].Item2.Item1; //preInstr.RemoveAt(preInstr.Count - 1); preInstr.Insert(preInstr.Count - 1, Instruction.CreateLdcI4(module)); preInstr.Insert(preInstr.Count - 1, OpCodes.Rem.ToInstruction()); preInstr.Insert(preInstr.Count - 1, Instruction.CreateLdcI4(0)); preInstr.Insert(preInstr.Count - 1, Instruction.Create(OpCodes.Ceq)); //preInstr.Insert(preInstr.Count - 1, Instruction.Create(OpCodes.Ret)); foreach (var item in preInstr) { methodDefs1.Body.Instructions.Add(item); } final.Add(methodDefs1, InstrToInt[i].Item2.Item2); } TypeDef type1 = new TypeDefUser("", "", loadedMod.CorLibTypes.Object.TypeDefOrRef); RenameTask.Rename(type1); type1.Attributes = dnlib.DotNet.TypeAttributes.Public | dnlib.DotNet.TypeAttributes.AutoLayout | dnlib.DotNet.TypeAttributes.Class | dnlib.DotNet.TypeAttributes.AnsiClass; loadedMod.Types.Add(type1); foreach (var item in final) { type1.Methods.Add(item.Key); } return(final); }
public void RemoteRename() { var task = new RenameTask(@"\\srvtestwebtpg\E$\FHLB MQApps\BloombergIntegration\bin\des.exe", "hi.exe", new DotNetPath()); task.Execute(); }
public void RenameOnTopOfConflictingFile() { var task = new RenameTask(_sourceFile, _conflictFile, new DotNetPath()); task.Execute(); }
public void NameIsDescriptive() { var task = new RenameTask(_sourceFile, _renameTo, new DotNetPath()); Assert.AreEqual(@"Rename '.\stuff.txt' to 'notstuff.txt'.", task.Name); }