11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/NetGhost.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Network Ghost
2 |
3 | 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)
4 |
5 | Change your mac address! Change your hostname! Fun for all the family! *
6 |
7 | \* May not actually be true.
8 |
9 | 
10 |
11 | ## What is it?
12 | An app that allows for randomising MAC addresses and hostnames on an android device. May not work with every android device around - try it out to see if it works!
13 |
14 | YOU NEED ROOT FOR THIS APP.
15 |
16 | ## Why?
17 | I got *really* fed up with miscellaneous forum posts which all say "run this busybox command" or "try this mystical app that works even though this one doesnt" and bizarre obscure errors that some people got and other ignored.
18 |
19 | Furthermore, MAC spoofing was *very* easy in the 4.0/4.1 era through a simple busybox command, but 4.2 onwards I kept getting a "WPA: 4-way handshake failed" error in logcat. Very mysterious.
20 |
21 | Pry-Fi worked in 4.4, but also would not let me *just* randomise my mac address when connecting to a network without the whole swapping out saved network lists. It also stopped working (for me at least) in 5.0.
22 |
23 | Finally, there seems to be a distinct lack of open source apps that let me change the MAC address. I hope this can change that.
24 |
25 | ## Where does it definitely work?
26 | * Samsung Galaxy S4 running Cyanogenmod 12.1
27 | * HTC One M7
28 | * HTC One M9
29 |
30 | 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.
31 |
32 | ## How do I get it?
33 | Install the apk file!
34 |
35 | ## How do I use it?
36 | Open up the app, flip the spoof switch. You will be asked to okay an update to /system files to allow this to work.
37 |
38 | 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:
39 | ```
40 | adb shell ip addr
41 | ```
42 | If you see something like:
43 | ```
44 | 4: wlan0: mtu 1500 qdisc pfifo_fast state DORMANT qlen 1000
45 | link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
46 | ```
47 | Where 00:11:22:33:44:55 is whatever is in the MAC address box in the app... Then you win! Now try and connect to a wifi network!
48 |
49 | If the toggle is set to user-set, the mac address you enter is set everytime the wifi turns on (NOTE: the wifi will turn on, off and back on again and this is normal).
50 |
51 | ## Can I change MAC addresses programatically? (e.g. from another app or from tasker?)
52 | Yes! Send an intent. Currently, you could send:
53 | * com.moosd.netghost.RANDOMISE_MAC - This forces a random MAC to be used right now.
54 | * com.moosd.netghost.SET_MAC_STATIC - This forces a given MAC to be used right now. The mac address should be supplied in an extra called "mac".
55 | * com.moosd.netghost.SET_MAC_ONESHOT - This forces a given MAC to be used right now, and don't remember it for next time. This means you can change the mac temporarily until the next time wifi is turned off and on again. The mac address should be supplied in an extra called "mac".
56 |
57 | To use this from tasker:
58 |
59 | 1. Open the task you want to add mac-changing magic to.
60 | 2. Add a new "Send Intent" action (search for send intent in the search box)
61 | 3. Set the "Action" to one of the intents mentioned above, e.g. com.moosd.netghost.SET_MAC_ONESHOT
62 | 4. Set the Extra field to "mac:00:11:22:33:44:55" (without the quotes and replace the 00:11:22:33:44:55 with the mac you want to change to)
63 | 5. Save it and run it to test if needed.
64 | 6. ???
65 | 7. Profit!
66 |
67 | ## How does this magic work if the busybox command doesn't work for wpa connections???
68 | Before 4.2, it was possible to change the mac address by entering in something like:
69 | ```
70 | busybox ifconfig wlan0 down
71 | busybox ifconfig wlan0 hw ether 00:11:22:33:44:55
72 | busybox ifconfig wlan0 up
73 | ```
74 | But afterwards, doing this will result in the mac address being changed in "ip addr". However, wpa_supplicant will continue to use the old mac address. (Test this using wpa_cli!) And simply killall wpa_supplicant messes up the wifi subsystem until you turn wifi off and on again (wpa_supplicant is used to authenticate with the wpa network!). And this resets the mac address!
75 |
76 | After much head-banging and frustration, I figured out that instead of
77 | ```
78 | busybox ifconfig wlan0 down
79 | ```
80 | It was necessary to turn it off the Android(TM) way, i.e.
81 | ```
82 | svc wifi disable
83 | ```
84 | 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).
85 |
86 | 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!
87 |
88 | 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.
89 |
90 | I have kept the commands running in a root shell to a minimum, since the wifi start/stop can be achieved in java.
91 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.moosd.netghost"
9 | minSdkVersion 17
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | }
25 |
--------------------------------------------------------------------------------
/app/libs/RootShell.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/app/libs/RootShell.jar
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/souradip/.android-sdks/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/com/moosd/netghost/ChangeReceiver.java:
--------------------------------------------------------------------------------
1 | package com.moosd.netghost;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 |
8 | public class ChangeReceiver extends BroadcastReceiver {
9 | public ChangeReceiver() {
10 | }
11 |
12 | @Override
13 | public void onReceive(Context context, Intent intent) {
14 | SharedPreferences settings = context.getSharedPreferences(
15 | "settings", 0);
16 | if (intent.getAction().equals("com.moosd.netghost.RANDOMISE_MAC")) {
17 | if (settings.getBoolean("spoofenabled", false)) {
18 | String rmac = Util.randomMAC();
19 | settings.edit().putString("macset", rmac).commit();
20 | WifiReceiver.state = 1;
21 | Util.setMAC(rmac, context);
22 | }
23 | } else if (intent.getAction().equals("com.moosd.netghost.SET_MAC_STATIC")) {
24 | if (settings.getBoolean("spoofenabled", false)) {
25 | String rmac = intent.getStringExtra("mac");
26 | settings.edit().putString("macset", rmac).commit();
27 | System.out.println("MAC static: "+rmac);
28 | WifiReceiver.state = 1;
29 | Util.setMAC(rmac, context);
30 | }
31 | } else if (intent.getAction().equals("com.moosd.netghost.SET_MAC_ONESHOT")) {
32 | if (settings.getBoolean("spoofenabled", false)) {
33 | String rmac = intent.getStringExtra("mac");
34 | System.out.println("MAC oneshot: "+rmac);
35 | WifiReceiver.state = 1;
36 | Util.setMAC(rmac, context);
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moosd/netghost/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.moosd.netghost;
2 |
3 | import android.app.Activity;
4 | import android.app.AlertDialog;
5 | import android.content.DialogInterface;
6 | import android.content.SharedPreferences;
7 | import android.os.Bundle;
8 | import android.text.Editable;
9 | import android.text.InputType;
10 | import android.text.TextWatcher;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 | import android.view.View;
14 | import android.widget.Button;
15 | import android.widget.CompoundButton;
16 | import android.widget.EditText;
17 | import android.widget.Switch;
18 | import android.widget.ToggleButton;
19 |
20 | public class MainActivity extends Activity {
21 |
22 | EditText macEntry = null, hostEntry = null;
23 | ToggleButton macToggle = null, hostToggle = null;
24 | Button updateButton = null, revertButton = null, uninstallButton = null;
25 | SharedPreferences settings = null;
26 | Switch spoofSwitch = null;
27 | public static MainActivity me = null;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_main);
33 | me = this;
34 |
35 | settings = getSharedPreferences("settings", 0);
36 |
37 | hostEntry = ((EditText) findViewById(R.id.editText2));
38 | hostToggle = ((ToggleButton) findViewById(R.id.toggleButton2));
39 |
40 | macEntry = ((EditText) findViewById(R.id.editText));
41 | macToggle = ((ToggleButton) findViewById(R.id.toggleButton));
42 |
43 | updateButton = ((Button) findViewById(R.id.button3));
44 | revertButton = ((Button) findViewById(R.id.button));
45 | uninstallButton = ((Button) findViewById(R.id.button4));
46 |
47 | spoofSwitch = ((Switch) findViewById(R.id.switch1));
48 |
49 | spoofSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
50 | @Override
51 | public void onCheckedChanged(CompoundButton buttonView,
52 | boolean isChecked) {
53 | // update settings
54 | if(!Util.isInstalled() && isChecked) {
55 | Util.askToInstall(MainActivity.this, true);
56 | }
57 | if(Util.isInstalled()) {
58 | settings.edit().putBoolean("spoofenabled", isChecked).commit();
59 | }
60 | // update ux
61 | updateUX();
62 | }
63 | });
64 |
65 | macEntry.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
66 | macEntry.setSingleLine();
67 |
68 | macEntry.addTextChangedListener(new TextWatcher() {
69 | String mPreviousMac = null;
70 |
71 | @Override
72 | public void afterTextChanged(Editable arg0) {
73 | }
74 |
75 | @Override
76 | public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
77 | }
78 |
79 | @Override
80 | public void onTextChanged(CharSequence s, int start, int before, int count) {
81 | String enteredMac = macEntry.getText().toString().toUpperCase();
82 | String cleanMac = clearNonMacCharacters(enteredMac);
83 | String formattedMac = formatMacAddress(cleanMac);
84 |
85 | int selectionStart = macEntry.getSelectionStart();
86 | formattedMac = handleColonDeletion(enteredMac, formattedMac, selectionStart);
87 | int lengthDiff = formattedMac.length() - enteredMac.length();
88 |
89 | setMacEdit(cleanMac, formattedMac, selectionStart, lengthDiff);
90 | }
91 |
92 | private String clearNonMacCharacters(String mac) {
93 | return mac.toString().replaceAll("[^A-Fa-f0-9]", "");
94 | }
95 |
96 | private String formatMacAddress(String cleanMac) {
97 | int grouppedCharacters = 0;
98 | String formattedMac = "";
99 |
100 | for (int i = 0; i < cleanMac.length(); ++i) {
101 | formattedMac += cleanMac.charAt(i);
102 | ++grouppedCharacters;
103 |
104 | if (grouppedCharacters == 2) {
105 | formattedMac += ":";
106 | grouppedCharacters = 0;
107 | }
108 | }
109 |
110 | if (cleanMac.length() == 12)
111 | formattedMac = formattedMac.substring(0, formattedMac.length() - 1);
112 |
113 | return formattedMac;
114 | }
115 |
116 | private String handleColonDeletion(String enteredMac, String formattedMac, int selectionStart) {
117 | if (mPreviousMac != null && mPreviousMac.length() > 1) {
118 | int previousColonCount = colonCount(mPreviousMac);
119 | int currentColonCount = colonCount(enteredMac);
120 |
121 | if (currentColonCount < previousColonCount) {
122 | formattedMac = formattedMac.substring(0, selectionStart - 1) + formattedMac.substring(selectionStart);
123 | String cleanMac = clearNonMacCharacters(formattedMac);
124 | formattedMac = formatMacAddress(cleanMac);
125 | }
126 | }
127 | return formattedMac;
128 | }
129 |
130 | private int colonCount(String formattedMac) {
131 | return formattedMac.replaceAll("[^:]", "").length();
132 | }
133 |
134 | private void setMacEdit(String cleanMac, String formattedMac, int selectionStart, int lengthDiff) {
135 | macEntry.removeTextChangedListener(this);
136 | if (cleanMac.length() <= 12) {
137 | macEntry.setText(formattedMac);
138 | macEntry.setSelection(selectionStart + lengthDiff);
139 | mPreviousMac = formattedMac;
140 | } else {
141 | macEntry.setText(mPreviousMac);
142 | macEntry.setSelection(mPreviousMac.length());
143 | }
144 | macEntry.addTextChangedListener(this);
145 | }
146 | });
147 |
148 | macToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
149 | @Override
150 | public void onCheckedChanged(CompoundButton buttonView,
151 | boolean isChecked) {
152 | if(isChecked) {
153 | settings.edit().putString("macset", Util.randomMAC()).commit();
154 | }
155 | // update settings
156 | settings.edit().putBoolean("macrandomise", isChecked).commit();
157 | //update ux
158 | updateUX();
159 | }
160 | });
161 | hostToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
162 | @Override
163 | public void onCheckedChanged(CompoundButton buttonView,
164 | boolean isChecked) {
165 | if(isChecked) {
166 | settings.edit().putString("hostset", Util.randomHostname()).commit();
167 | }
168 | // update settings
169 | settings.edit().putBoolean("hostrandomise", isChecked).commit();
170 | // update ux
171 | updateUX();
172 | }
173 | });
174 |
175 | updateButton.setOnClickListener(new View.OnClickListener() {
176 | @Override
177 | public void onClick(View v) {
178 | boolean macrandomise = settings.getBoolean("macrandomise", false), hostrandomise = settings.getBoolean("hostrandomise", false);
179 | if(macrandomise) {
180 | settings.edit().putString("macset", Util.randomMAC()).commit();
181 | } else {
182 | settings.edit().putString("macset", macEntry.getText().toString()).commit();
183 | }
184 | if(hostrandomise) {
185 | settings.edit().putString("hostset", Util.randomHostname()).commit();
186 | } else {
187 | settings.edit().putString("hostset", hostEntry.getText().toString()).commit();
188 | }
189 | updateUX();
190 | Util.setHost(hostEntry.getText().toString());
191 | Util.setMAC(macEntry.getText().toString(), MainActivity.this);
192 | }
193 | });
194 |
195 | uninstallButton.setOnClickListener(new View.OnClickListener() {
196 | @Override
197 | public void onClick(View v) {
198 | new AlertDialog.Builder(MainActivity.this)
199 | .setTitle("Unnstall")
200 | .setMessage("Are you sure you want to uninstall the changes to /system? You will not be able to modify your mac address.")
201 | .setNegativeButton("No", null)
202 | .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
203 | @Override
204 | public void onClick(DialogInterface dialog, int which) {
205 | settings.edit().putBoolean("spoofenabled", false).commit();
206 | Util.uninstall(MainActivity.this);
207 | updateUX();
208 | }
209 | })
210 | .create()
211 | .show();
212 | }
213 | });
214 |
215 | }
216 |
217 | @Override
218 | protected void onResume() {
219 | super.onResume();
220 | updateUX();
221 | }
222 |
223 | public void updateUX() {
224 | boolean macrandomise = settings.getBoolean("macrandomise", false), hostrandomise = settings.getBoolean("hostrandomise", false), spoofenabled = settings.getBoolean("spoofenabled", true);
225 |
226 | macEntry.setText(settings.getString("macset", Util.getMAC()));
227 | hostEntry.setText(settings.getString("hostset", Util.getHost()));
228 | spoofSwitch.setChecked(spoofenabled);
229 |
230 | macToggle.setEnabled(spoofenabled);
231 | hostToggle.setEnabled(spoofenabled);
232 |
233 | uninstallButton.setEnabled(Util.isInstalled());
234 |
235 | if(spoofenabled) {
236 | macToggle.setChecked(macrandomise);
237 | macEntry.setEnabled(!macrandomise);
238 |
239 | hostToggle.setChecked(hostrandomise);
240 | hostEntry.setEnabled(!hostrandomise);
241 |
242 | updateButton.setEnabled(true);
243 | revertButton.setEnabled(true);
244 | } else {
245 | macToggle.setChecked(false);
246 | macEntry.setEnabled(false);
247 |
248 | hostToggle.setChecked(false);
249 | hostEntry.setEnabled(false);
250 |
251 | updateButton.setEnabled(false);
252 | revertButton.setEnabled(false);
253 | }
254 | }
255 |
256 | @Override
257 | public boolean onCreateOptionsMenu(Menu menu) {
258 | // Inflate the menu; this adds items to the action bar if it is present.
259 | getMenuInflater().inflate(R.menu.menu_main, menu);
260 | return true;
261 | }
262 |
263 | @Override
264 | public boolean onOptionsItemSelected(MenuItem item) {
265 | // Handle action bar item clicks here. The action bar will
266 | // automatically handle clicks on the Home/Up button, so long
267 | // as you specify a parent activity in AndroidManifest.xml.
268 | int id = item.getItemId();
269 |
270 | //noinspection SimplifiableIfStatement
271 | if (id == R.id.action_settings) {
272 | return true;
273 | }
274 |
275 | return super.onOptionsItemSelected(item);
276 | }
277 | }
278 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moosd/netghost/Util.java:
--------------------------------------------------------------------------------
1 | package com.moosd.netghost;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.ProgressDialog;
5 | import android.content.Context;
6 | import android.content.DialogInterface;
7 | import android.net.wifi.WifiManager;
8 |
9 | import android.provider.ContactsContract;
10 | import com.stericson.RootTools.RootTools;
11 | import com.stericson.RootTools.exceptions.RootDeniedException;
12 | import com.stericson.RootTools.execution.Command;
13 | import com.stericson.RootTools.execution.CommandCapture;
14 |
15 | import java.io.FileInputStream;
16 | import java.io.IOException;
17 | import java.io.InputStream;
18 | import java.util.Random;
19 | import java.util.concurrent.TimeoutException;
20 |
21 | /**
22 | * Created by souradip on 23/06/15.
23 | */
24 | public class Util {
25 |
26 | public static void askToInstall(final Context ctx, final boolean update) {
27 | new AlertDialog.Builder(ctx)
28 | .setTitle("Install")
29 | .setMessage("To set this up I need to modify your system partition. This might brick your device (but shouldnt). You cool with that?")
30 | .setNegativeButton(android.R.string.cancel, null)
31 | .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
32 | @Override
33 | public void onClick(DialogInterface dialog, int which) {
34 | performInstall(ctx);
35 | if (update) {
36 | if (Util.isInstalled()) {
37 | MainActivity.me.settings.edit().putBoolean("spoofenabled", true).commit();
38 | }
39 | MainActivity.me.updateUX();
40 | }
41 | }
42 | })
43 | .create()
44 | .show();
45 | }
46 |
47 | public static void askToInstall(final Context ctx) {
48 | askToInstall(ctx, false);
49 | }
50 |
51 | public static void uninstall(Context ctx) {
52 | // show loading menu
53 | ProgressDialog dialog = ProgressDialog.show(ctx, "Uninstalling",
54 | "Remounting system...", true);
55 | dialog.show();
56 | // remount system
57 | final String[] result = {""};
58 | Command command = new Command(0, "mount -o rw,remount /system") {
59 | @Override
60 | public void output(int id, String line) {
61 | }
62 | };
63 | runCmd(command);
64 |
65 | // check if success
66 | command = new Command(0, "mount|grep system") {
67 | @Override
68 | public void output(int id, String line) {
69 | if(line.contains("rw")) result[0] = "yes";
70 | }
71 | };
72 | runCmd(command);
73 | if(!result[0].equals("yes")) {
74 | dialog.hide();
75 | new AlertDialog.Builder(ctx).setTitle("Error").setMessage("Error remounting system. Sorry! Nothing was touched.").setPositiveButton("OK", null).create().show();
76 | return;
77 | }
78 | result[0] = "";
79 |
80 | dialog.setMessage("Moving wpa_supplicant back");
81 | // move wpa_supplicant
82 | command = new Command(0, "mv /system/bin/wpa_supplicant_real /system/bin/wpa_supplicant") {
83 | @Override
84 | public void output(int id, String line) {
85 | }
86 | };
87 | runCmd(command);
88 |
89 | // check if success
90 | command = new Command(0, "ls /system/bin/wpa_*") {
91 | @Override
92 | public void output(int id, String line) {
93 | if(line.contains("_real")) result[0] = "yes";
94 | }
95 | };
96 | runCmd(command);
97 | if(result[0].equals("yes")) {
98 | dialog.hide();
99 | new AlertDialog.Builder(ctx).setTitle("Error").setMessage("Error moving wpa_supplicant back. Sorry! Failed.").setPositiveButton("OK", null).create().show();
100 | return;
101 | }
102 | result[0] = "";
103 |
104 | dialog.hide();
105 | new AlertDialog.Builder(ctx).setTitle("Success").setMessage("Uninstalled code successfully").setPositiveButton("OK", null).create().show();
106 | }
107 |
108 | public static void performInstall(Context ctx) {
109 | // show loading menu
110 | ProgressDialog dialog = ProgressDialog.show(ctx, "Installing",
111 | "Remounting system...", true);
112 | dialog.show();
113 | // remount system
114 | final String[] result = {""};
115 | Command command = new Command(0, "mount -o rw,remount /system") {
116 | @Override
117 | public void output(int id, String line) {
118 | }
119 | };
120 | runCmd(command);
121 |
122 | // check if success
123 | command = new Command(0, "mount|grep system") {
124 | @Override
125 | public void output(int id, String line) {
126 | if(line.contains("rw")) result[0] = "yes";
127 | }
128 | };
129 | runCmd(command);
130 | if(!result[0].equals("yes")) {
131 | dialog.hide();
132 | new AlertDialog.Builder(ctx).setTitle("Error").setMessage("Error remounting system. Sorry! Nothing was touched.").setPositiveButton("OK", null).create().show();
133 | return;
134 | }
135 | result[0] = "";
136 |
137 | dialog.setMessage("Moving wpa_supplicant");
138 | // move wpa_supplicant
139 | command = new Command(0, "mv /system/bin/wpa_supplicant /system/bin/wpa_supplicant_real") {
140 | @Override
141 | public void output(int id, String line) {
142 | }
143 | };
144 | runCmd(command);
145 |
146 | // check if success
147 | command = new Command(0, "ls /system/bin/wpa_*") {
148 | @Override
149 | public void output(int id, String line) {
150 | if(line.contains("_real")) result[0] = "yes";
151 | }
152 | };
153 | runCmd(command);
154 | if(!result[0].equals("yes")) {
155 | dialog.hide();
156 | new AlertDialog.Builder(ctx).setTitle("Error").setMessage("Error moving wpa_supplicant. Sorry! Nothing was touched.").setPositiveButton("OK", null).create().show();
157 | return;
158 | }
159 | result[0] = "";
160 |
161 | // inject our script
162 | dialog.setMessage("Injecting our mac changing code");
163 |
164 | command = new Command(0, "echo '#!/system/xbin/bash|/system/xbin/busybox ifconfig wlan0 up hw ether $(cat /dev/mac)|/system/bin/wpa_supplicant_real $@' | sed 's/|/\\n/g' > /system/bin/wpa_supplicant", "busybox chmod +x /system/bin/wpa_supplicant") {
165 | @Override
166 | public void output(int id, String line) {
167 | }
168 | };
169 | runCmd(command);
170 | // check if success
171 |
172 | if(isInstalled()) {
173 | dialog.hide();
174 | new AlertDialog.Builder(ctx).setTitle("Success").setMessage("Installed code successfully").setPositiveButton("OK", null).create().show();
175 | } else {
176 | //dialog.hide();
177 | //new AlertDialog.Builder(ctx).setTitle("Error").setMessage("Error inserting our wpa_supplicant. Will try to revert now.").setPositiveButton("OK", null).create().show();
178 | dialog.setMessage("Error inserting out wpa_supplicant. Trying to revert...");
179 | command = new Command(0, "mv /system/bin/wpa_supplicant_real /system/bin/wpa_supplicant") {
180 | @Override
181 | public void output(int id, String line) {
182 | }
183 | };
184 | runCmd(command);
185 | command = new Command(0, "ls /system/bin/wpa_*") {
186 | @Override
187 | public void output(int id, String line) {
188 | if(line.contains("_real")) result[0] = "yes";
189 | }
190 | };
191 | runCmd(command);
192 | if(result[0].equals("yes")) {
193 | new AlertDialog.Builder(ctx).setTitle("Error").setMessage("Error reverting wpa_supplicant! System in inconsistent state.").setPositiveButton("OK", null).create().show();
194 | } else {
195 | new AlertDialog.Builder(ctx).setTitle("Error").setMessage("Reverted successfully.").setPositiveButton("OK", null).create().show();
196 | }
197 | dialog.hide();
198 | }
199 | }
200 |
201 | public static boolean isInstalled() {
202 | try {
203 | byte[] buffer = new byte[4];
204 | InputStream is = new FileInputStream("/system/bin/wpa_supplicant");
205 | if (is.read(buffer) != buffer.length) {
206 | }
207 | is.close();
208 | if (new String(buffer).equals("#!/s"))
209 | return true;
210 | else return false;
211 | } catch (Exception e) {
212 | e.printStackTrace();
213 | return false;
214 | }
215 | }
216 |
217 | public static void runCmd(Command command) {
218 | boolean finished = false;
219 | try {
220 | Command com = RootTools.getShell(true).add(command);
221 | while (!finished) {
222 | try {
223 | com.waitForFinish(100);
224 | finished = true;
225 | } catch (InterruptedException e) {
226 | }
227 | }
228 | } catch (IOException e) {
229 | e.printStackTrace();
230 | } catch (RootDeniedException e) {
231 | e.printStackTrace();
232 | } catch (TimeoutException e) {
233 | e.printStackTrace();
234 | }
235 | }
236 |
237 | public static String randomMAC() {
238 | Random r = new Random();
239 | StringBuffer sb = new StringBuffer("e8:99:c4:");
240 | while (sb.length() < 17) {
241 | sb.append(Integer.toHexString(r.nextInt()).substring(0, 1));
242 | sb.append(Integer.toHexString(r.nextInt()).substring(0, 1));
243 | sb.append(":");
244 | }
245 |
246 | return sb.toString().substring(0, 17);
247 | }
248 |
249 | public static String randomHostname() {
250 | Random r = new Random();
251 | StringBuffer sb = new StringBuffer();
252 | while (sb.length() < 16) {
253 | sb.append(Integer.toHexString(r.nextInt()).substring(0, 1));
254 | }
255 |
256 | return "android-" + sb.toString().substring(0, 16);
257 | }
258 |
259 | public static void setMAC(String rmac, Context context) {
260 | if (!isInstalled()) {
261 | askToInstall(context);
262 | return;
263 | }
264 | runCmd(new CommandCapture(0, "setenforce 0"));
265 | try {
266 | Thread.sleep(200);
267 | } catch (Exception e) {
268 | }
269 |
270 | WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
271 | wifi.setWifiEnabled(false);
272 | try {
273 | Thread.sleep(1000);
274 | } catch (Exception e) {
275 | }
276 |
277 | System.out.println("setting MAC: " + rmac);
278 | //runCmd(new CommandCapture(0, "busybox ifconfig wlan0 hw ether " + rmac));
279 | runCmd(new CommandCapture(0, "echo \"" + rmac + "\" > /dev/mac"));
280 | try {
281 | Thread.sleep(200);
282 | } catch (Exception e) {
283 | }
284 |
285 | wifi.setWifiEnabled(true);
286 | }
287 |
288 | public static void setHost(String host) {
289 | runCmd(new CommandCapture(0, "setprop net.hostname " + host));
290 | }
291 |
292 | public static String getMAC() {
293 | final String[] result = {"deadbebe"};
294 | Command command = new Command(0, "busybox ip addr show dev wlan0") {
295 | @Override
296 | public void output(int id, String line) {
297 | if (line.contains("link/ether")) {
298 | String[] split = line.trim().split(" ");
299 | System.out.println("MAC - " + split[1]);
300 | result[0] = split[1];
301 | }
302 | }
303 | };
304 | runCmd(command);
305 | return result[0];
306 | }
307 |
308 | public static String getHost() {
309 | final String[] result = {"deadbebe"};
310 | Command command = new Command(0, "getprop net.hostname") {
311 | @Override
312 | public void output(int id, String line) {
313 | result[0] = line;
314 | }
315 | };
316 | runCmd(command);
317 | return result[0];
318 | }
319 | }
320 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moosd/netghost/WifiReceiver.java:
--------------------------------------------------------------------------------
1 | package com.moosd.netghost;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.net.NetworkInfo;
8 | import android.net.wifi.WifiManager;
9 |
10 | public class WifiReceiver extends BroadcastReceiver {
11 | private final String TAG = "WifiReceiver";
12 | public static int state = 0;
13 |
14 | @Override
15 | public void onReceive(Context context, Intent intent) {
16 | int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
17 | WifiManager.WIFI_STATE_UNKNOWN);
18 | String wifiStateText = "No State";
19 |
20 | String action = intent.getAction();
21 |
22 | if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
23 | WifiManager manager = (WifiManager) context
24 | .getSystemService(Context.WIFI_SERVICE);
25 | NetworkInfo networkInfo = intent
26 | .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
27 | NetworkInfo.State state = networkInfo.getState();
28 |
29 | if (state == NetworkInfo.State.DISCONNECTED) {
30 | if (manager.isWifiEnabled()) {
31 |
32 | doUpdate(context);
33 | wifiStateText = "WIFI_STATE_DISCONNECTED";
34 | }
35 | }
36 | }
37 |
38 | switch (wifiState) {
39 | case WifiManager.WIFI_STATE_DISABLING:
40 | wifiStateText = "WIFI_STATE_DISABLING";
41 | break;
42 | case WifiManager.WIFI_STATE_DISABLED:
43 | wifiStateText = "WIFI_STATE_DISABLED";
44 | break;
45 | case WifiManager.WIFI_STATE_ENABLING:
46 | wifiStateText = "WIFI_STATE_ENABLING";
47 |
48 | break;
49 | case WifiManager.WIFI_STATE_ENABLED:
50 | wifiStateText = "WIFI_STATE_ENABLED";
51 | if (state == 1) state--;
52 | else
53 | doUpdate(context);
54 | break;
55 | case WifiManager.WIFI_STATE_UNKNOWN:
56 | wifiStateText = "WIFI_STATE_UNKNOWN";
57 | break;
58 | default:
59 | break;
60 | }
61 |
62 | System.out.println("WIFI_recv: " + wifiStateText);
63 | }
64 |
65 | public void doUpdate(Context context) {
66 | SharedPreferences settings = context.getSharedPreferences(
67 | "settings", 0);
68 | if (settings.getBoolean("spoofenabled", false)) {
69 | String nhost = "";
70 | if (settings.getBoolean("hostrandomise", false)) {
71 | nhost = Util.randomHostname();
72 | settings.edit().putString("hostset", nhost).commit();
73 | } else {
74 | nhost = settings.getString("hostset", "");
75 | }
76 | Util.setHost(nhost);
77 |
78 | String rmac = "";
79 | if (settings.getBoolean("macrandomise", false)) {
80 | rmac = Util.randomMAC();
81 | settings.edit().putString("macset", rmac).commit();
82 | } else {
83 | rmac = settings.getString("macset", Util.randomMAC());
84 | }
85 | state = 1;
86 | Util.setMAC(rmac, context);
87 | }
88 | }
89 |
90 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
20 |
21 |
27 |
28 |
29 |
30 |
34 |
35 |
40 |
41 |
48 |
49 |
50 |
51 |
52 |
57 |
58 |
64 |
65 |
66 |
67 |
71 |
72 |
77 |
78 |
85 |
86 |
87 |
88 |
94 |
95 |
96 |
101 |
102 |
107 |
108 |
109 |
110 |
111 |
114 |
115 |
116 |
122 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Network Ghost
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.2.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jun 23 00:27:11 BST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/screenshots/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/souramoo/NetworkGhost/4fa44d9fb02dac8da1f0f5e0fbf6ef673b2fa945/screenshots/screenshot.png
--------------------------------------------------------------------------------
/scripts/wpa_supplicant:
--------------------------------------------------------------------------------
1 | #!/system/xbin/bash
2 |
3 | /system/xbin/busybox ifconfig wlan0 up hw ether $(cat /dev/mac)
4 | /system/bin/wpa_supplicant_real $@
5 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------