This repository has been archived on 2025-01-01. You can view files and clone it, but cannot push or open issues or pull requests.
ShiftOS_TheReturn/ShiftOS.WinForms/VirtualEnvironments.cs

153 lines
5.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
2017-06-24 14:41:45 -04:00
using System.Threading;
using System.Threading.Tasks;
2017-06-24 14:41:45 -04:00
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();
}
2017-06-24 14:41:45 -04:00
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; }
}
}