forked from Seuntjie900/DiceBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FortuneJack.cs
348 lines (306 loc) · 14.9 KB
/
FortuneJack.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using WebSocket4Net;
using System.Threading;
using System.Collections;
using System.Reflection;
namespace DiceBot
{
class FortuneJack:DiceSite
{
public FortuneJack(cDiceBot Parent)
{
this.Parent = Parent;
new Thread(new ThreadStart(KeepAliveThread)).Start();
}
bool IsFJ = true;
bool IsLoggedIn = false;
protected override void internalPlaceBet(bool High)
{
//64, 0.000000100 ,4950,0,1988923078
/*string s = "64,0.000000100,4950,0,33405318";
string msg = string.Format("61,{0},1,{1}", 1061249, ClientHandlr.CookieContainer.GetCookies(new Uri("https://fortunejack.com"))["PHPSESSID"].Value);
List<byte> bytes = new List<byte>();
foreach (char c in msg)
{
bytes.Add((byte)c);
}
//Client.Send(67);
*/
Client.Send("64,0.000000100,4950,0,1988923088\r\n");
}
public override void ResetSeed()
{
throw new NotImplementedException();
}
public override void SetClientSeed(string Seed)
{
throw new NotImplementedException();
}
DateTime LastKeepalive = DateTime.Now;
void KeepAliveThread()
{
while (IsFJ)
{
if (IsLoggedIn && IsFJ && (DateTime.Now - LastKeepalive).TotalSeconds > 120)
{
LastKeepalive = DateTime.Now;
KeepAlive();
}
Task.Delay(1000);
}
}
Random R = new Random();
void KeepAlive()
{
try
{
WebClient.GetStringAsync("api/main/keepAlive.php?rnd="+R.Next(0, int.MaxValue));
}
catch (AggregateException e)
{
}
catch
{ }
}
protected override bool internalWithdraw(double Amount, string Address)
{
throw new NotImplementedException();
}
HttpClient WebClient = null;
HttpClientHandler ClientHandlr = null;
CookieContainer cookies = null;
WebSocket Client = null;
public override void Login(string Username, string Password, string twofa)
{
try
{
/*ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;*/
cookies = new CookieContainer();
ClientHandlr = new HttpClientHandler { UseCookies = true, CookieContainer = cookies, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip };
WebClient = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://fortunejack.com/") };
WebClient.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
WebClient.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
WebClient.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("br"));
WebClient.DefaultRequestHeaders.Host = "fortunejack.com";
WebClient.DefaultRequestHeaders.Add("Origin", "https://fortunejack.com");
WebClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36");
string tmps = json.ToDateString(DateTime.UtcNow);
/*HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://fortunejack.com/");
if (Prox != null)
betrequest.Proxy = Prox;
betrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
betrequest.CookieContainer = Cookies;
HttpWebResponse EmitResponse;*/
string s1 = "";
try
{
HttpResponseMessage resp = WebClient.GetAsync("").Result;
if (resp.IsSuccessStatusCode)
{
s1 = resp.Content.ReadAsStringAsync().Result;
}
else
{
if (resp.StatusCode == HttpStatusCode.ServiceUnavailable)
{
s1 = resp.Content.ReadAsStringAsync().Result;
//cflevel = 0;
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
System.Windows.Forms.MessageBox.Show("fortunejack.com has their cloudflare protection on HIGH\n\nThis will cause a slight delay in logging in. Please allow up to a minute.");
});
if (!Cloudflare.doCFThing(s1, WebClient, ClientHandlr, 0, "fortunejack.com"))
{
finishedlogin(false);
return;
}
}
}
}
catch (AggregateException e)
{
finishedlogin(false);
return;
}
Cookie c = new Cookie();
foreach (Cookie tc in ClientHandlr.CookieContainer.GetCookies(new Uri("https://fortunejack.com")))
{
if (tc.Name == "__cfduid")
{
c = tc;
break;
}
}
/*betrequest = (HttpWebRequest)HttpWebRequest.Create("https://fortunejack.com/");
if (Prox != null)
betrequest.Proxy = Prox;
betrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
betrequest.CookieContainer = Cookies;
EmitResponse = (HttpWebResponse)betrequest.GetResponse();
sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();*/
string sEmitResponse = WebClient.GetStringAsync("").Result;
string phpsess = "";
CookieCollection tmp = ClientHandlr.CookieContainer.GetCookies(new Uri("https://fortunejack.com"));
List<KeyValuePair<string, string>> pairs = new List<KeyValuePair<string, string>>();
FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
sEmitResponse = WebClient.PostAsync("ajax/time.php", Content).Result.Content.ReadAsStringAsync().Result;
//https://fortunejack.com/ajax/gamesSearch.php
pairs = new List<KeyValuePair<string, string>>();
Content = new FormUrlEncodedContent(pairs);
sEmitResponse = WebClient.PostAsync("ajax/gamesSearch.php", Content).Result.Content.ReadAsStringAsync().Result;
pairs = new List<KeyValuePair<string, string>>();
Content = new FormUrlEncodedContent(pairs);
sEmitResponse = WebClient.PostAsync("ajax/time.php", Content).Result.Content.ReadAsStringAsync().Result;
tmp = ClientHandlr.CookieContainer.GetCookies(new Uri("https://fortunejack.com"));
pairs = new List<KeyValuePair<string, string>>();
pairs.Add(new KeyValuePair<string, string>("logName", Username));
pairs.Add(new KeyValuePair<string, string>("logPassword", Password));
//1456046111067
pairs.Add(new KeyValuePair<string, string>("nocache", tmps));
WebClient.DefaultRequestHeaders.Add("X-Requested-With","XMLHttpRequest");
Content = new FormUrlEncodedContent(pairs);
try
{
sEmitResponse = WebClient.PostAsync("ajax/login.php", Content).Result.Content.ReadAsStringAsync().Result;
if (!sEmitResponse.Contains("success"))
{ finishedlogin(false); return; }
}
catch (AggregateException e)
{ finishedlogin(false); return; }
sEmitResponse = WebClient.GetStringAsync("user.php").Result;
sEmitResponse = WebClient.GetStringAsync("games/dice/").Result;
pairs = new List<KeyValuePair<string, string>>();
Content = new FormUrlEncodedContent(pairs);
KeepAlive();
sEmitResponse = WebClient.PostAsync("ajax/time.php", Content).Result.Content.ReadAsStringAsync().Result;
sEmitResponse = WebClient.GetStringAsync("api/dice4/diceutils.php?act=rooms").Result;
List<KeyValuePair<string, string>> headers = new List<KeyValuePair<string, string>>();
List<KeyValuePair<string, string>> cookies2 = new List<KeyValuePair<string, string>>();
//headers.Add(new KeyValuePair<string, string>("Cookie", "_csn_session=" + cookie));
foreach (Cookie curCookie in ClientHandlr.CookieContainer.GetCookies(new Uri("https://fortunejack.com")))
{
cookies2.Add(new KeyValuePair<string, string>(curCookie.Name, curCookie.Value));
}
var domainTableField = ClientHandlr.CookieContainer.GetType().GetRuntimeFields().FirstOrDefault(x => x.Name == "m_domainTable");
var domains = (IDictionary)domainTableField.GetValue(ClientHandlr.CookieContainer);
foreach (var val in domains.Values)
{
var type = val.GetType().GetRuntimeFields().First(x => x.Name == "m_list");
var values = (IDictionary)type.GetValue(val);
foreach (CookieCollection cooks in values.Values)
{
foreach (Cookie curCookie in cooks)
{
cookies2.Add(new KeyValuePair<string, string>(curCookie.Name, curCookie.Value));
}
}
}
/*headers.Add(new KeyValuePair<string, string>("Origin", "https://fortunejack.com"));
//headers.Add(new KeyValuePair<string, string>("Host", "btrader.fortunejack.com"));
headers.Add(new KeyValuePair<string, string>("Upgrade", "websocket"));
headers.Add(new KeyValuePair<string, string>("Connection", "Upgrade"));
headers.Add(new KeyValuePair<string, string>("Accept-Encoding", "deflate"));
headers.Add(new KeyValuePair<string, string>("accept-language", "en-GB,en-US;q=0.8,en;q=0.6"));
headers.Add(new KeyValuePair<string, string>("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"));
headers.Add(new KeyValuePair<string, string>("Sec-WebSocket-Extensions", "client_max_window_bits"));
*/
Client = new WebSocket("wss://btrader.fortunejack.com:8080/ndice", "", cookies2, headers);
Client.Opened += Client_Opened;
Client.Error += Client_Error;
Client.Closed += Client_Closed;
Client.MessageReceived += Client_MessageReceived;
Client.DataReceived += Client_DataReceived;
Client.AutoSendPingInterval = 4;
Client.EnableAutoSendPing = true;
Client.Open();
/*while (Client.State == WebSocketState.Connecting)
{
Task.Delay(100);
}*/
finishedlogin(true);
IsLoggedIn = true;
//Client.Send("67,2");
}
catch (AggregateException e)
{
}
}
void Client_DataReceived(object sender, DataReceivedEventArgs e)
{
}
void Client_MessageReceived(object sender, MessageReceivedEventArgs e)
{
if (e.Message.StartsWith("63"))
{
Client.Send("67,2\r\n");
}
if (e.Message.StartsWith("65"))
{
}
if (e.Message.StartsWith("90"))
{
}
}
void Client_Closed(object sender, EventArgs e)
{
}
void Client_Error(object sender, SuperSocket.ClientEngine.ErrorEventArgs e)
{
}
void Client_Opened(object sender, EventArgs e)
{
//Client.Send("3probe");
//61,1020272,1,f3fn2alhsjofcmcrqg28adq8p5
//1061249
string msg = string.Format("61,{0},1,{1}", 1020272, ClientHandlr.CookieContainer.GetCookies(new Uri("https://fortunejack.com"))["PHPSESSID"].Value + "\r\n");
List<byte> bytes = new List<byte>();
bytes.Add(Convert.ToByte(61));
foreach ( char c in msg )
{
bytes.Add((byte)c);
}
byte[] tmpbytes = Encoding.UTF8.GetBytes(msg);
//Client.Send(bytes.ToArray(), 0, tmpbytes.Length);
//Task.Delay(1000);
Client.Send(msg);
//Task.Delay(1000);
//Client.Send("67,2");
}
public override bool Register(string username, string password)
{
throw new NotImplementedException();
}
public override bool ReadyToBet()
{
throw new NotImplementedException();
}
public override void Disconnect()
{
IsFJ = false;
IsLoggedIn = false;
if (Client!=null)
try
{
Client.Close();
}
catch { };
}
public override void GetSeed(long BetID)
{
throw new NotImplementedException();
}
public override void SendChatMessage(string Message)
{
throw new NotImplementedException();
}
}
}