-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
97 lines (67 loc) · 3.4 KB
/
Program.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jurassic;
using System.IO;
using System.Text.RegularExpressions;
using xNetStandard;
namespace IncapsulaBypass
{
class Program
{
static void Main(string[] args)
{
Regex incapsula_regex_code = new Regex("(?<=var b=\")(.*?)(?=\")");
Regex incapsula_regex_link = new Regex("(?<=xhr\\.open\\(\"GET\",\")(.*?)(?=\")");
string js;
string site;
string fullSite;
fullSite = args[0];
getSite();
void getSite()
{
site = fullSite.Replace("http://", "").Replace("https://", "").TrimEnd('/');
}
js = File.ReadAllText("incapsula.js");
HttpRequest httpRequest = new HttpRequest();
httpRequest.Cookies = new CookieDictionary(false);
httpRequest.ConnectTimeout = 10000;
httpRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/29.0.1547.76 Safari/537.36";
httpRequest.IgnoreProtocolErrors = true;
string input = httpRequest.Get(site, (RequestParams)null).ToString();
ScriptEngine scriptEngine = new ScriptEngine();
scriptEngine.Execute(js);
string b = incapsula_regex_code.Match(input).Value;
string link = incapsula_regex_link.Match(scriptEngine.Evaluate<string>("String.fromCharCode(" + scriptEngine.Evaluate<string>("getCode(\"" + b + "\")") + ")")).Value;
httpRequest.Get(site + link, (RequestParams)null);
var output = httpRequest.Get(site, (RequestParams)null).ToString();
Uri myUri = new Uri(fullSite);
Directory.CreateDirectory(myUri.Host);
using (StreamWriter sw = File.CreateText($"HTML_{myUri.Host}.txt"))
{
//Console.WriteLine("created HTML");
sw.WriteLine(output);
}
using (StreamWriter sw = File.CreateText($"Cookie_{myUri.Host}.txt"))
{
//Console.WriteLine("created Cookie");
sw.WriteLine(httpRequest.Cookies);
}
string currentPath = Directory.GetCurrentDirectory();
//Console.WriteLine(currentPath);
//string moveTo = System.IO.Path.Combine(currentPath, $"/{myUri.Host}", $"HTML_{myUri.Host}.txt");
//Console.WriteLine(currentPath + $"/{myUri.Host}/" + $"HTML_{myUri.Host}.txt");
if (File.Exists(currentPath + $"/{myUri.Host}/" + $"HTML_{myUri.Host}.txt"))
File.Delete(currentPath + $"/{myUri.Host}/" + $"HTML_{myUri.Host}.txt");
if (File.Exists(currentPath + $"/{myUri.Host}/" + $"Cookie_{myUri.Host}.txt"))
File.Delete(currentPath + $"/{myUri.Host}/" + $"Cookie_{myUri.Host}.txt");
File.Move($"HTML_{myUri.Host}.txt", currentPath + $"/{myUri.Host}/" + $"HTML_{myUri.Host}.txt");
File.Move($"Cookie_{myUri.Host}.txt", currentPath + $"/{myUri.Host}/" + $"Cookie_{myUri.Host}.txt");
}
}
}