public void ParseProxyAuthentication() { string TestLine = @"Proxy-Authenticate: Digest realm=""sip.cybercity.dk"",nonce=""1701b4767d49c41117c7b73a255a353"",opaque=""1701a1351f70795"",stale=false,algorithm=MD5"; ProxyAuthentication Parsed = ProxyAuthentication.Parse(TestLine); Assert.NotNull(Parsed); Assert.Equal("sip.cybercity.dk", Parsed.DigestRealm); Assert.Equal("1701b4767d49c41117c7b73a255a353", Parsed.Nonce); Assert.Equal("1701a1351f70795", Parsed.Opaque); Assert.False(Parsed.Stale); Assert.Equal("MD5", Parsed.Algorithm); }
public void AddProxyInfoToDb(ProxyAuthentication proxyAuthObj) { ProxyAuthenticator proxyobj = ReturnProxyAuthenticationInfo(); if (proxyobj == null) { Db4oClient.OMNConnection.Store(this); } else { proxyobj._proxyAuthObj = proxyAuthObj; Db4oClient.OMNConnection.Store(proxyobj); } Db4oClient.OMNConnection.Commit(); Db4oClient.OMNConnection.Ext().Refresh(proxyobj, 1); Db4oClient.CloseRecentConnectionFile(); }
public void AddProxyInfoToDb(ProxyAuthentication proxyAuthObj) { if (Db4oClient.RecentConnFile == null) { Db4oClient.RecentConnFile = Config.OMNConfigDatabasePath(); } _proxyAuthObj = proxyAuthObj; _container = Db4oClient.RecentConn; ProxyAuthenticator proxyobj = ReturnProxyAuthenticationInfo(); if (proxyobj == null) { _container.Store(this); } else { proxyobj._proxyAuthObj = proxyAuthObj; _container.Store(proxyobj); } _container.Commit(); _container.Ext().Refresh(proxyobj, 1); }
public ProxyLogin() { InitializeComponent(); try { ProxyAuthentication proxy = OMEInteraction.RetrieveProxyInfo(); if (proxy != null) { textBoxUserID.Text = proxy.UserName; textBoxPassword.Focus(); textBoxPort.Text = proxy.Port; textBoxProxy.Text = proxy.ProxyAddress; textBoxPassword.Text = Helper.DecryptPass(proxy.PassWord); } else { string domain = Environment.UserDomainName; string username = Environment.UserName; textBoxUserID.Text = domain + CONST_BACKSLASH + username; if (((WebProxy)GlobalProxySelection.Select).Address != null) { int colonIndex = ((WebProxy)GlobalProxySelection.Select).Address.ToString().LastIndexOf(':'); string proxystr = ((WebProxy)GlobalProxySelection.Select).Address.ToString().Substring(0, colonIndex); string port = ((WebProxy)GlobalProxySelection.Select).Address.ToString().Substring(colonIndex + 1, ((WebProxy)GlobalProxySelection.Select).Address.ToString().Length - colonIndex - 1); port.TrimEnd('/'); textBoxPassword.Text = string.Empty; textBoxProxy.Text = proxystr; textBoxPort.Text = port.Substring(0, 4); } } } catch (Exception e) { LoggingHelper.ShowMessage(e); } }
public void Testing() { var virtualSubject = new ProxyVirtual(); var virtualSubjectTest1 = virtualSubject.Request(); var authSubject = new ProxyAuthentication(); string authSubjectTest0; try { authSubject.Request(); } catch (Exception ex) { authSubjectTest0 = ex.Message; } var authSubjectTest1 = authSubject.Authenticate("password"); var authSubjectTest2 = authSubject.Request(); }
public static void SetProxyInfo(ProxyAuthentication proxyInfo) { ProxyAuthenticator proxyAuth = new ProxyAuthenticator(); proxyAuth.AddProxyInfoToDb(proxyInfo); }
/// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (NoEncryption.Expression != null) { targetCommand.AddParameter("NoEncryption", NoEncryption.Get(context)); } if (CertificateCACheck.Expression != null) { targetCommand.AddParameter("CertificateCACheck", CertificateCACheck.Get(context)); } if (CertificateCNCheck.Expression != null) { targetCommand.AddParameter("CertificateCNCheck", CertificateCNCheck.Get(context)); } if (CertRevocationCheck.Expression != null) { targetCommand.AddParameter("CertRevocationCheck", CertRevocationCheck.Get(context)); } if (EncodePortInServicePrincipalName.Expression != null) { targetCommand.AddParameter("EncodePortInServicePrincipalName", EncodePortInServicePrincipalName.Get(context)); } if (Encoding.Expression != null) { targetCommand.AddParameter("Encoding", Encoding.Get(context)); } if (HttpPrefix.Expression != null) { targetCommand.AddParameter("HttpPrefix", HttpPrefix.Get(context)); } if (MaxEnvelopeSizeKB.Expression != null) { targetCommand.AddParameter("MaxEnvelopeSizeKB", MaxEnvelopeSizeKB.Get(context)); } if (ProxyAuthentication.Expression != null) { targetCommand.AddParameter("ProxyAuthentication", ProxyAuthentication.Get(context)); } if (ProxyCertificateThumbprint.Expression != null) { targetCommand.AddParameter("ProxyCertificateThumbprint", ProxyCertificateThumbprint.Get(context)); } if (ProxyCredential.Expression != null) { targetCommand.AddParameter("ProxyCredential", ProxyCredential.Get(context)); } if (ProxyType.Expression != null) { targetCommand.AddParameter("ProxyType", ProxyType.Get(context)); } if (UseSsl.Expression != null) { targetCommand.AddParameter("UseSsl", UseSsl.Get(context)); } if (Impersonation.Expression != null) { targetCommand.AddParameter("Impersonation", Impersonation.Get(context)); } if (PacketIntegrity.Expression != null) { targetCommand.AddParameter("PacketIntegrity", PacketIntegrity.Get(context)); } if (PacketPrivacy.Expression != null) { targetCommand.AddParameter("PacketPrivacy", PacketPrivacy.Get(context)); } if (Protocol.Expression != null) { targetCommand.AddParameter("Protocol", Protocol.Get(context)); } if (UICulture.Expression != null) { targetCommand.AddParameter("UICulture", UICulture.Get(context)); } if (Culture.Expression != null) { targetCommand.AddParameter("Culture", Culture.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ProxyAccessType.Expression != null) { targetCommand.AddParameter("ProxyAccessType", ProxyAccessType.Get(context)); } if (ProxyAuthentication.Expression != null) { targetCommand.AddParameter("ProxyAuthentication", ProxyAuthentication.Get(context)); } if (ProxyCredential.Expression != null) { targetCommand.AddParameter("ProxyCredential", ProxyCredential.Get(context)); } if (SkipCACheck.Expression != null) { targetCommand.AddParameter("SkipCACheck", SkipCACheck.Get(context)); } if (SkipCNCheck.Expression != null) { targetCommand.AddParameter("SkipCNCheck", SkipCNCheck.Get(context)); } if (SkipRevocationCheck.Expression != null) { targetCommand.AddParameter("SkipRevocationCheck", SkipRevocationCheck.Get(context)); } if (SPNPort.Expression != null) { targetCommand.AddParameter("SPNPort", SPNPort.Get(context)); } if (OperationTimeout.Expression != null) { targetCommand.AddParameter("OperationTimeout", OperationTimeout.Get(context)); } if (NoEncryption.Expression != null) { targetCommand.AddParameter("NoEncryption", NoEncryption.Get(context)); } if (UseUTF16.Expression != null) { targetCommand.AddParameter("UseUTF16", UseUTF16.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
private void SetupChromeDriver(Access.Access access, string username, string server) { ChromeOptions options = new ChromeOptions(); // Turn on logging preferences for buildings localization (string). //var loggingPreferences = new OpenQA.Selenium.Chromium.ChromiumPerformanceLoggingPreferences(); //loggingPreferences.IsCollectingNetworkEvents = true; //options.PerformanceLoggingPreferences = loggingPreferences; //options.SetLoggingPreference("performance", LogLevel.All); if (!string.IsNullOrEmpty(access.Proxy)) { // add WebRTC Leak var extensionPath = DisableWebRTCLeak.CreateExtension(username, server, access); options.AddExtension(extensionPath); if (!string.IsNullOrEmpty(access.ProxyUsername)) { // Add proxy authentication extensionPath = ProxyAuthentication.CreateExtension(username, server, access); options.AddExtension(extensionPath); } options.AddArgument($"--proxy-server={access.Proxy}:{access.ProxyPort}"); options.AddArgument("ignore-certificate-errors"); // --ignore-certificate-errors ? } options.AddArgument($"--user-agent={access.UserAgent}"); //options.AddArguments("--disable-logging"); //options.AddArguments("--disable-metrics"); //options.AddArguments("--disable-dev-tools"); //options.AddArguments("--disable-gpu-shader-disk-cache"); //options.AddArguments("--aggressive-cache-discard"); //options.AddArguments("--arc-disable-gms-core-cache"); // Mute audio because of the Ads options.AddArguments("--mute-audio"); // Make browser headless to preserve memory resources // if (acc.Settings.HeadlessMode) options.AddArguments("headless"); // Do not download images in order to preserve memory resources / proxy traffic if (acc.Settings.DisableImages) { options.AddArguments("--blink-settings=imagesEnabled=false"); //--disable-images } // Add browser caching var dir = IoHelperCore.GetCacheDir(username, server, access); Directory.CreateDirectory(dir); options.AddArguments("user-data-dir=" + dir); // Hide command prompt chromeService = ChromeDriverService.CreateDefaultService(); chromeService.HideCommandPromptWindow = true; try { if (acc.Settings.OpenMinimized) { options.AddArguments("--window-position=5000,5000"); this.Driver = new ChromeDriver(chromeService, options); this.Driver.Manage().Window.Position = new System.Drawing.Point(200, 200); // TODO: change coords? this.Driver.Manage().Window.Minimize(); } else { this.Driver = new ChromeDriver(chromeService, options); } // Set timeout this.Driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(60); } catch (Exception e) { acc.Logger.Error(e, $"Error opening chrome driver! Is it already opened?"); } }