[EXPERIMENTAL] [PHP SCRIPT] WIFI-MAC Spoofer v1.1 - Optimus One, P500, V General

Hi.
I wasn't too sure, if I should post this into the development area, I think it fits more into general.
Introduction
According to this thread, I tried to write a little script which lets one spoof his wi-fi MAC address unindependently from any adb shell or usb connection. It's very experimental and might not work that properly. If I try it at home, my router somehow shuts down any incoming wi-fi connection in the whole network and turns the internet off. :/ But the script itself actually SEEMS to change the MAC address (according to what the wi-fi settings say).
I am not responsible for any damage to your phone. However, you can reset the changed MAC address anyway, if something bad happens.
Please note, that you are only allowed to use this script in those networks where you have the permission to do so. Especially the use of the "MAC takeover" function might be illegal in different networks.
Requirements
You will need SL4A (Android Scripting Environment) and PFA (PHP for Android). Check out: http://www.phpforandroid.net/#requirements
The script
PHP:
<?php
// config: config-file and tmp-file
$cnf = "/etc/wl/nvram.txt";
$tmp = "/sdcard/nvram-tmp.txt";
// this is my very dirty solution to replace the actual config file with a new edited one. root needed. might not work everywhere.
$cmd = 'su -c "mount -o rw,remount -t yaffs2 /dev/block/mtdblock4 /system; mv -f \"'.$tmp.'\" \"'.$cnf.'\"; chmod 644 \"'.$cnf.'\"; mount -o ro,remount -t yaffs2 /dev/block/mtdblock4 /system"';
// access android api
require_once("Android.php");
$droid = new Android();
// get config file src
$src = file_get_contents($cnf);
// check, if mac address was already spoofed before
preg_match("|macaddr=([a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2})|i", $src, $res);
$spoofed = false;
$macaddr = "13:57:9B:DF:13:37";
if(isset($res[1]))
{
$spoofed = true;
$macaddr = $res[1];
}
// pre-configurations
$title = "LG-OO-P500 MAC Spoofer";
$action = "start";
// main loop for actions
while(true)
{
switch($action)
{
// start
case "start":
$msg = "Your MAC address is currently set on default.";
// currently spoofed mac address?
if($spoofed)
{
$msg = "Your currently spoofed MAC address is: ".$macaddr;
}
$droid->makeToast($msg);
// create dialog
$droid->dialogCreateAlert($title);
$droid->dialogSetItems(array("Change MAC address", "MAC takeover", "Reset MAC address", "Exit"));
$droid->dialogShow();
// determine next action
$res = $droid->dialogGetResponse();
$actions = array("spoof", "scan", "reset", "exit");
$action = $actions[$res["result"]->item];
$droid->dialogDismiss();
break;
// spoof and reset action
case "spoof": case "scan": case "reset":
// get user input for new mac addr
switch($action)
{
case "spoof":
while(true)
{
$res = $droid->dialogGetInput($title, "Insert new MAC address", $macaddr);
$macaddr = strtoupper($res["result"]);
if(preg_match("|[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}|i", $macaddr))
{
break;
}
$droid->makeToast("Invalid MAC address. (example: 00:00:00:00:00:00 to FF:FF:FF:FF:FF:FF)");
}
$rpl = "macaddr=".$macaddr;
break;
case "scan":
$droid->dialogCreateSpinnerProgress("Now scanning network...");
// scan for MACs and filter ip and MAC addresses from the output
exec("arp -a", $out);
preg_match_all("|\(([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\) at ([a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2})|i", strtoupper(implode("\r\n", $out)), $res);
$droid->dialogDismiss();
// create new array
$arr = array();
for($i = 0; $i != count($res[1]); $i++)
{
$arr["list"][] = $res[1][$i]."\n=> ".$res[2][$i];
$arr["ip"][] = $res[1][$i];
$arr["mac"][] = $res[2][$i];
}
$droid->dialogCreateAlert("Found ".count($arr)." individuals... please choose:");
$droid->dialogSetItems($arr["list"]);
$droid->dialogShow();
$res = $droid->dialogGetResponse();
$rpl = "macaddr=".$arr["mac"][$res["result"]->item];
break;
case "reset": default:
$rpl = null;
break;
}
// edit src
($spoofed || empty($rpl)) ? $src = rtrim(preg_replace("|macaddr=.*|i", $rpl, $src)) : $src = rtrim($src)."\n".$rpl;
// disable wifi
$droid->toggleWifiState(false);
// save tmp file
$h = fopen($tmp, "w");
fwrite($h, $src);
fclose($h);
// overwrite with root privileges
exec($cmd);
$droid->makeToast("Operation complete.");
$action = "exit";
break;
// exit
case "exit":
// enable wlan and exit
$droid->toggleWifiState(true);
$droid->exit();
exit();
break;
}
}
I am really not sure, if it is going to work for you. I tested it under devoid #forever (CM7, 2.3.4). Maybe other ROMs and other smartphones are going to behave different. And to be honest, for me it didn't work that good either until now.
If you are having trouble, you can also try to reboot after spoofing.
Have fun trying.

