package vote;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
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 Vote {
public static void main(String args[]) throws ClientProtocolException, IOException
{
// HttpClient httpclient = new DefaultHttpClient();
String url="";
for(int j=180;j<230;j++)
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httpost = new HttpPost(url);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("username", "dsdgdd01"+j));
nvps.add(new BasicNameValuePair("email", "gfdg0101"+j+"@cm4d.cn"));
nvps.add(new BasicNameValuePair("password", "101010"));
nvps.add(new BasicNameValuePair("password2", "101010"));
HttpEntity httpentity = new UrlEncodedFormEntity(nvps, "utf-8");
httpost.setEntity(httpentity);
//伪造ip
httpost.setHeader("X-FORWARDED-FOR ", "213.125.18."+j);
// httpost.addHeader("X-FORWARDED-FOR ", "213.125.33.56");
HttpResponse response = httpclient.execute(httpost);
System.out.println(response.getEntity());
//获得cookie
Header locationHeader = response.getFirstHeader("Set-Cookie");
System.out.println(locationHeader);
Header h[]=response.getAllHeaders();
for(int i=0;i<h.length;i++)
{
System.out.println(h[i].getName()+": "+h[i].getValue());
}
//断开连接
httpost.abort();
// httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.ACCEPT_ALL);
String url2="";
HttpPost post2=new HttpPost(url2);
List<NameValuePair> pram2=new ArrayList<NameValuePair>();
pram2.add(new BasicNameValuePair("vid", "20"));
HttpEntity httpentity2 = new UrlEncodedFormEntity(pram2, "utf-8");
post2.setEntity(httpentity2);
post2.setHeader("Cookie", locationHeader.toString());
HttpResponse response2 = httpclient.execute(post2);
System.out.println(response2.getEntity());
post2.abort();
}
}
}
httpclient
最新推荐文章于 2022-12-08 14:47:20 发布