Inheritance: MonoBehaviour
Example #1
0
        private IResponse GenerateAuditHistory(ICruiseRequest request)
        {
            var velocityContext = new Hashtable();
            var links           = new List <IAbsoluteLink>();

            links.Add(new ServerLink(request.UrlBuilder, request.ServerSpecifier, "Server", ActionName));

            ProjectStatusListAndExceptions projects = farmService.GetProjectStatusListAndCaptureExceptions(request.ServerSpecifier, request.RetrieveSessionToken());

            foreach (ProjectStatusOnServer projectStatusOnServer in projects.StatusAndServerList)
            {
                DefaultProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(projectStatusOnServer.ServerSpecifier, projectStatusOnServer.ProjectStatus.Name);
                links.Add(new ProjectLink(request.UrlBuilder, projectSpecifier, projectSpecifier.ProjectName, ServerAuditHistoryServerPlugin.ActionName));
            }
            velocityContext["projectLinks"] = links;
            string sessionToken = request.RetrieveSessionToken(sessionRetriever);

            if (!string.IsNullOrEmpty(request.ProjectName))
            {
                velocityContext["currentProject"] = request.ProjectName;
                AuditFilterBase filter = AuditFilters.ByProject(request.ProjectName);
                velocityContext["auditHistory"] = farmService.ReadAuditRecords(request.ServerSpecifier, sessionToken, 0, 100, filter);
            }
            else
            {
                velocityContext["auditHistory"] = new ServerLink(request.UrlBuilder, request.ServerSpecifier, string.Empty, DiagnosticsActionName);
                velocityContext["auditHistory"] = farmService.ReadAuditRecords(request.ServerSpecifier, sessionToken, 0, 100);
            }

            return(viewGenerator.GenerateView(@"AuditHistory.vm", velocityContext));
        }
Example #2
0
        internal override bool Query()
        {
            base.Query();

            foreach (var l in serverLinks)
            {
                if (!string.IsNullOrEmpty(l.LocalLogin) && l.LocalLogin.Contains("Credentials"))
                {
                    var s = new ServerLink
                    {
                        ComputerName  = computerName,
                        Instance      = instance,
                        Vulnerability = "Excessive Privilege - Linked Server",
                        Description   = "One or more linked servers is preconfigured with alternative credentials which could allow a least privilege login to escalate their privileges on a remote server.",
                        Remediation   = "Configure SQL Server links to connect to remote servers using the login's current security context.",
                        Severity      = "Medium",
                        IsVulnerable  = "Yes",
                        IsExploitable = "Unknown",
                        Exploited     = "No",
                        ExploitCmd    = string.Format("e.g. SELECT * FROM OPENQUERY([{0}], \'SELECT system_user\')", instance),
                        Reference     = @"https://msdn.microsoft.com/en-us/library/ms190479.aspx",
                        Details       = string.Format("The SQL Server link {0} was found configured with the {1} login.", instance, l.LocalLogin)
                    };
                    links.Add(s);
                }
            }
            return(true);
        }
