How to use localhost ip in android emulator - Android Q&A, Help & Troubleshooting

I want to use the network ip of local host in emulator and how to configure it. please explain with steps in details

Related

[Q] Android USB reverse tethering: How to fool the apps

USB reverse tethering = Cellphone gets network connection from PC via USB.
I know how to do USB reverse tethering except for one problem: Many Android apps will check network connection using the code below before doing any useful work:
Code:
ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
The problem is that, when using USB reverse tethering, the above code will report no network connection. However, there IS a network connection (which is the USB reverse tethering itself), and ping, wget and all programs not doing this stupid check work well.
So the question is: How can I hack the system to let this network connection check return success (so that I can fool these apps)?
BTW. I use Cyanogenmod 7. And any solution specific to this MOD is also welcome.
Hello,
Could you please tell me how did you do the USB reverse tethering? Since on USB connection there is no option to do that under CM 7.1?
...
Thank you. Unfortunately the binary /system/bin/netsharing is not part of CM7.1, apparently it exists with Sense ROM. How do you manage to run it under CM7.1?
Sense ROM has the reverse USB tether built-in ("Internet passthrough"), maybe if the 2 commands could be executed, thanks to existing HTC NDIS driver doing NAT inside the PC it will work?
I've tested in CM7 that netsharing is not needed. Just execute the rest of the commands will be OK. Of course you need to do NAT on the PC because what you've setup is just a small LAN with private IP addresses.
Thank you for your input.
What I understand:
1- connect the phone via USB cable, choose charge only
2- Assuming my router has IP 192.168.1.1:
So I have to type these commands, could you confirm?
Code:
echo 4 > /sys/devices/platform/msm_hsusb/usb_function_switch
route add default gw 192.168.1.1
ifconfig usb0 192.168.1.1 mtu 500 up
But then how to do the NAT thing is out of my knowledge!
In fact what I want is when there is no router (since mine is wireless) with available Internet connetion
(ADSL line down). So I have to use USB 56kbps modem with telephone line to access Internet from the PC (running XP).
And I would like to plug the Android phone with USB cable and allow the phone to access Internet (Internet sharing
with the PC). I am not sure of the operations to do then.
Sorry but I don't know how to set up NAT on Windows XP... I use Linux and a simple iptables command suffices:
Code:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

for app developers and others, change mac automatic

I use:
busybox ip link set wlan0(or eth0) address XX:XX:XX:XX:XX:XX
To change Mac address on android, it need root, terminal emulator and busybox.
It work at the first time or second. But need to be done aigain every time we want to connect a wireless.
Insted of turn the wifi off and on and quickly run the command.(the command need to run before the wifi turn on complete).
I use the terminal with su:
svc wifi disable
svc wifi on
(need to wait 0.5s to proced)
busybox ip link set wlan0(or eth0) address XX:XX:XX:XX:XX:XX
and its done .
it will be great if an app developer can make an app to run this command automatically when we want to connect to wifi. it will make the mac address not permanent but almost.

[Q] there is no place like 127.0.0.1 [WORKAROUND FOUND]

hello guys,
i'm developing an automatic vulnerability scanner/exploiter for android.
i'm adding the cool feature of using the metasploit framework from our android phones, but i'm having a big issue.
i can start the MsfRpcd ( the metasploit daemon ) from a su shell an make it bind to the 127.0.0.1 address.
i can connect to the server using busybox netcat ( no Java though here ).
i can't connect to 127.0.0.1 from the android app! i got ECONNREFUSED.
uff!
after a bit of google i understood that JavaVM have a separate network and it filter out my connection to localhost/127.0.0.1.
how can i connect to a service bind to 127.0.0.1 on my phone from an android app?
this is a jail!
NOTES:
i gave a quick look at iptables -L output, maybe i can make some hack there, but probably i will break the JavaVM network.
thanks in advance!
-- tux_mind
PS:
binding on wifi ip is not an answer.
WORKAROUND:
do not use socket library, use URLConnection:
Code:
u = new URL("http", InetAddress.getLocalHost().getHostAddress(), mPort, "/api/");
huc = u.openConnection();
huc.setDoOutput(true);
huc.setDoInput(true);
huc.setUseCaches(false);
huc.setRequestProperty("Content-Type", "binary/message-pack");
huc.setReadTimeout(0);
huc.getOutputStream().close();
-1 for google

SSH over USB from Android to RaspberryPi

So there are many topics covering both SSH tethering and SSH reverse tethering, but they were not helpful for me. Below, I'll quickly explain what I want. Hope you can help me. Thanks.
It's easy to SSH from Windows/Linux/OSX to Android through USB but I want the reverse. My raspberrypi's IP for USBnet is 192.168.2.2, so when I am in Windows, I can easily install RNDIS driver, set IP for Windows to 192.168.2.1 and gateway 192.168.2.2 and SSH from Windows to Android. The reverse in also possible by following this guide for example. BUT, what I want is SSH from my Android to my raspberrypi through USB OTG with:
Raspberry Pi : 192.168.2.2
Android: 192.168.2.1
Any help is appreciated.

[Q] change DNS for mobile connection through ADB [7.1.1]

Hi, I'd like to be able to change the DNS for mobile connection via ADB in Android 7.1.1 (OMNIRom).
I tried by using setprop but the 'dig' command always gives 8.8.8.8 as the server. I'd like to change that, as I'd rather not use google dns for privacy reasons.
I have to say that the 'dig' command is issued in termux. Maybe this terminal emulator uses hardcoded DNSs?
Thanks a lot for any insight you can give me.
E.

Categories

Resources