Is this all this about adding macaddr in nvram.txt as we had this discussion earlier.
Nice work.
Sent from my LG-P500 using XDA Premium App

I added another very experimental function which I named "MAC takeover". It allows the user to scan the network for all connected MAC addresses and afterwards display and finally spoof one of those addresses.
The whole script might be buggy, so tell me if something doesn't work properly.
Please note, that you are only allowed to use this script in those networks where you have the permission to do so. Especially the use of the "MAC takeover" function might be illegal in different networks.
See the changes above in the source code.
Is this all this about adding macaddr in nvram.txt as we had this discussion earlier.
Click to expand...
Click to collapse
Yup, but it makes things a lot easier, because you just need your phone to change the MAC address. Additionally it has something like an interface.

I have a bash script somewhere doing the same (except for takeover... nasty boy ). Will post it when I find it. Should be a hell lot easier to use (just bash, no weird stuff needed.)

This is actually quite easy as well, you just need PHP installed on android. However, I'm also very interested in that bash script, please share!

Related

Modify apk to add a file in a specified path

Hello all. I need some information on how i can modify an existing apk and add a file to a specified path during installation.
Better...i need that installation creates a file in data/data/com.myprogram.android/myfile where com.myprogram.android is the path of program data. Is that possible???
thx
*bump* - after one year, this is exactly what i also need!
any answer to this? since i modify an existing .apk, changing the java-code is not an option. solution must be pure .apk based / via the manifest
you could do it in a few steps
1) copy the apk to somewhere safe (/mnt/sdcard)
2) uninstall the apk, maybe use PackageManager
3) unzip the apk to a folder, add your changed/new files, zip up the folder again (extension .apk). Use busybox's zip/unzip if you need
4)sign the new apk using this (i tried it it works)
5)install the new+signed apk, maybe use PackageManager
fl3xo said:
Hello all. I need some information on how i can modify an existing apk and add a file to a specified path during installation.
Better...i need that installation creates a file in data/data/com.myprogram.android/myfile where com.myprogram.android is the path of program data. Is that possible???
thx
Click to expand...
Click to collapse
The way I've done this in the past is just store whatever it is you want to add in the res/raw directory of the project, then when the program first runs, copy the raw resource wherever you want it in the tree.
Code:
// Copy the helper app from resources to an executable in our classpath
protected void CopyExtraBin() {
// check if it's already there
File helper = new File("/data/data/com.mypath.myprog/helper_app");
if (helper.exists()) {
// already there, nothing to do.
return;
}
InputStream setdbStream = getResources().openRawResource(R.raw.helper_app);
try {
byte[] bytes = new byte[setdbStream.available()];
DataInputStream dis = new DataInputStream(setdbStream);
dis.readFully(bytes);
FileOutputStream setdbOutStream = new FileOutputStream(
"/data/data/com.mypath.myprog/helper_app");
setdbOutStream.write(bytes);
setdbOutStream.close();
// set executable permissions on our helper
Process process = Runtime.getRuntime().exec("sh");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("chmod 755 /data/data/com.mypath.myprog/helper_app\n");
os.writeBytes("exit\n");
os.flush();
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
return;
}
}
Gene Poole said:
The way I've done this in the past is just store whatever it is you want to add in the res/raw directory of the project, then when the program first runs, copy the raw resource wherever you want it in the tree.
Code:
// Copy the helper app from resources to an executable in our classpath
protected void CopyExtraBin() {
// check if it's already there
File helper = new File("/data/data/com.mypath.myprog/helper_app");
if (helper.exists()) {
// already there, nothing to do.
return;
}
InputStream setdbStream = getResources().openRawResource(R.raw.helper_app);
try {
byte[] bytes = new byte[setdbStream.available()];
DataInputStream dis = new DataInputStream(setdbStream);
dis.readFully(bytes);
FileOutputStream setdbOutStream = new FileOutputStream(
"/data/data/com.mypath.myprog/helper_app");
setdbOutStream.write(bytes);
setdbOutStream.close();
// set executable permissions on our helper
Process process = Runtime.getRuntime().exec("sh");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("chmod 755 /data/data/com.mypath.myprog/helper_app\n");
os.writeBytes("exit\n");
os.flush();
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
return;
}
}
Click to expand...
Click to collapse
where to insert it?
Moved to Q&A.
mishanet said:
Gene Poole said:
The way I've done this in the past is just store whatever it is you want to add in the res/raw directory of the project, then when the program first runs, copy the raw resource wherever you want it in the tree.
Code:
// Copy the helper app from resources to an executable in our classpath
protected void CopyExtraBin() {
// check if it's already there
File helper = new File("/data/data/com.mypath.myprog/helper_app");
if (helper.exists()) {
// already there, nothing to do.
return;
}
InputStream setdbStream = getResources().openRawResource(R.raw.helper_app);
try {
byte[] bytes = new byte[setdbStream.available()];
DataInputStream dis = new DataInputStream(setdbStream);
dis.readFully(bytes);
FileOutputStream setdbOutStream = new FileOutputStream(
"/data/data/com.mypath.myprog/helper_app");
setdbOutStream.write(bytes);
setdbOutStream.close();
// set executable permissions on our helper
Process process = Runtime.getRuntime().exec("sh");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("chmod 755 /data/data/com.mypath.myprog/helper_app\n");
os.writeBytes("exit\n");
os.flush();
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
return;
}
}
Click to expand...
Click to collapse
where to insert it?
Click to expand...
Click to collapse
Yeah I have the same question. I'm wanting to add some files to /data/data/<appdirectory>/lib but since it's permissions are set to drwxr-xr-x system system I can't write to it without changing apk itself.
I tried putting this into some code and I just alot of cannot find symbol errors and DataInputStream and Toast. I'm sure It's just my limited knowledge and maybe changes in android but this example code doesn't seem to work for me.
Gene Poole said:
The way I've done this in the past is just store whatever it is you want to add in the res/raw directory of the project, then when the program first runs, copy the raw resource wherever you want it in the tree.
Code:
// Copy the helper app from resources to an executable in our classpath
protected void CopyExtraBin() {
// check if it's already there
File helper = new File("/data/data/com.mypath.myprog/helper_app");
if (helper.exists()) {
// already there, nothing to do.
return;
}
InputStream setdbStream = getResources().openRawResource(R.raw.helper_app);
try {
byte[] bytes = new byte[setdbStream.available()];
DataInputStream dis = new DataInputStream(setdbStream);
dis.readFully(bytes);
FileOutputStream setdbOutStream = new FileOutputStream(
"/data/data/com.mypath.myprog/helper_app");
setdbOutStream.write(bytes);
setdbOutStream.close();
// set executable permissions on our helper
Process process = Runtime.getRuntime().exec("sh");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("chmod 755 /data/data/com.mypath.myprog/helper_app\n");
os.writeBytes("exit\n");
os.flush();
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
return;
}
}
Click to expand...
Click to collapse

