Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjwood committed Feb 24, 2020
2 parents 1f5e71a + 9825fd0 commit 01ae163
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
<a href="https://play.google.com/store/apps/details?id=com.aaronjwood.portauthority.free"><img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" height="60"></a>

[![Codacy Badge](https://api.codacy.com/project/badge/grade/74a6e90f803d46a1a39b34daabeb8af1)](https://www.codacy.com/app/aaronjwood/PortAuthority)
[![Build Status](https://travis-ci.org/aaronjwood/PortAuthority.svg?branch=master)](https://travis-ci.org/aaronjwood/PortAuthority)
[![Build Status](https://travis-ci.org/aaronjwood/PortAuthority.svg)](https://travis-ci.org/aaronjwood/PortAuthority)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/8687/badge.svg)](https://scan.coverity.com/projects/aaronjwood-portauthority)
[![Known Vulnerabilities](https://snyk.io/test/github/aaronjwood/PortAuthority/badge.svg)](https://snyk.io/test/github/aaronjwood/PortAuthority)

## Overview

Expand Down
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 57
versionName "2.2.12"
versionCode 58
versionName "2.2.13"
applicationId "com.aaronjwood.portauthority"
setProperty("archivesBaseName", "PortAuthority-$versionName")
}
Expand All @@ -35,12 +35,13 @@ android {
buildTypes {
debug {
minifyEnabled false
useProguard false
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.pro'
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}

Expand Down
1 change: 1 addition & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class org.xbill.** { *; }
5 changes: 0 additions & 5 deletions app/proguard.pro

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public abstract class HostActivity extends AppCompatActivity implements HostAsyncResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.lang.ref.WeakReference;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -149,7 +148,7 @@ protected final void onProgressUpdate(Void... params) {
throw new Exception("Unable to access ARP entries");
}

reader = new BufferedReader(new InputStreamReader(ipProc.getInputStream()));
reader = new BufferedReader(new InputStreamReader(ipProc.getInputStream(), "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
String[] neighborLine = line.split("\\s+");
Expand All @@ -175,7 +174,7 @@ protected final void onProgressUpdate(Void... params) {
}
}
} else {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(ARP_TABLE), StandardCharsets.UTF_8));
reader = new BufferedReader(new InputStreamReader(new FileInputStream(ARP_TABLE), "UTF-8"));
reader.readLine(); // Skip header.
String line;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.charset.StandardCharsets;

public class ScanPortsRunnable implements Runnable {
private String ip;
Expand Down Expand Up @@ -66,12 +65,12 @@ public void run() {
SparseArray<String> portData = new SparseArray<>();
String data = null;
try {
InputStreamReader input = new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8);
InputStreamReader input = new InputStreamReader(socket.getInputStream(), "UTF-8");
BufferedReader buffered = new BufferedReader(input);
if (i == 22) {
data = parseSSH(buffered);
} else if (i == 80 || i == 443 || i == 8080) {
PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8), true);
PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"), true);
data = parseHTTP(buffered, out);
}
} catch (IOException e) {
Expand Down Expand Up @@ -115,9 +114,13 @@ private String parseSSH(BufferedReader reader) throws IOException {
private String parseHTTP(BufferedReader reader, PrintWriter writer) throws IOException {
writer.println("GET / HTTP/1.1\r\nHost: " + ip + "\r\n");
char[] buffer = new char[256];
reader.read(buffer, 0, buffer.length);
int bytesRead = reader.read(buffer, 0, buffer.length);
writer.close();
reader.close();
if (bytesRead == 0) {
return null;
}

String data = new String(buffer).toLowerCase();

if (data.contains("apache") || data.contains("httpd")) {
Expand All @@ -132,6 +135,18 @@ private String parseHTTP(BufferedReader reader, PrintWriter writer) throws IOExc
return "NGINX";
}

if (data.contains("node")) {
return "Node.js";
}

if (data.contains("tomcat")) {
return "Tomcat";
}

if (data.contains("litespeed")) {
return "LiteSpeed";
}

return null;
}
}

0 comments on commit 01ae163

Please sign in to comment.