forked from ivanmeler/SamFirm_Reborn
-
Notifications
You must be signed in to change notification settings - Fork 3
/
WebRequestExtension.cs
46 lines (45 loc) · 1.53 KB
/
WebRequestExtension.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using SamFirm;
namespace hadesFirm
{
public static class WebRequestExtension
{
public static WebResponse GetResponseFUS(this WebRequest wr)
{
try
{
WebResponse response = wr.GetResponse();
if (((IEnumerable<string>) response.Headers.AllKeys).Contains<string>("Set-Cookie"))
Web.JSessionID = WebRequestExtension.seal(response.Headers[HttpResponseHeader.SetCookie], "JSESSIONID");
if (((IEnumerable<string>) response.Headers.AllKeys).Contains<string>("NONCE"))
{
Web.EncryptedNonce = response.Headers["NONCE"];
Web.DecryptedNonce = KiesAuth.DecryptNonce(Web.EncryptedNonce);
Web.Auth = KiesAuth.GetAuth(Web.DecryptedNonce);
}
return response;
}
catch (WebException ex)
{
Logger.WriteLog("Error getting response: " + ex.Message, false);
if (ex.Status == WebExceptionStatus.NameResolutionFailure)
Web.SetReconnect();
return ex.Response;
}
}
private static string seal(string tuljan, string _param1)
{
string[] strArray = tuljan.Split(new char[2]{ ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
string empty = string.Empty;
foreach (string str in strArray)
{
if (str.Contains(_param1))
empty = str.Split(new string[1]{ "=" }, StringSplitOptions.RemoveEmptyEntries)[1];
}
return empty;
}
}
}