[Q] How select preferred network operators automatically?

Hallo,
I want to select preferred network operators automatically from device.
After I search for it, I found following:
Code:
final int EVENT_AUTO_SELECT_DONE = 300;
Message msg = mHandler.obtainMessage(EVENT_AUTO_SELECT_DONE);
phone.setNetworkSelectionModeAutomatic(msg);
So I need an instance of class "Phone". I tried this:
Code:
String phoneFactoryName = "com.android.internal.telephony.PhoneFactory";
String phoneName = "com.android.internal.telephony.Phone";
Class phoneFactoryClass = Class.forName(phoneFactoryName);
Class phoneClass = Class.forName(phoneName);
Method getDefaultPhone = phoneFactoryClass.getMethod("getDefaultPhone");
Object phoneObject = getDefaultPhone.invoke(null);
But the method "getDefaultPhone" can only called by looper.
Next I tried this:
Code:
String phoneAppName = "com.android.phone.PhoneApp";
Class phoneAppClass = Class.forName(phoneAppName);
Method getInstanceMethod = phoneAppClass.getMethod("getInstance");
Object phoneObject = getInstanceMethod.invoke(null);
But I get a ClassNotFoundException.
Can anybody help me, please?
sorry ,i can't help you
Yes it can be instantiated. But you have to overcome a couple of hurdles:
In your AndroidManifest.xml set
Code:
android:sharedUserId="android.uid.phone"
within the manifest-Tag. This is required to prevent a SecurityException from being thrown when protected Intents are sent by the methods you may invoke (like android.intent.action.SIM_STATE_CHANGED).
Set
Code:
android:process="com.android.phone"
in your application-Tag. This is required to allow the invocation of getDefaultPhone / makeDefaultPhone.
To do all this your app must be signed with the system signature key.

