zoukankan      html  css  js  c++  java
  • 灌水案例

    node.js实现灌水


    ###自动评论 - get是对request进行了封装,所以可以使用http的request - 原理:通过cookie,实现用户自动评论,headers中的cookie很重要 - `path: '/course/docomment'` - `'Content-Length': postData.length`
    var http = require('http');
    var querystring = require('querystring');         //加载序列化模块
    
    var postData = querystring.stringify({            
        'content': '妹子,求安慰',                    //灌水内容
        'mid': 8837                                   //FormData中的mid(课程号)
    })
    
    var options = {
        hostname: 'www.imooc.com',
        port: 80,
        path: '/course/docomment',                    //评论路径
        method: 'POST',
        headers: {    
           'Accept': 'application/json, text/javascript, */*; q=0.01',
           'Accept-Encoding': 'gzip, deflate',
           'Accept-Language': 'zh-CN',
           'Cache-Control': 'no-cache',
           'Connection': 'Keep-Alive',
           'Content-Length': postData.length,        //这里要修改为评论内容的长度
           'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
           'Cookie': 'imooc_uuid=492ffbb1-7380-47b0-86ee-9a8bee1e88a8; imooc_isnew_ct=1480587158;       Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1483414974,1483587044,1483696939,1483732760; imooc_isnew=2; loginstate=1; apsid=Q0OTQ2MWJjNjczOWMxZjdjOWRiZTJhZTg4YmYxN2EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANDM5OTQzMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxNDc3ODM1NzAxQHFxLmNvbQAAAAAAAAAAAAAAAAAAADM3MThmYmU3NzkzZWI3ZGJiOGI3NzZmMDU2MWI0Zjlh2oZnWNqGZ1g%3DOG; last_login_username=1477835701%40qq.com; IMCDNS=0; cvde=586f6b26ebe6d-150; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1483800760; PHPSESSID=rmj1gld73uuir54oqbkh2vihi5; jwplayer.qualityLabel=¸ßÇå; jwplayer.volume=21',
           'Host': 'www.imooc.com',
           'Referer': 'http://www.imooc.com/video/8837',
           'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393',
           'X-Requested-With': 'XMLHttpRequest'
        }
    }
    
    var req = http.request(options, function(res){
           console.log('Status:' + res.statusCode);
           console.log('headers:' + JSON.stringify(res.headers));
           res.on('data', function(chunk){
              console.log(Buffer.isBuffer(chunk));
              console.log(typeof chunk);
           })
           res.on('end', function(){
            console.log('评论完毕');
           })
    })
    
    req.on('error', function(e){
        console.log('Error:'+e.message)
    })
    req.write(postData);
    req.end();
    
    

    headers的获取

    • 打开浏览器控制台,Network
    • 在任意网站评论,点击提交
    • 会出现一个数据请求,点开后,即可找到headers
    异乡小龟
  • 相关阅读:
    win7 重装 docker 启动后无法启动错误解决
    ASP.NET MVC 播放远程服务器上的MP3文件
    ubuntu+mono+PetaPoco+Oracle+.net 程序部署
    .NET Core 2.0 问题杂记
    博客园挂了吗?
    Content-Type: application/vnd.ms-excel">
    Storm
    Razor语法
    类型后面加问号 int?
    Apache vue site configuration
  • 原文地址:https://www.cnblogs.com/scale/p/6260752.html
Copyright © 2011-2022 走看看