难得更新-脚本制作-最强版

首页 / 🍁编程类 / 正文

前言

最开始要来说,可能就今年开始吧,8月的第一个虎牙斗鱼脚本诞生,然后就一直拉不住闸了,哈哈哈,虽然么赚多少钱,但是开心就行了

开始的js

最开始用js写的,然后手机版用aotu.js,这个又没有学过,就只能一直用js写了,直到昨天晚上呢,别人说了一句话,我看了一篇帖子,我就越看越上头,回过头来,都4点了。
今年第一次熬这么晚,不过一个晚上学懂了一个东西。哈哈哈哈

那个东西

这个东西就是直接抓包,不过是手机端还是电脑端,你做操作就肯定会发起请求,用我们的专业名词来说就是请求,在简单来说就是一个网址,然后带上自己的东西去到另外一个地方。

方法

我看了好多篇文章,然后我最后想到了,利用java去模拟发送请求。这样既然很直接也很快速的,抢到自己想要的东西。

请求url+请求头+请求体+编码(发起请求)+聪明的我=脚本制作完成

具体教程

<dependency>
    <groupId>commons-httpclient</groupId>
    <artifactId>commons-httpclient</artifactId>
    <version>3.1</version>
</dependency>
<!-- apache http请求工具依赖包 -->
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.3.6</version>
</dependency>
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.lang.ArrayUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.util.*;

@Slf4j
public class HttpClientTest {
    /**
     * 发起post请求 没有任何body参数的情况
     *
     * @param url  请求的目标url地址
     * @param data 请求数据
     * @return 将响应结果转换成string返回
     * @throws IOException 可能出现的异常
     */
    private static String postMsg(String url, String data) throws IOException {
        // 根据url地址发起post请求
        HttpPost httppost = new HttpPost(url);

        StringEntity stEntity;

        // 获取到httpclient客户端
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            // 设置请求的一些头部信息
            httppost.addHeader("Content-Type", "application/json");
            httppost.addHeader("procode", "test");
            stEntity = new StringEntity(data, "UTF-8");
            httppost.setEntity(stEntity);
            // 设置请求的一些配置设置,主要设置请求超时,连接超时等参数
            RequestConfig requestConfig = RequestConfig.custom()
                .setConnectTimeout(5000).setConnectionRequestTimeout(1000).setSocketTimeout(5000)
                .build();
            httppost.setConfig(requestConfig);
            // 执行请求
            CloseableHttpResponse response = httpclient.execute(httppost);
            // 请求结果
            String resultString = "";
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                log.info("请求状态:{}", response.getStatusLine().getStatusCode());
                // 获取请求响应结果
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    // 将响应内容转换为指定编码的字符串
                    resultString = EntityUtils.toString(entity, "UTF-8");
                    log.info("Response content:{}", resultString);
                    return resultString;
                }
            } else {
                log.info("请求失败!");
                return resultString;
            }
        } catch (Exception e) {
            throw e;
        } finally {
            httpclient.close();
        }
        return null;
    }

    /**
     * body有内容的post请求方法 controller可以用bean直接接收参数
     *
     * @param url      目标地址
     * @param params   封装的参数
     * @param codePage 字符编码
     * @return 将响应结果转换成string返回
     * @throws Exception 可能出现的异常
     */
    private synchronized static String postData(String url, Map<String, String> params, String codePage) throws Exception {
        HttpClient httpClient = new HttpClient();
        // 请求相关超时时间设置
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(10 * 1000);
        httpClient.getHttpConnectionManager().getParams().setSoTimeout(10 * 1000);

        PostMethod method = new PostMethod(url);
        if (params != null) {
            // 内容编码设置
            method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, codePage);
            // 请求体信息设置
            method.setRequestBody(assembleRequestParams(params));
            // 请求头设置
            method.setRequestHeader("procode", "test");
        }

        // 响应结果信息处理
        String result = "";
        try {
            httpClient.executeMethod(method);
            result = new String(method.getResponseBody(), codePage);
        } catch (Exception e) {
            throw e;
        } finally {
            // 释放连接
            method.releaseConnection();
        }
        return result;
    }

    /**
     * 组装http请求参数
     *
     * @param data 键值对
     * @return 返回一个名称-值的键值对
     */
    private synchronized static NameValuePair[] assembleRequestParams(Map<String, String> data) {
        List<NameValuePair> nameValueList = new ArrayList<>();

        Iterator<Map.Entry<String, String>> it = data.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<String, String> entry = it.next();
            nameValueList.add(new NameValuePair(entry.getKey(), entry.getValue()));
        }

        log.info("键值对参数:{}", ArrayUtils.toString(nameValueList.toArray(new NameValuePair[nameValueList.size()])));

        return nameValueList.toArray(new NameValuePair[nameValueList.size()]);
    }

    /**
     * get请求
     *
     * @param url 目标请求地址
     * @return 将响应结果转换成string返回
     */
    private static String get(String url) {
        String result = "";
        try {
            // 根据地址获取请求
            HttpGet request = new HttpGet(url);
            request.setHeader("procode", "test");

            // 获取当前客户端对
            CloseableHttpClient httpclient = HttpClients.createDefault();
            // 通过请求对象获取响应对象
            HttpResponse response = httpclient.execute(request);
            // 判断请求结果状态码
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                result = EntityUtils.toString(response.getEntity());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }


    public static void main(String[] args) throws Exception {
        String url = "http://localhost:8080/sales-webapp/admin/report/smslist";
        // 发起post请求
        String resultPost = postMsg(url, "1");
        log.info("post返回结果:{}", resultPost);

        // 发起get请求
        String resultGet = get(url);
        log.info("get返回结果:{}", resultGet);

        // 测试body有参数的post方法
        Map<String, String> map = new HashMap<>(16);
        map.put("age", "13");
        map.put("name", "jason");
        String resultPostHaveBody = postData(url, map, "UTF-8");
        log.info("post带有body请求返回结果:{}", resultPostHaveBody);
    }
}

https://blog.51cto.com/u_14479502/3115669原文章这里
我写的就不发出来了,因为有重要的token和cookie值。

图片

虽然我不能放出我写的代码,然后已经可以正常使用了。
南香香

抓包工具

这边我也上了一个链接,安装就是汉化本,直接使用即可,唯独就是证书在这里弄下

这个图标点下,直接下一步即可,我也不知道为什么,反正就好了,哈哈哈哈
南香香

抓包工具下载地址

https://wwvv.lanzout.com/ipYNW1bt1hte

评论区
头像
    头像
    lldcxm
      

    大佬,求教,斗鱼崩铁的验证码怎么跳过?

    头像

    感谢分享

      头像
      南香香
        
      @srm供应商管理系统

      哈哈哈哈,么啥么啥

    头像
    jancy
      

    大佬这个怎么填写,用什么软件启动

      头像
      南香香
        
      @jancy

      java

    头像

    你好,看完你的博客文章,感觉很不错!希望与你网站首页友情链接
    流量卡知识网
    http://53go.cn/
    专注于移动/联通/电信推出的大流量多语音活动长短期套餐手机卡的相关知识的介绍普及

    听说互换友情链接可以增加网站的收录量,特此来换,如果同意的话就给internetyewu@163.com[微信ganenboy]发信息或者就在此回复下吧!【建站问题也可以一起讨论!】