Hi All,
I am writing a batch script to perform functions via ADB to set up our devices.
The device is rooted, and i can do the following via ABD:
adb root
adb remount
adb shell
sqlite3 /data/system/locksettings.db
sqlite3> update locksettings SET value='1' where name='lockscreen.disabled';
sqlite> .quit
There is not issue so far, and this works to disable the screen lock from swipe to "none"
Here is the issue, I have created a batch file, which processes all the various commands I have, which works perfectly, the problem is i cannot execute that as one command I.E.
adb shell sqlite3 /data/system/locksettings.db update locksettings SET value='1' where name='lockscreen.disabled';
This fails, i have tried various syntax changes but i get and error of TO MANY OPTIONS FOR LOCKSETTINGS
any thoughts or solutions would be most appreciated.
Kind regards
Anthony Aveley
AnthonyAveley said:
Hi All,
I am writing a batch script to perform functions via ADB to set up our devices.
The device is rooted, and i can do the following via ABD:
adb root
adb remount
adb shell
sqlite3 /data/system/locksettings.db
sqlite3> update locksettings SET value='1' where name='lockscreen.disabled';
sqlite> .quit
There is not issue so far, and this works to disable the screen lock from swipe to "none"
Here is the issue, I have created a batch file, which processes all the various commands I have, which works perfectly, the problem is i cannot execute that as one command I.E.
adb shell sqlite3 /data/system/locksettings.db update locksettings SET value='1' where name='lockscreen.disabled';
This fails, i have tried various syntax changes but i get and error of TO MANY OPTIONS FOR LOCKSETTINGS
any thoughts or solutions would be most appreciated.
Kind regards
Anthony Aveley
Click to expand...
Click to collapse
Hi Anthony
Please, feel welcome to access our experts at the below forum as they should be able to tackle your question.
Android Development and Hacking > Android General
Nice regards, good luck and mainly, have fun.
.
Related
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
i think that if you do:
su (to get superuser privileges)
sh your_script.sh
might work....
alternative is to install gscript and put your script in the gscript folder on sdcard....
The console needs to be granted superuser access, then ran as sh script.sh or bash script.sh. afaik at least. Youll probably have to use su like the person above said.
I did the su command. But i still can't open it. All other commands work.
Ok so it sorta worked.
I used the cd command to get to the file.
I used su command.
Then i typed sh script.sh .
Nothing happened, no echo or anything, just a new line with # on it.
What's happening.
Btw thanks for the replies.
krutle said:
I did the su command. But i still can't open it. All other commands work.
Click to expand...
Click to collapse
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
krutle said:
I did the su command. But i still can't open it. All other commands work.
Click to expand...
Click to collapse
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
ryocoon said:
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
Click to expand...
Click to collapse
This should be the solution. X is the execute bit. Basically without that bit set on the file permissions, the OS won't allow that file to be executed as a program.
chmod +x filename.sh
Try running that command in terminal emulator and it should clear things up.
Sent from my Inspire 4G using XDA App
I used that command and it said 'bad mode'.
It still doesn't work.
If you are running the script with this:
Code:
sh script.sh
then the executable bit doesn't need to be set in order to execute it, since you are specifying 'sh'. If you were trying to run it with this:
Code:
./script.sh
then it would require the executable bit to be set.
In an attempt to answer the question, where abouts is your script saved and which user owns it? Just as a quick test on mine, I made a script named test.sh (containing the same lines as yours) on the root of my sd card, cd'd to it and ran sh test.sh, and that seemed to work. That script ended up being owned by 'system'.
As a test to make sure sh is behaving, can you run the following from the terminal:
Code:
sh -c 'echo hello'
EDIT: note that all of the above was run as a regular user, not root.
Yeh it said hello when i did the command you said.
It must be a problem with the file in some way then. Can you run the following from the folder that your script is in and give the output?
Code:
ls -l | grep script.sh
Also, what did you use to make the script - terminal in Android, or adb'd it from your PC etc?
(Aside: just a thought, you probably can't do chmod's on sdcard files if it's formatted to FAT32 since FAT32 doesn't understand Linux permissions)
you can also try an app i found some time ago. SL4A
I made the file with silveredit. Just renamed .txt to .sh.
Btw i got it working with gscript, thanks for everyone's help
Run a reverse tethering shell script
I am trying to run a reverse tethering shell script using Android terminal Emulator(ATE). The script is saved as tether.unicode.sh under /sbin/. Its content is as follows:
Code:
ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
route add default gw 192.168.137.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.grps.http-proxy" ""
I executed the following command in ATE and got error.
Code:
$su
#sh /sbin/tether.unicode.sh
ifconfig: not found
netmask: not found
255.255.0: not found
..
#
Excuse me posting in this very old thread. I hope its better to continue here instead of opening a new thread.
P.S: I am able to execute all this statements by copying and pasting line by line in ATE.
nok2626 said:
I am trying to run a reverse tethering shell script using Android terminal Emulator(ATE). The script is saved as tether.unicode.sh under /sbin/. Its content is as follows:
Code:
ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
route add default gw 192.168.137.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.grps.http-proxy" ""
I executed the following command in ATE and got error.
Code:
$su
#sh /sbin/tether.unicode.sh
ifconfig: not found
netmask: not found
255.255.0: not found
..
#
Excuse me posting in this very old thread. I hope its better to continue here instead of opening a new thread.
P.S: I am able to execute all this statements by copying and pasting line by line in ATE.
Click to expand...
Click to collapse
it's because android doesn't know about these command, this is a native linux command, try to install busybox, edit your script like this
Code:
busybox ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
busybox route add default gw 192.168.137.1 dev usb0
busybox setprop net.dns1 8.8.8.8
busybox setprop "net.grps.http-proxy" ""
I hope these helpfull
krutle said:
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
Click to expand...
Click to collapse
Even though your device is rooted, android environment won't allow applications to execute 'sh' commands.
As android security architecture says, applications run within a secured execution space inside Application Sandbox, sh execution can bypass this security.
If there are any exceptional cases where few devices allow 'sh' execution, well... OEM's needs to be reviewed again.
Answer
Maybe you can try the method that I have specified and check whether it works
http://forum.xda-developers.com/showthread.php?t=2620394
krutle said:
Ok so it sorta worked.
I used the cd command to get to the file.
I used su command.
Then i typed sh script.sh .
Nothing happened, no echo or anything, just a new line with # on it.
What's happening.
Btw thanks for the replies.
Click to expand...
Click to collapse
the script is already run and no need to type the command again, note: some script files can damage your system if run twice
krutle said:
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
Click to expand...
Click to collapse
You have to put the script somewhere that it has permission to execute from, copy it to /data/local/tmp first. Then in your terminal run each of these commands;
su
cd /data/local/tmp/
chmod 0755 MyScriptName.sh
./MyScriptName.sh
When I CD to the platform-tools folder and type
Code:
adb devices
it says "adb: command not found" If anyone could help me that would be wonderful. I am on the Inspire/DesireHD running AOSP Gingerbread. Thanks!
You have two choices. You can either run the command prefixed with ./ (dot slash), which allows for executing an executable in the current directory:
Code:
./adb devices
Or, the other choice (which will be better if you intend to use adb a lot) is to add the platform-tools folder to your path by editing or creating the file .bashrc in your home folder (~/.bashrc).
Let's suppose your platform tools folder is: ~/.android-sdk/platform-tools
Then, you would want to add something along the lines of the following to your bashrc:
Code:
export PATH="$PATH:$HOME/.android-sdk/platform-tools"
Save the file, the run this or log out/in:
Code:
source ~/.bashrc
Et voila, you should now be able to run adb from any folder without issue.
Explanation: adding the new path (folder) to your PATH environment variable tells BASH to include that folder in its search for an executable. The reason $PATH is added at the beginning of the new string is so that your default path does not get overwritten. $HOME will simply expand to /home/your_user_name when BASH interprets it.
GENIUS! IT WORKED! Thank you! Now, one more question- how do I get superuser privileges using ADB? (device is rooted, of course)
No problem.
On my G1 you were root as soon as you adb'd in. Just tested on my Defy and '$' - shocking. So once you have run adb shell, just run 'su' (without quotes of course) and accept the permission on your phone screen as usual for root programs and you should be good to go.
Sorry to keep asking questions, but when I typed
Code:
su
into adb, it asked for a password. No popup on device screen. I do have superuser installed on the device.
That is odd. I'm not sure why that would be. I'll see if I can think of something though. Hopefully someone else can make a suggestion.
Thanks! You have been very helpful.
Don't think I can hit the thanks button from the app, sorry
Sent from my Inspire 4G using XDA App
I am not responsible for anything that may come of or from this information. Use at your own risk!
Step #1)
Create security lock through Settings (pattern, pin, password).
Step #2)
Add VPN connections
Step #3)
Plug the phone in and run these commands (requires adb to be setup properly and drivers). I am sure there is a way to do this directly on the phone but this is easier for me.
Commands to remove security:
Code:
adb shell
sqlite3 /data/system/locksettings.db
update locksettings set value=0 where name='lockscreen.password_type';
.exit
exit
Finished!
For me no reboot was required and you do not have to restore pattern in order to create more VPN connections.
Optional Step:
If you decide that you want to restore the security run the one that fits you.
Commands to restore pattern:
Code:
adb shell
sqlite3 /data/system/locksettings.db
update locksettings set value=65536 where name='lockscreen.password_type';
.exit
exit
Commands to restore pin:
Code:
adb shell
sqlite3 /data/system/locksettings.db
update locksettings set value=131072 where name='lockscreen.password_type';
.exit
exit
Commands to restore password:
Code:
adb shell
sqlite3 /data/system/locksettings.db
update locksettings set value=262144 where name='lockscreen.password_type';
.exit
exit
Great! Thank you!
really helpful, i've been fed up with stupid design.
Brilliant, does it also work for ICS?
I don't have an ICS device. If I can find someone that is willing to let me take a look at their ICS device I can see.
When I restart my phone, it needs a password to access VPN menu. what should I do? I don't want to run these commands every time I restart my phone. any solutions?
does it work with exchange password policy as well?
Sent from my GT-I9300 using xda app-developers app
P30SiNa said:
When I restart my phone, it needs a password to access VPN menu. what should I do? I don't want to run these commands every time I restart my phone. any solutions?
Click to expand...
Click to collapse
Hmm did notice that before I will see whats up with that,
portnoy.vitaly said:
does it work with exchange password policy as well?
Sent from my GT-I9300 using xda app-developers app
Click to expand...
Click to collapse
I am not sure but I would imagine so. I would try with pattern lock and not PIN or Password.
Says that "sqlite3: not found" ....
I justd used Forget password option and entered pin , then i didnt choose any options , and the pattern removed
Just tried this. Added vpn, removed lock pattern. It went back to slide, worked fine.
Rebooted, not visiting VPN settings it's asking me to enter credential storage...any ideas how I can a) get past this without wiping my wifi/vpns, or b) remove this but keep my vpns and slide lock?
sorset said:
Says that "sqlite3: not found" ....
I justd used Forget password option and entered pin , then i didnt choose any options , and the pattern removed
Click to expand...
Click to collapse
Same here.
Works great, thanks for sharing :good:
spumanti said:
Same here.
Works great, thanks for sharing :good:
Click to expand...
Click to collapse
Works for me, too, until I reboot :/
Doesn't work. Apparently it's problem with sqlite.
soinfo_relocate(linker.cpp:1013): cannot locate symbol "sqlite3_enable_load_extension" referenced by "sqlite3"...CANNOT LINK EXECUTABLE
Any help please?
Use Script Manager to make this done on every boot.
1. Make this a batch file:
Code:
#!/system/bin/sh
echo "update locksettings set value=0 where name='lockscreen.password_type';" | sqlite3 /data/system/locksettings.db
and save it to your sdcard
2. Use Script Manager to run it on boot and enable su (root).
3. Test it by running it from script manager and see if it runs correctly. You can try enabling PIN and it should be disabled after running this.
4. Final test: reboot your phone and see if PIN/password is disabled.
Keep in mind this gets executed after everything else, so if you try to wake your phone right away, you might still see the PIN prompt.
Another way without script manager:
1. Make this a batch file:
Code:
#!/system/bin/sh
echo "update locksettings set value=0 where name='lockscreen.password_type';" | sqlite3 /data/system/locksettings.db
and save it to your sdcard as 99pinremove
2. Run the following using adb:
Code:
adb shell
su
mount -o remount rw /system
cp /sdcard/99pinremove /etc/init.d/99pinremove
chmod 755 /etc/init.d/99pinremove
chown root:shell /etc/init.d/99pinremove
exit
exit
In 4.4 there is no such file
Code:
/data/system/locksettings.db
.. any ideas?
Here's (almost) the process I used
change settings on device
"Unknown Sources"
"USB Debugging"
Find which device is mounted as "/system"
On my stock ICS .26 system this is "/dev/block/mmcblk0p1", but this might be something different (?)
adb shell mount | grep " /system"
copy files to device
copy debugfs to device
adb push debugfs /data/local/
copy su to device
adb push su /data/local/
copy debugfsinput to device
adb push debugfsinput /data/local/
setup temp directory
rename /data/local/tmp to /data/local/tmp.bak
make a new /data/local/tmp that is a symlink to /system device (as determined in step B)
ln -s /dev/block/mmcblk0p1 /data/local/tmp
reboot tablet
mark debugfs program executable
adb shell chmod 777 /data/local/debugfs
run debugfs using "/data/local/debugfsinput" script
adb shell "/data/local/debugfs -w /dev/block/mmcblk0p1 < /data/local/debugfsinput"
cleanup
remove /data/local/tmp symlink
move /data/local/tmp.bak to /data/local/tmp
remove /data/local/su
remove /data/local/debugfs
remove /data/local/debugfsinput
reboot
test superuser (see if "su" command works [no output, especially no error message])
install superuser app
adb install Superuser.apk
One thing I did different in some places was to just do "adb shell", and then issue commands one-by-one in the remote shell.
Related threads:
How to root TF700 Jelly Bean from Linux without unlocking?
[description of process updated and moved to first post]
It occurs to me that steps D through J should be doable on the device using the Terminal Emulator app that I've got installed.
Thoughts, anyone? See any dangerous pitfalls ahead on the path I'm about to undertake?
I'm going to hold off on actually doing this until tomorrow. This will to give people a chance to respond, and I need to attend to other matters (dinner, chores, etc...)
bsammon said:
It occurs to me that steps D through J should be doable on the device using the Terminal Emulator app that I've got installed.
Click to expand...
Click to collapse
Another thought.... step C obviously doesn't need adb, and step K could be done with the "pm" command in the Terminal Emulator.
It seems I could do this without using adb at all--- not sure why I'd bother, unless I have problems getting it to work, or just to prove that I can.
I rooted my TF700 under Linux by reading the batch file and doing the steps manually - similar as you describe in your second post, but I even typed the input to debugfs manually. The whole process depends on getting at least "shell" user access, so I am not sure that it could be done without adb - a local terminal app would run under its own, more restricted user account.
_that said:
I rooted my TF700 under Linux by reading the batch file and doing the steps manually - similar as you describe in your second post, but I even typed the input to debugfs manually. The whole process depends on getting at least "shell" user access, so I am not sure that it could be done without adb - a local terminal app would run under its own, more restricted user account.
Click to expand...
Click to collapse
There is also a shell script version around for that famous rooting batch file. Technically obviously the same as reading the commands and typing them manually ... but still
FordPrefect said:
There is also a shell script version around for that famous rooting batch file. Technically obviously the same as reading the commands and typing them manually ... but still
Click to expand...
Click to collapse
But doing it manually is so much more l33t.
FordPrefect said:
There is also a shell script version around for that famous rooting batch file. Technically obviously the same as reading the commands and typing them manually ... but still
Click to expand...
Click to collapse
Got a link?
So I just spent a few hours digging into this and thought someone might need it sometime down the line.
My wife's job uses a Kindle Fire HD 10 and they have a parental lock on it. Today they needed to change a Wi-Fi setting and couldn't remember the lock password.
The following tutorial will use adb to temporarily root your Fire, update the database to corrupt the lock, and create a new Parental Lock.
What you'll need:
ADB
mtk-su (Download from the first post here, don't worry about using their tutorial since I'll reiterate it here)
1. After you download mtk-su, push it to your device
Code:
adb push path/to/mtk-su /data/local/tmp/
2. Open an adb shell and cd to the data/local/tmp folder
Code:
adb shell
cd /data/local/tmp
3. Write executable permissions to the script
Code:
chmod 755 mtk-su
4. With the screen on, run the script:
Code:
./mtk-su -v
5. You should now be at a root shell (you can tell by the # instead of the $ symbol). Read the mtk-su thread for debugging if you don't get a root shell.
6. Get to your databases folder:
Code:
# cd /data/data/com.android.providers.settings/databases
7. Send some commands to your settings.db to overwrite those parental password values:
Code:
sqlite3 settings.db "insert into secure values(NULL,'parental_password_exist', '0');"
sqlite3 settings.db "insert into secure values(NULL,'parental_control', '0');"
sqlite3 settings.db "insert into secure values(NULL,'com.amazon.parentalcontrols.changed', '0');"
8. Delete the original password salt and key files via:
Code:
rm ./data/securedStorageLocation/com.amazon.parentalcontrols/files/*
9. Congrats, your parental controls are now corrupted! Your WiFi, among other things probably, will not work! Head over to your Settings and click on Parental Controls. Turn them on and create a new password. Now everything will work again.