论坛首页 Web前端技术论坛

入侵初步

浏览 2022 次
锁定老帖子 主题:入侵初步
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-10-24  

  入侵的方式有很多种,技术手段的运用将事半功倍。

  做为正大光明,并且并不违法的做法就是要建立一批能打硬战的水军队伍,越多越好,话说sohu的服务多,有微博,博客等等,还将会有N多免费的服务在推出,所以我就就像<<搭车去柏林>>的谷岳一样,准备搭乘这种免费的班车。

  注册成为sohu的会员是一切的基础,手动做没有问题。但是一天要申请N多帐号就是一个问题。好,我介绍一下我使用的工具。

  htmlunit,导入这个相关包就可以

      如下代码是测试成功的示例,因为注册时填写哪个验证码是一个很为难的工作,所以我也有对付的方法。只做为参考,代码很乱,大家姑且看吧。

 

  先说下运行效果:

 


 

   如下是测试代码,请大家笑纳:

 

  package com.antbee.invade.begin;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.GeneralSecurityException;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import org.junit.Test;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlImageInput;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;

public class InvadeSohuMail {

	private final static String BASE_SING_URL = "http://passport.sohu.com";
	private final static String REG_MAIL_URL = BASE_SING_URL + "/web/dispatchAction.action?appid=1000&ru=http://mail.sohu.com/reg/signup_success.jsp";
	private final static String LOGIN_MAIL_URL = "http://mail.sohu.com/";
	private final static String MODIFY_INFO_URL = "https://passport.sohu.com/web/updateInfo.action?modifyType=userinfo";
	private WebClient client;

	@Test
	public void regMail() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
		init();
		HtmlPage signPage = client.getPage(REG_MAIL_URL);
		HtmlForm regForm = signPage.getFormByName("form1");
		regForm.click();

		HtmlInput u = regForm.getElementById("sohupp-email");
		HtmlInput psw = regForm.getElementById("sohupp-password");
		HtmlInput psw2 = regForm.getElementById("sohupp-confirmpwd");
		HtmlInput maskCode = regForm.getElementById("sohupp-validatecode");
		HtmlAnchor refreshButton = regForm.getElementById("sohupp-refreshvcode");
		u.focus();
		u.setValueAttribute("z9sshil98yqDnqg1f");
		u.mouseOut();
		u.click();

		psw.focus();
		psw.setValueAttribute("6byxdfdfzvwNLMyqfPd");
		psw.mouseOut();
		psw.click();

		psw2.focus();
		psw2.setValueAttribute("6bsadfyxzvwNLMyqfPd");
		psw2.mouseOut();
		psw2.click();

		maskCode.focus();
		maskCode.click();
		refreshButton.click();

		HtmlDivision maskPic = (HtmlDivision) signPage.getElementById("checkpic");// /servlet/Captcha?time=a
		String maskPicStyle = maskPic.getAttribute("style");
		String maskCodeImageUrl = maskPicStyle.split(";")[2];
		maskCodeImageUrl = maskCodeImageUrl.replace("background: url(\"", "");//
		maskCodeImageUrl = maskCodeImageUrl.substring(0, maskCodeImageUrl.indexOf(")") - 1);

		JFrame f2 = new JFrame();
		JLabel l = new JLabel(new ImageIcon(new URL(BASE_SING_URL + maskCodeImageUrl.trim())));
		System.out.println("图片地址:" + maskCodeImageUrl.trim());
		f2.getContentPane().add(l);
		f2.setSize(200, 200);
		f2.setTitle("验证码");
		f2.setVisible(true);
		String valicodeStr = JOptionPane.showInputDialog("请输入验证码:");
		f2.setVisible(false);
		System.out.println("验证码:" + valicodeStr);
		maskCode.setValueAttribute(valicodeStr);
		maskCode.mouseOut();
		maskCode.click();

		HtmlSubmitInput regButton = (HtmlSubmitInput) regForm.getElementById("sohupp-submit");
		regButton.focus();

		u.dblClick();
		psw.dblClick();
		psw2.dblClick();
		maskCode.dblClick();

		regButton.click();
		regButton.mouseOut();
		regButton.dblClick();
		HtmlPage sumitPage = regButton.click();
		// Thread.sleep(30000);
		System.out.println(sumitPage.getUrl());

