-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrequests_tools.java
169 lines (169 loc) · 5.85 KB
/
requests_tools.java
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
import java.io.File;
import java.util.*;
import java.net.*;
public class requests_tools
{
public static void main(String[]args) throws Exception
{
requests_tools_run();
return;
}
public static void requests_tools_run() throws Exception
{
Scanner scanner = new Scanner(System.in);
System.out.print("Setool-Main//Main Console//Requests_Tools//");
String input = scanner.nextLine();
command_line(input);
scanner.close();
}
public static void command_line(String input) throws Exception
{
//System.out.println(input);
for (int i =1 ; i <= 1 ; i++){
if (input.equals("exit"))
{
//go back to the main console
setool.run_main_function();
return;
}
if (input.equals("show options"))
{
try
{
String fileconfig = "./config/requests_tools";
File file = new File(fileconfig);
setool.read_logo(file);
requests_tools_run();
return;
}catch (Exception err)
{
System.out.println(err);
requests_tools_run();
}
}
if (input.equals("use url_resolution"))
{
System.out.println("[!]Enter 'exit' to exit");
Scanner scanner = new Scanner(System.in);
System.out.print("Setool-Main//Main Console//Requests_Tools//Url_Resolution//Enter URL:");
String inURL = scanner.nextLine();
if (inURL.equals("exit"))
{
requests_tools_run();
}
else
{
URL_resolution(inURL);
scanner.close();
requests_tools_run();
}
}
if (input.equals("use get_web_code"))
{
//get the webpage's recouces code
get_web_code();
}
if (input.equals("use get_website_info"))
{
Scanner in_URL = new Scanner(System.in);
System.out.print("Setool-Main//Main Console//Requests_Tools//Web_Info//Enter URL:");
String URL = in_URL.nextLine();
requests_tools.get_website_info(URL);
requests_tools_run();
in_URL.close();
}
else
{
requests_tools_run();
return;
}
}
}
public static void URL_resolution(String inURL) throws Exception{
try
{
URL url = new URL(inURL);
System.out.println("");
System.out.println("URL:" + url.toString());
System.out.println("Server Agreement:" + url.getProtocol());
System.out.println("File Path:" + url.getFile());
System.out.println("host:" + url.getHost());
System.out.println("Get Path:" + url.getPath());
System.out.println("Server Port " + url.getPort());
System.out.println("default Port" + url.getDefaultPort());
System.out.println("Content:"+ url.getContent());
System.out.println("HashCode:"+url.hashCode());
System.out.println("Users Info:" + url.getUserInfo());
System.out.println("Get Class:" + url.getClass());
System.out.println("");
}
catch (Exception err)
{
System.out.println(err);
}
finally
{
requests_tools_run();
}
}
public static void get_web_code() throws Exception
{
try{
Scanner scanner = new Scanner(System.in);
System.out.print("Setool-Main//Main Console//Requests_Tools//Url_Resolution//Enter URL:");
String URL = scanner.nextLine();
String encoding = "utf-8";
String get_code = web_clone.getHtmlResourceByUrl(URL, encoding);
System.out.println(get_code);
System.out.print("[?]Do you want write to the file:[Y or N]:");
String ch = scanner.nextLine();
if (ch.equals("Y") || ch.equals("y"))
{
String content = get_code;
System.out.print("Enter the file name:");
String name = scanner.nextLine();
setool.wirte_file(content, name);
}
else
{
System.out.println("End Optioning!");
}
}
catch (Exception error)
{
/* print error info */
System.out.println(error);
}
finally
{
requests_tools.requests_tools_run();
}
}
public static void get_website_info(String URL) throws Exception
{
try
{
//first , get ip
InetAddress inetAddress = InetAddress.getLocalHost();
System.out.println("");
System.out.println("[!]Your Host-->");
//users information
System.out.println("Your HostName: " + inetAddress.getHostName());
System.out.println("HashCode: " + inetAddress.hashCode());
System.out.println("Your Host Adress: " + inetAddress.getHostAddress());
System.out.println("");
for (int i = 1 ; i <= 1 ; i++)
{
System.out.println("[!]Target Host-->");
System.out.println("Target IP: " + InetAddress.getByName(URL));
System.out.println("AllByName: " + InetAddress.getAllByName(URL));
System.out.println("Class: " + InetAddress.class);
}
System.out.println("");
}
catch (Exception error)
{
System.out.println(error);
}
}
}