Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. # mv /system/bin/dnsmasq /system/bin/dnsmasq.bin
  2.  
  3. #!/system/bin/sh
  4.  
  5. OLD_SUBNET='192.168.43'
  6. NEW_SUBNET='192.168.1'
  7. WIFI_INTERFACE='wlan0'
  8. LOCAL_TABLE='97'
  9.  
  10. export PATH=/system/bin
  11.  
  12. # delete old route, add new
  13. ip route del ${OLD_SUBNET}.0/24 dev ${WIFI_INTERFACE} table $LOCAL_TABLE
  14. ip route add ${NEW_SUBNET}.0/24 dev ${WIFI_INTERFACE} table $LOCAL_TABLE
  15.  
  16. # set new IP address on Wi-Fi interface
  17. ip address add ${NEW_SUBNET}.1/24 dev $WIFI_INTERFACE
  18.  
  19. # inject new subnet in hard-coded arguments received from netd
  20. set -- $(printf '%s' "$*" | sed 's/'${OLD_SUBNET}'/'${NEW_SUBNET}'/g')
  21. unset OLD_SUBNET NEW_SUBNET
  22.  
  23. # execute original binary with new arguments
  24. exec dnsmasq.bin $*
  25.  
  26. ~# RULES="$(ip rule | grep -vE 'unreachable|local')"
  27. ~# echo "$RULES"
  28. ~# for t in $(echo "$RULES" | awk '{print $NF}' | uniq); do ip r s table $t; done
  29.  
  30. # execute binaries from /system/bin
  31. allow netd system_file dir { read open getattr search }
  32. allow netd system_file file { read gettattr open execute execute_no_trans }
  33.  
  34. # execute /system/bin/sh
  35. allow netd shell_exec file { read getattr open execute execute_no_trans }
  36.  
  37. # execute /system/bin/toolbox and its applets
  38. allow netd toolbox_exec file { read gettattr open execute execute_no_trans }
  39.  
  40. # configure RPDB rules / routing tables
  41. allow netd netd capability { sys_admin }
  42.  
  43. ~# chown 0.0 /system/bin/dnsmasq*
  44. ~# chmod 0755 /system/bin/dnsmasq*
  45. ~# chcon u:object_r:dnsmasq_exec:s0 /system/bin/dnsmasq*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement