Scripts for Nautilus (Linux file browser) - Android Software/Hacking General [Developers Only]

Hello !
I wrote some scripts for easily pushing and installing files/apks to your android device.
The advantage over "command line" and other scripts like mine :
- Multiple selection allowed (install 100 APKs in one click ! )
- You have a progress bar (shows only the progression between multiples files/ not the state of a single pushing).
- You can choose the destination on your phone with a simple prompt by choosing "Push to ..."
- It's a very simple and lightweight nautilus script...
- You don't have to (in fact, you can't) put the usb in "usb disk" mode, just have debugging enabled.
Examples
To simply install some applications, just select them, right click, go to scripts->ADB->install
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Progression :
Idem for files :
Progress :
Confirmation :
(So the "Push to ..." allow you to choose a destination. "Push to musique" is just a copy of "Push to sdcard" with the second line of the script changed to copy files to /sdcard/music/ instead of /sdcard/ )
How to install
- Download the scripts :
http://www.itstudents.be/~tom/android/ADB Scripts for Nautilus.tar.gz​- Uncompress the files in ~/.gnome2/nautilus_scripts/ADB/
So if your name is mario, you should copy the 3 files to :
/home/mario/.gnome2/nautilus-scripts/ADB/
You are not obliged to make the last folder named ADB, it's just to make "categories" in the Nautilus script menu (like in the screenshots)​
Requirements
- A correctly installed ADB
What is a correctly installed ADB?
- The PATH environment variable has to be set, to be able to just type "adb" and not "/path/to/sdk/platform-tools/adb". If it's not done :
Edit the file ~/.bashrc , you can do that by typing in the console
Code:
gedit ~/.bashrc
and add this line changed for yourself at the end of the file
Code:
export PATH=${PATH}:/path/to/android-sdk-linux_86/platform-tools/
Or, if this does'nt work :
Edit the file /etc/environment , you can do that by typing in the console
Code:
gedit /etc/environment
and add this text changed for yourself at the end of the line "PATH:", before the last ["]
Code:
:/path/to/android-sdk-linux_86/platform-tools/
- The rules for udev have to be made to allow any non-root user to access to the device
Method for any HTC device :
Edit with root rights the file /etc/udev/rules.d/51.android.rules by typing in the console :
Code:
gksudo gedit /etc/udev/rules.d/51.android.rules
and add the lines :
Code:
SUBSYSTEM=="usb|usb_device", SYSFS{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
Hope you'll enjoy !
Please correct my english

don't want people to know what you're listening to, eh?
It's cool; I like it.

very useful
thanks man

I've been wanting to do something like this but never had time to. Will definitely test this out!
Sent from my Nexus One using XDA App

Oh epic win thanks for this!
Sent from my HTC Hero using XDA App

Please reupload ADB Scripts for Nautilus.tar.gz somewhere.

Stupid me...
http://www.kmel.be/~tom/android/ADB Scripts for Nautilus.tar.gz
Please note a little "bug", the progress bar progress when a file start transfer. So if you send just one big file, it will be at 100% for a little time...
Easily correctible, but I haven't the time now...

MappaM said:
Stupid me...
http://www.kmel.be/~tom/android/ADB Scripts for Nautilus.tar.gz
Please note a little "bug", the progress bar progress when a file start transfer. So if you send just one big file, it will be at 100% for a little time...
Easily correctible, but I haven't the time now...
Click to expand...
Click to collapse
nice work. very handy
EDIT: actually I may have spoke too soon, these don't seem to be working for me. Ubuntu 10.10
I know my udev and $PATH are all set up correctly. So I'm not sure where these are failing for me..
any thoughts?
EDIT2: OK it was a $PATH issue the ~.bashrc however is only for interactive non login shells adding the adb path to ~.profile and a re-login solved my problem with this script. Or alternatively you could call adb in the script using it's full path.

Thanks MappaM for the great base script!
Here is my version of "Push to Movies":
My solution to the immediately full progress bar was to use the --pulsate option in zenity this works for me because I am likely to only be sending one file anyway and don't need the fine grain feed back of an incremental progress bar. The one that bounces back and forth is what you will see.
echo "15" ; sleep 1
is a hack, you may not need it but for me it lets the pulsate flag work.
zenity bugs reported here
https://bugs.launchpad.net/zenity/+bug/291850
https://bugzilla.gnome.org/show_bug.cgi?id=567663
Code:
#!/bin/sh
#this is MY path, your path will be different . change this path.
android_path="/sdcard/media/video/movies/"
i=1
(
for thing in "[email protected]"
do
# this first echo tricks the pulsate into working you may not need it. try it both with and without it.
echo "15" ; sleep 1
echo $(($i * 100 / $#))
echo "# Pushing \"${thing}\"" ;
adb push "${thing}" $android_path
i=$(($i+1))
done; i=$(($i-1)) ; echo "# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $android_path"

Related

( ADB Help ) how-to set ADB & Windows $Path

HOW-TO Fix **ADB is not recognized in the CMD**​
Navigate to & Left_Click on Start >
Right_Click on Computer >
Left_Click on Advance System Settings >
Left_Click on Environment Variables >
Left_Click on New ( User Variables ) >
Variables Name: ADB ( Or anything you want )
Variables Value: ;C:\SDK\tools ( Just like this, This is the Path of my adb.exe )
You must put a ; in front of ;C:\ ( adb Path goes here / Variables Value: )
That's it.. You now have set up adb to work Global via cmd prompt on win7
~Eugene
eugene373 said:
HOW-TO Fix **ADB is not recognized in the CMD**​
Navigate to & Left_Click on Start >
Right_Click on Computer >
Left_Click on Advance System Settings >
Left_Click on Environment Variables >
Left_Click on New ( User Variables ) >
Variables Name: ADB ( Or anything you want )
Variables Value: ;C:\SDK\tools ( Just like this, This is the Path of my adb.exe )
You must put a ; in front of ;C:\ ( adb Path goes here / Variables Value: )
That's it.. You now have set up adb to work Global via cmd prompt on win7
~Eugene
Click to expand...
Click to collapse
That should help with a lot of the issues I see being posted, not only here but on many Threads. Simple path statement 101
Better: Chose "Path" in "Systemvariables" and put it at the end of this line, i.e. like this: ";C:\android\platform-tools;C:\android\tools". Because then it'll even work if u run the cmd as administrator, which won't work if you do it as described above. Atleast its been the way on my W7 Ultimate 64
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Hi,
another way (and very useful for other reasons) is to change registry like this:
Code:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Prompt]
@="open cmd here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Prompt\Command]
@="cmd.exe /k pushd %L"
Afterwards you are - by right-clicking the adb-folder - directly in the right folder.
Don´t know if you have to restart, i´m using it just a long time.
Greets
idephili
or just put the tools folder and adb binarys in C:\Windows or C:\Widnows\System32 ;-)
done
I know this is of topic but thanks Eugene for all of your contributions
Sent from my HTC Sensation 4G using XDA Premium App
Eugene373, I am so happy you're devving on the Sensation! Thanks for the ADB how-to...it really helped! Will you continue to develop and make ROM's for this device?
Alternatively you can also copy the ADB and Fastboot.exe files over to System32 or SysWOW64 folders and they work fine as well.
as google shows up this thread here my two cents...
the mentioned methods don't work for me nor anyone else('s computer) running windows 7 professional 64 bit i know. here's what in fact works perfectly on any computer i tried it on:
copy the path to your adb.exe wherever it is, put a semicolon in front of the path and attach it to the existing entry in the PATH variable. no matter if you add it as an user oder system variable. last one is only to recommend as you're dealing with multiple users which all need to access adb via cmd
is there a way to convert the twrp file backup on my pc to get it back on to my phone to install the backup everytime i try to put it back on my phone via adb it errors out and im stuck at this point ive been at this for over 10 hours just trying to restore my backup i have the backup file on the pc and ive backed it up earlier but now it errors there has to be a way to get this backup back onto my phone in a way that it will recognize it and install it please help lol im familiar with custom roms and the like not a expert but i kinda know what im doing and ive loaded custom roms on many phones in the past with no issues but this one is proving to be a real pain using a note 4 n910t
for more info i was trying to install petbede's rom and i managed to get to the reboot stage and he states it could take anywhere from 7-10 mins on average for it to boot up but mine was going on 20 mins plus and was getting really hot so i pulled the plug and as long as ive been trying to do this in one sitting i just want my backup installed and to be done with it for a few days untill i can muster the courage to try it again but this time i will be backing up on a seperate sd card that i can just pop into the phone to restore from since the pc copy is not playing nice with me

[TIP] How to verify ROM downloads using Total Commander Android app (MD5 sum)

Many of you might be fans of the simple looking file manager packed with customizability and features, Total Commander for Android. And this app also happens to be totally free.
If you haven't heard about it and would like to check it out, go to its homepage or get it from Google Play.
Apart from the app being awesome in itself, its dev Christian Ghisler is a cool guy too. He is very quick in responding to questions, suggestions and bug reports.
(As of now) Total Commander does not have a 1-click solution to calculate MD5 sum of a file. I am used to calculating and verifying the MD5 sum of every ROM zip I download and so having that feature is very important to me. Of course there are other apps like Android File Verifier that do that + more. But I needed just a simple MD5 calculator without having to install any extra app for that.
After spending some time playing with various options in the Total Commander app and a tip from the dev, I was able to put together a neat way to calculate MD5 using TC Android.
SETUP STEPS (Need to do this just once):
1. Click on the "Add button" icon. ( If you don't see that icon, you probably have the secondary row of icons hidden; unhide that secondary row by clicking the rightmost icon on the bottom row of icons ).
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2. Configure the button as follows:
- Function type: Send shell command
- Command: sh
- Parameters: *md5sum %N ( The * makes the result of the command show up in a popup window. )
- You can change the icon if you want
HOW TO CALCULATE MD5 NOW:
1. Click on the icon of any file for which you want the MD5 sum so that a green tick appears on that icon.
2. And then hit on your newly created MD5 sum calculation button. It will takes few seconds for the MD5 sum calculation to finish if you are doing it for a large file like a ROM zip shown in the example in my screenshots.
Neet!
TCM is ultimate badass
Using U8110, V9. CM7 trough tapatalk
Another one:
Display usage and free space in current partition
(same scheme of pictures as in post#1)
2. Configure the button as follows:
- Function type: Send shell command
- Command: sh
- Parameters: *df -h . | cut -b 23-32,35-50
- You can change the icon if you want
I'm not sure, but I think the Parameters depend on the version of busybox in your device... maybe you have to fiddle around a little
@jazzboyrules: thanks for this thread! Could you change the title to "[TIP] Total Commander Android app: useful tips" or something like that? For sure there are much more ideas for this ingenious app.
jazzboyrules said:
2. Configure the button as follows:
- Function type: Send shell command
- Command: sh
- Parameters: *md5sum %N ( The * makes the result of the command show up in a popup window. )
- You can change the icon if you want
Click to expand...
Click to collapse
Thanks.
Just a minor glitch: use *md5sum "%N"
The quotes will ensure that it works even with file names that contain spaces.
Hmm... For larger files ~200MB (?), I get "Function aborted!" error.
tip for users without root
jazzboyrules said:
Many of you might be fans of the simple looking file manager packed with customizability and features, Total Commander for Android.
Click to expand...
Click to collapse
It should be noted that the method described by the OP, applies to devices with root.
If there is no root, first you need to:
1. install BusyBox Install (No Root) by @Jaredsburrows
2. through the application "BusyBox Install" to install busybox
3. in the application "BusyBox Install" copy environment variable and use the location of the file busybox to define the command sh for Total Commander
Code:
/data/data/burrows.apps.busybox/app_busybox/md5sum %N > %N.md5
In this case, the check sum sent to the file.
.
Thank you so much for this perfect solution!
As more and more often larger checksums are used, one can change the code a bit to calculate the sha-256 checksum of a file.
Just use:
*sha256sum "%N"
Sent from my Fairphone FP2 using XDA Labs

[Developers] Support and development init.d script

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Welcome to this subject where I'll share the following information to activate the terminal init.d our support, as well as the development of the topic is addressed primarily to the developer community roms in order to implement and improve its development in each of the phones and better autonomy thereof is provided.
Warning: Before continuing please read the documentation that will expose so they can check its development, those who only discuss other issues please abtenerse as this issue is not in order to respond is only to well that development develop properly targeted by this issue.
The tools I used for the development of the init.d support they can find at the end of the subject for downloading and asu same time the use so you can verify some of the things we will discuss on this issue.
no script can be universal because it is different and its code and some values and parameters are only applicable for each smartphone
Requirements: root access and SuperSU
1.- proceed with the most basic thing is to give root access to our terminal this method according in each terminal is indispensable as the first requirement
2.- as a second step this would be related to the installation of busybox in the terminal and ending with the installation of the same proceed with checking the same watching the following path with a file browser /system/xbin, if you have any doubts use the application busybox checker to verify the installation of the same
3.- as a third step needs a file browser and asu time they open the routes to them to enter and to edit text files comfortably
4.- as fourth step is to go to the /system /etc there init.qcom.post_boot.sh locate file name to open it proceed traditionally files editor of exploring and we should be on the part of all the way just to add the following lines
Code:
# support init.d
/system/xbin/busybox run-parts /system/etc/init.d
and finished we proceed to save changes to the file
5.- In this step we will create a folder called init.d name is created only once we proceed with changing the permissions would be: 0755 attached screenshot for more details of the permits, download the file will come a script called 99SuperSUDaemon and moved to the /system/etc/init.d apply the same route that takes the folder permissions ie the file 99SuperSUDaemon 0755 will have permission to run properly without any problem because if you put 0644 permits will not run
6.- proceed with terminal power cycle this is to enable support init.d our terminal as seen was not very complicated because they bring roms have actually proven but have not convecid me a story to execution of script obtaining a negative result this method I show a positive result :good:
-Tools
I bring a tool that enables init.d support only run automatically and ready
the end of the song I'll let the files that I used for this topic
1. As a first step it will be necessary to know what we are going and we want to remember that there is no script and not the same parameters with a value change at each terminal
2.- we will create in the internal memory of the terminal a folder called tools this may be optional but we'll use as an example to notice what we do at every step and can understand a bit about this topic
3.- after the tools created folder create a script so that they will ask is to copy the files that are present on that route in this case I will take as an example the following path: /proc/sys/vm is where some values are saved by heart
Code:
#!/system/bin/sh
# copying files
# script by kaiiori xda-developers
sleep 2
echo "creating internal memory directory"
busybox mkdir /storage/emulated/0/tools/vm
sleep 2
echo "copying files"
sleep 2
cp -r /proc/sys/vm /storage/emulated/0/tools
sleep 2
echo "copying completed"
exit 0;
save file vm.sh
4.- install android terminal in the terminal run the following commands
root permissions
Code:
su
go to the directory of your internal memory in this case this is my directory
Code:
cd /storage/emulated/0/tools
find files in the directory
Code:
ls
run the script through the terminal
Code:
sh vm.sh
in the directory /storage/emulated/0/tools/vm has been created a folder called VM and see if open files that have been copied to the internal memory of the terminal
5.- if you open the file values that have default in this case if you to installed scripts should the value applied to the parameter of the same appear if it is not is because there is a problem with the script in content and has to reahacer to carry just the change you want to apply
checking values applied
1.- after you created the script with the content you need to check to see if the value applied is that we have written script is the file we should show the same value as if it does not show is because the code is not right
2.- I leave a script will help them review the values and see if they were applied correctly
Code:
#!/system/bin/sh
# copying files
# script by kaiiori xda-developers
echo " " >>/storage/emulated/0/tools/info.log
echo "-------------------------------" >>/storage/emulated/0/tools/info.log
cat /proc/sys/vm/swappiness >>/storage/emulated/0/tools/info.log
echo " " >>/storage/emulated/0/tools/info.log
echo "-------------------------------" >>/storage/emulated/0/tools/info.log
root permissions
Code:
su
go to the directory of your internal memory in this case this is my directory
Code:
cd /storage/emulated/0/tools
find files in the directory
Code:
ls
run the script through the terminal
Code:
sh script_log.sh
in the directory you create a log file there appear the value that was applied in this case is 100 by default but as I modify it appears 40 that is the result we must apply
with this information I will end my subject just adding the init.d support users should provide updates and other improvements because honestly the code they use and check it when I get the same default the script I use for this and to apply the changes not be able to release it in no way is the greetings own development
reserv
reserved

[MOD] Audio gain enhancement for LG devices

First of all, but not less important...
I'm not responsible for anything that happens with your phone, also, some people experienced some bricks on certain devices, so, just take care where you put paths and data because your phone maybe vulnerable to bricks!
This audio modding guide is intended for experienced users. Mainly, in the Linux handling area, like customizing the kernel and playing with system internal parameters. Please don't play with this, you could overheat and/or damage your smartphone's motherboard if you mess with this menu options.​
Requirements:
A rooted LG device.
Stock ROM (includes customized or modded stock)
Universal Init.d
BusyBox
And remember, the curiosity killed the cat, don't be a cat.
System requirements:
Any LG device running ICS (or higher) stock ROM.
Procedure:
First part: setting up the environment
1. Open "Play Store", search for "BusyBox Free" (or open the play store link written above).
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2. Tap the first result and install it, then open.
3. Now, install BusyBox binaries in your device. Just tap "Install".
4. All done. If you see this, close the app.
5. Now, get back to "Play Store" and search for "Universal Init.d" (or open the play store link written above). Tap the first result.
6. Install it.
7. Open it.
8. Here, move the switch from "Off" to "On".
9. Close the app. The environment set up is done.
Second part: testing device's hardware limits
1. Go to the phone's launcher and tap "Phone".
2. Dial 3845#*<your model's numeric part>#. Mine's LG Optimus L9 (Argentina version), it's model number is P778G, in that case, I should dial 3845#*778#.
3. You'll now see the "Hidden Menu" window. There tap "H/W Device Test".
4. Now pick "Sound Test".
5. Tap "Audio CAL Tool".
6. Pick "SetGain".
7. Tap in the list menu next to "Device Type" and pick "headset".
8. Here, you'll see that there's an item called "HS_DL" and next to it a box where you can type a value. This value should be from 0 to 21. This is you headphone output's gain. Mine's default is 13. The maximum for me is 16, it starts crackling if higher. I suggest you to set it to 16.
9. After setting the value, tap "Ok".
10. Exit the menu.
11. Now, to test your new setting, unplug (if plugged) and plug your headphones again.
Third part: sticking your changes
By default, your device will reset everything as it was before with every reboot. What we gotta do to save those changes? We'll save the files you change when you tap "Ok" to another folder and then retrieve it every time the device boots. How? Here you'll see that:
1. Unplug the USB Cable (if plugged), go to Settings > Developer options and enable "USB Debugging".
2. Plug you device to a computer which has ADB (Android Debugging Bridge) installed. (will work on both Windows and Linux) Don't you know if you have it? Type "adb" at the command line, or "sudo adb" (sudo, just in case) in a Linux Terminal. If you see something similar to the next screenshot, you're okay.
3. Open up a command prompt (or Terminal, in Linux). Type:
Code:
adb shell su -c "cp '/data/audio/gain.table.0 /data/local/'"
4. Open a text editor and create a new file. In Linux, use whatever you like to (includes command line and GUI). In Windows, use Notepad++.
4.1 Only if using Windows:
Right click the bar at the bottom saying "Windows (CR LF)" and pick "Convert to UNIX format".
5. Type (or copy-paste) the next code:
Code:
cp -f /data/local/gain.table.0 /data/audio/
chmod 600 /data/audio/gain.table.0
6. Save the file as 02setaudiogain somewhere in your PC.
7. Go to the folder you saved the file in your PC and then, type those commands:
Code:
adb push 02setaudiogain /sdcard/
adb shell su -c 'mount -o remount,rw /system'
adb shell su -c 'cp /sdcard/02setaudiogain /system/etc/init.d/'
adb shell su -c 'chmod 755 /system/etc/init.d/02setaudiogain'
adb shell su -c 'mount -o remount,ro /system'
8. All done, reboot your device to test . Liked the commands part? Reboot it with this command if you don't like the UI anymore:
Code:
adb shell su -c 'reboot'
Fourth part: troubleshooting
Can't install BusyBox or turn on Universal Init.d?
Check for permission denials at SuperSu's (or your root permission management app) logs.
Device not booting anymore?
Restore a backup over recovery or use LG Mobile Support tool (included in LG PCSuite) to re-flash your device.
Fifth part: how it works
As stated by the logs I took from logcat, what you do when you tap "Ok" in the "Audio CAL Tool" is save some fields to a file called gain.table.0 in /data/audio (/data/audio/gain.table.0)
logcat:
Changes it makes:
​
Credits:
To @pauliero 's post for the hidden menu code: http://forum.xda-developers.com/showthread.php?t=2126949

[GUIDE][ARM32] Patching your own init and sepolicy

Hi guys!
I am posting a very noob friendly guide on replacing init with your patched init file. This will help loading the patched sepolicy and can get temporary unrestricted root shell.
This guide is a prequel to the guide I already posted.
A big thank you to my friend @matteogenacio for helping me out to compiling all the files and patching sepolicy and helping when I was stuck!
Requirements:
(1) dirtyc0w temporary root shell tool: Click Here (Windows only)
(2) dirtyc0w files needed: https://github.com/matteoserva/dirtycow-arm32/archive/master.zip
(2) IDA Pro (Demo version is ok)
(3) HexEditor
(4) You need Ubuntu
(5) Android NDK Compiler
(6)android-libsepol : https://android.googlesource.com/platform/external/libsepol
(7) LOT OF PATIENCE
Click to expand...
Click to collapse
→ Patching your init and loading it into your phone:
(1) Open run_for_arm_devices.bat.
(2) Type "id". You get something similar to this screenshot:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
(3) Type "cp init /sdcard/". Your original init file is copied into the sdcard.
(4) Type "exit" two times to get out of the shell.
(5) Type "adb pull /sdcard/init". The init file is copied into your computer.
(6) Open your init file in IDA PRO.
(7) Compare it with this source code: Click Here
(8) Look for the function which looks similar to this (This actually relates to bootchart_sample() function which you saw in the C++ code above):
(9) Compile shellcode.s using this command: arm-linux-androideabi-as shellcode.s -o shellcode
(10) Open shellcode file in HexEditor.
(11) Copy the content between AAAAINIT and AAAAFINE.
(12) Open init in XDA and copy the shellcode just after the "PUSHW {R4-R11,LR} line.
(13) My patched init file looked like this (more images to be added):
(14) At the end of the shellcode add "POP.W {R4-R11,PC}; NOP" instruction manually. Use ARMConverter. Copy the "Thumb2 HEX" Code.
(15) Click on File> Create DIFF File. Use a IDA Diff patcher to patch your original init.
(16) Now we have to load the init file. Turn off screen and wait 10 seconds.
(17) Type "adb push <your patched init file> /data/local/tmp".
(18) Open "run_for_arm_devices.bat".
(19) Type "run-as con". Then type "cd /data/local/tmp".
(20) Type "./a.out /init ./init". If it gives you "load destination error", try this one "./dirtycow /init ./init".
→ Injecting your sepolicy with rules for unrestricted access:
(1) Compile sepolicy-inject. Type this "gcc -std=gnu11 *.c -o t -I ../libsepol/include/ ../libsepol/src/libsepol.a -DARG_MAX=128" in terminal.
(2) Copy the the compiled sepolicy-inject file into sepolicy_generator. In sepolicy_generator folder, run ./installa.sh file.
(3) Now we have to copy the patched sepolicy file into phone. Type "adb push <your patched sepolicy file> /data/local/tmp/sepolicy".
Finally, open "adb logcat | grep audit". Look for messages that your sepolicy is loaded.
Hey we got root(temporary & unrestricted access)!
→ Notes:
(1) This works for only ARM32 Devices.
(2) This guide works regardless of your Android version. You can check if your phone is vulnerable to dirtyc0w using my debugging tools which I posted them in my guide.
(2) Another big thank you to my friend @matteogenacio for helping me out to compiling all the files and patching sepolicy and helping when I was stuck!
Reserved.
I'm glad I found this. I'm hoping maybe this can be converted to 64 bit, using a 64 bit dirty cow shell.
If you look in my thread, injecting root & setting SELinux, we have a 64bit shell.
Sorry if it's a noob question, but is "sepolicy" compatible between devices? My policy has attributes I wish it didn't have and I don't know how to remove them. So I thought replacing it with another one.
Was looking around XDA for a "guru's thread' on SeLinux - and found this one.
My Util bindfs wont work cos of SeL denials and I need help "neutralizing" the denial by changing SePolicy or alternatively running any relevant chron . So I'm putting my Q here. If ain't of relevance I'll Del it
A non root file explorer can rename existing file with bindfs but it cant create new files aka WhatsApp downloads fail
My Samsung Stock ROM SeLinux logging is disabled.
grep -i avc /proc/kmsg dmesg | grep -i avc logcat | grep -i avc
No results from above. So I cant figure out what's hurting the Create Perm
So I ( hopeully ) recreated the scenario on another Android 9 phone with SeLinux state changeable ( the other 1 is perm. enforced). & I get this avc denial
9421 9421 W com.whatsapp: type=1400 audit(0.0:15540): avc: denied { create } for comm=4D65646961446F776E6C6F61642023 name="LW9n+rkip578Ox9pPGthBD5DGfO7rIMxJyDHRHjQ9ZY=.tmp" scontext=u:r:untrusted_app:s0:c122,c257,c512,c768 tcontext=u:object_r:sdcardfs:s0 tclass=file permissive=0
So the issue could be untrusted app or becos my target /data/sdext3 has unlabeled context ?
ls -Zd /data/sdext3
u:object_r:unlabeled:s0 /data/sdext3
BTW just FYI chron fails. Why so ?
chcon -Rh u:object_r:sdcardfs:s0 /data/sdext3` # before that I `chown -R`ed to `root` entire `/data/sdext3` o/p of ths is `chcon: '/data/sdext3/j37 WhatsApp/data/colornote/backup/1606263606732-AUTO.doc' to u:object_r:sdcardfs:s0:
# Permission denied - throws this error for all files
. Does it mean I have to recompile kernel with updated policy OR any work-around ?

Categories

Resources