├── DNSChanger.spk ├── DNSChanger ├── DNSChanger.js └── Img │ └── DNSChanger.png ├── LICENSE ├── README.md └── Screenshots ├── Screenshot_20190119-165338.png ├── Screenshot_20190119-165942.png ├── Screenshot_20190124-015410.png ├── Screenshot_20190124-015419.png ├── Screenshot_20190124-015443.png ├── Screenshot_20190124-210731.png ├── Screenshot_20190124-210837.png └── Screenshot_20190126-014004.png /DNSChanger.spk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/DNSChanger.spk -------------------------------------------------------------------------------- /DNSChanger/DNSChanger.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author : gauravssnl 3 | I am just a student who failed. 4 | */ 5 | curr = -1; 6 | 7 | var WIDTH = app.GetScreenWidth(); 8 | var HEIGHT = app.GetScreenHeight(); 9 | 10 | function OnStart() { 11 | for (; ;) { 12 | var lay = app.CreateLayout("Linear"); 13 | lay.SetVisibility('Hide'); 14 | app.AddLayout(lay); 15 | var b = app.CreateButton(); 16 | lay.AddChild(b); 17 | var t = app.CreateText(); 18 | lay.AddChild(t); 19 | app.Wait(0.05); 20 | var h = +b.GetHeight(); 21 | var ht = +t.GetHeight(); 22 | app.DestroyLayout(lay); 23 | if (h) break; 24 | } 25 | BTN_HEIGHT = h; 26 | TXT_HEIGHT = ht; 27 | 28 | curr = 1; 29 | app.SetOrientation("portrait"); 30 | app.EnableBackKey(false); 31 | layMain = app.CreateLayout("Linear", "Vertical"); 32 | layMain.SetBackGradient("#eeeeee", "#ffffff"); 33 | layT = app.CreateLayout("Linear", "Horizontal,FillX,vcenter"); 34 | layT.SetBackColor("#ff0000"); 35 | layMain.AddChild(layT); 36 | var wBtn = BTN_HEIGHT * HEIGHT / WIDTH; 37 | sideBtn = app.CreateButton("[fa-list]", -1, -1, "fontawesome,Custom"); 38 | sideBtn.SetSize(wBtn, BTN_HEIGHT); 39 | sideBtn.SetTextSize(BTN_HEIGHT * HEIGHT / 2, 'px'); 40 | sideBtn.SetBackColor("#ff0000"); 41 | sideBtn.SetOnTouch(sideBtn_OnTouch); 42 | layT.AddChild(sideBtn); 43 | title = app.CreateText("DNSChanger", 1 - wBtn, -1, "fontawesome"); 44 | title.SetTextSize(25); 45 | layT.AddChild(title); 46 | 47 | var layBody = app.CreateLayout('linear'); 48 | layBody.SetSize(1, 1 - BTN_HEIGHT * 2 - TXT_HEIGHT); 49 | layMain.AddChild(layBody); 50 | 51 | txt1 = app.CreateText("Domain Name Server :", 1, -1, "Left"); 52 | txt1.SetTextSize(20); 53 | txt1.SetTextColor("Red"); 54 | layBody.AddChild(txt1); 55 | dnsEdit = app.CreateTextEdit("208.67.222.222", 1, -1, ""); 56 | dnsEdit.SetHint("Hint: OpenDNS server - 208.67.222.222"); 57 | dnsEdit.SetTextColor("Black"); 58 | layBody.AddChild(dnsEdit); 59 | app.AddLayout(layMain); 60 | txt3 = app.CreateText("System IP Info:", 1, -1, "Left"); 61 | txt3.SetTextSize(20); 62 | txt3.SetTextColor("Red"); 63 | layBody.AddChild(txt3); 64 | //txt3.Hide(); 65 | resultEdit = app.CreateText("", 1, -1, "MultiLine,Left") 66 | resultEdit.SetTextSize(20); 67 | resultEdit.SetTextColor("Black"); 68 | layBody.AddChild(resultEdit); 69 | // resultEdit.Hide(); 70 | layB = app.CreateLayout("Linear", "Horizontal,FillXY"); 71 | setBtn = app.CreateButton("Set DNS", 1 / 3, -1); 72 | layB.AddChild(setBtn); 73 | setBtn.SetOnTouch(setDNS); 74 | clearBtn = app.CreateButton("Clear", 1 / 3, -1); 75 | clearBtn.SetOnTouch(clear); 76 | deleteBtn = app.CreateButton("Flush DNS", 1 / 3); 77 | layB.AddChild(clearBtn); 78 | layB.AddChild(deleteBtn); 79 | layMain.AddChild(layB); 80 | deleteBtn.SetOnTouch(flushDNS); 81 | devText = app.CreateText("Developer: gauravssnl"); 82 | devText.SetTextColor("#ff0000"); 83 | devText.SetOnTouch(dev_OnTouch); 84 | 85 | layMain.AddChild(devText); 86 | createDrawer(); 87 | app.AddDrawer(drawerScroll, "Left", drawerWidth); 88 | // alert(app.SysExec("ip route show")); 89 | showSystemInfo(); 90 | print_info(); 91 | } 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | function clear() { 101 | dnsEdit.SetText(""); 102 | // resultEdit.SetText( "" ); 103 | } 104 | 105 | function dev_OnTouch() { 106 | app.ShowPopup("Developer: gauravssnl.\nApp uses Google Maps API to find Location details."); 107 | } 108 | 109 | 110 | function OnBack() { 111 | // layW.DestroyChild( ); 112 | if (curr == 2) { 113 | curr = 1; 114 | layW.Gone(); 115 | } 116 | else if (curr == 1) { 117 | curr = -1; 118 | app.ShowPopup("Press Back Key again to exit"); 119 | app.EnableBackKey(true); 120 | } 121 | 122 | //layT.Show(); 123 | //OnStart(); 124 | } 125 | 126 | 127 | function createDrawer() { 128 | drawerWidth = 0.75 129 | drawerScroll = app.CreateScroller(drawerWidth, 1); 130 | drawerScroll.SetBackColor("#ffffff"); 131 | layDrawer = app.CreateLayout("Linear", "Left"); 132 | drawerScroll.AddChild(layDrawer); 133 | layDrawerTop = app.CreateLayout("Absolute"); 134 | layDrawerTop.SetSize(drawerWidth, 0.23); 135 | layDrawerTop.SetBackGradient("#ff000f", "#ffff00"); 136 | layDrawer.AddChild(layDrawerTop); 137 | 138 | img = app.CreateImage("Img/DNSChanger.png", 0.15); 139 | img.SetPosition(drawerWidth * 0.06, 0.04); 140 | layDrawerTop.AddChild(img); 141 | 142 | appt = app.CreateText("DNSChanger", -1, -1, "Bold"); 143 | appt.SetPosition(drawerWidth * 0.3, 0.06); 144 | appt.SetTextSize(21, "dip"); 145 | layDrawerTop.AddChild(appt); 146 | 147 | dev = app.CreateText("gauravssnl"); 148 | dev.SetPosition(drawerWidth * 0.07, 0.155); 149 | dev.SetTextColor("#22ff22"); 150 | dev.SetTextSize(18, "dip"); 151 | layDrawerTop.AddChild(dev); 152 | email = app.CreateText("gaurav.ssnl@gmail.com"); 153 | email.SetPosition(drawerWidth * 0.07, 0.185); 154 | email.SetTextColor("Black"); 155 | layDrawerTop.AddChild(email); 156 | 157 | layMenu = app.CreateLayout("Linear", "Left"); 158 | layDrawer.AddChild(layMenu); 159 | lstdata = "About:: [fa-info-circle] ,Feedback:: [fa-pencil]"; 160 | listMenu1 = app.CreateList(lstdata, drawerWidth, -1, "Menu,Expand"); 161 | listMenu1.SetOnTouch(listMenu_OnTouch); 162 | layMenu.AddChild(listMenu1); 163 | } 164 | 165 | 166 | function listMenu_OnTouch(title, body, type, index) { 167 | app.CloseDrawer(); 168 | if (this == listMenu1) { 169 | if (title == "About") about(); 170 | else if (title == "Feedback") feedback(); 171 | } 172 | } 173 | 174 | function about() { 175 | dlg = app.CreateDialog("About"); 176 | layDlg = app.CreateLayout("Linear", "Vertical,Center"); 177 | layDlg.SetBackGradient("#eeeeee", "#ffffff"); 178 | layDlg.SetSize(0.9, 0.7); 179 | dlg.AddLayout(layDlg); 180 | msg = "DNSChanger App by gauravssnl
E-mail:
gaurav.ssnl@gmail.com

\ 181 | This app can be used to set DNS for mobile/WiFi network on Android phone.

\ 182 | Android has no option of setting DNS for mobile internet, so this app can help you to set DNS in that case.

\ 183 | This App requires root access as we need to use iptables.

\ 184 | Advantage: No Android VPN technique, no battery loss.

\ 185 | DroidScript(JavaScript) has been used to develop this App."; 186 | txt = app.CreateText(msg, 0.9, -1, "MultiLine,html,link,"); 187 | txt.SetTextSize(20); 188 | txt.SetTextColor("#ff0000"); 189 | txt.SetPadding(0.05, 0.0, 0.05, 0.0); 190 | layDlg.AddChild(txt); 191 | dlg.Show(); 192 | } 193 | 194 | function feedback() { 195 | app.OpenUrl("mailto:gaurav.ssnl@gmail.com?subject=LocateMeApp"); 196 | } 197 | 198 | 199 | function sideBtn_OnTouch() { 200 | app.OpenDrawer("Left"); 201 | } 202 | 203 | function print(msg, end = "\n") { 204 | if (resultEdit.GetText()) 205 | resultEdit.SetText(resultEdit.GetText() + end + msg); 206 | else 207 | resultEdit.SetText(msg); 208 | 209 | } 210 | 211 | function showSystemInfo() { 212 | resultEdit.SetText(""); 213 | res = exec("ip route show") 214 | if (res) { 215 | for (i = 0; i <= 70; i++) print("-", end = ""); 216 | 217 | 218 | res = res.split(" "); 219 | print("Gateway \t\t\t" + res[0]) 220 | ip = app.GetIPAddress(); 221 | if (ip === "0.0.0.0") dev = "rmnet_data0(Mobile Internet)"; 222 | else dev = "wlan0(WiFi)" 223 | print(res[1] + "\t\t \t\t\t\t\t\t\t " + dev); 224 | print(res[4] + " \t\t \t\t\t\t\t " + res[5]); 225 | print(res[7] + "\t\t \t\t\t\t\t " + res[8]); 226 | print(res[10] + "\t\t \t\t\t\t\t\t " + res[11] + "\n"); 227 | for (i = 0; i <= 70; i++) print("-", end = ""); 228 | } 229 | 230 | else 231 | print("Your are not connected to internet.\nPlease, switch on internet connection first.\n\n"); 232 | } 233 | 234 | function exec(cmd) { 235 | return app.SysExec(cmd); 236 | } 237 | 238 | function setDNS() { 239 | server = dnsEdit.GetText(); 240 | 241 | if (ValidateIPaddress(server)) { 242 | //clearActionData(); 243 | flushDNS(); 244 | print("Routing DNS request to server : " + server); 245 | app.SysExec("su -c iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination " + server); 246 | app.SysExec("su -c iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination " + server); 247 | app.SysExec("su -c setprop net.dns1 " + server); 248 | print("Routing DNS request to server completed"); 249 | } 250 | 251 | } 252 | 253 | function flushDNS() { 254 | clearActionData(); 255 | showSystemInfo(); 256 | print("Flushing Iptables NAT rules"); 257 | app.SysExec("su -c iptables -t nat -F"); 258 | print("NAT rule flushed"); 259 | } 260 | 261 | function ValidateIPaddress(ipaddress) { 262 | if (!ipaddress) { 263 | alert("Empty DNS address!") 264 | return (false) 265 | } 266 | // return true; 267 | if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) { 268 | return (true) 269 | } 270 | alert("You have entered an invalid DNS address!") 271 | return (false) 272 | } 273 | 274 | function clearActionData() { 275 | data = resultEdit.GetText(); 276 | lastIndex = data.lastIndexOf("-"); 277 | resultEdit.SetText(data.substring(0, lastIndex)); 278 | 279 | } 280 | 281 | function print_info() { 282 | print("This application requires rooted phone.\n Iptables should also be installed(busybox can help)."); 283 | } 284 | -------------------------------------------------------------------------------- /DNSChanger/Img/DNSChanger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/DNSChanger/Img/DNSChanger.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 GAURAV 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DNSChanger 2 | DNSChanger Android app 3 | 4 | This app can be used to set DNS for mobile/WiFi network on Android phone. 5 | 6 | Android has no option of setting DNS for mobile internet, so this app can help you to set DNS in that case. 7 | 8 | This App requires root access as we need to use iptables. 9 | 10 | Advantage: No Android VPN technique, no battery loss. 11 | 12 | DroidScript(JavaScript) has been used to develop this App. 13 | 14 | To verify DNS Change , we can use the command : 15 | ```code 16 | nslookup google.com 17 | ``` 18 | We can also use whatsmydnsserver.com for checking our current DNS . 19 | 20 | If you are using OpenDNS server ( 208.67.222.222), we can verify it by using welcome.opendns.com and we should see successful message. 21 | 22 | 23 | ## 1. App Home 24 | 25 | ![ScreenShot]( https://github.com/gauravssnl/DNSChanger/blob/master/Screenshots/Screenshot_20190124-015443.png ) 26 | 27 | 28 | 29 | ## 2. DNS setup successful 30 | 31 | ![ScreenShot]( https://github.com/gauravssnl/DNSChanger/blob/master/Screenshots/Screenshot_20190124-015419.png ) 32 | 33 | 34 | 35 | ## 3. DNS Flush 36 | 37 | ![ScreenShot]( https://github.com/gauravssnl/DNSChanger/blob/master/Screenshots/Screenshot_20190124-015443.png ) 38 | 39 | 40 | ## 4. DNS Change Verification 41 | 42 | ![ScreenShot]( https://github.com/gauravssnl/DNSChanger/blob/master/Screenshots/Screenshot_20190126-014004.png ) 43 | 44 | 45 | ## 5. OpenDNS Verification 46 | 47 | ![ScreenShot]( https://github.com/gauravssnl/DNSChanger/blob/master/Screenshots/Screenshot_20190124-210837.png ) 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Screenshots/Screenshot_20190119-165338.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/Screenshots/Screenshot_20190119-165338.png -------------------------------------------------------------------------------- /Screenshots/Screenshot_20190119-165942.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/Screenshots/Screenshot_20190119-165942.png -------------------------------------------------------------------------------- /Screenshots/Screenshot_20190124-015410.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/Screenshots/Screenshot_20190124-015410.png -------------------------------------------------------------------------------- /Screenshots/Screenshot_20190124-015419.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/Screenshots/Screenshot_20190124-015419.png -------------------------------------------------------------------------------- /Screenshots/Screenshot_20190124-015443.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/Screenshots/Screenshot_20190124-015443.png -------------------------------------------------------------------------------- /Screenshots/Screenshot_20190124-210731.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/Screenshots/Screenshot_20190124-210731.png -------------------------------------------------------------------------------- /Screenshots/Screenshot_20190124-210837.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/Screenshots/Screenshot_20190124-210837.png -------------------------------------------------------------------------------- /Screenshots/Screenshot_20190126-014004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravssnl/DNSChanger/23abc2897b51c62afa1611c87e9ef8eb8fae7ef2/Screenshots/Screenshot_20190126-014004.png --------------------------------------------------------------------------------