Skip to content

Commit 34092c1

Browse files
committed
[ExploitFinder] follow HTTP redirects.
Even if we tell to Java to do this it ignore our preferences. We have to do this my hand.
1 parent 41d6e3a commit 34092c1

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

cSploit/src/org/csploit/android/net/RemoteReader.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ public void run() {
357357
boolean isError;
358358
InputStream stream;
359359
Notifier notifier;
360-
URL url;
361360

362361
running = true;
363362

@@ -385,23 +384,28 @@ public void run() {
385384
stream = null;
386385

387386
try {
388-
url = new URL(task.getUrl());
389-
} catch (MalformedURLException e) {
390-
notifiers.execute(new Notifier(task, ("Bad URL: " + task.getUrl()).getBytes(), true));
391-
continue;
392-
}
387+
String url = task.getUrl();
393388

394-
if(!url.getHost().equals(host)) {
395-
Logger.error(String.format("RemoteReader[%s]: URL '%s' does not belong to me", host, task.getUrl()));
396-
notifiers.execute(new Notifier(task, "Host mismatch".getBytes(), true));
397-
continue;
398-
}
389+
Logger.info("fetching '" + url + "'");
399390

400-
Logger.info("fetching '" + url.toString() + "'");
391+
URL current = new URL(url);
401392

402-
try {
403-
connection = url.openConnection();
404-
stream = connection.getInputStream();
393+
for(int i=0;i<30;i++) {
394+
connection = current.openConnection();
395+
stream = connection.getInputStream();
396+
397+
if(!(connection instanceof HttpURLConnection))
398+
break;
399+
400+
HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
401+
int code = httpURLConnection.getResponseCode();
402+
403+
if(code != HttpURLConnection.HTTP_MOVED_PERM && code != HttpURLConnection.HTTP_MOVED_TEMP )
404+
break;
405+
406+
String location = connection.getHeaderField("Location");
407+
current = new URL(current, location);
408+
}
405409
} catch (IOException e) {
406410
if (connection != null && connection instanceof HttpURLConnection) {
407411
stream = ((HttpURLConnection) connection).getErrorStream();

0 commit comments

Comments
 (0)