aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/Hacking/PayloadFunc.cs
blob: 642b13819989bf8f609b9c17aa1bda6ec4afea90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ShiftOS.Engine;

namespace ShiftOS.Frontend
{
    class PayloadFunc
    {
        public static void DoHackFunction(int function)
        {
            switch (function)
            {
                default:
                    break;
                case 1:
                    Hacking.CurrentHackable.DoConnectionTimeout = false;
                    break;
                case 2:
                    new System.Threading.Thread(() =>
                    {
                        Console.WriteLine("FTP File Puller - Version 1.01");
                        foreach (var loot in Hacking.CurrentHackable.ServerFTPLoot)
                        {
                            var bytes = Hacking.GetLootBytes(loot.ID);
                            System.Threading.Thread.Sleep(4 * bytes.Length);
                            string localPath = "0:/home/documents/" + loot.LootName;
                            int count = 0;
                            while (Objects.ShiftFS.Utils.FileExists(localPath))
                            {
                                count++;
                                string truename = loot.LootName.Insert(loot.LootName.LastIndexOf('.'), $"-{count}");
                                localPath = $"0:/home/documents/{truename}";
                            }
                            Console.WriteLine($" --> from {Hacking.CurrentHackable.Data.SystemName}:21/home/documents/{loot.LootName} to {localPath}: {bytes.Length} bytes written");
                            Objects.ShiftFS.Utils.WriteAllBytes(localPath, bytes);
                        }
                        Console.WriteLine("Disconnecting from server...");
                        Hacking.EndHack();
                        TerminalBackend.SetShellOverride("");
                    }).Start();
                    break;
            }
        }
    }
}