public Boolean ReadLicence()
 {
     try
     {
         String Key = CryptographyClass.Decrypt(File.ReadAllText(LicencePath), EncryptionKey);
         if (Key != "")
         {
             if (opr.VerifyCode(Key) == true)
             {
                 return(true);
             }
             else
             {
                 LoggerClass.WriteLogWarning("Non Valid Licence");
                 File.Delete(LicencePath);
                 return(false);
             }
         }
         else
         {
             LoggerClass.WriteLogWarning("Non Valid Licence");
             File.Delete(LicencePath);
             return(false);
         }
     }
     catch (Exception ex)
     {
         LoggerClass.WriteLogError(ex.Message);
         return(false);
     }
 }
Exemple #2
0
 public void Create(String ssid, String key)
 {
     Message      = "";
     ps.Arguments = @"wlan set hostednetwork mode=allow ssid=" + ssid + " key=" + key;
     Execute(ps);
     LoggerClass.WriteLogInformation(Message);
 }
Exemple #3
0
 public static void ReadSettings()
 {
     try
     {
         if (File.Exists(ApplicationPath) == true)
         {
             String JsonSetting = File.ReadAllText(ApplicationPath);
             ApplicationSettings = JsonConvert.DeserializeObject <Settings>(JsonSetting);
             if (ApplicationSettings.CheckValidSettings != "OK")
             {
                 WriteDefaultSettingsBoolean = true;
             }
         }
         else
         {
             WriteDefaultSettingsBoolean = true;
         }
     }
     catch (Exception)
     {
         LoggerClass.WriteLogError("Cannot Find Setting File");
         MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         File.Delete(ApplicationPath);
         WriteDefaultSettingsBoolean = true;
     }
 }
Exemple #4
0
 public void Start()
 {
     Message      = "";
     ps.Arguments = "wlan start hosted network";
     Execute(ps);
     LoggerClass.WriteLogInformation(Message);
 }
 public void WriteLicence(String Key)
 {
     if (File.Exists(LicencePath) == true)
     {
         LoggerClass.WriteLogWarning("Licence Deleted");
         File.Delete(LicencePath);
     }
     File.WriteAllText(LicencePath, CryptographyClass.Encrypt(Key, EncryptionKey));
 }
