metalx1000

Android Custom boot.img to disable SELinux

Dec 1st, 2017
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.19 KB | None | 0 0
  1. #Android boot partition for start up script
  2. #disable SELinux
  3.  
  4. #check for needed programs
  5. if [ ! -f "/usr/bin/abootimg" ] || [ ! -f "/usr/bin/fastboot" ] || [ ! -f "/usr/bin/adb" ]
  6. then
  7.   apt-get install abootimg android-tools-fastboot android-tools-adb -y
  8. fi
  9.  
  10. #get image from android device
  11. #connect through adb to recovery (TWRP or Clockwork, etc)
  12. adb shell
  13.  
  14. #find boot partition
  15. adb shell ls -l /dev/block/bootdevice/by-name/boot|tr ' ' '\n'|grep mmc
  16.  
  17. #create img
  18. #dd if=/dev/block/mmcblk0p31 of=/tmp/boot.img bs=4096
  19. adb pull /dev/block/mmcblk0p31 boot.img
  20.  
  21. #check file
  22. file boot.img
  23.  
  24. #extract image
  25. abootimg -x boot.img
  26.  
  27. ##"updating bootimg.cfg" to disable SELinux
  28. #add 'androidboot.selinux=permissive' to the end of the 'cmdline'
  29. #example -- "https://raw.githubusercontent.com/metalx1000/Moto-G-root-tricks/master/config/bootimg.cfg"
  30. sed -i '${s/$/ androidboot.selinux=permissive/}' bootimg.cfg
  31.  
  32. #repackage
  33. #####abootimg --create boot2.img -f bootimg.cfg -k zImage -r initrd.img### this didn't work
  34. #Update image
  35. abootimg -u boot.img -f bootimg.cfg
  36.  
  37. #test it out
  38. sudo fastboot boot boot2.img
  39.  
  40. #Flash it
  41. sudo fastboot flash boot boot.img
  42.  
  43. #reboot
  44. sudo fastboot reboot
Add Comment
Please, Sign In to add comment