Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

App that tries all default passwords on router webpanel

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):

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.";
}
(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:

Code
logInToRouter("10.0.0.138", "Admin" ,"Admin");
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.


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"/>
added the following , didn't help
[Image: IqcFmkW]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by JohnWayneNov 7, 2020 06:10 PM 21 2,127 Nov 7, 2020 06:10 PM
Last Post: xHeaven
[C#] by t0fxMar 25, 2020 12:59 PM 57 4,697 Mar 25, 2020 12:59 PM
Last Post: Obistone
[.NET] by PRPSJan 25, 2020 03:16 AM 12 332 Jan 25, 2020 03:16 AM
Last Post: devLIGHT