diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index 34f9e9c..dee751b 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -55,11 +55,14 @@ namespace ShiftOS.WinForms.Applications public static void DisconnectRemote() { - OnDisconnect?.Invoke(); - CurrentRemoteUser = new Objects.ClientSave(); - if (!string.IsNullOrWhiteSpace(OpenConnection.SystemName)) - Infobox.Show("Connections terminated.", "All outbound File Skimmer connections have been terminated."); - OpenConnection = new ShiftOSEnvironment(); + Desktop.InvokeOnWorkerThread(() => + { + OnDisconnect?.Invoke(); + CurrentRemoteUser = new Objects.ClientSave(); + if (!string.IsNullOrWhiteSpace(OpenConnection.SystemName)) + Infobox.Show("Connections terminated.", "All outbound File Skimmer connections have been terminated."); + OpenConnection = new ShiftOSEnvironment(); + }); } public FileSkimmer() diff --git a/ShiftOS.WinForms/Commands.cs b/ShiftOS.WinForms/Commands.cs index c7d8f5b..c9e9376 100644 --- a/ShiftOS.WinForms/Commands.cs +++ b/ShiftOS.WinForms/Commands.cs @@ -49,7 +49,10 @@ namespace ShiftOS.Engine [Command("clear", description = "{DESC_CLEAR}")] public static bool Clear() { - AppearanceManager.ConsoleOut.Clear(); + Desktop.InvokeOnWorkerThread(() => + { + AppearanceManager.ConsoleOut.Clear(); + }); return true; } } diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 83515c4..dd84e94 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -359,6 +359,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] brute { + get { + object obj = ResourceManager.GetObject("brute", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 8390f39..07cf941 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -34618,6 +34618,9 @@ ..\Resources\strings_fr.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + ..\Resources\brute.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\PebcakDevelFS.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 diff --git a/ShiftOS.WinForms/Resources/brute.mp3 b/ShiftOS.WinForms/Resources/brute.mp3 new file mode 100644 index 0000000..ae20cc2 Binary files /dev/null and b/ShiftOS.WinForms/Resources/brute.mp3 differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index f287540..d79a7e3 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -873,6 +873,7 @@ + diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 0723a37..74e6ea6 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -163,6 +163,20 @@ namespace ShiftOS.WinForms.Stories } VirtualEnvironments.Clear(); Applications.FileSkimmer.DisconnectRemote(); + WriteLine("Connections terminated I see.. Alright. Have fun with those dummy documents - you can keep them if you'd like. There's nothing important in them."); + WriteLine("That's one thing you can do with brute and other hacking utilities. I'd recommend buying some of brute's Shiftorium upgrades to make it faster and more efficient."); + WriteLine("Also, along the way, you're going to find a lot of new tricks. Some of them will require more than just brute to get into."); + WriteLine("So be on the lookout on the Shiftnet for other hacking-related tools. You won't find any on Appscape, however..."); + WriteLine("That darn Aiden Nirh guy can't stand hackers."); + WriteLine("Looking at your logs, I see he's contacted you before... Seriously... don't let him find out about brute. He'll report it directly to DevX."); + WriteLine("Oh yeah, one more thing... that virus scanner... you may want to scan any files that you transfer from other systems with it."); + WriteLine("You never know what sorts of digital filth is hidden within such innocent-looking files."); + WriteLine("ALWAYS scan before opening - because if you open a file containing malicious code, it'll get run. It's just how ShiftOS's kernel works."); + Console.WriteLine("User has disconnected."); + Story.Context.MarkComplete(); + TerminalBackend.PrefixEnabled = true; + SaveSystem.SaveGame(); + TerminalBackend.PrintPrompt(); }); }); } @@ -173,6 +187,8 @@ namespace ShiftOS.WinForms.Stories //just to annoy victor tran } + const string VALID_PASSWORD_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_"; + public static string GenRandomPassword() { var rnd = new Random(); @@ -180,7 +196,8 @@ namespace ShiftOS.WinForms.Stories string pass = ""; for(int i = 0; i < len; i++) { - pass += (char)rnd.Next(255); + char c = VALID_PASSWORD_CHARS[rnd.Next(VALID_PASSWORD_CHARS.Length)]; + pass += c; } return pass; } diff --git a/ShiftOS.WinForms/VirtualEnvironments.cs b/ShiftOS.WinForms/VirtualEnvironments.cs index 5faa6ff..fb39569 100644 --- a/ShiftOS.WinForms/VirtualEnvironments.cs +++ b/ShiftOS.WinForms/VirtualEnvironments.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; +using ShiftOS.Engine; namespace ShiftOS.WinForms { @@ -27,6 +29,113 @@ namespace ShiftOS.WinForms _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); diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 85e1371..a9101b7 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -83,28 +83,15 @@ namespace ShiftOS.Engine /// The file to play. public static void Play(string file) { - bool play = true; - float volume = 1f; - if (SaveSystem.CurrentSave != null) + try { - play = (SaveSystem.CurrentSave.SoundEnabled); - volume = (float)SaveSystem.CurrentSave.MusicVolume / 100f; + var bytes = File.ReadAllBytes(file); + var str = new MemoryStream(bytes); + PlayStream(str); } - if (play) + catch { - try - { - _reader = new AudioFileReader(file); - _out = new WaveOut(); - _out.Init(_reader); - _out.Volume = volume; - _out.Play(); - _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; - } - catch (Exception ex) - { - Console.WriteLine("Audio error: " + ex.Message); - } + } } @@ -114,35 +101,14 @@ namespace ShiftOS.Engine /// The stream to read from. public static void PlayStream(Stream str) { - try + bool play = true; + if (SaveSystem.CurrentSave != null) + play = SaveSystem.CurrentSave.SoundEnabled; + if (play) { - bool play = true; - float volume = 1f; - if (SaveSystem.CurrentSave != null) - { - play = (SaveSystem.CurrentSave.SoundEnabled); - volume = (float)SaveSystem.CurrentSave.MusicVolume / 100f; - } - if (play) - { - try - { - while (_out.PlaybackState == PlaybackState.Playing) - { - Thread.Sleep(10); - } - } - catch { } - ShiftOS.Engine.AudioManager.Stop(); - _out = new WaveOut(); - var mp3 = new WaveFileReader(str); - _out.Init(mp3); - _out.Volume = volume; - _out.Play(); - _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; - } + var splayer = new System.Media.SoundPlayer(str); + splayer.Play(); } - catch { } } public static event Action PlayCompleted;