Ping app

hey guys,
Building an app that runs a ping command at the moment and I can't quite get it to work. If I modify the command to something that isn't a terminal command then it'll output my error statement but i can't get it to display the ping output. any help would be awesome. I know my outputs for my error are bad but it's an easy way to determine what path it's outputting.
package com.mycompany.myapp;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import java.io.*;
import java.lang.Process;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView Text = new TextView(this);
Runtime runtime = Runtime.getRuntime();
try
{
Process proc = runtime.getRuntime().exec("system/bin/ping 192.168.1.1");
BufferedReader in = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
String line = "null";
while ((line = in.readLine()) != null) {
Text.setText(in.readLine());
}
}
catch (Exception e)
{
String line="55";
Text.setText(line);
}
setContentView(Text);
}
}
Thanks for any help you guys can give me,
Adam
Hey,
Try using "system/bin/ping -c 1 192.168.1.1" instead.
And then add this line just after that:
Code:
proc.waitFor();
and while reading the output of the ping you might want to do it like this maybe?
Code:
String line = "";
String result = "";
while (line != null)
{
result = result + "\n" + line;
line = in.readLine();
}
Text.setText(result);
If you want to ping more than 1 packet I think it would be better to make a new thread and do proc.waitFor() in that thread. Then send a message using a handler to set the output of the ping to the TextView
k i have done that and that does make more sense but Im still getting a black screen on the output. i am testing on a Sony tab s and using AIDE (on the device) cause my eclipse is broken. this is how my code looks now,
package com.mycompany.myapp;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import java.io.*;
import java.lang.Process;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView Text = new TextView(this);
Runtime runtime = Runtime.getRuntime();
try
{
Process proc = runtime.getRuntime().exec("system/bin/ping 192.168.1.1");
BufferedReader in = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
String line = "null";
while ((line = in.readLine()) != null) {
Text.setText(in.readLine());
}
}
catch (Exception e)
{
String line="55";
Text.setText(line);
}
setContentView(Text);
}
}
Is there anything else I could be missing??
Thanks,
Adam
Hey, I think you posted the same code again.
I am not sure if you can read the process stream before it is complete and ping does take a long time to complete. So your main thread is blocking on it and it doesn't get to executing the setContentView.
Thats why I think going for a seperate thread is a better option.
so it would be better to put the ping into a new class and call on it when i need it??
Not a seperate class, a seperate thread to be more specific.
Even if you do put the ping code in a seperate class' method and call that method in onCreate it will still run on the your applications main thread.
What I was trying to say is something along the lines of the following code:
Code:
private TextView textView;
private Process process;
private Handler handler;
private Thread pingThread;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
textView = new TextView(this);
textView.setText("Pinging...");
setContentView(textView);
try
{
process = Runtime.getRuntime().exec("system/bin/ping -c 5 192.168.1.1");
handler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
String result = "";
while(line != null)
{
result = result + "\n" + line;
line = reader.readLine();
}
reader.close();
textView.setText(result);
}
catch(Exception e)
{
e.printStackTrace();
textView.setText("Error");
}
}
};
pingThread = new Thread()
{
@Override
public void run()
{
try
{
process.waitFor();
}
catch(Exception e)
{
e.printStackTrace();
}
handler.sendEmptyMessage(0);
}
};
pingThread.start();
} catch (Exception e)
{
e.printStackTrace();
}
}
I am not sure if this is exactly how you want your app to behave. There might be a better way of doing what you want than what I have suggested but I tested the above code and it works for me.
thats wicked, basically what want my program to do is to run a ping command through a usb to rj45 adapter. at the moment I just need it to do the ping command through wifi and once that was working I was going to set it up to go through usb.
I wonder if there's something I'm doing wrong like I'm build the apk in AIDE on the tablet or something, cause I'm still getting a black screen when booting the app.
If I error the code up a bit, Like put "system/bin/pi ....." instead I do get pinging on the app but no error output and if the code is fine then nothing displays
That is very strange :S.
If you use the incorrect command it works fine but when you use the correct command it doesn't?
Can you post your code? or provide more details if possible?
the code is just the code you posted cause I thought if a I could get it working with that code then modify it to what it needs to do, when the command is incorrect it displays "ping....." but doesn't display an error, I'm going to install eclipse and build the package with that and see how it goes. did you test on a tablet and what did you use to deploy the package?
Adz117 said:
the code is just the code you posted cause I thought if a I could get it working with that code then modify it to what it needs to do, when the command is incorrect it displays "ping....." but doesn't display an error, I'm going to install eclipse and build the package with that and see how it goes. did you test on a tablet and what did you use to deploy the package?
Click to expand...
Click to collapse
I think i know whats happening. It isnt the Ide and using eclipse wont make much of a difference.
Are you usIng something like -c 5 in the ping command? Cause if you aren't i think ping is Going to take a really long time and all you'll see on the screen is "Pinging..."
Yea I have got that in the command, when the code is correct and working I dont get anything all I get is a black screen. Its when I error the command up a bit that I get pinging
Sent from my Sony Tablet S using XDA
hey guys,
just got eclipse running and tested it on an avd emulator and it runs perfect, so the question is what would cause it not to run on my tablet?
I have no idea! I don't have access to an Android Tablet, so I can't test it out! I tested it out on my phone too and it works just fine.
One thing I can suggest though is:
Put log statements throughout the program to signify where the the control has reached. Then run it on your tablet. That should shed some light on where the code is failing on your tablet.
tested it on my phone which is running 2.3 and it failed on there as well, "ping......" would pop up for about a second then disappear, also if I use a command like ls instead of ping on my tablet it will work perfectly fine so I'm guessing for some reason past android 2.1 it doesn't like the ping command. any ideas?
I tested it out on phone with 2.2. Did you try putting log statements and checking where it is failing.
You could also add breakpoints in your code and run it?

