From 350d79db8c817cfc80e597c2bb37fbd11cc5c604 Mon Sep 17 00:00:00 2001 From: Will Shackleton Date: Mon, 27 Apr 2015 20:30:15 +0100 Subject: [PATCH] Fixed the blue ball machine (crudely) --- .../netspoofer/spoofs/RedirectSpoof.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/androidnetspoof/src/main/java/uk/digitalsquid/netspoofer/spoofs/RedirectSpoof.java b/androidnetspoof/src/main/java/uk/digitalsquid/netspoofer/spoofs/RedirectSpoof.java index 6b16630..f53b880 100644 --- a/androidnetspoof/src/main/java/uk/digitalsquid/netspoofer/spoofs/RedirectSpoof.java +++ b/androidnetspoof/src/main/java/uk/digitalsquid/netspoofer/spoofs/RedirectSpoof.java @@ -50,7 +50,7 @@ public class RedirectSpoof extends Spoof implements LogConf { public static final int MODE_BLUEBALL = 1; public static final int MODE_CUSTOM = 2; - private String redirect, host; + private String redirect, host, topLevelDomain; private static String getTitle(Context context, int mode) { switch(mode) { @@ -138,8 +138,9 @@ public void modifyRequest(HttpRequest request) { } @Override public void modifyResponse(HttpResponse response, HttpRequest request) { - if(response.getContentType().startsWith("text/html")) { - if(request.getHost().equals(host)) return; + if (response.getContentType().startsWith("text/html")) { + if (request.getHost().equals(host)) return; + if (request.getHost().endsWith(topLevelDomain)) return; response.reset(); response.setResponseCode(301); response.setResponseMessage("Moved Permanently"); @@ -155,6 +156,12 @@ private void setRedirect(String redirect) { this.redirect = redirect; try { host = Uri.parse(redirect).getHost(); + int index = host.indexOf('.'); + if (index == -1) { + topLevelDomain = host; + } else { + topLevelDomain = host.substring(index + 1); + } } catch(Exception e) { } // This exception will only happen on user // stupidity }