Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
Revert switch to bVNC
Browse files Browse the repository at this point in the history
Migration to bVNC needs more testing.
bVNC is not yet installed as part of NetHunter,
crashes on Galaxy Tab S4 and payment option not yet fully understood.
  • Loading branch information
Re4son committed Apr 17, 2019
1 parent 355b8c0 commit 9681cce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 62 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ android {
minSdkVersion 17
targetSdkVersion 28
versionCode 22
versionName "2019.2-rc4"
versionName "2019.2-rc5"
}

sourceSets {
Expand Down
79 changes: 18 additions & 61 deletions src/com/offsec/nethunter/VNCFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
Expand All @@ -18,20 +17,6 @@
import android.widget.Toast;

import com.offsec.nethunter.utils.NhPaths;
import com.offsec.nethunter.utils.ShellExecuter;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.AttributeView;
import java.nio.file.attribute.FileOwnerAttributeView;
import java.nio.file.attribute.GroupPrincipal;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.UserPrincipal;
import java.util.UUID;

import androidx.fragment.app.Fragment;

Expand All @@ -42,7 +27,6 @@ public class VNCFragment extends Fragment {
private String xheight;
private String localhostonly = "";

private boolean isbVNCinstalled = false;
NhPaths nh;
private static final String ARG_SECTION_NUMBER = "section_number";

Expand All @@ -61,6 +45,8 @@ public static VNCFragment newInstance(int sectionNumber) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

final View rootView = inflater.inflate(R.layout.vnc_setup, container, false);
SharedPreferences sharedpreferences = getActivity().getSharedPreferences("com.offsec.nethunter", Context.MODE_PRIVATE);
Context mContext = getActivity().getApplicationContext();

// Get screen size to pass to VNC
DisplayMetrics displaymetrics = new DisplayMetrics();
Expand Down Expand Up @@ -113,7 +99,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
});


check_bVNC();
return rootView;
}

Expand All @@ -128,46 +113,29 @@ private void intentClickListener_VNC() {
return;
}

if (!isbVNCinstalled) {
Toast.makeText(getActivity().getApplicationContext(), "bVNC app not found!", Toast.LENGTH_LONG).show();
return;
}

String _R_IP = ((EditText) getView().findViewById(R.id.vnc_R_IP)).getText().toString().replaceAll(" ", "");
String _R_PORT = ((EditText) getView().findViewById(R.id.vnc_R_PORT)).getText().toString().replaceAll(" ", "");
String _R_IP = ((EditText) getView().findViewById(R.id.vnc_R_IP)).getText().toString();
String _R_PORT = ((EditText) getView().findViewById(R.id.vnc_R_PORT)).getText().toString();
String _PASSWD = ((EditText) getView().findViewById(R.id.vnc_PASSWD)).getText().toString();
String _NICK = ((EditText) getView().findViewById(R.id.vnc_CONN_NICK)).getText().toString().replaceAll(" ","");
String _NICK = ((EditText) getView().findViewById(R.id.vnc_CONN_NICK)).getText().toString();
String _USER = ((EditText) getView().findViewById(R.id.vnc_USER)).getText().toString();
int _RESOLUTION = ((Spinner) getView().findViewById(R.id.resolution_spinner)).getSelectedItemPosition();

if (!_R_IP.equals("") && !_R_PORT.equals("") && !_NICK.equals("")) {

//Intent intent = getActivity().getApplicationContext().getPackageManager().getLaunchIntentForPackage("com.offsec.nhvnc");
Intent intent = getActivity().getApplicationContext().getPackageManager().getLaunchIntentForPackage("com.realvnc.viewer.android");
if (intent == null) {
Toast.makeText(getActivity().getApplicationContext(), "Make sure ip,port,nickname & password are not empty!", Toast.LENGTH_LONG).show();
} else {
ShellExecuter exe = new ShellExecuter();
String command;
String uuid = UUID.randomUUID().toString();
command = "su -c '/data/data/com.offsec.nethunter/files/scripts/bootkali vnc start " + uuid + " " + _NICK + " " + _R_IP + " " + _R_PORT + " " + _PASSWD + "'";
exe.RunAsRootWithException(command);

//intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
//intent.putExtra("com.offsec.nhvnc.EXTRA_CONN_DATA", true);
//intent.putExtra("R_IP", _R_IP);
//intent.putExtra("R_PORT", _R_PORT);
//intent.putExtra("PASSWD", _PASSWD);
//intent.putExtra("NICK", _NICK);
//intent.putExtra("USER", _USER);
//intent.putExtra("COLORMODEL", _RESOLUTION);
//startActivity(intent);
}
Intent intent = getActivity().getApplicationContext().getPackageManager().getLaunchIntentForPackage("com.offsec.nhvnc");
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.putExtra("com.offsec.nhvnc.EXTRA_CONN_DATA", true);
intent.putExtra("R_IP", _R_IP);
intent.putExtra("R_PORT", _R_PORT);
intent.putExtra("PASSWD", _PASSWD);
intent.putExtra("NICK", _NICK);
intent.putExtra("USER", _USER);
intent.putExtra("COLORMODEL", _RESOLUTION);

startActivity(intent);
}

} catch (Exception e) {
Log.d("errorLaunching", e.toString());
Toast.makeText(getActivity().getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
Toast.makeText(getActivity().getApplicationContext(), "NetHunter VNC not found!", Toast.LENGTH_SHORT).show();
}
}

Expand All @@ -183,15 +151,4 @@ private void intentClickListener_NH(final String command) {

}
}
private void check_bVNC() {
new Thread(new Runnable() {
public void run() {
ShellExecuter exe_check = new ShellExecuter();
if (exe_check.RunAsRootOutput("pm list packages | grep com.iiordanov.freebVNC").equals("")) {
isbVNCinstalled = false;
} else isbVNCinstalled = true;
}
}).start();
}

}
}

0 comments on commit 9681cce

Please sign in to comment.