0
点赞
收藏
分享

微信扫一扫

让八爪自动发消息的程序

alonwang 2022-07-27 阅读 9


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;import org.json.JSONException;
import org.json.JSONObject;
public class HttpUtil {
static class StringPair{
String key="";
String value="";
StringPair(String key,String value){
this.key=key;
this.value=value;

}
}
public static void main(String args[]){


List<StringPair> list=new ArrayList<StringPair>();

list.add(new StringPair("action","checkReg"));
list.add(new StringPair("cell", "5588236"));
list.add(new StringPair("checkCodeError", ""));
http("​​​http://www.ibazhua.com/api.htm",list​​​);




List<StringPair> list2=new ArrayList<StringPair>();
list2.add(new StringPair("action","getSessionId"));
String str= http("​​​http://www.ibazhua.com/api.htm",list2​​​);

try {
JSONObject dataJson = new JSONObject(str);

String sessionId = dataJson.getString("s");

http("​​​http://www.ibazhua.com/",sessionId​​​);
// httpGet("​​​http://www.ibazhua.com/css/style.css?v=0.9296646208485236",sessionId​​​);


} catch (JSONException e) {
e.printStackTrace();
}
// httpGet("​​​http://c.cnzz.com/cnzz_core.php?web_id=4088593&l=none​​​");

}

public static String http(String url, List<StringPair> params) { URL u = null;
HttpURLConnection con = null;
// 构建请求参数
StringBuffer sb = new StringBuffer();
sb.append("{");
if (params != null) {
//{"action":"checkReg","cell":"5588236","checkCodeError":""}
for (StringPair e : params) { sb.append('\"'+e.key+'\"');
sb.append(":");
sb.append('\"'+e.value+'\"');
sb.append(",");
}

}
System.out.println("send_url:" + url); System.out.println("send_data:" + sb.toString());
// 尝试发送请求
try {
u = new URL(url);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.99.60.90", 8080));



con = (HttpURLConnection) u.openConnection(proxy); con.setRequestMethod("POST");
con.setDoOutput(true);;
con.setDoInput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");

con.setRequestProperty("Cookie",
"bindCookie=dk7STdjC8UAa8RTsuYOpo8; CNZZDATA4088593=cnzz_eid=14016353-1354506651-http%253A%252F%252Fwww.igetui.com%252Fsolution.htm%253FtitleName%253D2s&ntime=1354666814&cnzz_a=8&retime=1354674213282&sin=none<ime=1354674213282&rtime=2; bdshare_firstime=1354522114381; phone=5588236; sendFilte=13439593183_5588236; moreThanSMS=13439593183_2; JSESSIONID=91dpyyf42wgz1h0s7510xkwd4");

con.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
OutputStreamWriter osw = new OutputStreamWriter(
con.getOutputStream(), "UTF-8"); osw.write(sb.substring(0, sb.length() - 1)+"}");
osw.flush();
osw.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
// con.disconnect();
}
}
// 读取返回内容
StringBuffer buffer = new StringBuffer();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(con
.getInputStream(), "UTF-8"));
String temp;
while ((temp = br.readLine()) != null) {
System.out.println(temp);
buffer.append(temp); buffer.append("\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return buffer.toString();
}



public static String http(String url, String sessionID) { URL u = null;
HttpURLConnection con = null;
// 构建请求参数
StringBuffer sb = new StringBuffer();
sb.append("-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"bindCode\"\r\n" +
"\r\n"+
"\r\n"+
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"contents\"; filename=\"\"\r\n" +
"Content-Type: application/octet-stream\r\n" +
"\r\n"+
"\r\n"+
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"uploadText\"\r\n" +
"\r\n"+
"12312312344444\r\n" +
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"uploadPhone\"\r\n" +
"\r\n"+
"5588236\r\n" +
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"uploadType\"\r\n" +
"\r\n"+
"text\r\n" +
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"status\"\r\n" +
"\r\n"+
"1\r\n" +
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"fileName\"\r\n" +
"\r\n"+
"\r\n"+
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"fileType\"\r\n" +
"\r\n"+
"\r\n"+
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"phoneType\"\r\n" +
"\r\n"+
"reg_bind\r\n" +
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"yzFlag\"\r\n" +
"\r\n"+
"h\r\n" +
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"resId\"\r\n" +
"\r\n"+
"126346\r\n" +
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"sourseUrl\"\r\n" +
"\r\n"+
"​​​www.ibazhua.com\r\n​​​" +
"-----------------------------7dc3ca27604c2\r\n" +
"Content-Disposition: form-data; name=\"sessionId\"\r\n" +
"\r\n"+
sessionID+"\r\n" +
"-----------------------------7dc3ca27604c2--\r\n"

);
System.out.println("send_url:" + url); System.out.println("send_data:" + sb.toString());
// 尝试发送请求
try {
u = new URL(url);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.99.60.90", 8080));



con = (HttpURLConnection) u.openConnection(proxy); con.setRequestMethod("POST");
con.setDoOutput(true);;
con.setDoInput(true);
con.setUseCaches(false);
con.setRequestProperty("Referer" ,"​​http://www.ibazhua.com/​​​");
con.setRequestProperty("Accept","text/html, application/xhtml+xml, */*");
con.setRequestProperty("Content-Type",
"multipart/form-data; boundary=---------------------------7dc3ca27604c2");
con.setRequestProperty("Accept-Encoding","gzip,deflate");

con.setRequestProperty("Cookie",
"bindCookie=dk7STdjC8UAa8RTsuYOpo8; CNZZDATA4088593=cnzz_eid=14016353-1354506651-http%253A%252F%252Fwww.igetui.com%252Fsolution.htm%253FtitleName%253D2s&ntime=1354666814&cnzz_a=9&retime="+
System.currentTimeMillis()+"&sin=none<ime=" +
System.currentTimeMillis()+"&rtime=2; bdshare_firstime=1354522114381; phone=5588236; sendFilte=13439593183_5588236; moreThanSMS=13439593183_2; JSESSIONID="+sessionID);

con.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
OutputStreamWriter osw = new OutputStreamWriter(
con.getOutputStream(), "UTF-8"); osw.write(sb.toString());
osw.flush();
osw.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
con.disconnect();
}
}
// 读取返回内容
StringBuffer buffer = new StringBuffer();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(con
.getInputStream(), "UTF-8"));
String temp;
while ((temp = br.readLine()) != null) {
System.out.println(temp);
buffer.append(temp); buffer.append("\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return buffer.toString();
}

public static String httpGet(String url, String sessionID) {
URL u = null;
HttpURLConnection con = null;
// 构建请求参数
StringBuffer sb = new StringBuffer();
System.out.println("send_url:" + url);
System.out.println("send_data:" + sb.toString());
// 尝试发送请求
try {
u = new URL(url);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.99.60.90", 8080));



con = (HttpURLConnection) u.openConnection(proxy); con.setRequestMethod("GET");
con.setDoOutput(true);;
con.setDoInput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");

con.setRequestProperty("Cookie",
"bindCookie=dk7STdjC8UAa8RTsuYOpo8; CNZZDATA4088593=cnzz_eid=14016353-1354506651-http%253A%252F%252Fwww.igetui.com%252Fsolution.htm%253FtitleName%253D2s&ntime=1354666814&cnzz_a=8&retime=1354674213282&sin=none<ime=1354674213282&rtime=2; bdshare_firstime=1354522114381; phone=5588236; sendFilte=13439593183_5588236; moreThanSMS=13439593183_2; JSESSIONID="+sessionID);

con.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
OutputStreamWriter osw = new OutputStreamWriter(
con.getOutputStream(), "UTF-8"); osw.write(sb.toString());
osw.flush();
osw.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
// con.disconnect();
}
}
// 读取返回内容
StringBuffer buffer = new StringBuffer();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(con
.getInputStream(), "UTF-8"));
String temp;
while ((temp = br.readLine()) != null) {
System.out.println(temp);
buffer.append(temp); buffer.append("\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return buffer.toString();
}
public static String httpGet(String url) {
URL u = null;
HttpURLConnection con = null;
// 构建请求参数
StringBuffer sb = new StringBuffer();
System.out.println("send_url:" + url);
System.out.println("send_data:" + sb.toString());
// 尝试发送请求
try {
u = new URL(url);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.99.60.90", 8080));



con = (HttpURLConnection) u.openConnection(proxy); con.setRequestMethod("GET");
con.setDoOutput(true);;
con.setDoInput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");

con.setRequestProperty("Cookie",
"cna=zvYgCd1ka24CAd6ABrmyYOmf");
con.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
OutputStreamWriter osw = new OutputStreamWriter(
con.getOutputStream(), "UTF-8"); osw.write(sb.toString());
osw.flush();
osw.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
con.disconnect();
}
}
// 读取返回内容
StringBuffer buffer = new StringBuffer();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(con
.getInputStream(), "UTF-8"));
String temp;
while ((temp = br.readLine()) != null) {
System.out.println(temp);
buffer.append(temp); buffer.append("\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return buffer.toString();
}


}

举报

相关推荐

0 条评论