i9305 not wokring 2G network in Android 5.1

Hi,
I have a problem with 2G (edge, I didn`t try GPRS) networks on my i9305 in Android 5.1. I can connect to 3G and 4G without problem, but for 2G I get only an exclamation mark on the side of the signal icon and no connection. I tried several ROMs, which I found here and my own cm12.1 build (I actually started with that one) - all with the same result:
AOSP-5.1.1-20150605-i9305-rodman01.zip
BlissPop-v4.0.3-i9305-UNOFFICIAL-20151011-2232.zip
LS-LP-v4.1-2015-10-23-liquid_i9305.zip
Sammy_Resurrection-Remix-LP-v5.5.9-20151122-i9305.zip
cm-12.1-20151201-UNOFFICIAL-i9305.zip (from winxuser)
I did some debugging and discovered that the problem is in wrong data coming from rild. I described it with more details here: forum.cyanogenmod.org/topic/118467-how-to-debug-non-working-2g-network I even found on the web some logs with the same wrong value and posts describing similar or the same behavior. I also found some posts saying, that it is fixed, but I can`t find any ROM, where it is working.
As you can see in my post on cyanogenmod forum, I have a solution, but not a nice one. It is a hack. So I want to ask – is there someone who had the same problem and fixed it? Or some who has the same phone and not this problem? If yes, how did you fix it? Exactly which ROM, prorietary files did you use?
Thank you
Pavel
OK, I am giving up. I tried several more ROMs:
Slim-i9305-5.1.1.beta.0.9-UNOFFICIAL-20151024-2015.zip
aicp_i9305_lp-10.0-NIGHTLY-20151128.zip
cm-12.1-20151202-UNOFFICIAL-i9305.zip
nameless-5.1.1-20151019-i9305-NIGHTLY.zip
The result is still the same. Maybe it has something to do with carrier operator (but I don`t have this problem in cm 11). I found fix similar to mine, which I described in cyanogenmod forum, so I`ll use that. See here github.com/CyanogenMod/android_device_samsung_jf-common/blob/cm-12.1/ril/telephony/java/com/android/internal/telephony/jflteRIL.java if you are interested. Specifically method responseVoiceDataRegistrationState. It replaces the wrong rild data in the same way.
I have the same problem @p.a.n.
Please tell me how I fix it, even if it´s a hack... Thanks
Hi,
here is the final diff I use:
Code:
project device/samsung/smdk4412-qcom-common/
diff --git a/ril/telephony/java/com/android/internal/telephony/smdk4x12QComRIL.java b/ril/telephony/java/com/android/internal/telephony/smdk4x12QComRIL.java
index 0e8d798..619be34 100644
--- a/ril/telephony/java/com/android/internal/telephony/smdk4x12QComRIL.java
+++ b/ril/telephony/java/com/android/internal/telephony/smdk4x12QComRIL.java
@@ -409,8 +409,8 @@ public class smdk4x12QComRIL extends RIL implements CommandsInterface {
case RIL_REQUEST_UDUB: ret = responseVoid(p); break;
case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break;
case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break;
- case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseVoiceDataRegistrationState(p); break;
- case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseVoiceDataRegistrationState(p); break;
+ case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseVoiceDataRegistrationState(p,false); break;
+ case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseVoiceDataRegistrationState(p,true); break;
case RIL_REQUEST_OPERATOR: ret = operatorCheck(p); break;
case RIL_REQUEST_RADIO_POWER: ret = responseVoid(p); break;
case RIL_REQUEST_DTMF: ret = responseVoid(p); break;
@@ -580,9 +580,16 @@ public class smdk4x12QComRIL extends RIL implements CommandsInterface {
}
private Object
- responseVoiceDataRegistrationState(Parcel p) {
+ responseVoiceDataRegistrationState(Parcel p, boolean data) {
String response[] = (String[])responseStrings(p);
if (isGSM){
+ if(data &&
+ response.length > 4 &&
+ response[0] != null && response[0].equals("1") &&
+ response[3] != null && response[3].equals("102")){
+ riljLog("responseVoiceDataRegistrationState overriding 102 -> 2");
+ response[3]="2";
+ }
return response;
}
if (response.length>=10){
Or you can try replace /system/framework/telephony-common.jar with attached telephony-common.jar, but be careful with that (make backup), I can`t guarantee that it will work with the rest of your system.

[Ugoos X3 and probably a lot of other devices, and even NAS devices] [Solved] Why samba/smb transfer rate is slow despite a gigabit Ethernet port ?

Hello everyone,
For my first thread, I won't ask a question, I will post a solution.
I have recently acquired a second-hand Ugoos X3 device, which is quite a good device.
But I have been really frustrated upon testing it after unboxing it, because despite the fact that this device advertises for the ability of having a Gigabit ethernet port and a builtin samba server, my tests showed a max 11,4 MiB/s instead of rather a 114 MiB/s.
I started to identify the reason, with a vast amount of Googling. After realizing how many people on earth already been through this (mostly unsolved) issue, and after testing the good gigabit-readiness of my Ethernet cable, I dug into the rabbit hole of the system.
I then discovered the root causes, and you won't like it :
- the smbd binary dates from 2005
- the smb.conf is counter-optimized and dates from this 2005 era
See for yourself:
Code:
/data/system/samba_________________ug # ./smbd -V
Version 3.0.20a
Code:
[global]
interfaces = wlan0 eth0 eth1 eth2
min protocol = SMB2
bind interfaces only = yes
workgroup = WORKGROUP
server string = Samba on Android mediacenter
netbios name = mybox
#remote announce = 255.255.255.255
encrypt passwords = yes
security = SHARE
restrict anonymous = 0
load printers = no
printcap name = /dev/null
disable spoolss = yes
deadtime = 5
delete readonly = yes
nt acl support = no
inherit permissions = yes
socket options = IPTOS_LOWDELAY TCP_NODELAY SO_SNDBUF=64000 SO_RCVBUF=64000 SO_KEEPALIVE
local master = no
unix extensions = yes
[internal storage]
vfs objects = fake_perms
comment = mybox /sdcard
path = /sdcard
force user = root
read only = no
writable = yes
guest ok = yes
A lot of directives in this config file are totally deprecated, and the "socket options" is responsible for capping at 11,4 MiB/s.
So after having spent this vast amount of time finding the issue, I took some to patch.
Here's my solution.
0) Root your device
1) Download the Termux compiled package of your device architecture of the "samba" package : https://grimler.se/termux-packages-24/pool/main/s/samba/
2) On your device, replace the smbd binary with the Termux one, at this location : "/data/system/samba_________________ug"
3) Replace the original "smb.conf" (same directory than previous) configuration with this one (which by way the contains security hardening features and support SMBv2 which allows not installing SMBv1 on Windows...)
Code:
[global]
lock dir = /data/local/tmp/lock/
state directory = /data/local/tmp/state/
ncalrpc dir = /data/local/tmp/ncalrpc/
interfaces = wlan0 eth0 eth1 eth2
server min protocol = SMB2
bind interfaces only = yes
workgroup = WORKGROUP
server string = Samba on Android mediacenter
netbios name = mybox
server role = standalone server
security = user
map to guest = Bad Password
usershare allow guests = yes
load printers = no
printcap name = /dev/null
disable spoolss = yes
deadtime = 5
delete readonly = yes
nt acl support = no
inherit permissions = yes
local master = no
disable netbios = yes
smb ports = 445
lm announce = no
multicast dns register = no
[internal storage]
vfs objects = fake_perms
comment = mybox /sdcard
path = /sdcard
force user = root
read only = no
writable = yes
guest ok = yes
4) Edit the "smbd" binary calling line in the "samba-rc" launching script, with this one
Code:
$PRE/smbd -D -s /data/system/samba_________________ug/smb.conf
Reboot your device, you now have a best-of-breed samba server and configuration.
A simple but heartful message to Ugoos: update the packages you use in your image ! We need more up-to-date binaries and configuration from your products ! Provide firmwares that does not require to make people do insecure stuff such as installing SMBv1 client on their client !
I am really grateful to these resources which helped a lot:
- https://lafibre.info/nas/perfs-moisies-avec-samba/ (sorry, in french, use google translate)
- https://serverfault.com/questions/470650/samba-configuration-for-public-shares/700449#700449
- https://blog.hiebl.cc/posts/why-your-samba-config-does-not-work/
Hello. According to your instructions with file replacement and line editing, the server becomes inoperable. The server activation checkbox is not activated in the ugoos settings. Please describe the actions in more detail or upload files for replacement.
Hello @Nereal-NeSkill,
As of step 1), try to perform a "pkg install samba" first with Termux.
Then, can you perform a "./samba-rc start" and paste here the output ?
Was a bit skeptical replacing daemon but It works great!

Categories

Resources