Example #3
0
        private bool _AddLink(DataRow r)
        {
            ServerLink s = new ServerLink
            {
                servername     = (string)r["servername"],
                sourceInstance = sourceInstance,
                version        = (string)r["version"],
                linkuser       = (string)r["linkuser"],
                role           = (int)r["role"]
            };

            try
            {
                lock (serverLinks)
                {
                    if (!serverLinks.ContainsKey(s.servername))
                    {
                        serverLinks.Add(s.servername, s);
                    }
                    else
                    {
                        Console.WriteLine("[*] Duplicate Key: {0}", s.servername);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(true);
        }
        public bool Init()
        {
            try
            {
                Link = new ServerLink(Tunnel);

                Link.LoadCertificatesFromFiles(
                    CertificateAuthorityPath,
                    CertificatePath,
                    SignaturePath);

                if (Link.PerformHandshake().Type != HandshakeResultType.Successful)
                {
                    Log.Error("Handshake failed, can't init");
                    return(false);
                }

                LinkToTun = (sender, data) =>
                {
                    Tun.Write(data);
                    Log.Trace("Wrote {0} bytes", data.Length);
                    Log.Trace("Packet from link: {0} -> {1}", NetworkTools.GetSource(data), NetworkTools.GetDestination(data));

                    if (Address == null)
                    {
                        if (NetworkTools.GetSource(data).ToString().StartsWith("10.0.0"))
                        {
                            Address = NetworkTools.GetSource(data);
                        }
                    }
                };

                Link.OnDataReceived += LinkToTun;

                return(true);
            }
            catch (Exception ex)
            {
                Log.Error("Failed to initialize client instance");
                Log.Error("\tRemote endpoint: {0}", Tunnel.ToString());
                Log.Error(ex);

                try
                {
                    End();
                    Log.Info("Successfully terminated client instance");
                }
                catch
                {
                    Log.Info("Failed to terminate client instance");
                }

                return(false);
            }
        }
        private NativeSessionInfo GetNativeSessionInfo()
        {
            NativeSessionInfo nativeSessionInfo = GetDefaultNativeSessionInfo();

            // Determine credentials
            Schema.ServerLinkUser linkUser = ServerLink.GetUser(ServerProcess.ServerSession.User.ID);
            nativeSessionInfo.HostName = ServerProcess.ServerSession.SessionInfo.HostName;
            nativeSessionInfo.UserID   = linkUser.ServerLinkUserID;
            nativeSessionInfo.Password = Schema.SecurityUtility.DecryptPassword(linkUser.ServerLinkPassword);
            return(nativeSessionInfo);
        }
        public void OnWorldServerStateChanged(ServerLink serverLink)
        {
            WorldServer world = serverLink as WorldServer;

            this.Invoke(new MethodInvoker(() =>
            {
                if (world == listBox_WorldSevers.SelectedItem)
                {
                    SetInstServerInfo(world);
                }
            }));
        }
        public void OnGeneralServerStateChanged(ServerLink serverLink)
        {
            GeneralServer general = serverLink as GeneralServer;

            this.Invoke(new MethodInvoker(() =>
            {
                if (general == listBox_GeneralServers.SelectedItem)
                {
                    SetInstServerInfo(general);
                }
            }));
        }
Example #8
0
        public FormMain()
        {
            InitializeComponent();
            sl = new ServerLink();

            ls      = new Listener(sl);
            ls.form = this;

            //listBoxFriend.DisplayMember = "Nickname";
            listBoxFriend.DrawMode = DrawMode.OwnerDrawFixed;

            msgHistorys = new Dictionary <string, MsgHistory>();
        }
        private void SetInstServerInfo(ServerLink link)
        {
            bool   isConnected = false;
            string name        = "";

            if (link != null)
            {
                isConnected = link.IsConnected;
                name        = link.ServerName;
            }

            checkBox_instServIsConnected.Checked = isConnected;
            label_InstServName.Text = name;
        }
Example #10
0
 public ClientData GetClientFromLink(ServerLink serverLink)
 {
     lock (_UserListLock)
     {
         foreach (var user in Clients)
         {
             if (user.Connection.ServerLink == serverLink)
             {
                 logger.Debug("GetClientFromLink found: " + user.ClientId);
                 return(user);
             }
         }
     }
     return(null);
 }
Example #11
0
        private IResponse GenerateUserList(ICruiseRequest request, string message, string error)
        {
            Hashtable velocityContext = new Hashtable();

            velocityContext["message"] = message;
            velocityContext["error"]   = error;

            var links = new List <IAbsoluteLink>();

            links.Add(new ServerLink(request.UrlBuilder, request.ServerSpecifier, "User List", ActionName));

            ProjectStatusListAndExceptions projects = farmService.GetProjectStatusListAndCaptureExceptions(request.ServerSpecifier, request.RetrieveSessionToken());

            foreach (ProjectStatusOnServer projectStatusOnServer in projects.StatusAndServerList)
            {
                DefaultProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(projectStatusOnServer.ServerSpecifier, projectStatusOnServer.ProjectStatus.Name);
                links.Add(new ProjectLink(request.UrlBuilder, projectSpecifier, projectSpecifier.ProjectName, ServerUserListServerPlugin.ActionName));
            }
            velocityContext["projectLinks"] = links;
            string             sessionToken = request.RetrieveSessionToken(sessionRetriever);
            List <UserDetails> allUsers     = farmService.ListAllUsers(request.ServerSpecifier, sessionToken);

            foreach (UserDetails user in allUsers)
            {
                if (user.DisplayName == null)
                {
                    user.DisplayName = string.Empty;
                }
            }
            velocityContext["users"] = allUsers;
            if (!string.IsNullOrEmpty(request.ProjectName))
            {
                velocityContext["currentProject"]  = request.ProjectName;
                velocityContext["diagnosticsCall"] = new ProjectLink(request.UrlBuilder, request.ProjectSpecifier, string.Empty, DiagnosticsActionName);
            }
            else
            {
                velocityContext["diagnosticsCall"] = new ServerLink(request.UrlBuilder, request.ServerSpecifier, string.Empty, DiagnosticsActionName);
            }

            return(viewGenerator.GenerateView(@"UserList.vm", velocityContext));
        }
Example #12
0
        async Task Load()
        {
            IsBusy = true;
            try
            {
                await Task.Delay(2000);

                var datos = await ServerLink.GetDataAsync <List <Models.ContratistaModel> >("Contratista");

                list.Clear();
                foreach (var itm in datos)
                {
                    list.Add(itm);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                IsBusy = false;
            }
        }
 /// <summary>
 /// Connect to RTMPServer, nocallback (you use the OnConnect event)
 /// </summary>
 public void Connect(string connectUrl)
 {
     ServerLink serverLink = new ServerLink(connectUrl);
     Connect(serverLink, null);
 }
 /// <summary>
 /// Make connection with a RTMP server like Wowza, red5 or FMS
 /// </summary>
 /// <returns></returns>
 public void Connect(string connectUrl, NC_ResultCallBackConnect resultCallBackConnect)
 {
     ServerLink serverLink = new ServerLink(connectUrl);
     Connect(serverLink, resultCallBackConnect);
 }
 /// <summary>
 /// Connect to RTMPServer, nocallback (you use the OnConnect event)
 /// </summary>
 public void Connect(ServerLink serverLink)
 {
     Connect(serverLink, null, null);
 }
 public void Connect(ServerLink serverLink, NC_ResultCallBackConnect resultCallBackConnect)
 {
     Connect(serverLink, resultCallBackConnect, null);
 }
        /// <summary>
        /// Make connection with a RTMP server like Wowza, red5 or FMS
        /// </summary>
        /// <returns></returns>
        public void Connect(ServerLink serverLink, NC_ResultCallBackConnect resultCallBackConnect, params AMFObjectProperty[] amfProperties)
        {
            // First check if there isn't a build connection in the message queue
            lock (lockVAR)
            {
                if (messageQueue != null)
                {
                    foreach (MQ_RTMPMessage msg in messageQueue)
                    {
                        if (msg.MethodCall == MethodCall.ConnectRTMPServer)
                        {
                            // cancel, we're already trying to do it!
                            return;
                        }
                    } //foreach
                }
            } //lock

            netConnectionConnectInfo.Clear();

            MQ_RTMPMessage message = new MQ_RTMPMessage();
            message.MethodCall = MethodCall.ConnectRTMPServer;
            message.Params = new object[] { serverLink, resultCallBackConnect, amfProperties };

            AddMessageToPump(message);
        }
        private void MQ_Connect(ServerLink sl, NC_ResultCallBackConnect onResult, params AMFObjectProperty[] amfProperties)
        {
            MQ_Close();

            netConnectionState = NetConnectionState.Connecting;
            serverLink = sl;
            bool success = MQInternal_MakeConnection(amfProperties);
            if (success)
            {
                netConnectionState = NetConnectionState.Connected;
            }

            if (success)
            {
                success = false;

                // Now we have to wait for the "onConnect" event to be send by the wowza server, before we can say the
                // connection was successful. We do this for a max of 7 seconds, if no "onConnect" then
                // disconnect and say failed
                DateTime timeStamp = DateTime.Now.AddMilliseconds(onConnectWaitTimeoutMS);
                while (!success && (timeStamp - DateTime.Now).TotalMilliseconds > 0)
                {
                    if (netConnectionState == NetConnectionState.Connected)
                    {
                        if (MQInternal_IsConnected)
                        {
                            if (MQInternal_DataInSocket)
                            {
                                RTMPPacket packet = null;
                                ReadPacket(out packet);
                                // When we get an Invoke while connecting this is the "connect" event!
                                // where we have been waiting for.
                                if (packet.PacketType == PacketType.Invoke)
                                {
                                    success = true;
                                }

                                HandleClientPacket(packet);
                            }
                        }
                        else
                        {
                            // There is no connection anymore
                            break;
                        }
                    }
                    // don't use cpu 100%
                    if (!success)
                    {
                        Thread.Sleep(10);
                    }
                } //while

                // Close connection when failed!
                if (!success || (DateTime.Now - timeStamp).TotalMilliseconds > 0)
                {
#if SSL
                    if (sslStream != null)
                    {
                        try
                        {
                            sslStream.Close();
                            sslStream.Dispose();
                        }
                        catch { }
                    }
                    sslStream = null;
#endif
                    if (tcpSocket != null)
                    {
                        try
                        {
                            tcpSocket.Shutdown(SocketShutdown.Both);
                            tcpSocket.Close();
                        }
                        catch { }
                    }
                    tcpSocket = null;

                    // temporary before we set the state to disconnected!
                    netConnectionState = NetConnectionState.Connecting;
                    dtNetConnectionKeepAlive = DateTime.Now;
                }
            }

            if (onResult != null)
            {
                // this is delegate given when connecting (used by Mediaplayer class)
                // makes event OnConnect not needed
                DoNC_ResultCallBackConnectEvent(onResult, success);
            }

            // Now we do a "global" onConnect
            if (success && OnConnect != null)
            {
                MQ_RTMPMessage message = new MQ_RTMPMessage();
                message.MethodCall = MethodCall.OnEventCallUserCode;
                message.Params = new object[] { OnConnect, this };
                AddOnEventUserCallCodeToPump(message);
            }

            if (!success)
            {
                // Set state
                netConnectionState = NetConnectionState.Disconnected;
            }
        }
 public void Setup()
 {
     serverSpecifier = new DefaultServerSpecifier(serverName);
     urlBuilderMock  = new Mock <ICruiseUrlBuilder>();
     serverLink      = new ServerLink((ICruiseUrlBuilder)urlBuilderMock.Object, serverSpecifier, description, this.action);
 }
Example #20
0
 public UserConnection(TcpClient tcpClient, ServerLink serverLink = null, ClientLink clientLink = null)
 {
     this.ServerLink = serverLink;
     this.ClientLink = clientLink;
     this.TcpClient  = tcpClient;
 }
Example #21
0
        private void ProcessClient(object argument)
        {
            TcpClient client = (TcpClient)argument;

            logger.Debug($"Client socket accepted..");
            TcpTunnel tunnel = new TcpTunnel(client);

            logger.Debug($"Client tunnel created..");
            ServerLink link = new ServerLink(tunnel);

            logger.Debug($"Client link created..");

            link.RememberRemoteCertAuthority = RememberCertificates;
            link.NoAuthentication            = NoAuthentication;

            //link.RememberPeerKeys = true;

            // Get a key from the precomputed keys list
            string ca, priv;

            byte[] sign;

            (ca, priv, sign) = KeyManager.GetNextAvailableKeys();

            if (String.IsNullOrEmpty(ca) || String.IsNullOrEmpty(priv) || sign.Length == 0)
            {
                logger.Error("GetNextAvailableKeys returned empty data!");
                link.Close();
                return;
            }

            logger.Debug($"Passing certificates into Bifrost..");
            link.LoadCertificatesNonBase64(ca, priv, sign);

            link.OnDataReceived += Link_OnDataReceived;
            link.OnLinkClosed   += Link_OnLinkClosed;

            logger.Debug($"Performing handshake with client..");
            var result = link.PerformHandshake();

            if (result.Type == HandshakeResultType.Successful)
            {
                logger.Debug($"Handshake was a success!");
                var connection = new UserConnection(client, serverLink: link);
                var user       = new ClientData(connection);
                user.ClientKeys.ServerCertificateAuthority = ca;
                user.ClientKeys.PrivateKey = priv;
                user.ClientKeys.SignKey    = sign;
                // for use after handshake and when remembering clientCa (unimplemented)
                //user.Client.ClientKeys.ClientCertificateAuthority = clientCa;

                lock (_UserListLock)
                {
                    if (Clients.Count + 1 > MaxConnections)
                    {
                        link.Close();
                        return;
                    }
                    Clients.Add(user);
                }

                Utilities.RaiseEventOnUIThread(OnUserConnected, user);
            }
            else
            {
                logger.Info($"Handshake failure: {result.Type}");
                link.Close();
            }
        }
        private NativeSessionInfo GetServerLinkNativeSessionInfo()
        {
            NativeSessionInfo nativeSessionInfo = null;

            if (ServerLink.MetaData != null)
            {
                Tag tag;

                tag = ServerLink.GetMetaDataTag("DefaultIsolationLevel");
                if (tag != Tag.None)
                {
                    if (nativeSessionInfo == null)
                    {
                        nativeSessionInfo = new NativeSessionInfo();
                    }
                    nativeSessionInfo.DefaultIsolationLevel = (NativeIsolationLevel)Enum.Parse(typeof(NativeIsolationLevel), tag.Value);
                }

                tag = ServerLink.GetMetaDataTag("DefaultLibraryName");
                if (tag != Tag.None)
                {
                    if (nativeSessionInfo == null)
                    {
                        nativeSessionInfo = new NativeSessionInfo();
                    }
                    nativeSessionInfo.DefaultLibraryName = tag.Value;
                }

                tag = ServerLink.GetMetaDataTag("DefaultMaxCallDepth");
                if (tag != Tag.None)
                {
                    if (nativeSessionInfo == null)
                    {
                        nativeSessionInfo = new NativeSessionInfo();
                    }
                    nativeSessionInfo.DefaultMaxCallDepth = Convert.ToInt32(tag.Value);
                }

                tag = ServerLink.GetMetaDataTag("DefaultMaxStackDepth");
                if (tag != Tag.None)
                {
                    if (nativeSessionInfo == null)
                    {
                        nativeSessionInfo = new NativeSessionInfo();
                    }
                    nativeSessionInfo.DefaultMaxStackDepth = Convert.ToInt32(tag.Value);
                }

                tag = ServerLink.GetMetaDataTag("DefaultUseDTC");
                if (tag != Tag.None)
                {
                    if (nativeSessionInfo == null)
                    {
                        nativeSessionInfo = new NativeSessionInfo();
                    }
                    nativeSessionInfo.DefaultUseDTC = Convert.ToBoolean(tag.Value);
                }

                tag = ServerLink.GetMetaDataTag("DefaultUseImplicitTransactions");
                if (tag != Tag.None)
                {
                    if (nativeSessionInfo == null)
                    {
                        nativeSessionInfo = new NativeSessionInfo();
                    }
                    nativeSessionInfo.DefaultUseImplicitTransactions = Convert.ToBoolean(tag.Value);
                }

                tag = ServerLink.GetMetaDataTag("ShouldEmitIL");
                if (tag != Tag.None)
                {
                    if (nativeSessionInfo == null)
                    {
                        nativeSessionInfo = new NativeSessionInfo();
                    }
                    nativeSessionInfo.ShouldEmitIL = Convert.ToBoolean(tag.Value);
                }

                tag = ServerLink.GetMetaDataTag("UsePlanCache");
                if (tag != Tag.None)
                {
                    if (nativeSessionInfo == null)
                    {
                        nativeSessionInfo = new NativeSessionInfo();
                    }
                    nativeSessionInfo.UsePlanCache = Convert.ToBoolean(tag.Value);
                }
            }

            return(nativeSessionInfo);
        }
 public void Setup()
 {
     serverSpecifier = new DefaultServerSpecifier(serverName);
     urlBuilderMock  = new DynamicMock(typeof(ICruiseUrlBuilder));
     serverLink      = new ServerLink((ICruiseUrlBuilder)urlBuilderMock.MockInstance, serverSpecifier, description, this.action);
 }
Example #24
0
 public void Create(out IServerLink @object, String pipeID) => @object = new ServerLink(pipeID);