Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
[+] web server getter
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbecvar committed Feb 12, 2023
1 parent 534efa3 commit fa97208
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<modelVersion>4.0.0</modelVersion>

<properties>
<build.version>3.0.0</build.version>
<build.version>4.0.0</build.version>
<build.package>xyz.becvar.websitescanner</build.package>
<build.main>xyz.becvar.websitescanner.Main</build.main>
<build.java.version>17</build.java.version>
</properties>

<groupId>xyz.becvar.websitescanner</groupId>
<artifactId>WebsiteScanner</artifactId>
<version>3.0.0</version>
<version>4.0.0</version>
<packaging>jar</packaging>

<build>
Expand Down
32 changes: 31 additions & 1 deletion src/main/java/xyz/becvar/websitescanner/SiteScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
import java.io.FileReader;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;

public class SiteScanner {

Expand All @@ -33,6 +37,8 @@ public void scan(String url) {
//Print real ip and save to log file
realIPScan(url);

getServer(url);

//Save to log file
fileUtils.saveMessageLog("\n\nFound dirs & subdomains " + url, "scanned_logs/" + validator.urlStrip(url) + ".log");

Expand All @@ -48,7 +54,6 @@ public void scan(String url) {
finalSave(url);
}


//Get real site ip by url
public void realIPScan(String url) {
//Get real site ip
Expand All @@ -61,6 +66,31 @@ public void realIPScan(String url) {
fileUtils.saveMessageLog("REAL IP: " + realIP, "scanned_logs/" + validator.urlStrip(url) + ".log");
}

public void getServer(String url) {

URL obj = null;
try {
obj = new URL(url);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
URLConnection conn = null;
try {
conn = obj.openConnection();
} catch (IOException e) {
throw new RuntimeException(e);
}

//get header by 'key'
String server = conn.getHeaderField("Server");

//Print real ip to console
Logger.log("Server running on " + url + "is: " + server);

//Save real ip to log file
fileUtils.saveMessageLog("SERVER: " + server, "scanned_logs/" + validator.urlStrip(url) + ".log");
}

//Scan page file system
public void fileSystemScan(String url) {

Expand Down

0 comments on commit fa97208

Please sign in to comment.