-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBHVRSesseion.cs
147 lines (130 loc) · 4.9 KB
/
BHVRSesseion.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using Fiddler;
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
namespace Demon_Panel
{
internal class BHVRSeession
{
public static event CookieHandler OnTokenReceived
{
add
{
CookieHandler cookieHandler = BhvrSession;
CookieHandler cookieHandler2;
do
{
cookieHandler2 = cookieHandler;
CookieHandler value2 = (CookieHandler)Delegate.Combine(cookieHandler2, value);
cookieHandler = Interlocked.CompareExchange(ref BhvrSession, value2, cookieHandler2);
}
while (cookieHandler != cookieHandler2);
}
remove
{
CookieHandler cookieHandler = BhvrSession;
CookieHandler cookieHandler2;
do
{
cookieHandler2 = cookieHandler;
CookieHandler value2 = (CookieHandler)Delegate.Remove(cookieHandler2, value);
cookieHandler = Interlocked.CompareExchange(ref BhvrSession, value2, cookieHandler2);
}
while (cookieHandler != cookieHandler2);
}
}
public static void start()
{
FiddlerApplication.BeforeRequest += new SessionStateHandler(CatchBeforeRequest);
EnsureRootCertificate();
if (Main.Host == "steam")
Process.Start("steam://rungameid/381210");
else
{
MessageBox.Show("Please launch the game manually over your launcher.");
}
FiddlerApplication.Startup(((FiddlerCoreStartupSettingsBuilder<FiddlerCoreStartupSettingsBuilder, FiddlerCoreStartupSettings>)((FiddlerCoreStartupSettingsBuilder<FiddlerCoreStartupSettingsBuilder, FiddlerCoreStartupSettings>)((FiddlerCoreStartupSettingsBuilder<FiddlerCoreStartupSettingsBuilder, FiddlerCoreStartupSettings>)((FiddlerCoreStartupSettingsBuilder<FiddlerCoreStartupSettingsBuilder, FiddlerCoreStartupSettings>)((FiddlerCoreStartupSettingsBuilder<FiddlerCoreStartupSettingsBuilder, FiddlerCoreStartupSettings>)new FiddlerCoreStartupSettingsBuilder().ListenOnPort(0)).RegisterAsSystemProxy()).ChainToUpstreamGateway()).DecryptSSL()).OptimizeThreadPool()).Build());
}
public static void Stop()
{
DisableProxy();
FiddlerApplication.Shutdown();
}
public static void CookieAdd(string cookie)
{
BhvrSession(cookie);
}
public static bool RemoveRootCertificate()
{
bool result;
try
{
CertMaker.removeFiddlerGeneratedCerts(true);
result = true;
}
catch
{
result = false;
}
return result;
}
public static void DisableProxy()
{
try
{
FiddlerApplication.Shutdown();
string keyName = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
Registry.SetValue(keyName, "ProxyEnable", 0);
Registry.SetValue(keyName, "ProxyServer", "");
Registry.SetValue(keyName, "ProxyOverride", "");
}
catch
{
}
}
public static bool EnsureRootCertificate()
{
if (!CertMaker.rootCertExists())
{
if (!CertMaker.createRootCert())
{
return false;
}
if (!CertMaker.trustRootCert())
{
return false;
}
FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.bc.cert", null);
FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.bc.key", null);
}
return true;
}
public static void CatchBeforeRequest(Session Core)
{
if (Core.uriContains("api/v1/Inventories"))
{
if (Core.uriContains("steam.live"))
{
Main.Host = "steam";
Main.Kraken = "steam";
}
else if (Core.uriContains("grdk.live"))
{
Main.Host = "grdk";
Main.Kraken = "grdk";
}
else if (Core.uriContains("brill.live"))
{
Main.Host = "brill";
Main.Kraken = "egs";
}
Main.UserAgent = Core.oRequest.headers["User-Agent"];
CookieAdd(Core.oRequest["Cookie"]);
}
}
public static CookieHandler BhvrSession;
public delegate void CookieHandler(string cookie);
}
}