		String successTitle = sumitPage.getTitleText();
		if (successTitle.equals("搜狐通行证")) {
			System.out.println("成功");
		}
		// System.out.println(sumitPage.asXml());
	}

	@Test
	public void welcomeSohuMail() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
		SoldierModel soldierModel = new SoldierModel();
		soldierModel.setScreenCode("efbe13av6sadfc4nss");
		soldierModel.setUserPassword("cwA5sh5asdfasbA3Jss87jJ");
		soldierModel.setUserName("渡过快乐的每一天!");
		loginSohuMail(soldierModel);
	}

	/**
	 * 登录sohuMail
	 * 
	 * @throws IOException
	 * @throws MalformedURLException
	 * @throws FailingHttpStatusCodeException
	 * @throws InterruptedException
	 */
	private void loginSohuMail(SoldierModel soldierModel) throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
		init();
		HtmlPage loginPage = client.getPage(LOGIN_MAIL_URL);
		HtmlInput userName = loginPage.getHtmlElementById("username");
		HtmlInput password = loginPage.getHtmlElementById("password");
		HtmlImageInput loginButton = loginPage.getHtmlElementById("login_img");

		userName.focus();
		userName.setValueAttribute(soldierModel.getScreenCode());
		userName.mouseOut();

		password.focus();
		password.setValueAttribute(soldierModel.getUserPassword());
		password.mouseOut();

		loginButton.focus();
		loginButton.click();
		Thread.sleep(28000);
		HtmlPage welcomePage = client.getPage(LOGIN_MAIL_URL);
		String welcomeTitle = welcomePage.getTitleText().trim();
		System.out.println(welcomeTitle);
		Boolean successFlag = false;
		if (welcomeTitle.equals("闪电邮 - 搜狐")) {
			successFlag = true;
		}
		if (successFlag) {
			HtmlPage modifyInfoPage = client.getPage(MODIFY_INFO_URL);
			HtmlInput userId = modifyInfoPage.getHtmlElementById("userid");
//			List list = modifyInfoPage.getElementsByName(name)
//	        for( Iterator it = list.iterator(); it.hasNext(); ) {
//	            HtmlRadioButtonInput radio =
//	(HtmlRadioButtonInput)it.next();
//	            System.out.println(radio.getValueAttribute() + ' ' +
//	radio.getNextSibling().asText() );
//	        }
			HtmlRadioButtonInput female = modifyInfoPage.getHtmlElementById("female");
			
			HtmlInput year = modifyInfoPage.getHtmlElementById("year");
			HtmlInput month = modifyInfoPage.getHtmlElementById("month");
			HtmlInput day = modifyInfoPage.getHtmlElementById("day");
			HtmlInput userProvince = modifyInfoPage.getElementByName("user.province");
			HtmlInput userCity = modifyInfoPage.getElementByName("user.city");
			HtmlInput userEducation = modifyInfoPage.getElementByName("user.education");
			
			userId.focus();
			userId.mouseDown();
			userId.setValueAttribute(soldierModel.getUserName());
			userId.mouseUp();
			
			female.focus();
			female.mouseDown();
			female.click();
			female.mouseUp();
			
			year.setValueAttribute("1988");
			month.setValueAttribute("03");
			day.setValueAttribute("11");
			userProvince.setValueAttribute("上海");
			
			HtmlSubmitInput submitUserInfo = modifyInfoPage.getElementByName("submit");
			HtmlPage userInfoPage = submitUserInfo.click();
			System.out.println(userInfoPage.getUrl());
			System.out.println(userInfoPage.asXml());
			
		}
//		System.out.println(welcomePage.getUrl());
		// System.out.println(welcomePage.asXml());
	}

	private void init() {
		client = new WebClient(BrowserVersion.FIREFOX_3_6);
		client.setJavaScriptEnabled(true);
		client.setThrowExceptionOnScriptError(false);
		client.setThrowExceptionOnFailingStatusCode(false);
		try {
			client.setUseInsecureSSL(true);
		} catch (GeneralSecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

 

 

    其中sohu也不傻,一个IP一天最多能提供15个帐号的注册,哪怎么办呢?好办,webclient启用代理呀。每15个或者12个就换一批代理。

 手累点,一个小时我注册了50个左右,但是也太累。

  • 大小: 103 KB
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics