Jul 22, 2015 10:28 AM
(This post was last modified: Jul 23, 2015 10:07 AM by Benoit ᵇᵃˡˡˢ.)
I'm trying to make an app that tries all default router passwords on the router. I've made the following function to imitate logging in to the web-panel (router):
(Taken from stackoverflow). My router's IP is located at 10.0.0.138 and when trying to login with chrome and the credentials Admin:Admin , I am able to successfully login. However when invoke the method I've created with the following:
I get an exception saying connection to 10.0.0.138 is refused. What am i doing wrong here? Am i missing some kind of technical aspect?
Tried looking at chrome headers , and saw there was a header Authorization in chrome headers and my request had the identical value in my HttpGet.
I don't know if it matters , but this is for android.
added the following , didn't help
Code
public String logInToRouter(String routerIP , String user , String pass)
{
HttpClient httpClient = new DefaultHttpClient();
routerIP = "http://" + routerIP;
HttpGet httpGet = new HttpGet(routerIP);
httpGet.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials
(user, pass),"UTF-8", false));
HttpResponse httpResponse;
try {
httpResponse = httpClient.execute(httpGet);
} catch (IOException e) {
e.printStackTrace();
return "Exception";
}
int statusCode = httpResponse.getStatusLine().getStatusCode();
if(statusCode == 200)
return "Status Code : 200";
else if(statusCode == 403)
return "Forbidden";
else if(statusCode == 401)
return "Unauthorized";
else
return "Please manually check.";
}Code
logInToRouter("10.0.0.138", "Admin" ,"Admin");Tried looking at chrome headers , and saw there was a header Authorization in chrome headers and my request had the identical value in my HttpGet.
I don't know if it matters , but this is for android.
Code
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.internet"/>
