{"action":"created","issue":{"url":"https://api.github.com/repos/quasar/QuasarRAT/issues/408","labels_url":"https://api.github.com/repos/quasar/QuasarRAT/issues/408/labels{/name}","comments_url":"https://api.github.com/repos/quasar/QuasarRAT/issues/408/comments","events_url":"https://api.github.com/repos/quasar/QuasarRAT/issues/408/events","html_url":"https://github.com/quasar/QuasarRAT/issues/408","id":113012401,"number":408,"title":"The UPNP Error does not popup on Quasar startup","user":{"login":"webiummedia","id":4869819,"avatar_url":"https://avatars.githubusercontent.com/u/4869819?v=3","gravatar_id":"","url":"https://api.github.com/users/webiummedia","html_url":"https://github.com/webiummedia","followers_url":"https://api.github.com/users/webiummedia/followers","following_url":"https://api.github.com/users/webiummedia/following{/other_user}","gists_url":"https://api.github.com/users/webiummedia/gists{/gist_id}","starred_url":"https://api.github.com/users/webiummedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webiummedia/subscriptions","organizations_url":"https://api.github.com/users/webiummedia/orgs","repos_url":"https://api.github.com/users/webiummedia/repos","events_url":"https://api.github.com/users/webiummedia/events{/privacy}","received_events_url":"https://api.github.com/users/webiummedia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-23T12:47:35Z","updated_at":"2015-11-06T15:22:20Z","closed_at":null,"body":"When you open Quasar it starts listening to port by itself. But if i stop start manually, i get the Upnp error. That means, for some reason, the Upnp is not functional on startup and there's no popup to let me know."},"comment":{"url":"https://api.github.com/repos/quasar/QuasarRAT/issues/comments/154436483","html_url":"https://github.com/quasar/QuasarRAT/issues/408#issuecomment-154436483","issue_url":"https://api.github.com/repos/quasar/QuasarRAT/issues/408","id":154436483,"user":{"login":"AlienHack","id":8213866,"avatar_url":"https://avatars.githubusercontent.com/u/8213866?v=3","gravatar_id":"","url":"https://api.github.com/users/AlienHack","html_url":"https://github.com/AlienHack","followers_url":"https://api.github.com/users/AlienHack/followers","following_url":"https://api.github.com/users/AlienHack/following{/other_user}","gists_url":"https://api.github.com/users/AlienHack/gists{/gist_id}","starred_url":"https://api.github.com/users/AlienHack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlienHack/subscriptions","organizations_url":"https://api.github.com/users/AlienHack/orgs","repos_url":"https://api.github.com/users/AlienHack/repos","events_url":"https://api.github.com/users/AlienHack/events{/privacy}","received_events_url":"https://api.github.com/users/AlienHack/received_events","type":"User","site_admin":false},"created_at":"2015-11-06T15:22:20Z","updated_at":"2015-11-06T15:22:20Z","body":"Simply Copy and Paste this in .\\Server\\Core\\Networking\\Utilities\\UPNP.cs\r\n\r\n```\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing Mono.Nat;\r\nusing System.Windows.Forms;\r\n\r\nnamespace xServer.Core.Networking.Utilities\r\n{\r\n    internal static class UPnP\r\n    {\r\n        private static Dictionary<int, Mapping> _mappings;\r\n        private static bool _discoveryComplete;\r\n        private static INatDevice _device;\r\n        private static int _port = -1;\r\n\r\n        /// <summary>\r\n        /// Initializes the discovery of new UPnP devices.\r\n        /// </summary>\r\n        public static void Initialize()\r\n        {\r\n            _mappings = new Dictionary<int, Mapping>();\r\n\r\n            try\r\n            {\r\n                NatUtility.DeviceFound += DeviceFound;\r\n                NatUtility.DeviceLost += DeviceLost;\r\n\r\n                _discoveryComplete = false;\r\n\r\n                NatUtility.StartDiscovery();\r\n            }\r\n            catch (Exception)\r\n            {\r\n                MessageBox.Show(\"QuasarRAT: UPNP Initialize Failed\");\r\n            }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Initializes the discovery of new UPnP devices\r\n        /// and creates a port map with the given port.\r\n        /// </summary>\r\n        /// <param name=\"port\">The port to map.</param>\r\n        public static void Initialize(int port)\r\n        {\r\n            _port = port;\r\n            Initialize();\r\n        }\r\n\r\n        /// <summary>\r\n        /// Tells if the class found an UPnP device.\r\n        /// </summary>\r\n        public static bool IsDeviceFound\r\n        {\r\n            get { return _device != null; }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Creates a new port map.\r\n        /// </summary>\r\n        /// <param name=\"port\">The port to map.</param>\r\n        /// <param name=\"externalPort\">The port which has been mapped, -1 if it failed.</param>\r\n        /// <returns>True if successfull, else False.</returns>\r\n        public static bool CreatePortMap(int port, out int externalPort)\r\n        {\r\n            if (!_discoveryComplete)\r\n            {\r\n                externalPort = -1;\r\n                return false;\r\n            }\r\n\r\n            try\r\n            {\r\n                Mapping mapping = new Mapping(Protocol.Tcp, port, port);\r\n\r\n                for (int i = 0; i < 3; i++)\r\n                    _device.CreatePortMap(mapping);\r\n\r\n                if (_mappings.ContainsKey(mapping.PrivatePort))\r\n                    _mappings[mapping.PrivatePort] = mapping;\r\n                else\r\n                    _mappings.Add(mapping.PrivatePort, mapping);\r\n\r\n                externalPort = mapping.PublicPort;\r\n                return true;\r\n            }\r\n            catch (MappingException)\r\n            {\r\n                externalPort = -1;\r\n                return false;\r\n            }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Deletes an existing port map.\r\n        /// </summary>\r\n        /// <param name=\"port\">The port to delete.</param>\r\n        public static void DeletePortMap(int port)\r\n        {\r\n            if (!_discoveryComplete)\r\n                return;\r\n\r\n            Mapping mapping;\r\n            if (_mappings.TryGetValue(port, out mapping))\r\n            {\r\n                try\r\n                {\r\n                    for (int i = 0; i < 3; i++)\r\n                        _device.DeletePortMap(mapping);\r\n                }\r\n                catch (MappingException)\r\n                {\r\n                }\r\n            }\r\n        }\r\n\r\n        private static void DeviceFound(object sender, DeviceEventArgs args)\r\n        {\r\n            _device = args.Device;\r\n\r\n            NatUtility.StopDiscovery();\r\n\r\n            _discoveryComplete = true;\r\n\r\n            if (_port > 0)\r\n            {\r\n                int outPort;\r\n                CreatePortMap(_port, out outPort);\r\n            }\r\n        }\r\n\r\n        private static void DeviceLost(object sender, DeviceEventArgs args)\r\n        {\r\n            _device = null;\r\n            _discoveryComplete = false;\r\n        }\r\n    }\r\n}\r\n\r\n```"}}