吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 9881|回复: 28
收起左侧

[Java 原创] 【Java】BiliBiliLeader B站全自动挂机工具(Web版)

[复制链接]
陈浩 发表于 2020-12-1 09:15
本帖最后由 陈浩 于 2020-12-1 10:36 编辑

BiliBiliLeader B站全自动挂机工具


近期看B站挂机工具火爆,利用业余时间,自己写了个Web版的挂机工具。
全程调用API ,基本上没啥难点,但凡是个程序员都能写,不过得是有时间的程序员。


源码已发布到github,大家可以下载研究一下,也可以二开加上一些没有的功能或者接口。


github:https://github.com/957153124/BiliBiliLeader

自己使用白嫖的服务器搭建了个演示地址:http://gxe.me  演示账号:test,密码:123
服务器因为是白嫖的 无防御,相信各位大侠都是有武德的.

系统图片
OHDX3_DFDQDTS]PU3RLZK@V.png

3QXCVMI`74RI78JA~ITU@20.png


实现也很简单.不信你看.


基本实现

[Java] 纯文本查看 复制代码
/**
     * 获取指定分区最新视频
     * @Param SESSDATA
     * @param ps //每页数量
     * @return
     * @throws IOException
     */
    public static List<VideoList> video(String SESSDATA,int ps) throws IOException {
        String videoPath = "http://api.bilibili.com/x/web-interface/dynamic/region?rid=21&ps="+ps+"&pn=1";//获取分区视频排行榜列表
        String cookie = "SESSDATA="+SESSDATA+";";
        JSONObject videoObject = sendHttpGet(videoPath,cookie);

        VideoApi videoApi = JSON.parseObject(videoObject.toJSONString(), VideoApi.class);

        List<VideoList> videoList = videoApi.getData().getArchives();
        return videoList;
    }

    /**
     * 投币接口
     * @param SESSDATA
     * @param csrf
     * @param bvid
     * @return
     */
    public static String toubi(String SESSDATA, String csrf, String bvid) {
        String toubiPath = "http://api.bilibili.com/x/web-interface/coin/add";//投币
        String cookie = "SESSDATA="+SESSDATA+";";
        HashMap<String,String> toubiMap = new HashMap<>();
        toubiMap.put("bvid",bvid);
        toubiMap.put("multiply","1");
        toubiMap.put("csrf",csrf);
        JSONObject toubiMapObject = sendHttpPost(toubiPath,toubiMap,cookie);
        ToubiApi toubiApi = JSON.parseObject(toubiMapObject.toJSONString(), ToubiApi.class);
        System.out.println("消息提醒:"+ toubiApi.getMessage());
        return toubiApi.getMessage();
    }

    /**
     * 登录接口
     * @param SESSDATA
     * @return
     * @throws IOException
     */
    public static LoginData login(String SESSDATA) throws IOException {
        String loginPath = "http://api.bilibili.com/x/web-interface/nav";//投币
        String cookie = "SESSDATA="+SESSDATA+";";
        JSONObject toubiMapObject = sendHttpGet(loginPath,cookie);
        LoginApi loginApi = JSON.parseObject(toubiMapObject.toJSONString(), LoginApi.class);
        LoginData loginData = loginApi.getData();
        return loginData;
    }

    /**
     * 验证视频是否已经投币过一次
     * @param SESSDATA
     * @param bvid
     * @return
     * @throws IOException
     */
    public static boolean verificationVideo(String SESSDATA,String bvid) throws IOException {
        String verificationVideoPath = "http://api.bilibili.com/x/web-interface/archive/coins?bvid="+bvid;//投币
        String cookie = "SESSDATA="+SESSDATA+";";
        JSONObject verificationVideoMapObject = sendHttpGet(verificationVideoPath,cookie);
        VerificationVideo verificationVideo = JSON.parseObject(verificationVideoMapObject.toJSONString(), VerificationVideo.class);
        VerificationVideoData verificationVideoData = verificationVideo.getData();
        if(verificationVideoData.getMultiply()==0){
            return true;
        }else{
            return false;
        }

    }

    /**
     * 获取登录二维码链接
     * @return
     * @throws IOException
     */
    public static UrlData bilibiliCode() throws IOException {
        String bilibiliCodePath = "http://passport.bilibili.com/qrcode/getLoginUrl";//投币
        JSONObject bilibiliCodeObject = sendHttpGet(bilibiliCodePath,null);
        Url url = JSON.parseObject(bilibiliCodeObject.toJSONString(), Url.class);
        UrlData urlData = url.getData();
        return urlData;

    }

    /**
     * 验证并接收二维码登录信息(Cookie)
     * @param oauthKey
     * @return
     * @throws IOException
     */
    public static Object bilibiliLoginInfo(String oauthKey) throws IOException {
        String bilibiliCodePath = "http://passport.bilibili.com/qrcode/getLoginInfo?oauthKey="+oauthKey;//投币
        HashMap<String,String> bilibiliLoginInfoMap = new HashMap<>();
        bilibiliLoginInfoMap.put("oauthKey",oauthKey);
        JSONObject bilibiliCodeObject = sendHttpPost(bilibiliCodePath,bilibiliLoginInfoMap,null);
        LoginInfoData loginInfoData = null;
        Integer num = null;
        if(bilibiliCodeObject.get("data").getClass().equals(Integer.class)){
            LoginInfoInteger loginInfoInteger = JSON.parseObject(bilibiliCodeObject.toJSONString(), LoginInfoInteger.class);
            num = loginInfoInteger.getData();
        }else{
            LoginInfo loginInfo = JSON.parseObject(bilibiliCodeObject.toJSONString(), LoginInfo.class);
            loginInfoData = loginInfo.getData();
        }

        if(null!=num){
            return num;
        }else{
            return loginInfoData;
        }



    }

    /**
     * 观看视频接口
     * @param SESSDATA
     * @param bvid
     * @return
     * @throws IOException
     */
    public static VideoPlay videoPlay(String SESSDATA,String bvid) throws IOException {
        String videoPlayPath = "https://api.bilibili.com/x/click-interface/web/heartbeat?played_time=16&bvid="+bvid;//投币
        HashMap<String,String> videoPlayPathMap = new HashMap<>();
        videoPlayPathMap.put("played_time","16");
        videoPlayPathMap.put("bvid",bvid);
        String cookie = "SESSDATA="+SESSDATA+";";
        JSONObject bilibiliCodeObject = sendHttpPost(videoPlayPath,videoPlayPathMap,cookie);

        VideoPlay videoPlay= JSON.parseObject(bilibiliCodeObject.toJSONString(), VideoPlay.class);

        return videoPlay;


    }

    /**
     * 分享视频接口
     * @param csrf
     * @param SESSDATA
     * @param bvid
     * @return
     * @throws IOException
     */
    public static VideoShare videoShare(String csrf,String SESSDATA,String bvid) throws IOException {

        String videoSharePath = "https://api.bilibili.com/x/web-interface/share/add";//投币

        HashMap<String,String> videoShareMap = new HashMap<>();
        videoShareMap.put("csrf",csrf);
        videoShareMap.put("bvid",bvid);
        String cookie = "SESSDATA="+SESSDATA+";";
        JSONObject bilibiliCodeObject = sendHttpPost(videoSharePath,videoShareMap,cookie);

        VideoShare videoShare= JSON.parseObject(bilibiliCodeObject.toJSONString(), VideoShare.class);

        return videoShare;


    }

    /**
     * 直播中心签到接口
     * @param SESSDATA
     * @return
     * @throws IOException
     */
    
    public static Sign sign(String SESSDATA) throws IOException {

        String videoSharePath = "https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign";//投币
        String cookie = "SESSDATA="+SESSDATA+";";
        JSONObject bilibiliCodeObject = sendHttpGet(videoSharePath,cookie);

        Sign sign= JSON.parseObject(bilibiliCodeObject.toJSONString(), Sign.class);

        return sign;


    }

    /**
     * 查看当日投了几个币  (上限5个)
     * @param SESSDATA
     * @return
     * @throws IOException
     */
    public static ToubiVerification toubiVerification(String SESSDATA) throws IOException {

        String videoSharePath = "https://api.bilibili.com/x/web-interface/coin/today/exp";//投币
        String cookie = "SESSDATA="+SESSDATA+";";
        JSONObject bilibiliCodeObject = sendHttpGet(videoSharePath,cookie);

        ToubiVerification toubiVerification= JSON.parseObject(bilibiliCodeObject.toJSONString(), ToubiVerification.class);

        return toubiVerification;


    }

    /**
     * server酱 还没写
     * @param SCKEY
     * @param list
     * @throws IOException
     */
    public static void serverJ(String SCKEY,List<String> list) throws IOException {
        String desp= "";
        for(String serverJ :list){
            desp+=serverJ;
        }
        String serverJPath = "https://sc.ftqq.com/"+SCKEY+".send?text=BiliBili每日任务日报 -gxe.me&desp="+desp;
        sendHttpGet(serverJPath,null);
    }


    /**
     * post请求
     * @param url
     * @param params
     * @param cookie
     * @return
     */
    public static JSONObject sendHttpPost(String url, HashMap<String, String> params, String cookie){
        URL realUrl = null;
        InputStream in = null;
        HttpURLConnection conn = null;
        StringBuffer sb = new StringBuffer();
        if(params != null){
            //将哈希表参数转化为字符串
            for(Map.Entry<String,String>e :params.entrySet()){
                sb.append(e.getKey());
                sb.append("=");
                sb.append(e.getValue());
                sb.append("&");
            }
            sb=sb.deleteCharAt(sb.length() - 1);
        }
        String stringParams = sb.toString();


        //发送请求
        try{
            realUrl = new URL(url);
            conn = (HttpURLConnection)realUrl.openConnection();

            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Cookie", cookie);
            conn.setRequestProperty("User-Agent", "BiLiBiLiLeader/1.0.0 (957153124@qq.com)");
            PrintWriter pw = new PrintWriter(conn.getOutputStream());
            pw.print(stringParams);
            pw.flush();
            pw.close();
            in = conn.getInputStream();//获得返回的输入流
        }catch(Exception e){
            e.printStackTrace();
        }
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        StringBuffer buffer = new StringBuffer();
        String line = "";
        try {
            while ((line = br.readLine()) != null) {
                buffer.append(line);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        String result = buffer.toString();//返回低字符串
        JSONObject josonResult = null;
        try{

            josonResult = JSONObject.parseObject(result);
        }catch (Exception e){
            e.printStackTrace();
        }
        return josonResult;

    }

    /**
     * get请求
     * @param url
     * @param cookie
     * @return
     * @throws IOException
     */
    public static JSONObject sendHttpGet(String url, String cookie) throws IOException {
        URL urlGet = new URL(url);
        HttpURLConnection conn =(HttpURLConnection) urlGet.openConnection();
        conn.setRequestMethod("GET");
        if(cookie!=null){
            conn.setRequestProperty("Cookie", cookie);
        }
        conn.setRequestProperty("User-Agent", "BiLiBiLiLeader/1.0.0 (957153124@qq.com)");

        conn.setDoInput(true);
        BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder buffer = new StringBuilder();

        String line = "";
        try {
            while ((line = br.readLine()) != null) {
                buffer.append(line);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        String result = buffer.toString();//返回低字符串
        JSONObject josonResult = null;
        try{

            josonResult = JSONObject.parseObject(result);
        }catch (Exception e){
            e.printStackTrace();
        }
        return josonResult;

    }


[Java] 纯文本查看 复制代码
//每日24点01分触发
    @Scheduled(cron="0 1 0 * * ?")
    public void bilibiliTasks() throws IOException {
        List<Admin> adminList = adminService.selectAll();
        for(Admin admin:adminList){
            List<String> strings = new ArrayList<>();
            if(admin.getUserId() !=null && admin.getSESSDATA()!=null && admin.getCsrf()!=null){
                strings.add("运行开始时间:"+new Date());
                strings.add("---开始【登录】---");
                LoginData loginData = ApiUtil.login(admin.getSESSDATA());
                Level level = loginData.getLevel_info();
                strings.add("登录成功,用户名: "+loginData.getUname());
                strings.add("硬币余额: "+loginData.getMoney());
                strings.add("当前等级: "+level.getCurrent_level());
                List<VideoList> videoDataListPlay = ApiUtil.video(admin.getSESSDATA(),1);
                VideoList videoDataPlay = videoDataListPlay.get(0);
                strings.add("---结束【登录】---");
                strings.add("");
                strings.add("---开始【观看&分享视频】---");
                strings.add("获取随机视频:《"+videoDataPlay.getTitle()+"》");
                strings.add("---开始观看视频---");
                ApiUtil.videoPlay(admin.getSESSDATA(),videoDataPlay.getBvid());
                strings.add("---视频观看完毕---");
                strings.add("---开始分享视频---");
                ApiUtil.videoShare(admin.getCsrf(),admin.getSESSDATA(),videoDataPlay.getBvid());
                strings.add("---开始分享完毕---");
                strings.add("");
                strings.add("---开始【投币】---");
                if(loginData.getMoney()>0){

                    ToubiVerification toubiVerification = ApiUtil.toubiVerification(admin.getSESSDATA());
                    if(toubiVerification.getData()==50){
                        strings.add("---今日已投5枚硬币,再投也不会有经验啦!!---");
                    }else{
                        List<VideoList> videoDataList = ApiUtil.video(admin.getSESSDATA(),50);
                        for(int i=0;i<5;i++){
                            VideoList videoData = videoDataList.get(i);
                            boolean flag = ApiUtil.verificationVideo(admin.getSESSDATA(),videoData.getBvid());
                            if(flag== true){
                                ApiUtil.toubi(admin.getSESSDATA(),admin.getCsrf(),videoData.getBvid());
                                strings.add("为《"+videoData.getTitle()+"》投币成功");
                            }else{
                                i--;
                            }
                        }
                    }
                }else{
                    strings.add("---投币结束,原因:硬币余额不足!---");
                }
                strings.add("---结束【投币】---");
                strings.add("---开始【直播中心签到】---");
                Sign sign = ApiUtil.sign(admin.getSESSDATA());
                if(sign.getMessage().equals("0")){
                    strings.add("直播中心签到成功!");
                }else{
                    strings.add(sign.getMessage());
                }
                strings.add("---结束【直播中心签到】---");
                strings.add("");
                strings.add("");
                strings.add("---全部任务已完成---");
                String json = JSONUtil.toJsonStr(strings);
                BilibiliLog bilibiliLog = new BilibiliLog();
                bilibiliLog.setCreateTime(new Date());
                bilibiliLog.setAid(admin.getId());
                bilibiliLog.setText(json);
                bilibiliLogService.BilibiliLogAdd(bilibiliLog);
            }
        }



    }



免费评分

参与人数 7吾爱币 +7 热心值 +6 收起 理由
ltfFighting + 1 鼓励转贴优秀软件安全工具和文档!
寒墨轩 + 1 + 1 系统繁忙了
祈LHL + 2 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
3323215 + 1 + 1 谢谢@Thanks!
可绪KK + 1 谢谢@Thanks!
乔生 + 1 + 1 谢谢@Thanks!
hxq40 + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

祈LHL 发表于 2021-8-20 00:20
本帖最后由 祈LHL 于 2021-8-20 08:23 编辑

我部署上去了,可是后台登陆不上。。。怎么办?显示登陆失败
使用的账号密码分别是admin和123,但是显示登陆失败,一切按照GitHub仓库提示操作的,请问是怎么回事呢?

没事了。。。原来是数据库名得改成manager_system。。。

还是有报错,运行程序出现

2021-08-20 08:18:16.599 ERROR 1836298 --- [nio-8999-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: Table 'manager_system.Bilibili_Log' doesn't exist
### The error may exist in file [/www/wwwroot/B/target/classes/mapper/BilibiliLogMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select id,aid,text,create_time from Bilibili_Log         where TO_DAYS(create_time) = TO_DAYS(NOW()) and aid=?         order by create_time desc         limit 1
### Cause: java.sql.SQLSyntaxErrorException: Table 'manager_system.Bilibili_Log' doesn't exist
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Table 'manager_system.Bilibili_Log' doesn't exist] with root cause


请问如何解决呢?
branch518 发表于 2020-12-1 10:29
 楼主| 陈浩 发表于 2020-12-1 10:33

那是因为没有Cookie 你可以扫描二维码获取一下,然后删除掉,毕竟是演示地址。
branch518 发表于 2020-12-1 10:35
陈浩 发表于 2020-12-1 10:33
那是因为没有Cookie 你可以扫描二维码获取一下,然后删除掉,毕竟是演示地址。

好的,感谢楼主
wanshiz 发表于 2020-12-1 17:14
楼主大圣。谢谢分享。
wanlai 发表于 2020-12-1 19:51

楼主大圣。谢谢分享。
乔生 发表于 2020-12-1 20:27
用了BilibiliTask这个两天今天系统提示账号异常使用,看样子是有封号的风险
 楼主| 陈浩 发表于 2020-12-1 22:29
乔生 发表于 2020-12-1 20:27
用了BilibiliTask这个两天今天系统提示账号异常使用,看样子是有封号的风险

大家都是调用同一个API 没办法啦
sdlgl0905 发表于 2020-12-2 08:15
我用了十来天,今天 也提示异常了!先停两天再说
Ez4U 发表于 2020-12-3 12:33
乔生 发表于 2020-12-1 20:27
用了BilibiliTask这个两天今天系统提示账号异常使用,看样子是有封号的风险

我已经被警告了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-23 17:33

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表