Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ################################################################################################################################################
  4. #
  5. # Title: DroidXTools
  6. # Author: Wolf Syntax (Jayson D. Alpe)
  7. # Desription: A tools for modifying MAC Address and DNS, a tool also for viewing WiFi saved password and creating backup of build.prop file
  8. # Instruction:
  9. #
  10. # Download Terminal Emulator and DroidEdit
  11. # To execute this file: sh DroidXTools
  12. #
  13. #
  14. # (c) Wolf Syntax 2016. All rights reserved.
  15. #
  16. #
  17. ################################################################################################################################################
  18.  
  19.  
  20. v=$1
  21. root_dir=""
  22. root_level=-1;
  23. cur_dir=`pwd`
  24. flag=0
  25.  
  26. #WiFi
  27. wifi_mac=""
  28. prod_info="productinfo/wifimac.txt"
  29.  
  30. nstat="data/system/netstats/"
  31.  
  32. #LoginDetails
  33. usrname=""
  34. passwrd=""
  35. session_id=0
  36.  
  37.  
  38. #Module for restarting device
  39. shutdown()
  40. {
  41. reboot;
  42. }
  43.  
  44. #Module for checking if system directory exist
  45. checkDir()
  46. {
  47. if [[ -d "system" ]]; then
  48. flag=1;
  49. fi
  50. }
  51.  
  52. #Module for getting Root level directory (Depth)
  53. getRLevel()
  54. {
  55. until [[ $flag -eq 1 ]]; do #while flag is 0
  56.  
  57. checkDir;
  58. cd ..
  59. let root_level++; #increment while system dir not found
  60. done
  61.  
  62. ctr=0
  63. while [[ $ctr -lt $root_level ]]; do
  64. root_dir="$root_dir../"
  65. let ctr++;
  66. done
  67.  
  68. }
  69.  
  70. #Module for Setting up DNS
  71. setDNS()
  72. {
  73.  
  74.  
  75. echo "======================================"
  76. echo "======== < DNS Changer Tool > ========"
  77. echo "======================================"
  78. echo -e "\nList of available DNS:"
  79. echo -e " \n1\tGoogle DNS\n2\tOpenDNS\n3\tLevel 3\n4\tComodo\n5\tNorton Connect Safe\n6\tSmartViper\n7\tFreeDNS\n8\tYandex\n9\tHurricane Electric\nC\tCustom DNS\n"
  80.  
  81. options=0
  82.  
  83. wlan_dns1=""
  84. wlan_dn2=""
  85. dns_type="";
  86.  
  87. confirm="";
  88.  
  89. echo -ne "Choose from the option: "
  90. read options
  91.  
  92. bool=0;
  93.  
  94. case $options in
  95. "1" ) wlan_dns1="8.8.8.8"; wlan_dns2="8.8.4.4";dns_type="Google DNS";;
  96. "2" ) wlan_dns1="208.67.222.222"; wlan_dns2="208.67.220.220";dns_type="OpenDNS";;
  97. "3" ) wlan_dns1="209.244."; wlan_dns2=""dns_type="Level 3";;
  98. "4" ) wlan_dns1="8.26.56.26"; wlan_dns2="8.20.247.20"; dns_type="Comodo";;
  99. "5" ) wlan_dns1="199.85.126.10"; wlan_dns2="199.85.127.10";dns_type="Norton Connect Safe";;
  100. "6" ) wlan_dns1="208.76.50.50"; wlan_dns2="208.76.51.51";dns_type="SmartViper";;
  101. "7" ) wlan_dns1="37.235.1.174"; wlan_dns2="37.235.1.177";dns_type="FreeDNS";;
  102. "8" ) wlan_dns1="77.88.8.8"; wlan_dns2="77.88.8.1";dns_type="Yandex";;
  103. "9" ) wlan_dns1="74.82.42.42"; wlan_dns2="74.82.42.42";dns_type="Hurricane Electric";;
  104. "C" ) checkCustomIP; dns_type="Custom DNS" bool=1;;
  105. *) echo "Invalid option!"; bool=1;;
  106. esac
  107.  
  108. if [[ $bool -eq 0 ]]; then
  109.  
  110.  
  111. setprop dhcp.wlan0.dns1 $wlan_dns1;
  112. setprop dhcp.wlan0.dns2 $wlan_dns2;
  113.  
  114. setprop net.dns1 $wlan_dns1;
  115. setprop net.dns2 $wlan_dns2;
  116.  
  117. echo "Applying $dns_type successfully!";
  118. fi
  119. }
  120.  
  121. #Set custom IP for DNS
  122. checkCustomIP()
  123. {
  124. dns_1=""
  125. dns_2=""
  126.  
  127. echo -ne "Primary DNS: "
  128. read dns_1;
  129.  
  130. echo -ne "Secondary DNS: "
  131. read dns_2;
  132.  
  133. if [[ $dns_1 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ && $dns_2 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
  134.  
  135. OIFS=$IFS
  136. IFS='.'
  137. dns_1=($dns_1)
  138. IFS=$OIFS
  139.  
  140. checker=0;
  141.  
  142. if [[ ${dns_1[0]} -le 255 && ${dns_1[1]} -le 255 && ${dns_1[2]} -le 255 && ${dns_1[3]} -le 255 ]]; then
  143. echo "Applying Primary Custom DNS";
  144. setprop dhcp.wlan0.dns1 $wlan_dns1;
  145. setprop net.dns1 $wlan_dns1;
  146. else
  147.  
  148. echo "Primary DNS Invalid! i.e. 255.255.255.255"
  149. fi
  150.  
  151. OIFS=$IFS
  152. IFS='.'
  153. dns_2=($dns_2)
  154. IFS=$OIFS
  155.  
  156.  
  157. if [[ ${dns_2[0]} -le 255 && ${dns_2[1]} -le 255 && ${dns_2[2]} -le 255 && ${dns_2[3]} -le 255 ]]; then
  158. echo "Applying Secondary Custom DNS";
  159. setprop dhcp.wlan0.dns2 $wlan_dns2;
  160. setprop net.dns2 $wlan_dns2;
  161. else
  162. echo "Invalid format! i.e. 255.255.255.255"
  163. fi
  164.  
  165. else
  166.  
  167. if [[ $dns_1 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
  168. echo -ne ""
  169. else
  170. echo "Invalid Primary DNS"
  171. fi
  172.  
  173.  
  174. if [[ $dns_2 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
  175. echo -ne ""
  176. else
  177. echo "Invalid Secondary DNS"
  178. fi
  179.  
  180. fi
  181. }
  182.  
  183.  
  184. #MAC Changer Module
  185. setMAC()
  186. {
  187. wifi_mac="$root_dir$prod_info"
  188. new_mac="00:00:00:00:00:00";
  189. cd $cur_dir
  190. echo "Current Directory: $cur_dir"
  191. #echo "Root DIR $root_dir"
  192.  
  193. echo -ne "Enter custom MAC Address (BSSID) : "
  194.  
  195. read new_mac
  196.  
  197. if [[ $new_mac =~ ^[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}$ ]]; then
  198.  
  199. cd $root_dir
  200. echo "Creating backup of wifimac.txt"
  201. cp "productinfo/wifimac.txt" "$cur_dir/wifimac.txt"
  202. echo "$new_mac" > "productinfo/wifimac.txt"
  203. echo "MAC Address modified!"
  204.  
  205. fi
  206.  
  207.  
  208. }
  209.  
  210. #Create a backup of build.prop
  211. cloneProp()
  212. {
  213. cd $cur_dir
  214. cd $root_dir
  215. cd system
  216. echo "Cloning Build.prop to $cur_dir"
  217. cp build.prop $cur_dir
  218.  
  219. }
  220.  
  221.  
  222. #Clear data usage module : Settings > Data Usage
  223. clearData()
  224. {
  225. cd $cur_dir
  226. echo -ne "Clearing Data Usage"
  227. cd $root_dir
  228. cd data/system/netstats/
  229.  
  230. if [[ `ls -A` ]]; then
  231. rm *
  232. fi
  233.  
  234. echo -ne " Successfully!\n"
  235. }
  236.  
  237. #Module for displaying saved WiFi password
  238. sniff()
  239. {
  240. cd $cur_dir
  241. cd $root_dir
  242. cd data/misc/wifi
  243. echo "WiFi Password(s) "
  244. if [[ -f wpa_supplicant.conf ]]; then
  245. echo "WPA Security"
  246. cat wpa_supplicant.conf | grep psk
  247. fi
  248.  
  249. if [[ -f wep_supplicant.conf ]]; then
  250. echo "WEP Security"
  251. cat wep_supplicant.conf | grep psk
  252. fi
  253. }
  254.  
  255. #Login module
  256. verify()
  257. {
  258.  
  259. echo -ne "Username: "
  260. read usrname
  261.  
  262. echo -ne "Password: "
  263. read passwrd
  264. curr_dir=`pwd`
  265. if [[ $usrname == "root" && $passwrd == "toor" ]]; then
  266. echo "Login successful!"
  267. session_id=1
  268. if [[ $session_id -eq 1 ]]; then
  269. main;
  270. fi
  271.  
  272. echo "$session_id" > session.log
  273.  
  274. else
  275. echo "Invalid credentials"
  276. session_id=0
  277. echo "0" > session.log
  278.  
  279. fi
  280.  
  281. }
  282.  
  283. #Module for displaying script version
  284. version()
  285. {
  286. echo "DroidXTools v1.0.3"
  287. echo "Developed by Wolf Syntax"
  288. }
  289. main()
  290. {
  291. # echo "Main module"
  292.  
  293. cur_dir=`pwd`
  294. clear
  295. getRLevel;
  296. echo -ne "\t\t DroidXTools\n\t\tversion 1.0.3\n\t Developed by Wolf Syntax\n"
  297. echo -ne "================================================\n"
  298. echo -e "-build\tClone Build.prop\n-clear\tClear Data Usage\n-mac\tMAC Changer\n-wifi\tView WiFi Password\n-r\tReboot Device\n-v\tCheck Version\nexit\tClose session\n"
  299. proc="";
  300. echo -ne "================================================\n"
  301. echo "Note: Please grant as super user. command: su"
  302. echo -ne "Choose process: "
  303. read proc;
  304.  
  305. case $proc in
  306. "-build" ) cloneProp;;
  307. "-clear" ) clearData;;
  308. "-mac" ) setMAC;;
  309. "-wifi" ) sniff;;
  310. "-r" ) shutdown;;
  311. "-v" ) version;;
  312. "exit" ) cd $cur_dir; echo "0" > session.log; exit;;
  313. * ) echo "Invalid option!";;
  314. esac
  315. cd $cur_dir
  316. # clearData
  317.  
  318. # cloneProp;
  319. # setMAC;
  320. # setDNS;
  321.  
  322. }
  323.  
  324. if [[ -f session.log ]]; then
  325. session_id=$(< session.log);
  326. if [[ session_id -eq 0 ]]; then
  327. verify;
  328. else
  329. main;
  330. fi
  331.  
  332. else
  333. verify;
  334. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement