using System;
using System.IO;
+using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace SpeedportHybridControl.Implementations {
public static class Cryptography {
- private static string EncryptionKey = "FD25B8d0afB9DDB";
- private static byte[] salt = new byte[] { 82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129 };
+ private static string KEY = "8E16A57381AFDA47856682CEBE85DCF5982F59321AE28B2822C1C9E1FC481C50";
+ private static string IV = "7CD37E78623793D4C4BB81DB73B08522";
public static string Encrypt (string clearText) {
byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);
return result;
}
- Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, salt);
- encryptor.Key = pdb.GetBytes(32);
- encryptor.IV = pdb.GetBytes(16);
+ encryptor.KeySize = 256;
+ encryptor.BlockSize = 128;
+ encryptor.Mode = CipherMode.CBC;
+ encryptor.Padding = PaddingMode.PKCS7;
+ encryptor.Key = util.HexToByte(KEY);
+ encryptor.IV = util.HexToByte(IV);
+
using (MemoryStream ms = new MemoryStream()) {
using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write)) {
cs.Write(clearBytes, 0, clearBytes.Length);
return result;
}
- Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, salt);
- encryptor.Key = pdb.GetBytes(32);
- encryptor.IV = pdb.GetBytes(16);
+ encryptor.KeySize = 256;
+ encryptor.BlockSize = 128;
+ encryptor.Mode = CipherMode.CBC;
+ encryptor.Padding = PaddingMode.PKCS7;
+ encryptor.Key = util.HexToByte(KEY);
+ encryptor.IV = util.HexToByte(IV);
+
using (MemoryStream ms = new MemoryStream()) {
using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write)) {
cs.Write(cipherBytes, 0, cipherBytes.Length);
_executeMethod = executeMethod;
}
- public bool CanExecute (object parameter) {
+ public bool CanExecute (object parameter = null) {
return true;
}
public event EventHandler CanExecuteChanged;
- public void Execute (object parameter) {
+ public void Execute (object parameter = null) {
_executeMethod.Invoke();
}
}
using Newtonsoft.Json.Linq;
using System;
+using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
namespace SpeedportHybridControl.Implementations {
public static class util {
+ public static byte[] HexToByte (string hex) {
+ return Enumerable.Range(0, hex.Length).Where(x => x % 2 == 0).Select(x => Convert.ToByte(hex.Substring(x, 2), 16)).ToArray();
+ }
+
/**
* get sha256
*
using SpeedportHybridControl.Implementations;
using SpeedportHybridControl.Model;
using Newtonsoft.Json;
+using System.Security;
namespace SpeedportHybridControl.Data {
public class SpeedportHybridAPI : SingletonFactory<SpeedportHybridAPI> {
* @param string $password
* @return bool
*/
- public bool login (string passwort) {
- if (passwort.IsNullOrEmpty()) {
+ public bool login (string password) {
+ if (password.IsNullOrEmpty()) {
return false;
}
_cookie = new CookieContainer();
- _password = passwort;
+ _password = password;
_challenge = getChallenge();
- _hash = string.Concat(_challenge, ":", _password).sha256();
+ _hash = string.Concat(_challenge, ":", password).sha256();
string response = sendRequest("data/Login.json", string.Concat("csrf_token=nulltoken&showpw=0&password=", _hash));
if (response.IsNullOrEmpty())
_derivedk = "";
LoginPageModel lpm = Application.Current.FindResource("LoginPageModel") as LoginPageModel;
- lpm.LogoutAction();
+ lpm.LoginCommand.Execute();
+ MainWindowModel mwm = Application.Current.FindResource("MainWindowModel") as MainWindowModel;
+ mwm.SwitchToLoginPage.Execute();
- new Thread(() => { MessageBox.Show("Session expired.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ new Thread(() => { MessageBox.Show("Session expired.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
_checkIsActive = false;
return false;
}
_derivedk = "";
LoginPageModel lpm = Application.Current.FindResource("LoginPageModel") as LoginPageModel;
- lpm.LogoutAction();
+ lpm.LoginCommand.Execute();
+ MainWindowModel mwm = Application.Current.FindResource("MainWindowModel") as MainWindowModel;
+ mwm.SwitchToLoginPage.Execute();
}
jArray = null;
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
- Closing="Window_Closing"
- SizeChanged="update_size"
Height="350"
Width="530"
MinHeight="350"
</StackPanel.Resources>
<Button Command="{Binding Path=SwitchToLoginPage}" Background="{Binding Path=ButtonLoginPageBackground}" x:Name="btnLogin" Content="{Binding Path=LoginButtonContent}"/>
- <Button Command="{Binding Path=SwitchToStatusPage}" Background="{Binding Path=ButtonStatusPageBackground}" Click="button_click" x:Name="btnStatus" Content="Status"/>
+ <Button Command="{Binding Path=SwitchToStatusPage}" Background="{Binding Path=ButtonStatusPageBackground}" x:Name="btnStatus" Content="Status"/>
<Button Command="{Binding Path=SwitchToOverviewPage}" IsEnabled="{Binding Path=ButtonOverviewPageIsActive}" Background="{Binding Path=ButtonOverviewPageBackground}" x:Name="btnOverview" Content="Overview"/>
<Button Command="{Binding Path=SwitchToDSLPage}" IsEnabled="{Binding Path=ButtonDSLPageIsActive}" Background="{Binding Path=ButtonDSLPageBackground}" x:Name="btnDsl" Content="DSL"/>
<Button Command="{Binding Path=SwitchToLteInfoPage}" IsEnabled="{Binding Path=ButtonLteInfoPageIsActive}" Background="{Binding Path=ButtonLteInfoPageBackground}" x:Name="btnLteInfo" Content="LteInfo"/>
<Button Command="{Binding Path=SwitchToAboutPage}" Background="{Binding Path=ButtonAboutPageBackground}" x:Name="btnAbout" Content="Über" VerticalAlignment="Top" HorizontalAlignment="Right" Width="32" Margin="0,0,3,0"/>
<DockPanel Margin="0,22,0,0">
- <Frame x:Name="frame" NavigationUIVisibility="Hidden" Panel.ZIndex="1" Content="{Binding Path=FrameSource}"/>
+ <Frame x:Name="frame" NavigationUIVisibility="Hidden" Panel.ZIndex="1" Content="{Binding Path=FrameSource, NotifyOnSourceUpdated=True}"/>
</DockPanel>
</Grid>
</Window>
using System.Windows.Shapes;
using System.ComponentModel;
using SpeedportHybridControl.Implementations;
+using Microsoft.Win32;
namespace SpeedportHybridControl {
/// <summary>
public MainWindow () {
InitializeComponent();
}
-
- private void button_click (object sender, RoutedEventArgs e) {
- }
-
- void Window_Closing (object sender, CancelEventArgs e) {
- }
-
- public void update_size (object sender, SizeChangedEventArgs e) {
- }
}
}
using SpeedportHybridControl.Data;
using System.Windows;
using System.Threading;
+using System.Security;
namespace SpeedportHybridControl.Model {
class LoginPageModel : SuperViewModel {
-using System.Windows;
+using SpeedportHybridControl.Model;
+using System.Windows;
using System.Windows.Controls;
namespace SpeedportHybridControl.page {
-using System.Windows;
+using SpeedportHybridControl.Model;
+using System.Windows;
using System.Windows.Controls;
namespace SpeedportHybridControl.page {