aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/VirtualEnvironments.cs
diff options
context:
space:
mode:
authorwilliam341 <[email protected]>2017-06-29 13:13:45 -0700
committerwilliam341 <[email protected]>2017-06-29 13:13:45 -0700
commitad387c41e7d6cc547431e88695d4723ea2dba913 (patch)
treea68282dda40c4f0b28883241c7adcf9010f4550e /ShiftOS.WinForms/VirtualEnvironments.cs
parentb4b19e7a4d203b58537f5b98214296ab52c49b2d (diff)
parent5bebd4411bc6266cbee482a429ba794eefa8f9b6 (diff)
downloadshiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.gz
shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.bz2
shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.zip
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS.WinForms/VirtualEnvironments.cs')
-rw-r--r--ShiftOS.WinForms/VirtualEnvironments.cs152
1 files changed, 152 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/VirtualEnvironments.cs b/ShiftOS.WinForms/VirtualEnvironments.cs
new file mode 100644
index 0000000..fb39569
--- /dev/null
+++ b/ShiftOS.WinForms/VirtualEnvironments.cs
@@ -0,0 +1,152 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using ShiftOS.Engine;
+
+namespace ShiftOS.WinForms
+{
+ public static class VirtualEnvironments
+ {
+ private static List<ShiftOSEnvironment> _environments = new List<ShiftOSEnvironment>();
+
+ public static void Create(string sysname, List<ShiftOS.Objects.ClientSave> users, ulong cp, ShiftOS.Objects.ShiftFS.Directory fs)
+ {
+ var env = new ShiftOSEnvironment
+ {
+ SystemName = sysname,
+ Users = users,
+ Codepoints = cp,
+ Filesystem = fs
+ };
+ _environments.Add(env);
+ }
+
+ public static void Clear()
+ {
+ _environments.Clear();
+ }
+
+ const string VALID_PASSWORD_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_";
+
+
+ [RequiresUpgrade("brute")]
+ [Command("brute")]
+ public static void Brute()
+ {
+ TerminalBackend.PrefixEnabled = false;
+ bool cracked = false;
+ var brute = Properties.Resources.brute;
+ var str = new System.IO.MemoryStream(brute);
+ var reader = new NAudio.Wave.Mp3FileReader(str);
+ var _out = new NAudio.Wave.WaveOut();
+ _out.Init(reader);
+ _out.PlaybackStopped += (o, a) =>
+ {
+ if (cracked == false)
+ {
+ cracked = true;
+ TerminalCommands.Clear();
+ ConsoleEx.Bold = true;
+ ConsoleEx.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine(" - access denied - ");
+ ConsoleEx.ForegroundColor = ConsoleColor.Gray;
+ ConsoleEx.Bold = false;
+ ConsoleEx.Italic = true;
+ Console.WriteLine("password could not be cracked before connection termination.");
+ }
+ TerminalBackend.PrefixEnabled = true;
+ TerminalBackend.PrintPrompt();
+ _out.Dispose();
+ reader.Dispose();
+ str.Dispose();
+ };
+ _out.Play();
+
+ var t = new Thread(() =>
+ {
+
+
+ Console.WriteLine("brute - version 1.0");
+ Console.WriteLine("Copyright (c) 2018 hacker101. All rights reserved.");
+ Console.WriteLine();
+ Thread.Sleep(4000);
+ Console.WriteLine("Scanning outbound connections...");
+ if (string.IsNullOrWhiteSpace(Applications.FileSkimmer.OpenConnection.SystemName))
+ {
+ Thread.Sleep(2000);
+ Console.WriteLine(" - no outbound connections to scan, aborting - ");
+ _out.Stop();
+ _out.Dispose();
+ reader.Dispose();
+ str.Dispose();
+ }
+ else
+ {
+ Thread.Sleep(2000);
+ var con = Applications.FileSkimmer.OpenConnection;
+ Console.WriteLine($@"{con.SystemName}
+------------------
+
+Active connection: ftp, rts
+System name: {con.SystemName}
+Users: {con.Users.Count}");
+ Thread.Sleep(500);
+ var user = con.Users.FirstOrDefault(x => x.Permissions == Objects.UserPermissions.Root);
+ if (user == null)
+ Console.WriteLine(" - no users found with root access - this is a shiftos bug - ");
+ else
+ {
+ Console.WriteLine(" - starting bruteforce attack on user: " + user.Username + " - ");
+ var rnd = new Random();
+
+ char[] pass = new char[user.Password.Length];
+ for (int i = 0; i < pass.Length; i++)
+ {
+ if (cracked == true)
+ break;
+ while (pass[i] != user.Password[i])
+ {
+ if (cracked == true)
+ break;
+ char c = VALID_PASSWORD_CHARS[rnd.Next(VALID_PASSWORD_CHARS.Length)];
+ if (char.IsLetterOrDigit(c))
+ {
+ pass[i] = c;
+ Console.WriteLine(new string(pass));
+ Console.WriteLine();
+ Thread.Sleep(1);
+ }
+ }
+ }
+ if (cracked == false)
+ {
+ cracked = true;
+ TerminalCommands.Clear();
+ Console.WriteLine(" - credentials cracked. -");
+ Console.WriteLine($@"sysname: {con.SystemName}
+user: {user.Username}
+password: {user.Password}");
+ }
+ }
+ }
+ });
+ t.Start();
+ }
+
+ public static ShiftOSEnvironment Get(string sysname)
+ {
+ return _environments.FirstOrDefault(x => x.SystemName == sysname);
+ }
+ }
+
+ public class ShiftOSEnvironment
+ {
+ public string SystemName { get; set; }
+ public ulong Codepoints { get; set; }
+ public ShiftOS.Objects.ShiftFS.Directory Filesystem { get; set; }
+ public List<ShiftOS.Objects.ClientSave> Users { get; set; }
+ }
+}