Binding a tcp port to a block device ? - Galaxy Tab 4 Q&A, Help & Troubleshooting

@Zaphodspeaks
Z,
okay i found a lead here http://stackoverflow.com/questions/...-android-device-failing-to-bind-tcp-port-5037
Android enforces its Internet Permission via a modification to the Linux Kernel which checks that a process is a member of an associated unix group before allowing it to open sockets in the AF_INET domain.
Such membership is inherited, so native code executed, either as a JNI library or by invoking a distinct executable, will only be able to perform network operations if it is either run as a privileged user automatically having this membership (such as adb's "shell" account, or as root on an engineering build) or run under the identify of an application package having the Internet permission in its manifest.
Click to expand...
Click to collapse
i'm going to snoop around the source and se if i can figure out how to tweak android tools source to build a modded adb and daemon and try it out.
interesting side note, even without root as long as adb is insecure you can push and run certain scripts and binaries seemingly outside of security if you work out of /data/local/tmp
for anyone wondering i had a though that maybe i could use the tab's in-house adb to connect to "itself" and achieve a root prompt.
m
EDIT- I found Q&A !!! i think ? umm this is q&a right? xD

This looks promising and fascinating.. If you pull this off, I think you will be the first to ever of done anything like this..

Zaphodspeaks said:
This looks promising and fascinating.. If you pull this off, I think you will be the first to ever of done anything like this..
Click to expand...
Click to collapse
I'd like to try it, i've been working with some simple c programming execises for the last few days
trying to figure out how to get certain system calls to work for miscellanious hooliganery! xD
i found out if you run /init in terminal you will reboot your device to recovery.
i have to re-flash a clean instance of the lp 5.1.1 firmware and then the unsecured boot.img so selinux is still intact,
then push a copy of the init binary to /data/local/tmp via adb and execute it.
if it works , then i have some neat ideas!
m
edit- i also have a new boot image which automatically mounts my debian chroot and exports the $PATH to my gcc
to anyone who needs to mount a custom block device
you need an entry like this in init.environ.rc
# Debian CHROOT
export DEBIAN_ROOT /debian
export TMPDIR /tmp
mount -t proc none /debian/proc
mount -t sysfs none /debian/sys
mount -o bind /dev /debian/dev
mount -o bind /proc/net /debian/proc/net
mount -t devpts none /debian/dev/pts
[this is for mounting my chroot, so all i have to do is run the chroot command itself and all my needed mounts are already in place]
and amend your path and ld library entries
export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/gcc/bin:/system/xbin:/bin:/usr/bin:/usr/sbin
export LD_LIBRARY_PATH /system/lib:/system/gcc/lib:/system/vendor/lib
NOTE TO SELF- pipe the output of strace <command> to text
strace id &> narc.txt

moonbutt74 said:
I'd like to try it, i've been working with some simple c programming execises for the last few days
trying to figure out how to get certain system calls to work for miscellanious hooliganery! xD
i found out if you run /init in terminal you will reboot your device to recovery.
i have to re-flash a clean instance of the lp 5.1.1 firmware and then the unsecured boot.img so selinux is still intact,
then push a copy of the init binary to /data/local/tmp via adb and execute it.
if it works , then i have some neat ideas!
m
Click to expand...
Click to collapse
Damn I wish I had your skills.. Programming is NOT my forte.... Hardware repair and PC diagnostics is what I'm best at..

@Zaphodspeaks
OKAY,
stumbled across something interesting, this will be slightly interrupted as i need to switch to tab for the second part of the post,
[via adb shell]
strace adb shell
one line in particular caught my notice in the output of strace
Code:
connect(3, {sa_family=AF_FILE, path="[COLOR="Red"]/tmp/5037[/COLOR]"}, 12) = 0
back in a minute... okay, i'm on tab from clean reboot,
when running adb shell [remember the above] i get this
Code:
[email protected]:/ # adb shell
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
error: device not found
1|[email protected]:/ #
okay now [with unsecured boot.img] as normal user in tab you cannot do this part, BUT you can via adb shell on pc-side
Code:
mkdir /data/local/tmp/5038
EDITED - see edit below [dammit, i really have to start taking notes]
EDIT
that's maybe a "HIT" of some kind. How to make it work from there i'm not sure yet.
okay i goofed by mkdir 5038 should actually be a link to socket [DERP]
i'll get back to this after some breakfast so as to avoid brain death from overcaffination. xD
i had to edit this, i lost a step somewhere, should have posted all of this from the first time around
I'm trying to understand sockets and pipes, yay!
m

okay
i learnded me how to create a symlink to a socket
ln socket:[5038] /blah-blah/5038 [sort of ]
i'm guessing i need to be looking at how /proc works
for an example in /proc/5743/fd
10 -> socket:[41910]
from http://www.linuxquestions.org/quest...an-i-create-a-socket-file-248399/#post4398605
Lots of misunderstanding here; let's see if I can clarify.
A socket file is not a regular file, it's more like an IP address (it is also not a fifo, although those are similar). A socket file is created by the system when a program calls bind on a unix domain socket, which is a special kind of network socket that can only be internal to one computer. The system then associates this special file with the socket file descriptor that the program bound (or more specifically, the "inode" to which that file descriptor refers).
From that point on, the program that created the socket has no interaction with the socket by the filename. If you move it elsewhere, create new links to it, or remove it, you may confuse other programs that are trying to talk to the program in question, but the program itself won't see it at all. You are only changing the set of names that point at that inode (and you can connect to the listening program at that new name!). Thinking of the filename as a domain name, the inode as the ip address, and the filesystem as DNS isn't so very far off.
Click to expand...
Click to collapse
i'm guessing sock_create is a c thing http://linux.die.net/man/2/socket
i have authbind "working" after getting the source configured for ndk-build , but i don't yet know what a good example of it's usage would be to prove that it functions as it should.

@osm0sis,
okay, as per your instucts , i did this
[email protected]:/ # cat /sdcard/dooby
#!/system/bin/sh
cd /sdcard
setprop service.adb.tcp.port 5555
stop adbd && start adbd
adb connect 192.168.254.42
pwd
adb shell pwd
[email protected]:/ # /sdcard/./dooby
connected to 192.168.254.42:5555
/sdcard
/
[email protected]:/ #
now of i understand this correctly i am connecting to myself via my router, right?
you know, if i remount / and touch this script there and run it with a little modification i can probably create a loop, xD

Sounds fun. Glad to be of service.

Related

[Q] Syslog for Android?

I'm trying to start busybox's httpd at boot w/o success. However, I can start it manually post-boot w/o problems. Can I enable a syslog facility so I can see what happens when the bootup script calls it?
Code:
httpd -p 80 -u 80 -h /sdcard/www -c /etc/httpd.conf
I've tried running the process as -u 80 and as -u 0, both work post-boot, not before.
It's Linux - if there is an rc.local you should be able to drop a string in there to make it start.
KaiserLinux said:
It's Linux - if there is an rc.local you should be able to drop a string in there to make it start.
Click to expand...
Click to collapse
Not that simple
There is no rc.local, but I inserted
Code:
/sbin/syslogd -O /data/log/syslog
into the beginning of init.rc, but it logs nothing.
Go into applications and turn on debugging mode. Plug your phone into your computer and run 'adb logcat' or something to that effect. You can play around with your phone and watch the log scroll by.
Your gonna need the whole ADB setup. Go to the samsung epic 4G wiki and check the article about getting root and flashing a new kernel. This will have the instructions for getting ADB on your system as well.
KaiserLinux said:
Go into applications and turn on debugging mode. Plug your phone into your computer and run 'adb logcat' or something to that effect. You can play around with your phone and watch the log scroll by.
Your gonna need the whole ADB setup. Go to the samsung epic 4G wiki and check the article about getting root and flashing a new kernel. This will have the instructions for getting ADB on your system as well.
Click to expand...
Click to collapse
I've compiled my own rooted kernel and a new busybox with syslogd to see if I can diagnose why bb's httpd isn't starting at boot. As I mentioned, it starts manually w/o a problem. adb logcat isn't very useful in this particular situation. Thanks for the reply though.
jocala said:
There is no rc.local, but I inserted
Code:
/sbin/syslogd -O /data/log/syslog
into the beginning of init.rc, but it logs nothing.
Click to expand...
Click to collapse
I'm kind of a noob myself, but I recall reading that init.rc isn't really a shell script. It has a special syntax that is parsed by Android init, I'm not sure just throwing shell commands in there is going to work. I'd post a link to the doc but I can't post links yet
coldguy said:
I'm kind of a noob myself, but I recall reading that init.rc isn't really a shell script. It has a special syntax that is parsed by Android init, I'm not sure just throwing shell commands in there is going to work. I'd post a link to the doc but I can't post links yet
Click to expand...
Click to collapse
Weird, the first 500 lines of init.rc are nothing BUT shell commands.
i.e. chmod 0666 /dev/input/event0
Anyway, further along in init.rc the daemon processes are started up. syntax looks like:
Code:
service playlogo /system/bin/playlogo
user root
oneshot
I've tried setting up my programs (httpd,syslogd) as services, no joy.
jocala said:
Not that simple
There is no rc.local, but I inserted
Code:
/sbin/syslogd -O /data/log/syslog
into the beginning of init.rc, but it logs nothing.
Click to expand...
Click to collapse
sorry to hijack your post.
but i want to know how do you modify the /init.rc,
because when i reboot, the /init.rc will automatic recovery the old verison.
did you check the /init.rc, is it modified, after your phone reboot?
Does logcat not give you the info you want?
You can go here to find out how to redirect stdout and stderr to the logcat as well.
init.rc is part of the root fs, which is compiled into the kernel. So, a custom kernel is required. Search for custom kernel for details.

[GUIDE] ADB Workshop and Guide for everyone

This workshop was held in #android-learning on irc.freenode.net by XDA Member Adrynalyne. All credit to him for this guide, I simply am taking it and turning it into a guide. Here we go!
You can find the raw IRC log here
Good evening folks, and welcome to my ADB workshop. This is by no means a full explanation on the subject, but more of a crash course to help folks get up to speed, and get more from their devices. There may be some things you already know here, so please be patient and respect those who do not.
Reference Files
http://adrynalyne.us/files/How to install adb.pdf
http://adrynalyne.us/files/Using ADB.pdf
So, lets just start with the basics.
What is ADB?
ADB stands for the android debugging bridge and is used for testing and debugging purposes by developers.
However, we like to get more out of our devices, and its a great way to fix things.
Knowing adb can mean the difference between a paperweight and a working phone.
So, to start with, we will look at installing ADB.
Generally speaking, the Sun/Oracle JDK is required to run all SDK functions.
ADB is but one tool in the SDK arsenal.
So, we begin by downloading and installing the JDK. This can be found here:
https://cds.sun.com/is-bin/[email protected]_Developer
Choose your OS, download and install. I recommend that 64 bit users use the regular x86/32 bit version as well.
Moving ahead, we download the Windows sdk from here:
http://dl.google.com/android/installer_r08-windows.exe
Due to already installing JDK, you won't be stopped by the install process.
Now, if you notice, I installed it to:
C:\android-sdk-windows
I did this because it makes things easier when setting up path variables.
I encourage everyone to do the same, but obviously it is not required.
So, this SDK is handy, but is only good up to 2.2. We want the latest and greatest! (Well I do)
So, we navigate to:
C:\android-sdk-windows\
and we run SDK Manager.exe
If you notice in your PDF file for installing adb, you will notice that you can update, and I made a choice not to include earlier sdk versions.
I won't go into full detail on that, but depending on the version of SDK you have, 8 or 9, it WILL make a difference in using adb.
By default, for version 8 adb.exe resides in C:\android-sdk-windows\tools
By default, for version 9 adb.exe resides in C:\android-sdk-windows\platform-tools
We will assume version 9 in this guide
Really, the SDK is installed and adb is usable right now, but in my humble opinion, its not enough
I like the ability to use adb in ANY directory on my machine.
To do this, we edit Windows's environment variables.
Specifically, the system path.
To do this, we click on start, or the orb (depending on OS), and right click on Computer, left clicking on properties in the menu.
If its windows XP, I believe it brings you into advanced system properties immediatly. Vista and 7 need a second step.
On the left hand side, as you notice I have highlighted in the pdf, left click advanced system settings.
Under advanced tab, we left click environment variables...
There are two boxes here.
We are concerned with system variables, however.
So we scroll down the list and highlight path and click edit.
Ignoring all the extra stuff in here, make sure you are at the end of the line, and type
Code:
;C:\android-sdk-windows\platform-tools
The semicolon allows us to separate it
from the previous path statement.
Click ok all the way out.
We now have ADB setup globally. We can use cmd.exe (I use powershell) and no matter what directory we are in, adb is recognized.
If it is not, make certain you entered the path into system variables, and made no typos.
If you installed to a different location, you will need to adjust the path accordingly.
This concludes the section on installing the Android SDK to use ADB.
This next section will be on using ADB, so please open that pdf now.
Now, this applies to any OS, not just Windows.
Well, with the exception of the USB drivers.
I will not go too much into that, but if you take a look at the PDF, it goes through installing usb drivers for the sdk, and how to download them.
Fiarly straightforward, in that rspect.
Now, to setup our phones to use with the SDK and ADB, we must change some settings.
First, we go to menu softkey, then settings.
We scroll down to Applications and tap it.
Under Development, we will check Enable USB Debugging. Please note the SGS phones are different in this respect.
The USB cable must be unplugged before enabling or disabling this setting.
Once this is done, we are now ready to play with adb
One quick note: If you get device not found/conencted, please reboot your phone. DJ05 has a quirk in it where ADBD randomly crashes on boot.
A reboot will fix this
ADBD= ADB Daemon
Ok, continuing on.
Lets look at installing applications. This is also known as sideloading.
Unlike installing from the SD card, it does not require unknown sources to be enabled.
The command for this is
Code:
adb install packagename
This assumes that you are working from the directory where the file is located.
This will install the application to /data/app.
It will also show sometimes useful errors if install fails.
That is not something you will see from the Android GUI.
Now, a lot of us have probably deleted files with apps like Root Explorer. While this isn't really a bad thing, it leaves behind databases and data for the application removed.
This is where the 0kb applicaiton entries come from.
If you take that application entry name, you can uninstall the extra data via adb.
First we go to the adb shell which logs into the phone.
Code:
adb shell
If we end up with a $, we will want admin rights, in many cases. This is not one of them, I don't beleive.
To get admin rights, you want to type
Code:
su
Look at your phone if this is the first time, it may prompt you to allow access. Else you will get permission denied.
If you are not rooted, this will not work either.
Ok, now that we are logged in, we will type
Code:
pm uninstall packagename
where packagename is the name of the 0kb listing.
Now this seems like a pain in the a** and I agree.
HOWEVER
There will be a time where Manage applications crashes when you try to uninstall it from the phone. In this case, a factory reset, or this method is the only effective way to fix the problem.
Moving on.
How many of us have removed system applications or renamed them? Did you know that you can simply disable them from the system?
Code:
adb shell
su
pm disable appllicationname
This will disable it, and the system will ignore it.
This can be seen as safer than deleting or renaming things, but your mileage may vary.
On the other hand, you can also re-enable these applications.
Code:
adb shell
su
pm enable applicationname
Please note: Not all applications will properly re-enable. I believe a factory reset or reinstall of said application will fix the issue.
Also, application names are absolutely case sensitive.
*nix based Operating Systems see the letter 'a' and 'A' as two different things.
when you log into adb shell, you are playing by android rules
Ok, a lot of us tweak and mod our phones and turning off the device to get to clockwork recovery, or battery pulls, or multiple button holds to get into Download mode are troublesome and annoying at best.
ADB can help us here.
Here, we do not need to be logged into the shell
If we want to merely reboot the phone:
Code:
adb reboot
If we want to go to recovery (works well with voodoo5)
Code:
adb reboot recovery
If we want to go to Download Mode because we need Odin, heaven forbid:
Code:
adb reboot download
Its instant. No waiting on animations or anything else.
Its also handy if Android has locked up, but yet still works in adb.
I for one hate taking my case off to battery pull.
So now we move on to pushing and pulling files.
Sometimes, I don't feel like mounting my sd card to copy a file over to my phone.
I can use this command to push a file straight to my sd card:
Code:
adb push filename /pathtodirectoryonphone
So for instance, if I have test.txt that I want to send, I would type:
Code:
adb push test.txt /sdcard/
and there it goes.
Ok moving on
Pushing files can be done to any directory, however, some are protected.
For instance, /system is going to give you a permission denied or a read only filesystem error.
To get around this, the easiest thing to do is push the file to your sdcard, then log into the shell:
Code:
adb shell
Code:
su
We will then mount the system as writable
Code:
mount -o rw,remount /dev/block/stl9 /system
Then we can use something like
Code:
cp /sdcard/test.txt /system/app/test.txt
cp stands for copy
and it requires the path of the file and destination path. The name of the file is optional
When you copy it, you can rename it to whatever you like.
For instance, if we wanted to backup a file
Code:
cp /sdcard/test.txt /sdcard/backuptest.txt
Now, lets assume you do not have busybox installed.
You non rooted users will not.
Then you must use a slightly more complicated command called dd
This is used like this:
Code:
dd if=/sdcard/test.txt of=/system/app/test.txt
if is for inputfile
of= output file
Not every user friendly, but probably one of the safer copy commands.
Ok, moving on to pulling files.
Lets say you want to get a file from your phone, to modify, backup, etc.
To do this, we simply use adb in this manner:
Code:
adb pull /pathtofile/filename destinationname
For instance, if I wanted to backup ADW launcher in system/app
I would do this
Code:
adb pull /system/app/ADWLaucnher.apk ADWLauncher.apk
And it will pull the file from the phone and put it in the current directory.
Like above, you can specifcy where it goes.
pushing files to the sdcard, it seems prudent to talk about changing permissions.
sdcards are typically fat32, which destroys permisisons, and Android is heavily permission based.
So if you push an application to your sd card, then try to copy it to /system/app/ bad things are going to happen, or the app may not even show up.
So in that case, we use something called chmod.
This is used in this manner
Code:
adb shell
su
chmod 755 /pathtoapplication/applicationname
Keep in mind
you dont want to do this while its still on your sd card.
an example
Code:
adb shell
su
chmod 755 /system/app/ADWLauncher.apk
755 is good for applications and script files.
Just a couple more topics to cover.
Lets go over deleting files.
This becomes especially handy for removing rogue applications.
To do this, we must be in the adb shell.
Code:
adb shell
su
rm /system/app/ADWLauncher.apk
You may need to remount system as writable with:
Code:
mount -o rw,remount /dev/block/stl9 /system
That applies when using chmod as well.
So what I did above was delete ADW Launcher from system/app
However, what if I wanted to delete the entire contents of a directory?
Same thing as before, except
Code:
adb shell
rm -f /data/dalvik-cache/*.*
I just cleared my dalvik-cache with that command
very quick, very effective.
If you just tried that, please reboot your phone now
Ok....this leaves us with the final topic: logcat
logcat allows us to log what the OS is doing, and possibly delve information for when things are not working
its quite simple Reading it is another.
To use logcat
Code:
adb shell
logcat
To logcat to a certain file do
Code:
adb shell
logcat > /sdcard/logcat.txt
Now we let the log settle down to a reasonable amount of data coming in and not a wall of scrolling, then start the app in question. When it gives an error, we hit ctrl-C and kill the adb shell session.
This should have captured enough data to see the error. Now, I prepared an example. A user came to me on IRC, and Google Maps was force closing. Clearing data didnt fix it, Clearing dalvik-cache, and fix permissions did not fix it. In this case, the user did not know how to use adb So I had him grab an app called alogcat from the market and email me the log. This is also a very valid method.
this file explains what the problem was, and highlights what to look for as an example.
http://adrynalyne.us/files/logcat.pdf
___________________________________________________________________
This concludes the guide from Adrynalyne, there will be more workshops such as this one in irc.freenode.net #android-learning.
Thanks to everyone in #samsung-fascinate !
Reserved for possible extension of topic
Great, saves a lot of questions/answers & search
Every new user should read this!!
Thread stuck as valuable reference thread
Just to add, if I may, a little about the permissions...
============================================================
File permissions for Unix... which Android is based, just so those who tinker with the file permissions may know what they are getting into.
============================================================
Use the chmod command to set file permissions.
The chmod command uses a three-digit code as an argument.
The three digits of the chmod code set permissions for these groups in this order:
1.Owner (you)
2.Group (a group of other users that you set up)
3.World (anyone else browsing around on the file system)
Each digit of this code sets permissions for one of these groups as follows. Read is 4. Write is 2. Execute is 1.
The sums of these numbers give combinations of these permissions:
0 = no permissions whatsoever; this person cannot read, write, or execute the file
1 = execute only
2 = write only
3 = write and execute (1+2)
4 = read only
5 = read and execute (4+1)
6 = read and write (4+2)
7 = read and write and execute (4+2+1)
Chmod commands on file apple.txt (use wildcards to include more files)
Command Purpose
chmod 700 apple.txt Only you can read, write to, or execute apple.txt
chmod 777 apple.txt Everybody can read, write to, or execute apple.txt
chmod 744 apple.txt Only you can read, write to, or execute apple.txt Everybody can read apple.txt;
chmod 444 apple.txt You can only read apple.txt, as everyone else.
Detecting File Permissions
You can use the ls command with the -l option to show the file permissions set. For example, for apple.txt, I can do this:
$ ls -l apple.txt
-rwxr--r-- 1 december december 81 Feb 12 12:45 apple.txt
$
The sequence -rwxr--r-- tells the permissions set for the file apple.txt. The first - tells that apple.txt is a file. The next three letters, rwx, show that the owner has read, write, and execute permissions. Then the next three symbols, r--, show that the group permissions are read only. The final three symbols, r--, show that the world permissions are read only.
Compliments and full credit from:
http://www.december.com/unix/ref/chmod.html
Amazing thread just what I needed lol thanks!
cooolone2 said:
Just to add, if I may, a little about the permissions...
============================================================
File permissions for Unix... which Android is based, just so those who tinker with the file permissions may know what they are getting into.
============================================================
Use the chmod command to set file permissions.
The chmod command uses a three-digit code as an argument.
The three digits of the chmod code set permissions for these groups in this order:
1.Owner (you)
2.Group (a group of other users that you set up)
3.World (anyone else browsing around on the file system)
Each digit of this code sets permissions for one of these groups as follows. Read is 4. Write is 2. Execute is 1.
The sums of these numbers give combinations of these permissions:
0 = no permissions whatsoever; this person cannot read, write, or execute the file
1 = execute only
2 = write only
3 = write and execute (1+2)
4 = read only
5 = read and execute (4+1)
6 = read and write (4+2)
7 = read and write and execute (4+2+1)
Chmod commands on file apple.txt (use wildcards to include more files)
Command Purpose
chmod 700 apple.txt Only you can read, write to, or execute apple.txt
chmod 777 apple.txt Everybody can read, write to, or execute apple.txt
chmod 744 apple.txt Only you can read, write to, or execute apple.txt Everybody can read apple.txt;
chmod 444 apple.txt You can only read apple.txt, as everyone else.
Detecting File Permissions
You can use the ls command with the -l option to show the file permissions set. For example, for apple.txt, I can do this:
$ ls -l apple.txt
-rwxr--r-- 1 december december 81 Feb 12 12:45 apple.txt
$
The sequence -rwxr--r-- tells the permissions set for the file apple.txt. The first - tells that apple.txt is a file. The next three letters, rwx, show that the owner has read, write, and execute permissions. Then the next three symbols, r--, show that the group permissions are read only. The final three symbols, r--, show that the world permissions are read only.
Compliments and full credit from:
http://www.december.com/unix/ref/chmod.html
Click to expand...
Click to collapse
Thanks! Added
ih4ckback said:
Amazing thread just what I needed lol thanks!
Click to expand...
Click to collapse
Thanks, all goes to Adrynalyne
Thanks for the guide. Helped me pick out the stupid stupid mistakes I was making...so just a problem. I'm able to use fastboot easily but I seem to be unable to use ADB still on my windows 7. It says there are no devices and I'm dang well sure I have USB debugging on. Is it because Windows 7 is missing drivers for the nexus one or something else?
wonderful guide. I would like to add it to the guides thread.
Really awesome work, thumbs up.
But we should also take a guide on installing adb with Ubuntu/Linux, which isn't a very difficult thing...
mm7490 said:
Really awesome work, thumbs up.
But we should also take a guide on installing adb with Ubuntu/Linux, which isn't a very difficult thing...
Click to expand...
Click to collapse
If I got time tomorrow I could do that. I work primarily in Linux also
Sent from my Samsung Fascinate using Tapatalk Pro
This is good but I have a problem, when I try to remove an .apk file from /system/app it fails and says 'rm failed, Directory not empty'
I have followed exact instructions many time but never succeeded :s any help!!
(I am runnging these commands in device mod)
when I am in recovery mod I get this prompt ~ # and I am not able to enter su mod. how to get rid of this??
Well when the $ changes to # it means you have SU access
mustafa.aziz said:
This is good but I have a problem, when I try to remove an .apk file from /system/app it fails and says 'rm failed, Directory not empty'
Click to expand...
Click to collapse
Please give us the exact command(s) you entered
Here are the commands I entered after adb shell;
su
mount -o rw,remount /dev/block/stl9 /system
rm /system/app/mytouchmusic-signed.apk
exact message returned is 'rm failed for mytouchmusic-signed.apk, Directory not empty'
mustafa.aziz said:
Here are the commands I entered after adb shell;
su
mount -o rw,remount /dev/block/stl9 /system
rm /system/app/mytouchmusic-signed.apk
exact message returned is 'rm failed for mytouchmusic-signed.apk, Directory not empty'
Click to expand...
Click to collapse
Ok i think you need to do a recursive force delete which should be rf but i am not too sure! could somebody please confirm/ correct this?
Well, I don't think so ^^ As he doesn't want to erase a whole directory, but only a file.
What surprises me the most is the returned message... You're trying to delete an apk, and it says it's a directory :/
Could you please give us the output of this :
Code:
su
mount -o rw,remount /dev/block/stl9 /system
ls -l /system/app/mytouch*
Perhaps you don't even need the su and mount lines, but I'm not sure about that, and that can't harm your system ^^
Khoral said:
Well, I don't think so ^^ As he doesn't want to erase a whole directory, but only a file.
Click to expand...
Click to collapse
I know he doesn't want to delete a whole directory, but since the apk isn't compressed perhaps android looks at is as a directory and not a file? i don't know since what was returned suggested that it was a directory i presumed it was a directory! :S
mustafa.aziz said:
Here are the commands I entered after adb shell;
su
mount -o rw,remount /dev/block/stl9 /system
rm /system/app/mytouchmusic-signed.apk
exact message returned is 'rm failed for mytouchmusic-signed.apk, Directory not empty'
Click to expand...
Click to collapse
rm -rf /blah/blah
here is your desired output:
sh-3.2# su
su
sh-3.2# mount -o rw,remount /dev/block/stl9 /system
mount -o rw,remount /dev/block/stl9 /system
sh-3.2# ls -l /system/app/mytouch*
ls -l /system/app/mytouch*
-rw-r--r-- root root 299838 2008-08-01 18:00 mytouchmusic-signed.apk
sh-3.2#

CLI Play

One thing that I really love about Android, is the Gnu/Linux system running in the background. I use Linux on all my regular machines where I do most work via my beloved terminal.
Playing in CLI on Android Phones is just as much fun only Android is missing a lot of the toys I'm used to. So I'm making a collection of some of these tools, some found on the Web and some Home made.
Here if the first collection of the things I've collected so far.
Most of it can be found in different places on the Web, but I find it a lot easier to just get it in one place.
http://dl.dropbox.com/u/14234754/XDA_GLOBAL/android_cli_extras.tar.gz
This small Archive contains the fallowing:
Bash 4.1 - This shell is made to become the default shell on your phone regardless if you connect via SSH or local terminal. Also added an bashrc file.
SSH Shell Client
Remount script - Makes it easier to optain RW on /system (HTC Users will need S-Off)
Nano Editor with terminfo not defined, fix
Init Script to set a user defined hostname and update the hosts file
Now, I don't remember where everything comes from. I believe that the Nano Editor is from the MoDaCo Forum (The terminfo fix is placed in the /system/bin/sh script). The Remount Script is from somewhere on this forum. Bash, I don't remember. SSH Client is from the Better Terminal APK (Perhaps an SFTP client would be nice to). The rest is just some small home made shell scripts.
The Hostname can be changed in /system/etc/init.d/05userinit (Make sure that your current ROM does not already has init scripts to alter hostname. Some custom ROMs do)
The bashrc file is placed in /system/etc/bashrc
This location can be changed in /system/bin/sh
The remount script makes it faster and easier to option RW on /system.
Just type "remount rw" in the shell to switch to Read/Write and then "remount ro" to switch back to Read-only. HTC Users needs S-Off in order to write to /system.
In order to copy the files to the /system partition, you need to option Read/Write without the remount script. In the Shell type "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system". (HTC Users without S-Off will need to do this using ADB in recovery)
If you use the Better Terminal APK for Android, you need to go to settings and make sure that it uses Android Terminal. Otherwise it will use it's own bash which only works when in Better Terminal and also it's full of errors. Also in the option "Command Line" it should be "/system/bin/sh". Make sure that there is NO - at the end, example "/system/bin/sh - ". You might need to remove it twice before it is gone.
(Just in case anyone should wonder. Yes your phone needs to be rooted)
Also if anyone has more fun CLI stuff for android then please bring it

Optware for Android

I was looking for a command line ssh program for Android, and was surprised that I couldn't find anything. I didn't want to install a chroot environment, but then I found Optware for Android. I've used it before on other devices and it's VERY useful for getting a more complete unix environment on otherwise stripped down linux devices.
The version on that page was built for a rooted Nook Color, but I only had to make minor changes to get it to run on an Epic running SRF:
1. Extract miniunz from Barnes and Noble's Nook Color 1.2 update zip and put it somewhere in the path - I put mine at /system/bin. You can get it from the first link here http://www.google.com/search?q=nook+color+1.2+update.
2. Make sure /system has at least 2MB or so free. Mine was full... I deleted a few ringtones from /system/media/audio/ringtones/
3. run this:
mount -o remount,rw /
ln -s /data/tmp /tmp
4. Follow the instructions from the Optware for Android page
Optware will now be installed, but pretty much nothing will run at the moment. I'm VERY new to Android, so I don't know that this is the right way to fix it, but here's what I did to get it working:
1. mount -o remount,rw /system
create /system/xbin/optlinks.sh with these contents:
#!/bin/sh
if [ ! -L /tmp ]; then
mount -o remount,rw /
ln -s /data/opt/lib/ld-linux.so.3 /lib/ld-linux.so.3
ln -s /data/opt /opt
ln -s /data/tmp /tmp
mount -o remount,ro /
fi
create /system/xbin/shell.sh with these contents:
#!/bin/sh
/system/bin/su -c /system/xbin/optlinks.sh
/system/bin/su -c "/opt/bin/bash --login"
2. chmod 755 shell.sh and optlinks.sh
3. Edit /etc/profile and add :/opt/sbin:/opt/bin to the PATH export and :/opt/lib to the LD_LIBRARY_PATH export.
4. Install Jack Palevich's Terminal Emulator from the Market
5. In Terminal Emulator's Prefs, set Initial Command to shell.sh.
I had to put the optlinks.sh part in because that's what optware expects - the Nook has those locations, SRF doesn't. Symlinks seem to work fine, but they disappear on reboot - no idea why - so that's why I run it every time.
Now, when I launch Terminal Emulator, I get a root shell, and can use ipkg install to get anything optware provides. It would be really cool if I the shell was run as a normal (non-root) user, and even better if the optware installer didn't need all the workarounds. Anybody have any ideas?
Tried this on CM 7
First off, thanks!
I tried this on CM 7 nightly (nexus one) and here is what I found:
- Most importantly, it broke root access to other apps on the phone. Not sure if this is due to not being able to update init.rc, may try to sort this out later.
- The goal of the install is to be able to run an SSH server and in addition to that you will have access to optware.
- The default busybox that is included with CM7 does not include adduser, addgroup or passwd applets which will cause things to fail once the install script tries to add a new user. Also, there is an app called "busybox installer" on the market that *will* update busybox, however it depends on libraries that CM7 does not include by default. The result is none of the busybox applets can reach the internet due to not being able to resolve domain names.
If you open the optware-bootstrap-0.0.1.shar file with 7zip, you will see there is a busybox executable included. It's an older version, however it includes what you need. I copied that version to /system/xbin and I was able to use the aforementioned applets
- At the end of my install I received an error that it was unable to edit the ram disk while trying to update init.rc. I think the solution is to add a script to /system/etc/init.d/ . Still working that out.
- I'm probably going to try combining this method with this one: http://android.modaco.com/topic/312...cripts-installing-bash-dropbear-mc-nano-opkg/ Since this is more of a manual method, however it's connecting to a custom optware feed that only has a few packages.
I dont suppose you got anywhere with this?
Looking to install optware on my desire hd running miui rom.

Full Root for Nook Glowlight

It took some doing, but after following the instructions in this link:
http://forum.xda-developers.com/showthread.php?t=2559915
I was finally able to root my Nook Glowlight. The instructions are kind of sprawled out and extremely unclear so I will sum up.
As always, you will need the ADB. In order to install the ADB, you need the Java Development Kit and the Android Studio (formerly known as the Android SDK)
http://www.oracle.com/technetwork/java/javase/downloads/index.html
http://developer.android.com/sdk/installing/studio.html
How to obtain root via ADB: The ONLY way you can root is using Windows. I was successful on Windows 7 32 bit, but it may be possible on other versions.
step 1) install bootloader driver.
You need to grab the drivers from here (bnusbdrivers.zip):
http://forum.xda-developers.com/showpost.php?p=49665945&postcount=279&nocache=1&z=184593200683593
then, open the Device Manager (on Windows). Be ready to right click on the new device 'omap3660' that shows.
With the nook turned completely off, plug in a USB cable. you will have less than 3 seconds to right click the new omap3660 device that shows up in the system profiler.
If you were successful and you right clicked on it in time, manually install the Barnes & Noble USB driver (there are entries added to the generic Google drivers for both the TI Omap 3660 bootloader and the ADB device after you modify the uRamdisk later on)
***NOTE***
If you WEREN'T successful on your first try (took me THREE times to get to it in time), you aren't going to get another chance to install the drivers. At least not easily anyway, because after Windows tries to automatically install the drivers for the bootloader and fails, it will disregard the device any time it shows up after that. So, you are going to need to delete the registry entries that it created, which in my experience was easier said than done. Even admin access was not sufficient to make the necessary changes to the registry.
You will need to launch regedit.exe using another tool called psexec which is available here:
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
after you download the pstools package, copy those .exe files to C:\Windows\System32\ (in order to add them to $PATH in cmd.exe)
Then, once you've installed the pstools commands to C:\Windows\System32\, run cmd.exe as admin (right click it and select 'run as administrator') and then open regedit.exe with the following command
Code:
psexec -s -i -d regedit.exe
Then, once regedit is open you need to find the keys created by the Nook bootloader and delete them. The Nook bootloader's device ID is 0451:d00e
You are going to be looking in HKEY_LOCAL_MACHINE\Current Control Set\enum\usb\ for the keys with the bootloader's device IDs. There may also be keys generated in control set 001 and 002 as well. Delete all of those keys and then reboot your computer. Then with the nook power off completely, repeat the process from the first step. eventually you will be successful installing the bootloader driver.
Step 2) temporarily boot with uRamdisk-noogie
you need to download omaplink.exe from here:
http://www.temblast.com/android.htm
and you also need to download the four files which allow you to temporarily mount the boot partition; omap3_aboot.bin, u-boot-ng2-exp-v03.bin, uImage-ng2-130-stk and uRamdisk-noogie.
They are available here:
http://forum.xda-developers.com/showpost.php?p=49779966&postcount=285
download usbboot-ng2-images-noogie-v1.zip
The next part is easy.
Extract the .zip file and then fire up cmd.exe. cd into the directory of the newly extracted .zip
in the new working directory, enter the command
Code:
omaplink omap3_aboot.bin u-boot-ng2-exp-v03.bin uImage-ng2-130-stk uRamdisk-noogie
Then, with the Nook powered all the way off and omaplink running, plug it in and a few seconds later, after the device boots up all the way, you will be looking at the contents of the boot partition instead of the internal storage like normal.
Step 3) Edit uRamdisk
you will need to download bootutil.exe from here
http://www.temblast.com/android.htm
copy bootutil.exe to C:\Windows\System32
with the boot partition mounted, copy uRamdisk to your computer and extract the files init.rc and default.prop, eg;
Code:
bootutil /x /v uRamdisk init.rc default.prop
then using notepad++ (available here: http://notepad-plus-plus.org/) edit the files as follows
default.prop
ro.secure=0
ro.allow.mock.location=1
ro.debuggable=1
persist.service.adb.enable=1
and
init.rc
comment out lines 375 and 392-399
(do this by adding a # to the beginning of the line)
uncomment line 215
(do this by deleting the # at the beginning of the line)
save both files and then repack them into uRamdisk
Code:
bootutil /r /v uRamdisk init.rc default.prop
copy uRamdisk back onto the Nook, eject the disk and power off the device. Reboot and you should be able to connect to ADB via WiFi
eg;
Code:
adb connect 192.168.0.10
replacing '10' with whatever IP your Nook is grabbing from your router.
Step 4) Full Root
at this point, you have root access via ADB only. You will not have root access in any apps like Root Explorer, Terminal, TiBackup, etc.
In order to finish PROPERLY rooting your Nook, you need to install 'su' to /system/bin/ and install the superuser.apk
Code:
adb connect 192.168.0.10
adb shell mount -o remount, rw /system
adb push su /system/bin/
adb shell chmod 6755 /system/bin/su
adb install superuser.apk
reboot your device one more time and then you will be fully rooted.
*** Note ***
this devices firmware seems to be a strange hybrid between donut and eclair, although it purports itself to be Android 2.1. The Superuser.apk and su binary came from an old Cyanogenmod 4.6 build in case anyone was wondering (Android Donut). The ones from Cyanogenmod 5 (Android Eclair) do not work. you will get the 'install failed older sdk' error.
installing busybox
I tired installing busybox by using the stericson busybox pro.apk. It would always freeze at 6.47%.
I figured out that if I grabbed an older version of the busybox binary and pushed it to /system/xbin manually and then chmodded it to the proper permissions, auto updates and proper symlinking work using the busybox app
Code:
adb shell mount -o remount, rw /system
adb shell mkdir -p /system/xbin
adb push busybox /system/xbin
adb shell chmod 6755 /system/xbin/busybox
adb install busybox.apk
Then reboot, and run the busybox app to update and create symlinks.
enjoy!
installing nano and bash
Code:
adb connect 192.168.0.10
adb shell
mount -o remount, rw /system
adb push nano /system/xbin/
chmod 6755 /system/xbin/nano
adb push bash /system/xbin/
chmod 6755 /system/xbin/bash
bash
mv /system/bin/sh /system/bin/sh.bak
ln -s /system/xbin/bash /system/bin/sh
chmod 6755 /system/bin/sh
adb push profile /system/etc/
adb push terminfo /system/etc/
and then in terminal emulator under 'Preferences' change the initial command to
Code:
export TERMINFO=/system/etc/terminfo;export TERM=linux;export HOME=/sdcard;
and finally
Code:
adb push bashrc /sdcard
adb shell
mv /sdcard/bashrc /sdcard/.bashrc
exit
nano works just fine via ADB, but because of lack of 'ctrl' key (and physical buttons to assign it to) you won't be able to write files (ctrl+o) using the terminal on your nook. But between having full proper root access, busybox, a proper bash terminal emulator and nano for editing config files, this should REALLY extend the usefulness of your Nook Glowlight. It should work just fine on other versions of Nook too.
Hi N00b-un-2,
Many thanks for your summary!
There is one important edit that I think you missed,
in init.rc you also need to:
Line #375, comment out "disabled" with a # at the start of the line.
(see http://forum.xda-developers.com/showthread.php?p=49070213#post49070213)
without this I couldn't get adb to connect.
And since you already made it very noob friendly, might I suggested you clarify:
Line #215 remove # to enable adb over wifi
(rather than search for 5555)
Also, I'm not expert, but I believe the commands to get superuser on the device are (at least it worked for me):
adb connect 192.168.x.x
adb shell mount -o remount, rw /system
adb push su /system/bin/
adb shell chmod 6755 /system/bin/su
adb install superuser.apk
Finally, I'm not sure if this is important, but maybe remount system as read only again:
adb shell mount -o remount, ro /system
Thanks again, nice work!
---------- Post added at 01:48 PM ---------- Previous post was at 01:10 PM ----------
Hi again,
had similar issues with installing busybox, here's what worked for me (note needed to run su to create dir):
adb shell mount -o remount, rw /system
adb shell /system/bin/su
adb shell mkdir -p /system/xbin
adb push busybox /system/xbin
adb shell chmod 6755 /system/xbin/busybox
adb install busybox.apk
cheers.
As far as remounting /system as ro, I would HIGHLY recommend just rebooting at this point, otherwise your nook might be stuck in a weird pseudo-rooted state. Probably won't cause any problems, but why risk it?
Thanks for clarifying the line number. I will make the appropriate edits to my instructions. I was working off the top of my head and couldn't remember what exact line the ADB over TCP config was, as I just used ctrl+w '5555' to find it myself.
There are several pre-edited uRamdisk images floating around the forum with various features enabled which would be easier for noobs than extracting the config files and manually editing and then repacking them. In the future I'll probably throw those on here as well.
darz said:
Hi N00b-un-2,
Many thanks for your summary!
There is one important edit that I think you missed,
in init.rc you also need to:
Line #375, comment out "disabled" with a # at the start of the line.
(see http://forum.xda-developers.com/showthread.php?p=49070213#post49070213)
without this I couldn't get adb to connect.
And since you already made it very noob friendly, might I suggested you clarify:
Line #215 remove # to enable adb over wifi
(rather than search for 5555)
Also, I'm not expert, but I believe the commands to get superuser on the device are (at least it worked for me):
adb connect 192.168.x.x
adb shell mount -o remount, rw /system
adb push su /system/bin/
adb shell chmod 6755 /system/bin/su
adb install superuser.apk
Finally, I'm not sure if this is important, but maybe remount system as read only again:
adb shell mount -o remount, ro /system
Thanks again, nice work!
---------- Post added at 01:48 PM ---------- Previous post was at 01:10 PM ----------
Hi again,
had similar issues with installing busybox, here's what worked for me (note needed to run su to create dir):
adb shell mount -o remount, rw /system
adb shell /system/bin/su
adb shell mkdir -p /system/xbin
adb push busybox /system/xbin
adb shell chmod 6755 /system/xbin/busybox
adb install busybox.apk
cheers.
Click to expand...
Click to collapse
N00b-un-2 said:
There are several pre-edited uRamdisk images floating around the forum with various features enabled which would be easier for noobs than extracting the config files and manually editing and then repacking them. In the future I'll probably throw those on here as well.
Click to expand...
Click to collapse
Would have been good if I could have easily found a pre-edited image, but your instructions were a great alternative, thanks again
darz said:
Would have been good if I could have easily found a pre-edited image, but your instructions were a great alternative, thanks again
Click to expand...
Click to collapse
Sorry for the really noob question, I have rooted, wifi adb running and installed apps as per your instructions, but I can't seem to access any of it on the nook. How can I get access to the launcher I installed?
You mentioned pre-edited images, do any of those come with the apps I need to get access to a custom launcher?
Cheers,
Dariusz
==============
Updated: All sorted
==============
For some reason had some issues with ADW launcher, Launcher pro worked fine.
ps I think I made a mistake with the su step I suggested, if you run a one line shell command I don't think it keeps su privileges, so I believe you need to run commands within the shell as per below:
adb shell
mount -o remount, rw /system
/system/bin/su
mkdir -p /system/xbin
exit
adb push busybox /system/xbin
adb shell chmod 6755 /system/xbin/busybox
adb install busybox.apk
Noob
Hey guys any instructions noob friendly or a video in youtube,i stick up at dab connect 192.168.0.10.I dos't have a Windows PC and using Mac whit Parallels Desktop.Is it possible instructions for Mac?
The above instructions from N00b-un-2 should work fine running a vm with parallels on your Mac.
OB
Sent from my SPH-D710VMUB using Tapatalk 2
valentin1985 said:
Hey guys any instructions noob friendly or a video in youtube,i stick up at dab connect 192.168.0.10.I dos't have a Windows PC and using Mac whit Parallels Desktop.Is it possible instructions for Mac?
Click to expand...
Click to collapse
Before you perform the adb connect step you need to find out what your IP address is:
On your nook, click on the settings icon in the top right corner and then select "Change"
Under Wireless Networks, select the wifi name that you are already connected to (where it says "Connected to the internet")
This will display your connection details, remember that IP address
Now go back to your pc and type:
adb connect [IP address]
darz said:
Before you perform the adb connect step you need to find out what your IP address is:
On your nook, click on the settings icon in the top right corner and then select "Change"
Under Wireless Networks, select the wifi name that you are already connected to (where it says "Connected to the internet")
This will display your connection details, remember that IP address
Now go back to your pc and type:
adb connect [IP address]
Click to expand...
Click to collapse
BIG HINT! If you're using Powershell ISE, you have to type .\adb.exe connect [IP address] or else it won't recognize "adb" as an executable!
Don't ask why, because I don't know. :?
thenookieforlife3 said:
BIG HINT! If you're using Powershell ISE, you have to type .\adb.exe connect [IP address] or else it won't recognize "adb" as an executable!
Don't ask why, because I don't know. :?
Click to expand...
Click to collapse
So far so good,but now what?
valentin1985 said:
So far so good,but now what?
Click to expand...
Click to collapse
I just gave a little tip on Powershell ISE. I do not know much about the Nook GlowLight rooting process, as I have a NSTG, not a NG. Ask someone else.
thenookieforlife3 said:
I just gave a little tip on Powershell ISE. I do not know much about the Nook GlowLight rooting process, as I have a NSTG, not a NG. Ask someone else.
Click to expand...
Click to collapse
Yes,i try whit dis command .\adb.exe connect 192.168.0.9 but result is the same.
valentin1985 said:
Yes,i try whit dis command .\adb.exe connect 192.168.0.9 but result is the same.
Click to expand...
Click to collapse
But that's okay! What I said was, if you are using the command program Powershell ISE, do it that way instead. But you are just using cmd.exe, not Powershell ISE!
In cmd.exe, which is what you are using, it is not neccessary to type .\adb.exe. Just type adb.
From there, ask someone else in this thread.
thenookieforlife3 said:
But that's okay! What I said was, if you are using the command program Powershell ISE, do it that way instead. But you are just using cmd.exe, not Powershell ISE!
In cmd.exe, which is what you are using, it is not neccessary to type .\adb.exe. Just type adb.
From there, ask someone else in this thread.
Click to expand...
Click to collapse
I prefer to use ConEmu or Console2 when I am forced to use Windows. Not a big fan of CMD.EXE or Powershell/PowershellISE. there are plenty of other CLI alternatives out there
N00b-un-2 said:
I prefer to use ConEmu or Console2 when I am forced to use Windows. Not a big fan of CMD.EXE or Powershell/PowershellISE. there are plenty of other CLI alternatives out there
Click to expand...
Click to collapse
Well, as I ONLY use Windows and Powershell ISE has a nice-enough layout for my purposes, I use it. That's why I gave a tip on it.
Actually on a lot of installs just typing adb in the command console won't work either unless it's got the path variable set up correctly, I find it easiest to just right click and choose run as administrator, no need for the path to be setup.
OB
Sent from my SPH-D710VMUB using Tapatalk 2
FW 1.2.1
Hi guys,
thanks for creating this thread. I was wondering if this rooting procedure was tested with the firmware 1.2.1 ?
real-6 said:
Hi guys,
thanks for creating this thread. I was wondering if this rooting procedure was tested with the firmware 1.2.1 ?
Click to expand...
Click to collapse
This rooting procedure is for the new Nook GlowLight with firmware 1.3.1. Your device is a Nook Simple Touch with GlowLight, which can be rooted very easily using the rooting package here.

Categories

Resources