コード例 #1
0
ファイル: Program.cs プロジェクト: resistor420/C2Bridge
        private static BridgeProfile GetProfile(ref string[] args)
        {
            BridgeProfile profile = new BridgeProfile();

            if (args.Contains("--profile"))
            {
                List <string> argList   = args.ToList();
                int           profIndex = argList.IndexOf("--profile");
                if (args.Length < profIndex)
                {
                    return(null);
                }
                try
                {
                    profile = BridgeProfile.Create(args[profIndex + 1]);
                }
                catch
                {
                    return(null);
                }
                argList.Remove(args[profIndex]);
                argList.Remove(args[profIndex + 1]);
                args = argList.ToArray();
            }
            return(profile);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: resistor420/C2Bridge
 static void Main(string[] args)
 {
     try
     {
         BridgeProfile profile = GetProfile(ref args);
         if (profile == null)
         {
             PrintUsage();
             return;
         }
         if (args.Length < 2 || !IPAddress.TryParse(args[0], out IPAddress BridgeAddress) || !int.TryParse(args[1], out int BridgePort))
         {
             PrintUsage();
             return;
         }
         args = args.Skip(2).ToArray();
         using (CancellationTokenSource source = new CancellationTokenSource())
         {
             BridgeConnector connector = new BridgeConnector(BridgeAddress, BridgePort, source.Token);
             IC2Bridge       bridge    = new TcpC2Bridge(connector, profile, args);
             bridge.RunAsync(source.Token).Wait(source.Token);
         }
     }
     catch (Exception e)
     {
         Console.Error.WriteLine($"C2Bridge Exception: {e.Message}{Environment.NewLine}{e.StackTrace}");
     }
 }
コード例 #3
0
ファイル: TCPC2Bridge.cs プロジェクト: resistor420/C2Bridge
 // The TcpC2Bridge constructor requires the ExternalPort to be specified in the string[] args.
 public TcpC2Bridge(BridgeConnector connector, BridgeProfile profile, string[] args) : base(connector, profile)
 {
     if (args.Length != 1 || !int.TryParse(args[0], out int ExternalPort))
     {
         Console.Error.WriteLine("Usage: TCPC2Bridge <bridge_connector_args> <external_tcp_port>");
         Environment.Exit(1); return;
     }
     this.ExternalPort = ExternalPort;
 }
コード例 #4
0
 /// <summary>
 /// The constructor for the C2Bridge. New C2Bridges should use their own constructor that accepts
 /// any command line arguments needed for the C2Bridge to function.
 /// </summary>
 /// <param name="Connector">The BridgeConnector that handles communication with the Covenant server.</param>
 /// <param name="Profile">The BridgeProfile that handles the parsing and formatting of data.</param>
 protected C2Bridge(BridgeConnector Connector, BridgeProfile Profile)
 {
     this.BridgeConnector          = Connector;
     this.BridgeProfile            = Profile;
     BridgeConnector.OnReadBridge += OnReadBridge;
 }