Related
Lately these toast notes have been popping up. But what are they? Ive done some digging and this is what i've found.
First off ICS roms use mksh shell as default. In ICS, mksh use /system/etc/mkshrc as the default profile if we log into
android with adb shell.
So if you want to export some environment variable, you can change this file.
And you can change the default profile file path by changing MKSHRC_PATH
in Android.mk.
You should be able to run "adb shell cmd", then the mkshrc will not be used.
.
(ip route 224.0.0.0/4 toast)
What is it? Well thanks to XDA member phealy we have the real answer. 224.0.0.0/4 is the standard IP multicast range - this command just forces multicasting out of the wifi interface (since AFAIK cell carriers don't allow multicasting on their data connections). This prevents multicast traffic from attempting to use the mobile network connection and failing.
Source----> (http://en.wikipedia.org/wiki/Multicast_address)
(mksh toast)
mksh is a command interpreter intended for both interactive and shell script use. Its command language is a superset of the sh(C) shell language and largely compatible to the original Korn shell.
mksh is the MirBSD Korn Shell, largely similar to the original AT&T ksh, pdksh’s actively developed successor, portable. It includes bug fixes and improvements in order to produce a modern, robust shell good for interactive and especially script use. It has UTF-8 support and extended compatibility to other modern shells.
source of mksh info-----> http://lists.linaro.org/pipermail/linaro-dev/2011-November/008785.html
So as it seems both are not malicous,and don't cause any internal damage. Not 100% verified,it's yet to be fully determined.
I'd be interested in knowing if any progress has been made on this. Thanks.
Any progress
Is there any progress on authentication of this request. Is it totally safe?
nabeeldall said:
Is there any progress on authentication of this request. Is it totally safe?
Click to expand...
Click to collapse
It's safe.
Sent from my HTC One
42
Just in case someone digs out this thread while looking for this…
that thread has them answers! ☺
I made this for my own reference and would like some experienced users to critique it (please don't laugh) and help me add to it. This is a first draft replacing the "napkin" I've got tucked under my keyboard. Specifically simple for newbes like myself to just help us get started with Terminal, Scripting, ADB and have a command reference to follow.
Please chim in on the ADB section which I know needs some serious help. I have almost no experience with ADB but seek to learn and document more so its useful. Or if something already exists like this but way better please point me to it so I can take from it or use it to replace this.
Thanks in advance!
Edit1: Redline1, change to:
chmod octal...10 columns: 1 Type, 9 Permissions
Nice start.
Some comments from top to bottom:
You don't need semicolons after each line. Only if you want to write more than one command on the same line - e.g. "if some condition; then".
For the directory commands (cd, mkdir, ...), you can type directories with leading "/" if you want to specify the complete path starting from root, and without leading "/" to refer to subdirectories of the current directory. ".." is the parent directory of the current directory.
"which" scans your $PATH for the command you give it, so especially if it exists multiple times it shows you "which" will get run if you type it without specifying a path. It has nothing to do with directories.
The permission groups are usually called "u=user", "g=group" and "o=other" (not "everyone else)". And "s---------" is a socket, not a binary - the rest is correct. Read all you wanted to know about the output of ls and much more here: http://www.gnu.org/software/coreuti...ion-is-listed.html#What-information-is-listed
You confused "logwrapper" with "logcat". You use "logcat" to display the log and "logwrapper" to redirect the output of something in your script to logcat.
"sh script.sh" will execute a script even if it doesn't have the "executable" permission set. Use chmod 7xx to make it executable directly without "sh".
"adb command" doesn't exist - to run a single command, you need to say "adb shell xxx".
"adb fastboot" also doesn't exist, at least on my adb.
Some general tips:
Many or all commands in busybox have built-in help if you invoke them with "--help". Also adb shows a small manual if you invoke it without parameters.
You can use most basic reference material for Linux, e.g. guides about shell scripting. It's 95% the same on Android.
Always be very careful when running commands as root - the system assumes you know what you are doing. There is no safety net. For example, "rm -rf" will happily wipe your entire device (if mounted writable) if you add a space between the following "/" and the rest of the path.
Thanks oodels for the feedback and corrections. I will update and rev the document based on this feedback when I get the time.
Also thanks for always being the one who takes the time to reply in detail to my threads, give me guidance, and inspire me to learn more about the discussion topic while NEVER making me feel like I have asked a dumb question or am the newbe I am. I had a college professor that reminds me of you who told me the only dumb question I could ask was the one I didn't ask. I appreciate that more than I can express. You are a plethora of knowledge and a master instructor with a winning humble and tackful approach to education and inspiration; a rare gem.
_that said:
Always be very careful when running commands as root - the system assumes you know what you are doing. There is no safety net. For example, "rm -rf" will happily wipe your entire device (if mounted writable) if you add a space between the following "/" and the rest of the path.
Click to expand...
Click to collapse
Thanks for _that tip. Knowing this now I think I will remove that example from the newbe guide as someone could easily mistype it, add a space after /, and wipe their device from the root down. I will also add the -i option to the command(s) that are dangerous, requiring user intervention (permission) to proceed with the command as a newbe safety factor.
Overview
About a month ago I got the urge to do some reverse engineering of ADB so that I could write an Android app that would be able to talk to devices the same way that the adb command-line tool distributed with the Android SDK does (without requiring root!).
The app that came about from this work has been on the Play Store about a month: https://play.google.com/store/apps/details?id=com.cgutman.androidremotedebugger
I had planned to do an open-source release of the library that I wrote for the app, but hadn't found the time to tidy up the code until recently. So today is my official announcement of the open-source release of my ADB work.
TL;DR full sources and detailed JavaDoc are here: https://github.com/cgutman/AdbLib
Functionality
AdbLib implements a connection object (AdbConnection) that sits atop a standard Java Socket class which it uses as the underlying transport for the ADB connection and all streams operating over it. The AdbConnection object contains methods for the creation of AdbStreams which represent the underlying data streams of ADB. AdbConnection also maintains the connection thread responsible for processing and responding to packets from the target device.
The AdbConnection object has an associated AdbCrypto object which abstracts the 2048-bit RSA key authentication used on Android 4.2.2 and later. AdbCrypto also has the capability of saving and loading key pairs, along with generating a fresh key pair. AdbCrypto requires an implementation the AdbBase64 interface which does the conversion of the RSA public key to a Base-64 encoded string that is transmitted to the 4.2.2+ device the first time it connects.
There's also low level AdbProtocol class which has many useful definitions and functions for receiving, validating, and generating ADB packets. This class's methods and fields are used by AdbConnection for packet processing and generation.
Conclusion
Hopefully you guys can do something cool with this library. It's under the BSD license so there shouldn't be any problem getting it included in any projects. I'd be happy to help with any bugs found or provide assistance integrating the library into projects. I also accept patches/pull requests
I've also published the Wireshark dissector I wrote to analyze the ADB protocol: https://github.com/cgutman/wireshark-adb-dissector
@cgutman thanks for this. I am examining how I can integrate this into CASUAL. It would be good for keeping the ADB process count low.
Would you be kind enough to document the flow here? I'm reading the code and I'm 1/2 way getting it, but I want a solid plan before I do a full-scale integration. Do you think you can do a flow of some sort?
Here's how I would be interested in using this library, from the desktop side. Would I hit any limitations here?
adb detect-device loop on port 5555
adb devices -- get number of devices detected
adb push -- fileinputstream from local file to /sdcard/
adb reboot recovery
adb wait-for-recovery
adb shell "echo foo>/data/cache/bar"
adb shell killall recovery
adb reboot
adb wait-for-device
It would be really neat to be able to contribute some things to this project and if this has basic functionality to be able to perform the above from the desktop side, I would be interested in generating several helper methods/classes which will act more familiar to those who are used to the command-line binary. I would also add features not found in command line like adb wait-for-any.
AdamOutler said:
@cgutman thanks for this. I am examining how I can integrate this into CASUAL. It would be good for keeping the ADB process count low.
Would you be kind enough to document the flow here? I'm reading the code and I'm 1/2 way getting it, but I want a solid plan before I do a full-scale integration. Do you think you can do a flow of some sort?
Here's how I would be interested in using this library, from the desktop side. Would I hit any limitations here?
adb detect-device loop on port 5555
adb devices -- get number of devices detected
adb push -- fileinputstream from local file to /sdcard/
adb reboot recovery
adb wait-for-recovery
adb shell "echo foo>/data/cache/bar"
adb shell killall recovery
adb reboot
adb wait-for-device
It would be really neat to be able to contribute some things to this project and if this has basic functionality to be able to perform the above from the desktop side, I would be interested in generating several helper methods/classes which will act more familiar to those who are used to the command-line binary. I would also add features not found in command line like adb wait-for-any.
Click to expand...
Click to collapse
already sounds like this could become very useful, an option to pull partitions from the device would be nice aswell!
ricky310711 said:
already sounds like this could become very useful, an option to pull partitions from the device would be nice aswell!
Click to expand...
Click to collapse
I've already got that option in CASUAL. Download any CASUAL from last night on, and you can use CASUAL.jar --execute "$PULL /dev/block/whatever, local file". The $FLASH command works the same, but it requires that you invert the args. It establishes a direct connection via TCP over USB and flashes the partition.
Will definayltely check it out, any chance of autodetection in the future?
For example umm
$pull boot
Autodetects mmcbl0p5?
Or is it just something we are gonna have to live with?
Sent from my GT-I9300 using xda app-developers app
ricky310711 said:
Will definayltely check it out, any chance of autodetection in the future?
For example umm
$pull boot
Autodetects mmcbl0p5?
Or is it just something we are gonna have to live with?
Sent from my GT-I9300 using xda app-developers app
Click to expand...
Click to collapse
That would be another feature all together... I can make that happen on newer devices. But this method WILL require root access of some kind on the device. Its really intended for flashing a recovery as part of a root exploit and making a backup of said recovery.
That would be great, I know this can be done on a rooted phone with pushing a utility to xbin or sbin and using shell to copy the boot.img to sdcard then pulling it?
Sent from my GT-I9300 using xda app-developers app
AdamOutler said:
@cgutman thanks for this. I am examining how I can integrate this into CASUAL. It would be good for keeping the ADB process count low.
Would you be kind enough to document the flow here? I'm reading the code and I'm 1/2 way getting it, but I want a solid plan before I do a full-scale integration. Do you think you can do a flow of some sort?
Here's how I would be interested in using this library, from the desktop side. Would I hit any limitations here?
adb detect-device loop on port 5555
adb devices -- get number of devices detected
adb push -- fileinputstream from local file to /sdcard/
adb reboot recovery
adb wait-for-recovery
adb shell "echo foo>/data/cache/bar"
adb shell killall recovery
adb reboot
adb wait-for-device
It would be really neat to be able to contribute some things to this project and if this has basic functionality to be able to perform the above from the desktop side, I would be interested in generating several helper methods/classes which will act more familiar to those who are used to the command-line binary. I would also add features not found in command line like adb wait-for-any.
Click to expand...
Click to collapse
AdbLib is a low-level abstraction of an ADB connection and its associated streams. It might not be exactly what you're looking for here. It's not really meant to be used as a direct replacement for the full adb command line client, since for one, it only handles ADB devices over the network.
There's no concept of detecting devices since connections are driven by you specifying a target to connect to. Conceivable you could push files with AdbLib (since it's just pushing data over a stream) but I haven't analyzed that protocol enough to know how it expects the file data to be sent.
Similarly, some of the special adb commands like "reboot" and "reboot recovery" should theoretically just be streams too, but I haven't analyzed the way the protocol deals with those commands.
The shell commands should be simple to send over AdbLib (since that's what it was originally designed for). To do this, you create a socket connected to your ADB target and pass it to AdbConnection.create() with an AdbCrypto object that contains a key pair that was either newly generated or loaded from a file. You then cal AdbConnection.connect() to begin the connection handshake process. When that returns, the handshake is finished. You can call AdbConnection.open("shell: killall recovery") and that will create a stream connected to the killall process (so you can send and receive output via stdin, stdout, and stderr). When the process terminates, your stream will close.
Sorry for reviving this old thread, but if anybody is interested in using AdbLib library, it's now available on maven central repo. It is slightly modified version of the library, but API hasn't changed much.
I'm reviving this thread once again
I used this adb library to create a Tasker Plugin!
https://play.google.com/store/apps/details?id=com.ADBPlugin
Please have a look
@cgutman Just a quick question. How do you send the ctrl+c from your app using this library? I can't seem to find it
Well, this is just a simple script to view Nice Value/Niceness of processes and PIDs. I made this because i can't seem to find a simple and direct way to view niceness, so I'm sharing it with you.
Okay, What is Nice?
nice is a program found on Unix and Unix-like operating systems such as Linux. It directly maps to a kernel call of the same name. nice is used to invoke a utility or shell script with a particular priority, thus giving the process more or less CPU time than other processes. A niceness of −20 is the highest priority and 19 is the lowest priority. The default niceness for processes is inherited from its parent process and is usually 0.
Uses and effect
nice becomes useful when several processes are demanding more resources than the CPU can provide. In this state, a higher-priority process will get a larger chunk of the CPU time than a lower-priority process. Only the superuser (root) may set the niceness to a smaller (higher priority) value. On Linux it is possible to change /etc/security/limits.conf to allow other users or groups to set low nice values.
How to Install:
Download the pdf file linked below
This needs busybox so you gotta have one - tip: use @YashdSaraf's
Move it in '/system/bin' or '/system/xbin'
Rename to niceness (or anything you want)
Set permissions to 755
How to Use:
Open Terminal Emulator or adb shell
Code:
niceness (name of the running process/pid)
BOOM!
Download
https://www.androidfilehost.com/?fid=385035244224394124
reserved
same can be achieved with below command in terminal emulator -
busybox ps -o pid,nice,comm
JumboMan said:
same can be achieved with below command in terminal emulator -
busybox ps -o pid,nice,comm
Click to expand...
Click to collapse
i know, but I'm lazy to type all that stuff so I made it :silly:
Thanx, ll use it
I am looking for advice on how to define a "sudo" command, given that I have a working "su" command.
I have been getting away with
Code:
alias sudo='su -c '
but recently got a silly error message that makes me think I need more than one backward-slash to escape the asterisk I am trying to pass to "find" in an "-iname" option. (And leaves me wondering what I've been doing this last year when I thought it was working as expected.)
@Cruzy12100 described using "sudo". I wanted (and still want) him to explain in detail how he comes to have an "sudo" command available.
To invoke SU command the synthax is
Code:
su -c '<YOUR-COMMAND-HERE>'
Note that the <YOUR-COMMAND-HERE> must be enclosed with single quotes.
Currently, using the "su" provided by Magisk, I get away with the alias I described.
@jcmm11 advised me to use
Code:
alias sudo='su -c "[email protected]"'
I remember on an earlier Android, with a different "su", I had to enclose the argument in quotes, which then led to the nightmare of trying to multiply backward slashes when trying to re-issue a command, this time as an argument to "su". On that tablet, I just gave up and switched to "root mode" when I needed to.
When I use "su" in Linux, I don't have to wrap the command in quotes -- it's easy to recall a command, put sudo in front of it, and execute it. (I'm mostly using "ls" and "find", so there's usually no risk of damaging anything.)
I just tried playing with the "[email protected]" construct. In my tests, with
Code:
alias xxx='echo fore "[email protected]" aft"'
The "[email protected]" doesn't seem to do anything:
Code:
xxx asdf
produces
fore aft asdf
Maybe the suggestion was targeting a different shell.
J.Michael said:
Currently, using the "su" provided by Magisk, I get away with the alias I described.
@jcmm11 advised me to use
Code:
alias sudo='su -c "[email protected]"'
I remember on an earlier Android, with a different "su", I had to enclose the argument in quotes, which then led to the nightmare of trying to multiply backward slashes when trying to re-issue a command, this time as an argument to "su". On that tablet, I just gave up and switched to "root mode" when I needed to.
When I use "su" in Linux, I don't have to wrap the command in quotes -- it's easy to recall a command, put sudo in front of it, and execute it. (I'm mostly using "ls" and "find", so there's usually no risk of damaging anything.)
I just tried playing with the "[email protected]" construct. In my tests, with
Code:
alias xxx='echo fore "[email protected]" aft"'
The "[email protected]" doesn't seem to do anything:
Code:
xxx asdf
produces
fore aft asdf
Maybe the suggestion was targeting a different shell.
Click to expand...
Click to collapse
Couple of points, prefaced by the fact that I can't currently test or verify anything.
First of all, about [email protected] Specifically from the documentation for mksh (which is Android's default shell):
Same as $*, unless it is used inside double quotes, in whichcase a separate word is generated for each positional parameter.If there are no positional parameters, no word is generated. [email protected]can be used to access arguments, verbatim, without losing NULLarguments or splitting arguments with spaces.
Magisk switched to ensuring that any startup scripts etc use Magisk's BusyBox commands on order to ensure consistency. I don't however think that su changed the shell to the BusyBox shell (which is ash, the Almquist shell), that would actually be bad for consistency.
For a test try something like:
alias sudo='su -c "[email protected]"'
sudo echo test
and see what happens. It should just return "test".
Personally I've never cared for sudo. I've always just preferred to use su, both on Android and Linux. But that's another discussion entirely.
jcmm11 said:
...
For a test try something like:
alias sudo='su -c "[email protected]"'
sudo echo test
and see what happens. It should just return "test".
...
Click to expand...
Click to collapse
It printed "test"
My problem is that I do not see any evidence that '"[email protected]"' is expanding to anything: I get the same result with or without that construct.
Code:
alias xxx='echo a "[email protected]" b'
alias yyy='echo a b '
I think I am using "sh" as a shell, both in my normal terminal, and when I use "su". (/bin/sh is not a link to toybox, it is a 400KB file)