[Android Apps and Games] :
UPDATE:

I have a "working" version 0.4. The issue is I can't get it to function 100% :(

Are there any developers that would be willing to look at the source code and point me in the right direction? I am still learning java so I probably just missed something but I can't seem to get my check boxes to run correctly.

What I want to happen is:

if checkbox == checked
then

disable binary here

if checkbox == unchecked

then

enable binary here

But it doesn't do this instead it just displays the message saying it finished but it didn't. Also how do I run the entire app as root?

Source in question:

/*Copyright (C) 2013 x942 AKA Kyle Davidson

*This program is free software; you can redistribute it and/or
*modify it under the terms of the GNU General Public License
*as published by the Free Software Foundation; either version 2
*of the License, or (at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program; if not, write to the Free Software
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.shadcat.secdroid;

import java.io.File;
import java.io.IOException;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

addListenerOnChkssh();
addListenerOnChksshd();
addListenerOnChknc();
addListenerOnChkadbd();
addListenerOnChktelnet();

}
private void addListenerOnChktelnet() {
CheckBox chktelnet = (CheckBox) findViewById(R.id.checkBox5);
chktelnet.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if ( isChecked) {
File telnetbin = new File ("/system/bin/", "telnet");
if (telnetbin.exists()) {
//File is present now let's disable it!
String telnet[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /system/bin/telnet"}; //Setting variable 'telnet' to disable binary
try {
Process process = Runtime.getRuntime().exec(telnet); //Executing variable "telnet"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"telnet is now disabled", Toast.LENGTH_LONG).show();
}
//If the file isn't in bin let's check xbin
if (!telnetbin.exists()) {
File telnetxbin = new File("/system/xbin/", "telnet");
if (telnetxbin.exists()) {
String telnet[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /system/xbin/telnet"}; //Setting variable 'telnet' to disable binary
try {
Process process = Runtime.getRuntime().exec(telnet); //Executing variable "telnet"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"telnet is now disabled", Toast.LENGTH_LONG).show();
}
}
//Not in xbin or bin let's tell the user we can't find it!
else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"telnet wasn't found!", Toast.LENGTH_LONG).show();
if ( !isChecked) {
File telnetbine = new File("/system/bin/", "telnet");
if (telnetbine.exists()) {

String telnet[]={"su","-c", "chmod 0755 /system/bin/telnet"}; //Setting variable 'telnet' to enable binary
try {
Process process = Runtime.getRuntime().exec(telnet); //Executing variable "telnet"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"telnet (netcat) is now enabled!", Toast.LENGTH_LONG).show();
}
}
if (!telnetbin.exists()) {
File telnetxbine = new File("/system/xbin/", "telnet");
if (telnetxbine.exists()) {
String telnet[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / chmod 0755 /system/xbin/telnet"}; //Setting variable 'telnet' to enable binary
try {
Process process = Runtime.getRuntime().exec(telnet); //Executing variable "telnet"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"telnet is now enabled", Toast.LENGTH_LONG).show();
}
}
else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"telnet wasn't found!", Toast.LENGTH_LONG).show();
}

}
});

}

private void addListenerOnChkadbd() {
// ADBD CheckBox
CheckBox chkadbd = (CheckBox) findViewById(R.id.checkBox4);
chkadbd.setOnCheckedChangeListener(new OnCheckedChangeListener() {

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//is adbd checked?
if ( isChecked) {
//Let's make sure the file is present
File checkadbd = new File("/sbin/", "adbd");
if (checkadbd.exists()) {
//File is present now let's disable it!
String adbd[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /sbin/adbd "}; //Setting variable 'adbd' to disable binary
try {
Process process = Runtime.getRuntime().exec(adbd); //Executing variable "adbd"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"ADBD is now disabled", Toast.LENGTH_LONG).show();
}

else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"ADBD wasn't found!", Toast.LENGTH_LONG).show();

}

if ( !isChecked) {
String adbdon[]={"su","-c", "chmod 0755 /system/xbin/adbd && chmod 0755 /system/bin/adbdd"}; //Setting variable 'adbdon' to enable binary
try {
Process process = Runtime.getRuntime().exec(adbdon); //Executing variable "adbd"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"ADBD is now enabled!", Toast.LENGTH_LONG).show();
}
}
});
}
private void addListenerOnChknc() {
// NC (Net-Cat) CheckBox
CheckBox chknc = (CheckBox) findViewById(R.id.checkBox3);
chknc.setOnCheckedChangeListener(new OnCheckedChangeListener() {

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//is chkSSH checked?
if ( isChecked) {
File ncbin = new File("/system/bin/", "nc");
if (ncbin.exists()) {
//File is present now let's disable it!
String nc[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /system/bin/nc"}; //Setting variable 'nc' to disable binary
try {
Process process = Runtime.getRuntime().exec(nc); //Executing variable "nc"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"nc is now disabled", Toast.LENGTH_LONG).show();
}
//If the file isn't in bin let's check xbin
if (!ncbin.exists()) {
File ncxbin = new File("/system/xbin/", "nc");
if (ncxbin.exists()) {
String nc[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /system/xbin/nc"}; //Setting variable 'nc' to disable binary
try {
Process process = Runtime.getRuntime().exec(nc); //Executing variable "nc"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"nc is now disabled", Toast.LENGTH_LONG).show();
}
}
//Not in xbin or bin let's tell the user we can't find it!
else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"nc wasn't found!", Toast.LENGTH_LONG).show();
if ( !isChecked) {
File ncbine = new File("/system/bin/", "nc");
if (ncbine.exists()) {

String nc[]={"su","-c", "chmod 0755 /system/bin/nc"}; //Setting variable 'nc' to enable binary
try {
Process process = Runtime.getRuntime().exec(nc); //Executing variable "nc"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"NC (netcat) is now enabled!", Toast.LENGTH_LONG).show();
}
}
if (!ncbin.exists()) {
File ncxbine = new File("/system/xbin/", "nc");
if (ncxbine.exists()) {
String nc[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / chmod 0755 /system/xbin/nc"}; //Setting variable 'nc' to enable binary
try {
Process process = Runtime.getRuntime().exec(nc); //Executing variable "nc"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"nc is now enabled", Toast.LENGTH_LONG).show();
}
}
else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"nc wasn't found!", Toast.LENGTH_LONG).show();
}

}
});

}
private void addListenerOnChksshd() {
// SSHD Checkbox
CheckBox chksshd = (CheckBox) findViewById(R.id.checkBox2);
chksshd.setOnCheckedChangeListener(new OnCheckedChangeListener() {

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//is chkSSH checked?
if ( isChecked) {
File sshdbin = new File("/system/bin/", "sshd");
if (sshdbin.exists()) {
//File is present now let's disable it!
String sshd[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /system/bin/sshd"}; //Setting variable 'sshd' to disable binary
try {
Process process = Runtime.getRuntime().exec(sshd); //Executing variable "sshd"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"sshd is now disabled", Toast.LENGTH_LONG).show();
}
//If the file isn't in bin let's check xbin
if (!sshdbin.exists()) {
//sshdxbine variable declared
File sshdxbin = new File("/system/xbin/", "sshd");
//if present declare variable sshd
if (sshdxbin.exists()) {
String sshd[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /system/xbin/sshd"}; //Setting variable 'sshd' to disable binary
try {
Process process = Runtime.getRuntime().exec(sshd); //Executing variable "sshd"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"sshd is now disabled", Toast.LENGTH_LONG).show();
}
}
//Not in xbin or bin let's tell the user we can't find it!
else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"sshd wasn't found!", Toast.LENGTH_LONG).show();
if ( !isChecked) {
//Declare variable sshdbine
File sshdbine = new File("/system/bin/", "sshd");
//if present declare variable sshd
if (sshdbine.exists()) {

String sshd[]={"su","-c", "chmod 0755 /system/bin/sshd"}; //Setting variable 'sshd' to enable binary
try {
Process process = Runtime.getRuntime().exec(sshd); //Executing variable "sshd"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"sshd (netcat) is now enabled!", Toast.LENGTH_LONG).show();
}
}
//file isn't in bin let's try xbin
if (!sshdbin.exists()) {
//sshdxbine varible declared
File sshdxbine = new File("/system/xbin/", "sshd");
//if sshdxbine is present set veriable sshd to enable it
if (sshdxbine.exists()) {
String sshd[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / chmod 0755 /system/xbin/sshd"}; //Setting variable 'sshd' to enable binary
try {
Process process = Runtime.getRuntime().exec(sshd); //Executing variable "sshd"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"sshd is now enabled", Toast.LENGTH_LONG).show();
}
}
//Not in bin or xbin notify user!
else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"sshd wasn't found!", Toast.LENGTH_LONG).show();
}

}

});
}

private void addListenerOnChkssh() {
// SSH Checkbox
CheckBox chkssh = (CheckBox) findViewById(R.id.checkBox1);
chkssh.setOnCheckedChangeListener(new OnCheckedChangeListener() {

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//is chkSSH checked?
if ( isChecked) {
File sshbin = new File("/system/bin/", "ssh");
if (sshbin.exists()) {
//File is present now let's disable it!
String ssh[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /system/bin/ssh"}; //Setting variable 'ssh' to disable binary
try {
Process process = Runtime.getRuntime().exec(ssh); //Executing variable "ssh"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"ssh is now disabled", Toast.LENGTH_LONG).show();
}
//If the file isn't in bin let's check xbin
if (!sshbin.exists()) {
//sshxbine variable declared
File sshxbin = new File("/system/xbin/", "ssh");
//if present declare variable ssh
if (sshxbin.exists()) {
String ssh[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / && chmod 000 /system/xbin/ssh"}; //Setting variable 'ssh' to disable binary
try {
Process process = Runtime.getRuntime().exec(ssh); //Executing variable "ssh"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"ssh is now disabled", Toast.LENGTH_LONG).show();
}
}
//Not in xbin or bin let's tell the user we can't find it!
else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"ssh wasn't found!", Toast.LENGTH_LONG).show();
if ( !isChecked) {
//Declare variable sshbine
File sshbine = new File("/system/bin/", "ssh");
//if present declare variable ssh
if (sshbine.exists()) {

String ssh[]={"su","-c", "chmod 0755 /system/bin/ssh"}; //Setting variable 'ssh' to enable binary
try {
Process process = Runtime.getRuntime().exec(ssh); //Executing variable "ssh"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"ssh (netcat) is now enabled!", Toast.LENGTH_LONG).show();
}
}
//file isn't in bin let's try xbin
if (!sshbin.exists()) {
//sshxbine varible declared
File sshxbine = new File("/system/xbin/", "ssh");
//if sshxbine is present set veriable ssh to enable it
if (sshxbine.exists()) {
String ssh[]={"su","-c", "mount -o rw,remount -t rootfs rootfs / chmod 0755 /system/xbin/ssh"}; //Setting variable 'ssh' to enable binary
try {
Process process = Runtime.getRuntime().exec(ssh); //Executing variable "ssh"
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Here we display text showing we are secure now!
Toast.makeText(MainActivity.this,
"ssh is now enabled", Toast.LENGTH_LONG).show();
}
}
//Not in bin or xbin notify user!
else
//Oops! File isn't there. Could it be else where? If not we are secure!
Toast.makeText(MainActivity.this,
"ssh wasn't found!", Toast.LENGTH_LONG).show();
}

}

});

}
//Check if app has run before or not
public void onCreate(){
boolean firstrun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("firstrun", true);
//If this is first run than show Welcome dialog and README button
if (firstrun){
new AlertDialog.Builder(this)
.setTitle("SecDroid v0.4")
.setMessage("Welcome to SecDroid. Press README for the Readme or press continue.")
.setPositiveButton("README", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
myWebLink.setData(Uri.parse("https://github.com/x942/secdroid/blob/master/README.md"));
startActivity(myWebLink);
}

})

.setNegativeButton("Continue", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// do nothing
dialog.dismiss();
}
})
.show();
}

}
private Menu menu;
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
return true;
}
}

I also attached the entire project if someone can please take a look at it. I just need some pointers thankyou!