Exemple #6
0
        private void ExitButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                ExitButtonClicked = true;
                LoggerClass.WriteLogInformation("Program Exited");
                SetThreadExecutionState(ES_CONTINUOUS);
                Hotspot.Stop();
                Application.Exit();
            }
        }
 private void ShareInternetButton_Click(object sender, EventArgs e)
 {
     try
     {
         Hotspot.ShareInternet(FromNetworkListComboBox.SelectedItem.ToString(), ToNetworkListComboBox.SelectedItem.ToString(), true);
         LoggerClass.WriteLogInformation(Hotspot.Message);
         MessageBox.Show("Network is Shared", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #8
0
        public void ShareInternet(String pubConnectionName, String priConnectionName, bool isEnabled)
        {
            Message = "";
            bool    hasCon          = false;
            dynamic everyConnection = null;
            dynamic connectionProp  = null;

            everyConnections = netSharingManager.EnumEveryConnection;
            foreach (dynamic connection in everyConnections)
            {
                everyConnection = netSharingManager.INetSharingConfigurationForINetConnection(connection);
                connectionProp  = netSharingManager.NetConnectionProps(connection);

                if (connectionProp.Name == pubConnectionName)
                {
                    hasCon        = true;
                    this.Message += String.Format("Setting ICS Public {0} on connection: {1} \n", isEnabled, pubConnectionName);
                    if (isEnabled)
                    {
                        everyConnection.EnableSharing(0);
                    }
                    else
                    {
                        everyConnection.DisableSharing();
                    }
                }

                if (connectionProp.Name == priConnectionName)
                {
                    hasCon        = true;
                    this.Message += String.Format("Setting ICS Private {0} on connection: {1} \n", isEnabled, priConnectionName);
                    if (isEnabled)
                    {
                        everyConnection.EnableSharing(1);
                    }
                    else
                    {
                        everyConnection.DisableSharing();
                    }
                }
            }
            LoggerClass.WriteLogInformation(Message);
            if (!hasCon)
            {
                this.Message += "No connection found!";
            }
        }
Exemple #9
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (ExitButtonClicked != true)
     {
         DialogResult result = MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             LoggerClass.WriteLogInformation("Program Exited");
             SetThreadExecutionState(ES_CONTINUOUS);
             Hotspot.Stop();
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            Settings NewSettings = new Settings();

            NewSettings.CheckValidSettings        = @"OK";
            NewSettings.EnableLogging             = EnableLoggingCheckBox.Checked;
            NewSettings.StartHotspotAutomatically = StartHotspotAutomaticallyCheckBox.Checked;
            NewSettings.StartMinimized            = StartMinimizedCheckBox.Checked;
            NewSettings.ShowMessageMinimized      = ShowMessageMinimizedCheckBox.Checked;
            File.Delete(SettingsPath);
            String jsonSettings = JsonConvert.SerializeObject(NewSettings);

            File.WriteAllText(SettingsPath, jsonSettings);
            MainForm.ReadSettings();
            UpdateSettings();
            MessageBox.Show("Settings Saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            LoggerClass.WriteLogInformation("Settings Saved");
        }
Exemple #11
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ReadSettings();
            UpdateLabelsText();
            ConnectedUsersTimer.Start();
            ContextMenu NotificationMenu = new ContextMenu();
            MenuItem    Item1            = new MenuItem
            {
                Index = 0,
                Text  = "Show Program"
            };

            Item1.Click += Item1_Click;
            MenuItem Item2 = new MenuItem
            {
                Index = 1,
                Text  = "Exit"
            };

            Item2.Click += Item2_Click;
            NotificationMenu.MenuItems.Add(Item1);
            NotificationMenu.MenuItems.Add(Item2);
            notifyIcon1.ContextMenu = NotificationMenu;
            if (IOkey.ReadLicence() == false)
            {
                RegisterButton.PerformClick();
            }
            else
            {
                LoggerClass.WriteLogInformation("Licence Verified" + Environment.NewLine + "Program Started");
                RegisterButton.Visible = false;
            }
            if (NetworkInfo.NetworkStatus == "Started")
            {
                LoggerClass.WriteLogInformation("Hotspot Started");
            }
            else
            {
                LoggerClass.WriteLogInformation("Hotspot Not Started");
            }
        }
Exemple #12
0
        public void InitializeNetwork()
        {
            ps = new ProcessStartInfo("cmd.exe");
            ps.UseShellExecute        = false;
            ps.RedirectStandardOutput = true;
            ps.CreateNoWindow         = true;
            ps.FileName = "netsh";

            netSharingManager = Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.HNetShare.1"));

            if (netSharingManager == null)
            {
                this.Message = "HNetCfg.HNetShare.1 was not found! \n";
                LoggerClass.WriteLogError(Message);
                hasNetSharingManager = true;
            }
            else
            {
                hasNetSharingManager = false;
            }

            if (netSharingManager.SharingInstalled == false)
            {
                this.Message = "Sharing on this platform is not available \n";
                LoggerClass.WriteLogError(Message);
                hasNetSharingManager = false;
            }
            else
            {
                hasNetSharingManager = true;
            }

            if (hasNetSharingManager)
            {
                everyConnections = netSharingManager.EnumEveryConnection;
            }
        }
 private void RegisterButton_Click(object sender, EventArgs e)
 {
     if (RegisterTextBox.Text == null)
     {
         MessageBox.Show("Provide Serial Key", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ValidationKey = false;
         RegisterTextBox.Focus();
     }
     else if (opr.VerifyCode(RegisterTextBox.Text) == false)
     {
         MessageBox.Show("Invalid Serial Key", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ValidationKey        = false;
         RegisterTextBox.Text = null;
         RegisterTextBox.Focus();
     }
     else
     {
         MessageBox.Show("Valid Serial Key", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ValidationKey = true;
         IOKey.WriteLicence(RegisterTextBox.Text);
         LoggerClass.WriteLogInformation("Inserted Valid Serial Key EncyptedKey=" + System.IO.File.ReadAllText(SerialKeyIOClass.LicencePath));
         this.Close();
     }
 }
Exemple #14
0
        public NetworkInfoClass GetNetworkInfo()
        {
            Message = "";
            NetworkInfoClass Info = new NetworkInfoClass();

            ps.Arguments = "wlan show hostednetwork";
            Execute(ps);
            try
            {
                Info.NetworkStatus = (Regex.Match(Message, @"[\n\r].*Status                 : \s*([^\n\r]*)")).Groups[1].Value;
            }
            catch (Exception)
            {
                Info.NetworkStatus = null;
            }
            try
            {
                Info.SSID = (Regex.Match(Message, @"[\n\r].*SSID name              : \s*([^\n\r]*)")).Groups[1].Value.Replace("\"", "");
            }
            catch (Exception)
            {
                Info.SSID = null;
            }
            try
            {
                Info.NumOfClients = (Regex.Match(Message, @"[\n\r].*Number of clients      : \s*([^\n\r]*)")).Groups[1].Value;
            }
            catch (Exception)
            {
                Info.NumOfClients = "0";
            }
            try
            {
                MatchCollection Clients = Regex.Matches(Message, @"([0-9a-f]{2}(?::[0-9a-f]{2}){5})");
                foreach (Match ClientMAC in Clients)
                {
                    foreach (Capture CaptureMAC in ClientMAC.Captures)
                    {
                        Info.ConnectedClients.Add(CaptureMAC.Value);
                    }
                }
            }
            catch (Exception)
            {
                Info.ConnectedClients = null;
            }
            if (WriteLog == true)
            {
                LoggerClass.WriteLogInformation(Message);
            }
            Message      = "";
            ps.Arguments = "wlan show  hostednetwork setting=security";
            Execute(ps);
            try
            {
                Info.Key = (Regex.Match(Message, @"[\n\r].*User security key      : \s*([^\n\r]*)")).Groups[1].Value;
            }
            catch (Exception)
            {
                Info.Key = null;
            }
            if (WriteLog == true)
            {
                LoggerClass.WriteLogInformation(Message);
            }
            return(Info);
        }