[WIP] Run Script via ADB as Root - EVO 4G Android Development

What we need is a program to simplify remote modifications.
Here's why:
You can't run a command via adb that passes variables without actually entering the shell.
You can push a script, but it wont run unless you chmod which requires root.
There is no way (currently) for a batch script to run as run.
I was thinking it would be very easy to write a median to allow us to do such.
I know some devs here use .Net, I am familiar with .Net myself but I've been very busy.
I'm comfortable using whatever language, if anyone wishes to help out while I'm in the middle of my move, that would be great. I'd be able to jump in and help out in about a week or two.
Here's some documentation:
http://msdn.microsoft.com/en-us/library/yz3fhfz1(v=VS.71).aspx
Even just a simple EXE that allows a script to be pushed, chmodded, and executed would be perfect.
There are many routes that can be taken, this is just one.

Why dont you put what ever scripts you need in a folder on your phone and just run them locally via adb.
adb shell "[path]/[path]/script.acss"
Variables can be pushed in with new scripts almost instantly.
Is this what your thinking?
Sent from my SM-N900T using Tapatalk

Related

Replacement for craptacular adb shell

Hey everybody. I'm on windows and adb's shell just keeps on pissing me off. Mainly, how pressing tab actually inserts a tab rather than tab completion . I'd really like to do something about this.
Here's a list of the things i've tried to get rid of this super-annoying behaviour.
-rolled a cross-compiler toolchain (glibc-based) for my phone (HTC Magic) and cross-compiled bash (in a vm). I actually made this work even with dynamic linking, and can start bash from within an instance of "adb shell". Unfortunatly, this doesn't change the tab behaviour, which appears to be baked into adb rather than a problem with the default shell.
-I thought i'd try something fancy by doing...
adb shell mkfifo /fifo
adb shell "bash > /fifo < fifo 2> /fifo"
adb forward tcp:9001 dev:/fifo
and starting putty in raw mode, connecting to localhost:9001. Unfortunatly, all is what happens is i get an echo of what i type and if i press enter a few times putty spits out ": command not found". I can't see why this shouldn't work but I suspect i'm Doing It Wrong.
-Searching the forum revealed puttycyg, which is actually really handy but unfortunatly suffers from the same tab completion problem as using adb shell in cmd.exe
How do you guys do it? Am I onto something with the adb forward thing? If so, how do I make that work?
I have also compiled bash but I have tab completion though adb. I do however use Linux as my desktop OS and am connecting through Konsole. So you could just try to install KDE for Windows. I know that I've looked for good terminal applications for windows but found none. They're all **** compared to what's available on nix.
This is my simple bashrc:
Code:
# If interactive do nothing.
[ -z "$PS1" ] && return
export HOME="/sdcard/"
PS1='[email protected]\h:\w\$ '
Also it's full of aliases for busybox. By replacing built in ls and similar you even get nice colors But still no line editing for some reason. I figure I might just need a proper libreadline or similar for that.
If anybody's interested in how I got this working, i cross-compiled socat for the droid. Required configuring with --disable-termios and manually editing config.h to set the #define for CRDLY_SHIFT and a couple other *_SHIFT macros to some values i found in Config/linux-2.6.24.h (or something similar, posting from memory here)
Once socat is on the phone, I made it pipe data from a bash shell to a unix socket it is listening on:
socat unix-listen:/dev/adbsock,fork exec:"/bin/bash -li",pty,stderr,setsid,sigint
(command shamelessly copied from http://superuser.com/questions/123790/socat-and-rich-terminals-with-ctrlc-ctrlz-ctrld-propagation ).
Then, on the pc i run adb forward tcp:9001 localfilesystem:/tmp/adbsock
And if i connect putty to localhost:9001 in raw mode (disabling line editing and local echo) I get a fairly complete bash shell that you can not only use tab completion on but even vi works
Again, posting from memory here so if anyone wants to try this and is running into problems i can dig it up from my ~/.bash_history.
Any chance you can post your socat port?
The tab completion thing is driving me insane! I don't understand why the ADB shell in *nix is proper, but the windows version sucks so much hairy donkey balls.
I've been using Ansicon so I at least get color in my shell, but ADB still mangles tab, and I don't even want to talk about what it does to Nano. Ugh!
Oh wow, this takes me back. I don't even have my android phone anymore (cancelled the contract due to terribly crap network service, and (unfortunately) the iPhone was the best phone in its price range from my new carrier).
So I don't have any files to give to you...
But, from what I can remember, to make it work, I built a cross binutils and gcc loosely following the instructions from the LFS book, compiled glibc + a few other libs socat wanted with it, and then socat itself, and then bash. I then copied the cross libc.so.6, ld-linux.so.2 (or whatever it's called on ARM) and all the libs socat wanted to /lib on the phone, and the socat and bash binaries to /bin. It's convenient that android keeps its important stuff in /system because it means you can avoid screwing around with your toolchain to make it look for a dynamic linker in some location other than /lib.
From memory socat was the only thing I had problems compiling, and thankfully I've already posted roughly what i had to do to it to make it build (because there's no way I remember lol)
Sorry I can't be more helpful!

[Q] adb shell busybox vi? Should this work?

I want to edit with busybox vi running from the phone within an adb shell.
I am running a DOS box cmd window or a cygwin rxvt shell window, both don't work, where I connect to the phone with an adb shell. Then I run busybox vi. The vi runs but the default termcap or terminfo or whatever it is doesn't seem to be right because busybox vi comes up but I can't seem to get the ESC key to take so I can switch between command and insert modes of operation. On the phone it works correctly.
I hate editing on the phone. I would much rather work on the workstation.
I've read on a wiki busybox vi page that busybox vi only supports vt102. Any ideas if this should work or what I could try?
Thanks in advance.
Same here. I spend half the morning playing with TERMs, trying to get a dos or cygwin terminal to run vi. vi runs fine in Terminal emulator, but like you, I don't wan to edit on the phone.
I found JOE (Joe's Own Editor) ported to Android. I installed it because it supposedly uses TERM=unknown. That didn't work from DOS either. But it did work from a cygwin bash shell, with TERM=linux in the adb shell. Now there is the learning curve to use JOE...
I too would be happy to hear which TERM setting will work with a DOS adb shell.
Face same situation here. Is it resolved?
If not, how you gurus work around on this basic issue?
I don't know much about VNC yet. Could it be a viable direction that worth spending effort?
Adb shell and Vi - info
I too just spent a lot of time trying to get vi to work under "adb shell". ESC was especially a problem. Ultimately, I wasn't able to get it to work correctly, but SSH seems to work fine.
There are a lot of details about what I learned on Stackoverflow (I'm a new member here, so I can't post the link, but you can search for it -- the title is "adb shell: can't use the ESCAPE KEY").
Has anyone gotten this to work correctly? Or is it simply an incomplete/buggy implementation of adb's shell?
Thanks,
Barry

Carrier IQ

So, looks like we have Carrier IQ on our phones, thanks to AT&T. Any luck on getting a 3rd party ROM on here yet? Any estimates as to when?
Can you give us more information? like how you found it on the phone, what steps did you take?
With more info, those of us in the know can figure out how to disable it, or remove it, without having to resort to waiting for a rom.
I have been looking for it for quite some time without much luck.
It's the device health app.it calls the ciq agent . Easily frozen.
Sent from my MB865
mtnlion said:
It's the device health app.it calls the ciq agent . Easily frozen.
Sent from my MB865
Click to expand...
Click to collapse
Thanks, I will see what else I can come up with for the ciq agent, maybe a way I can fake it out on the *NIX side of the house.
Yep first thing I went looking for after I got root.
Bloat freezer. It's free, finds it fast. When you freeze device health it doesn't want to close and keeps force closing, just reboot, it will be frozen and not running.
Douchewithaphone said:
Bloat freezer. It's free, finds it fast. When you freeze device health it doesn't want to close and keeps force closing, just reboot, it will be frozen and not running.
Click to expand...
Click to collapse
Must be rooted.
Sent from my mAtrix2!!
Well, I have found a way from the UNIX end to stop this thing in it's tracks, but it is not pretty for those unfamiliar with command line....
What we have to do is uncompress the kernel image in the boot.img remove the sys.DeviceHealth from the init.rc file there, then compress the kernel back up, all using cpio.... now to see if I can possibly make it work, and not brick any phones in the process, maybe I can throw a quick apk together next week.
I have tried the bloat freezer and the android assistant and I can still find the sys.DeviceHealth running on the UNIX side with the ps command, so this is a nasty one.
I will keep you guys posted, If I can find a better way.
Here is the link I saw, and how I figured out where sys.DeviceHealth is starting from.
For those interested ONLY. PLEASE do not try this yet, give me some more time to play with this in an emulator and see what I can come up with.
I am just sharing information at this time. BTW Zygote is the process that is calling the sys.DeviceHealth on the Atrix 2.
To see this Do the following from the terminal emulator app on your phone or though adb shell.
ps | grep -i Heal
ps | grep -i zygote
If you notice on the sys.DeviceHealth process that the second number is the same number as the first number of the zygote process.... What that means is that the zygote process starts the sys.DeviceHealth process. The first number is process ID (the processes "adress" so to speak), and the second number is the Parent process ID (The process that started the next one).
http://vinnysoft.blogspot.com/2009/12/zygote-system-process.html
jimbridgman said:
Here is the link I saw, and how I figured out where sys.DeviceHealth is starting from.
For those interested ONLY. PLEASE do not try this yet, give me some more time to play with this in an emulator and see what I can come up with.
I am just sharing information at this time. BTW Zygote is the process that is calling the sys.DeviceHealth on the Atrix 2.
To see this Do the following from the terminal emulator app on your phone or though adb shell.
ps | grep -i Heal
ps | grep -i zygote
If you notice on the sys.DeviceHealth process that the second number is the same number as the first number of the zygote process.... What that means is that the zygote process starts the sys.DeviceHealth process. The first number is process ID (the processes "adress" so to speak), and the second number is the Parent process ID (The process that started the next one).
http://vinnysoft.blogspot.com/2009/12/zygote-system-process.html
Click to expand...
Click to collapse
zygote appears to be a process respawner (watchdog) of some type. The trick is to find out where its config lies and tweak that to prevent the launching of sys.DeviceHealth.
I've just got the busybox installed that came with TiBackup and the shell tools are sorely limited (no grep for eg.). The shell itself is also pretty limited (no pipe??? WTF?). I had a version of bash on my atrix4g, and I'm wondering if you know of a reliable source for bash and shell tools for the atrix2?
A lil info on what AT&T says and how it uses Carrier IQ and some of the devices it is on can be read here http://m.androidcentral.com/atts-us...its-own-analytics-app-not-just-embedded-phone
razholio said:
zygote appears to be a process respawner (watchdog) of some type. The trick is to find out where its config lies and tweak that to prevent the launching of sys.DeviceHealth.
I've just got the busybox installed that came with TiBackup and the shell tools are sorely limited (no grep for eg.). The shell itself is also pretty limited (no pipe??? WTF?). I had a version of bash on my atrix4g, and I'm wondering if you know of a reliable source for bash and shell tools for the atrix2?
Click to expand...
Click to collapse
Yes that is exactly what zygote is. You would disable the sys.DeviceHealth in the EXACT way it says in the in link I posted, but you have to uncompress the kernel image, and extract the init.rc in there, then edit it to not include the sys.DeviceHealth, then re-compress it with cpio. This is just for information right now, so that later on when the ROM developers get started, they can use this info for their ROMs. I am testing this using a couple Android emulators to see what I can do with this.
As for a reliable busybox, I like the version from JRummy16 in the market, go grab that an install the latest version of busybox from his installer you downloaded (I think it is 1.19.3 or something similar).
also go get the hackers keyboard in the market, it helps a lot if you EVER use the terminal app ON the phone, heck I like for text and typing as well.
Jim: I'm assuming you mean the initrd image and not the kernel, or is that all wrapped up into one in android? the initrd is an odd place for the system's watchdog config. I suppose putting it in the kernel image prevents disabling it because presumably we don't have the key to sign the new image...
that's a new version of busybox, but I'm more interested in one with all of the options compiled in. What I have is pretty bare-bones... Does his busybox have grep at least? what do you do for a decent shell?
razholio said:
Jim: I'm assuming you mean the initrd image and not the kernel, or is that all wrapped up into one in android? the initrd is an odd place for the system's watchdog config. I suppose putting it in the kernel image prevents disabling it because presumably we don't have the key to sign the new image...
that's a new version of busybox, but I'm more interested in one with all of the options compiled in. What I have is pretty bare-bones... Does his busybox have grep at least? what do you do for a decent shell?
Click to expand...
Click to collapse
Yes in the initrd image the kernel is packed in there, as well as the init.rc file on Android, as well the filesystem subset, etc.
The init.rc file in / on the phone is NOT the one the kernel itself executes, take a look at that link I posted, Here is the excerpt we are interested in, I am pretty sure that the sys.DeviceHealth is in the exact same place:
I want to get a bit more control of what things are starting up when. To do this I need to modify the init.rc file. To do this I first extracted the the ramdisk to the fileystem so that I can modify it (gnucpio -iz -F ramdisk.img).
After this I simply commented out the line from init.rc. Then we can recreate it: (gnucpio -i -t -F ../ramdisk.img | gnucpio -o -H newc -O ../rootfs.img).
Click to expand...
Click to collapse
Yes both the stericson and JRummy16 busybox have most every command in the busybox you really need, oh and they create links in /system/bin for you, so that you can run commands without needing to always type busybox in front of the command.
As far as shells, I am a bourne or korn guy, so I just use the default /system/bin/sh, since I am closely intimate with bourne, being the UNIX Engineer that I am, and handling anything at the lowest level of the OS still requires bourne. But I love to program in korn (ksh), but I have not found any android shells that are useable beyond the basics, since we really are not going to spend much time there, it does not matter much. I would get aquainted the bourne, that android uses, since android seems be using the old school UNIX style bourne, more and more, yes there is some bourne again in there too.
P.S. pipe is in the /system/bin/sh, just make sure you source the /osh/apath.sh file, to get the /system/bin and /system/xbin in the shell...
The hackers keyboard has things like the arrow keys so that you can command recall, and other helpful things.
If you really need to run something, from the shell, just make sure put sh in front of it, or it won't run in a shell, one of the oddities about Android.
I have tested the method I mentioned before, and uncompressing the ramdisk that holds the kernel, and removing the sys.DeviceHealth from the init,rc, and it does work, after packaging it back up with CPIO. I tested this on an older phone that does not have a locked bootloader.
I am afraid to test it on the Atrix 2 since we still do not have a true way to get back after a soft brick at that low level.
Given the fact that this was another style of phone, and an unlocked bootloader, and the fact that the process name is a little different, I am still confident we can do something similar for our phone.
If you follow the directions on my post, you'll find it much easier to disable the Carrier IQ.
http://forum.xda-developers.com/show...6#post20281786
mrpoet said:
If you follow the directions on my post, you'll find it much easier to disable the Carrier IQ.
http://forum.xda-developers.com/show...6#post20281786
Click to expand...
Click to collapse
^^^^^^^^^^^Page not found^^^^^^^^^^^
kirkgbr said:
^^^^^^^^^^^Page not found^^^^^^^^^^^
Click to expand...
Click to collapse
Try this Link. I am not sure if it will do the job for us or not, because we don't have the same Apps installed as the Epic 4g that this original post was copied from.
Here is the thread, mrpoet created and pointed to:
http://forum.xda-developers.com/showthread.php?t=1390874
Here is the original one, that he does link to in his references:
http://forum.xda-developers.com/showthread.php?t=1373394
I am going to see if it works.
----Edit---
I just gave this a try and all the commands ran successfully, but sys.DeviceHealth is still running after following the above post.
JRW 28 said:
A lil info on what AT&T says and how it uses Carrier IQ and some of the devices it is on can be read here http://m.androidcentral.com/atts-us...its-own-analytics-app-not-just-embedded-phone
Click to expand...
Click to collapse
Just to let everyone know, the information contained in the link that JRW 28 posted, is an accurate statement from AT&T.
I have inside information that, that is BS. There are 100's of Terrabytes of Disk Storage just for this purpose.
They're a pack of bastards.

busy box

recently rooted my Samsung galaxy y just for running chainfire3d to play HD games.. now my question is what is busy box actually in geeks word? does i actually need it? please i m little bit confused...
Sent from my GT-S5360 using XDA App
shivam1688 said:
recently rooted my Samsung galaxy y just for running chainfire3d to play HD games.. now my question is what is busy box actually in geeks word? does i actually need it? please i m little bit confused...
Sent from my GT-S5360 using XDA App
Click to expand...
Click to collapse
Once you have a rooted device, and you're running or planning to run root required apps, then it is recommended that you have it.
Theonew said:
Busybox adds additional commands that the normal android command system does not have/understand on it's own (It gives you additional LINUX/UNIX based commands). See here: http://busybox.net/about.html.
Click to expand...
Click to collapse
In short: Busybox is a tool to manage computers.
A bit longer: Busybox is actually a collection of a whole bunch of tools to do various stuff like manage (copy, move, delete) files, configure network settings, edit text files, decompress archives, etc, etc.
@shivam1688: In response to the second part of your question, Busybox is very useful for those people who will perform command-line operations within the operating system of their phone / tablet. But if you are not familiar with file commands such as copy, move, vi, etc or if you have no further plans to modify your Galaxy, then you may choose to not install Busybox. If, at some point in the future, you decide you need to use command line operations, you can always install Busybox at that time, when needed.
Busybox is a swiss army knife utility that implments a wide range of POSIX (Linux, Unix) commands such as shells and utilities like grep, ls, and more (many dozens) for smaller devices such as embedded devices and smartphones. Anything using shell scripts is going to want to have Busybox on the Android device. Full linux systems have full libraries and individual commands that take up a lot more room but tend to be more "feature full". Busybox reimpliments them in one smaller, tighter, monolithic package. It's something you are probably going to want sooner or later.

Security of Android Devices

Hello all. I'm currently taking a computer security class and to make the long story short, at the end of the semester I will have to turn in a research paper and do a 30 minute presentation on it. The topic I chose for this is "Exploring the techniques used to gain access to personal information on Android devices; the methods hackers use and the type of data they are seeking." So if you could please post links to any articles that you come across that talk about security of android devices. Also, I could really use any magazine or book suggestions. Thanks!
Look up open wifi hackers. They can steal your junk if your network isn't secured. Sorry no article
Sent from my ASUS Transformer Pad TF300T using XDA Premium HD app
You should write about the easiest method - allowing to isntall ab with lots of different permisions.
^Installing apps with dubious permissions is what I'm sure he's getting at and that has been the only major "flaw" as of yet. Considering that it requires the user to sideload questionable apps or to download from unprotected app sites it's not the worst thing ever.
Anti-virus/Anti-malware apps still remain next to useless on Android devices. The other main exploits that are used such as spoofing, etc, are simply able to function on any device operating over an unsecured wifi network and aren't unique to Android. I really don't think you're going to find much in the way of peer-reviewed articles on this topic, but I'd recommend that you used the databases available to you through your school rather than just taking articles handed to you by others.
MissionImprobable said:
^Installing apps with dubious permissions is what I'm sure he's getting at and that has been the only major "flaw" as of yet.
Click to expand...
Click to collapse
Not really the only flaw, there is a way to get android to install a rootkit which needs no extra priveleges to do what it wants on your android device. It isn't out in the wild but it can be, and has been, done to highlight an android vulnerability.
http://m.networkworld.com/news/2012...tkit&client=ms-opera-mini-android&channel=new
Dave
( http://www.google.com/producer/editions/CAownKXmAQ/bigfatuniverse )
Sent from my LG P920 using Tapatalk 2
keynith said:
Look up open wifi hackers. They can steal your junk if your network isn't secured. Sorry no article
Click to expand...
Click to collapse
With all due respect, have you ever *tried* to intercept SSL traffic for a non-browser-based Android app? It's hard as hell to do with a phone & fake AP under your direct rooted control, and damn near *impossible* to casually pull off against a random stranger's phone at Starbucks.
Android MITM is *hard*, and the #1 method of reliably doing it for penetration testing is to hack the app's decompiled SMALI to replace the certificate-validation logic with a dummy class that ignores cert errors.
Put another way, if somebody sniffs your password to something over wifi, it's because the idiot who wrote the app submitted your credentials without using SSL, and not because the access point was "open". Successful Android non-browser SSL MITM isn't "black hat", it's "black magic."
Also, WPA(2), WEP, etc might give some speedbump-like protection against totally random strangers who stumble upon an access point from the outside, but they won't do jack to protect you from the guy sipping a lattè next to you & running Wireshark while connected to the AP using the same key YOU are.
Wifi encryption is there to keep people from leeching free internet service, not to keep your traffic safe from other connected users. That's why ipsec & SSL exist.
There's exactly one safe way to use public wifi -- through a PPTP vpn tunnel (L2TP has a few known Android vulnerabilities).
Sent from my SAMSUNG-SGH-I747 using Tapatalk 2
An application called adb (or android debug bridge) will get you significant access to an android handset via a USB cable. This is part of the android software development kit. Set up your PC with the SDK, install the add-on platform tools, login as root and start the adb server. You can run a shell with the "adb shell" and use "adb pull" and "adb push" to transfer files. The "adb shell" command gives you a shell prompt on the android device and the "su" command gives you root access. This works even with the screen locked with a PIN.
Want to root your device? Download the zip file for rooting a handset and look at the installer script. That can tell you where to copy the su binary - remount your devices /system partition as read-write using "mount -o rw,remount" and follow the installer script.
adrian816 said:
An application called adb (or android debug bridge) will get you significant access to an android handset via a USB cable. This is part of the android software development kit. Set up your PC with the SDK, install the add-on platform tools, login as root and start the adb server. You can run a shell with the "adb shell" and use "adb pull" and "adb push" to transfer files. The "adb shell" command gives you a shell prompt on the android device and the "su" command gives you root access. This works even with the screen locked with a PIN.
Want to root your device? Download the zip file for rooting a handset and look at the installer script. That can tell you where to copy the su binary - remount your devices /system partition as read-write using "mount -o rw,remount" and follow the installer script.
Click to expand...
Click to collapse
Thanks a lot!!
#### Sent from my GN7 #### B0$N4 ####

Categories

Resources