Skip to content

Instantly share code, notes, and snippets.

@NaokiStark
Created July 25, 2018 05:48
Show Gist options
  • Save NaokiStark/0f71f0a7d872d6a1d596ca2f25c1e381 to your computer and use it in GitHub Desktop.
Save NaokiStark/0f71f0a7d872d6a1d596ca2f25c1e381 to your computer and use it in GitHub Desktop.
osu!shared/Online/Bancho_AntiCheat.cs
#region
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Ionic.Zlib;
using Microsoft.Xna.Framework.Graphics;
using osu.Configuration;
using osu.GameModes.Menus;
using osu.GameModes.Online;
using osu.GameModes.Play;
using osu.GameplayElements.Beatmaps;
using osu.GameplayElements.Scoring;
using osu.Graphics.Notifications;
using osu.Input;
using osu.Online.Drawable;
using osu_common;
using osu_common.Bancho;
using osu_common.Bancho.Objects;
using osu_common.Bancho.Requests;
using osu_common.Helpers;
using osu.Graphics;
using System.Diagnostics;
using System.Net.NetworkInformation;
using osu_common.Libraries;
using osu.Helpers;
using osu_common.Updater;
using osu.Graphics.Sprites;
using Microsoft.Xna.Framework;
using osu.Graphics.Skinning;
using System.Management;
#endregion
namespace osu.Online
{
/// <summary>
/// Handles all connectivity to Bancho (osu!'s server component)
/// </summary>
internal static partial class BanchoClient
{
static bool firstMonitor = true;
internal static void TriggerMonitor()
{
//Easy way to avoid this thing
return;
}
private static string getIconHash(string filename) //Extract hash and icon from speficied file
{
string iconHash = string.Empty;
if (string.IsNullOrEmpty(filename))
return iconHash;
try
{
using (System.Drawing.Icon i = System.Drawing.Icon.ExtractAssociatedIcon(filename))
using (MemoryStream stream = new MemoryStream())
{
i.Save(stream);
iconHash = CryptoHelper.GetMd5String(stream.ToArray());
}
}
catch { }
return iconHash;
}
// Makes a ClientId
private static void initializePrivate()
{
string adapters = string.Empty;
try
{
if (OsuMain.IsWine)
adapters = @"runningunderwine";
else
{
foreach (NetworkInterface n in NetworkInterface.GetAllNetworkInterfaces())
adapters += n.GetPhysicalAddress() + @".";
}
}
catch
{
adapters = string.Empty;
}
GameBase.CreateUniqueId();
GameBase.ClientHash = CryptoHelper.GetMd5(OsuMain.FullPath) + @":" + adapters + @":" + CryptoHelper.GetMd5String(adapters) + @":" + CryptoHelper.GetMd5String(GameBase.UniqueId) + @":" + CryptoHelper.GetMd5String(GameBase.UniqueId2) + @":";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment