Skip to content

Commit

Permalink
Got around to updating the app with my system-modification way of
Browse files Browse the repository at this point in the history
changing mac addresses.

This should work on more devices, as long as you have root and your
/system can be mounted read-write.
  • Loading branch information
souramoo committed Dec 18, 2015
1 parent 2031703 commit 7e71811
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 67 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion NetGhost.iml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Network Ghost

Android MAC/Hostname Spoofing in Lollipop 5.1 (And probably older Androids too) (tested on Galaxy S4 w/ cyanogenmod 12.1)
Android MAC/Hostname Spoofing in Lollipop 5.1 (And probably older Androids too) (tested on Galaxy S4 and HTC One M7/M9 w/ cyanogenmod 12.1)

Change your mac address! Change your hostname! Fun for all the family! *

\* May not actually be fun for ALL the family. Your dog probably doesn't care about this.
\* May not actually be true.

![Screenshot](screenshots/screenshot.png)

Expand All @@ -24,14 +24,18 @@ Finally, there seems to be a distinct lack of open source apps that let me chang

## Where does it definitely work?
* Samsung Galaxy S4 running Cyanogenmod 12.1
* HTC One M7
* HTC One M9

NOTE: Some MAC addresses cannot be set. For example, "11:22:33:44:55:66" will not work on my S4 but "00:11:22:33:44:55" will.

## How do I get it?
Install the apk file!

## How do I use it?
Open up the app, hit the toggle button to change "User-set" to "randomise" and hit "update". Verify the mac has really been changed to what the app says by opening up a terminal and running:
Open up the app, flip the spoof switch. You will be asked to okay an update to /system files to allow this to work.

Hit the toggle button to change "User-set" to "randomise" and hit "update". Verify the mac has really been changed to what the app says by opening up a terminal and running:
```
adb shell ip addr
```
Expand Down Expand Up @@ -76,7 +80,10 @@ It was necessary to turn it off the Android(TM) way, i.e.
```
svc wifi disable
```
Which kills wpa_supplicant, allowing us to swap out the mac address and turn wifi back on (which restarts wpa_supplicant, forcing it to re-read the mac address into memory). I have kept the commands running in a root shell to a minimum, since the wifi start/stop can be achieved in java.
Which kills wpa_supplicant, allowing us to swap out the mac address and turn wifi back on (which restarts wpa_supplicant, forcing it to re-read the mac address into memory).

But some devices bring down the network interface when the wifi is turned off, not letting us change the mac address. And when it's brought back up, wpa_supplicant is started up and the mac address is locked in again! What a travesty!

But it's okay, I've come up with a workaround. This app will now install the workaround into /system and this new method should be more portable across devices.

## Extension: HTC one
For my HTC one, the above method does not work because on wifi restart, the device is brought down and up before wpa_supplicant is called. /dev is mounted as tmpfs so to save flash read-write cycles, I made a script that replaces wpa_supplicant. Move /system/bin/wpa_supplicant to /system/bin/wpa_supplicant_real and adb push scripts/wpa_supplicant /system/bin/wpa_supplicant - the git version of the app will now push the mac address to /dev/mac and it will be set just before calling wpa_supplicant for realz.
I have kept the commands running in a root shell to a minimum, since the wifi start/stop can be achieved in java.
9 changes: 3 additions & 6 deletions app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="NetGhost" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="NetworkGhost" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand All @@ -13,11 +13,8 @@
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand Down
38 changes: 35 additions & 3 deletions app/src/main/java/com/moosd/netghost/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.moosd.netghost;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Editable;
Expand All @@ -19,14 +21,16 @@ public class MainActivity extends Activity {

EditText macEntry = null, hostEntry = null;
ToggleButton macToggle = null, hostToggle = null;
Button updateButton = null, revertButton = null;
Button updateButton = null, revertButton = null, uninstallButton = null;
SharedPreferences settings = null;
Switch spoofSwitch = null;
public static MainActivity me = null;

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

settings = getSharedPreferences("settings", 0);

Expand All @@ -38,6 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {

updateButton = ((Button) findViewById(R.id.button3));
revertButton = ((Button) findViewById(R.id.button));
uninstallButton = ((Button) findViewById(R.id.button4));

spoofSwitch = ((Switch) findViewById(R.id.switch1));

Expand All @@ -46,7 +51,12 @@ protected void onCreate(Bundle savedInstanceState) {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// update settings
settings.edit().putBoolean("spoofenabled", isChecked).commit();
if(!Util.isInstalled() && isChecked) {
Util.askToInstall(MainActivity.this, true);
}
if(Util.isInstalled()) {
settings.edit().putBoolean("spoofenabled", isChecked).commit();
}
// update ux
updateUX();
}
Expand Down Expand Up @@ -182,6 +192,26 @@ public void onClick(View v) {
}
});

uninstallButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new AlertDialog.Builder(MainActivity.this)
.setTitle("Unnstall")
.setMessage("Are you sure you want to uninstall the changes to /system? You will not be able to modify your mac address.")
.setNegativeButton("No", null)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
settings.edit().putBoolean("spoofenabled", false).commit();
Util.uninstall(MainActivity.this);
updateUX();
}
})
.create()
.show();
}
});

}

@Override
Expand All @@ -190,7 +220,7 @@ protected void onResume() {
updateUX();
}

private void updateUX() {
public void updateUX() {
boolean macrandomise = settings.getBoolean("macrandomise", false), hostrandomise = settings.getBoolean("hostrandomise", false), spoofenabled = settings.getBoolean("spoofenabled", true);

macEntry.setText(settings.getString("macset", Util.getMAC()));
Expand All @@ -200,6 +230,8 @@ private void updateUX() {
macToggle.setEnabled(spoofenabled);
hostToggle.setEnabled(spoofenabled);

uninstallButton.setEnabled(Util.isInstalled());

if(spoofenabled) {
macToggle.setChecked(macrandomise);
macEntry.setEnabled(!macrandomise);
Expand Down
Loading

0 comments on commit 7e71811

Please sign in to comment.