自动生成IP模拟POST访问后端程序

原博客地址:https://blog.csdn.net/u014001866/article/details/50618915

这边分享一个IP生成器,每次用不同的IP模拟URL的POST提交,对后端进行强访问。

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.Random;
 
/**
 * @author
 * @date 2016年1月26日 下午4:13:07
 */
public class Test {
    public static void main(String[] args) {
        while (true) {
            String sr = Test
                    .sendPost(
                            "访问路径",
                            "&参数");//a=2222
            System.out.println(sr);
            try {             
                Thread.sleep(90000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
 
    public static String sendPost(String url, String param) {
        PrintWriter out = null;
        BufferedReader in = null;
        String result = "";
        try {
            URL realUrl = new URL(url);
            URLConnection conn = realUrl.openConnection();
 
            // 随机生成ip
            String ip = randIP();
            conn.setRequestProperty("X-Forwarded-For", ip);
            conn.setRequestProperty("HTTP_X_FORWARDED_FOR", ip);
            conn.setRequestProperty("HTTP_CLIENT_IP", ip);
            conn.setRequestProperty("REMOTE_ADDR", ip);
            conn.setRequestProperty("Host", "");
            conn.setRequestProperty("Connection", "keep-alive");
            conn.setRequestProperty("Content-Length", "17");
            conn.setRequestProperty("Accept", "application/json");
            conn.setRequestProperty("Origin", "ORIGIN");
            conn.setRequestProperty(
                    "User-Agent",
                    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
            conn.setRequestProperty("Content-Type",
                    "application/x-www-form-urlencoded");
            conn.setRequestProperty(
                    "Referer",
                    "REFERER");
            conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
            conn.setRequestProperty("Accept-Language",
                    "zh-CN,zh;q=0.8,en;q=0.6,ja;q=0.4,pt;q=0.2");
 
            conn.setDoOutput(true);
            conn.setDoInput(true);
            out = new PrintWriter(conn.getOutputStream());
            out.print(param);
            out.flush();
            in = new BufferedReader(
                    new InputStreamReader(conn.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (Exception e) {
            System.out.println("发送 POST 请求出现异常!" + e);
            e.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return result;
    }
 
    public static String randIP() {
        Random random = new Random(System.currentTimeMillis());
        return (random.nextInt(255) + 1) + "." + (random.nextInt(255) + 1)
                + "." + (random.nextInt(255) + 1) + "."
                + (random.nextInt(255) + 1);
    }
 
}
 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
【网站模拟访问机】 本程序是一款通过模拟IE访问来增加网站的pv流量,并通过模拟百度和谷歌的关键字搜索来增加网站的搜索排名及网站收录。 特点: 1、采用代理IP的真实访问模拟,适应各种统计软件; 2、模拟访问速度根据时段智能控制,使数据看上去更真实; 3、网页深度访问模拟,区别于其他软件只能刷指定的几个页面, 本软件根据设定的地址,进行搜索,可以访问页面内最大20层深度的页面。 4、模拟真实的百度和谷歌搜索,并自动翻页查找搜索结果,区别于其它软件的直接url访问; 5、代理地址筛选,直接粘贴代理网站的地址,自动进行格式化和晒选,生成列表文件备用; 备注: 1、被模拟网页必须规范化html代码,并保证打开速度; 2、每个网页的title必须正确; 3、所有页面中不得有死链接; 4、所输入配置文件的关键字必须在百度和谷歌搜索引擎中能搜索到本站链接,建议在前三页之内。 5、本程序采用netwinform框架开发,运行程序需要先安装 Microsoft .NET Framework 3.5 安装包 安装包下载地址可参考 http://www.netwinform.com/plusinfo.aspx?id=5 使用: 第一步、下载后,解压缩; 第二步、修改配置文件并保存; 第三步、运行主程序 webpv_autoadd.exe 第四步、载入代理IP地址列表 第五步、点启动按钮启动相应的模拟器(可同时启动三个模拟器,也可以启动多个客户端) 注册: 本软件与域名进行绑定,不限客户端数量。 试用版会每个小时自动终止网站模拟,并弹出注册提示框,点击【继续试用】按钮后,再重新点启动按钮,可以继续试用。如果想支持本软件,长期使用用本软件,建议联系软件作者索取软件注册码。 【NetWinForm程序园】 网址: http://www.netwinform.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值