-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
147 lines (126 loc) · 5.23 KB
/
Program.cs
File metadata and controls
147 lines (126 loc) · 5.23 KB
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 System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
namespace HTML_Dumper
{
internal class Program
{
private static void Main(string[] args)
{
// Start
Console.Clear();
Console.Title = "HTML Dumper";
Console.WriteLine();
Console.Write(" URL -> ");
Console.ForegroundColor = ConsoleColor.Cyan;
string str = Console.ReadLine();
Console.Clear();
Console.WriteLine();
Index(str);
CSS(str);
JS(str);
Console.WriteLine();
Print(" Done!");
Console.ReadKey();
}
public static void Index(string URL)
{
if (!Directory.Exists("Dumped")) { Directory.CreateDirectory("Dumped"); }
var httpRequest = new Leaf.xNet.HttpRequest();
httpRequest.AllowAutoRedirect = false;
httpRequest.UserAgentRandomize();
var src = httpRequest.Get(URL).ToString();
File.WriteAllText("Dumped/index.html", src);
Print(" Index: " + URL);
}
public static void CSS(string URL)
{
List<string> CSS_Files = new List<string>();
var httpRequest = new Leaf.xNet.HttpRequest();
httpRequest.AllowAutoRedirect = false;
httpRequest.UserAgentRandomize();
var src = httpRequest.Get(URL).ToString();
string[] lines = src.Split(new[] { "\n" }, StringSplitOptions.None);
foreach (var item in lines)
{
if (item.ToString().Contains("<link rel=\"stylesheet\" href=\""))
{
var CSS_URL = Parse(item.ToString(), "<link rel=\"stylesheet\" href=\"", "\"/>");
CSS_Files.Add(CSS_URL);
Print(" CSS: " + CSS_URL);
}
}
foreach (var item in CSS_Files)
{
if (item.Contains("http"))
{
var CSS_Source = httpRequest.Get(item);
var item2 = item.Replace("http://", "").Replace("https://", "").Replace("//", "/").Split('/')[0];
File.WriteAllText(item2, CSS_Source.ToString());
}
else
{
var CSS_Url_ = URL + item;
CSS_Url_ = CSS_Url_.Replace("http://", "").Replace("https://", "").Replace("//", "/").Split('/')[0];
var CSS_Source = httpRequest.Get(CSS_Url_ + "/" + item);
File.WriteAllText("Dumped/" + item.Replace("_", "").Replace("/", ""), CSS_Source.ToString());
}
}
}
public static void JS(string URL)
{
List<string> JS_Files = new List<string>();
var httpRequest = new Leaf.xNet.HttpRequest();
httpRequest.AllowAutoRedirect = false;
httpRequest.UserAgentRandomize();
var src = httpRequest.Get(URL).ToString();
string[] lines = src.Split(new[] { "\n" }, StringSplitOptions.None);
foreach (var item in lines)
{
if (item.ToString().Contains("<script") && item.EndsWith("</script>"))
{
var JS_URL = Parse(item.ToString(), "src=\"", "\"></script>");
JS_Files.Add(JS_URL);
Print(" JS: " + JS_URL);
}
}
foreach (var item in JS_Files)
{
if (item.Contains("http"))
{
var CSS_Source = httpRequest.Get(item).ToString();
var item2 = item.Replace("http://", "").Replace("https://", "").Replace("//", "/").Split('/')[0];
File.WriteAllText(item2, CSS_Source.ToString());
}
else
{
var CSS_Url_ = URL + item;
CSS_Url_ = CSS_Url_.Replace("http://", "").Replace("https://", "").Replace("//", "/").Split('/')[0];
var CSS_Source = httpRequest.Get(CSS_Url_ + "/" + item);
File.WriteAllText("Dumped/" + item.Replace("_", "").Replace("/", ""), CSS_Source.ToString());
}
}
}
private static string Parse(string input, string beginning, string end)
{
int num = input.IndexOf(beginning) + beginning.Length;
int num2 = input.IndexOf(end, num);
return (end == "") ? input.Substring(num) : input.Substring(num, num2 - num);
}
private static void Print(string input)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write(" [");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("DUMPER");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write("]");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(input);
}
}
}