首页 > 其他分享 >JS逆向实战2--cookie-AcwScV2加密—某招标信息网

JS逆向实战2--cookie-AcwScV2加密—某招标信息网

时间:2022-08-29 11:35:47浏览次数:75  
标签:-- AcwScV2 0x20a7bf JS 0x217721 session var 0xe89588 self

cookies的获取

  1. 首先拿到第一次访问原链接 拿到acw_tc的值,然后放到session中去
  2. 再用这个session再次访问原链接拿到js加载的加密的真实数据。用了一些反混淆。
  3. 最后获取这个数据中的args1,再通过js获取到正确cookies最终请求到数据

js代码如下


var _0x5e8b26 = '3000176000856006061501533003690027800375'

var getAcwScV2 = function (arg1) {
    String['prototype']['hexXor'] = function (_0x4e08d8) {
        var _0x5a5d3b = '';
        for (var _0xe89588 = 0x0; _0xe89588 < this['length'] && _0xe89588 < _0x4e08d8['length']; _0xe89588 += 0x2) {
            var _0x401af1 = parseInt(this['slice'](_0xe89588, _0xe89588 + 0x2), 0x10);
            var _0x105f59 = parseInt(_0x4e08d8['slice'](_0xe89588, _0xe89588 + 0x2), 0x10);
            var _0x189e2c = (_0x401af1 ^ _0x105f59)['toString'](0x10);
            if (_0x189e2c['length'] == 0x1) {
                _0x189e2c = '0' + _0x189e2c;
            }
            _0x5a5d3b += _0x189e2c;
        }
        return _0x5a5d3b;
    };
    String['prototype']['unsbox'] = function () {
        var _0x4b082b = [0xf, 0x23, 0x1d, 0x18, 0x21, 0x10, 0x1, 0x26, 0xa, 0x9, 0x13, 0x1f, 0x28, 0x1b, 0x16, 0x17, 0x19, 0xd, 0x6, 0xb, 0x27, 0x12, 0x14, 0x8, 0xe, 0x15, 0x20, 0x1a, 0x2, 0x1e, 0x7, 0x4, 0x11, 0x5, 0x3, 0x1c, 0x22, 0x25, 0xc, 0x24];
        var _0x4da0dc = [];
        var _0x12605e = '';
        for (var _0x20a7bf = 0x0; _0x20a7bf < this['length']; _0x20a7bf++) {
            var _0x385ee3 = this[_0x20a7bf];
            for (var _0x217721 = 0x0; _0x217721 < _0x4b082b['length']; _0x217721++) {
                if (_0x4b082b[_0x217721] == _0x20a7bf + 0x1) {
                    _0x4da0dc[_0x217721] = _0x385ee3;
                }
            }
        }
        _0x12605e = _0x4da0dc['join']('');
        return _0x12605e;
    };
    var _0x23a392 = arg1['unsbox']();
    arg2 = _0x23a392['hexXor'](_0x5e8b26);
    return arg2
};

python代码


# -*- coding: utf-8 -*-
# @Time    : 2022/7/4 17:55
# @Author  : lzc
# @Email   : [email protected]
# @File    : AnHuiProvinceOnlineInvestPro.py
# @Software: PyCharm
import re
import requests
from execjs import compile
from selenium import webdriver as uc
from scrapy.selector import Selector

from conf.diff_config import URL_DATA_INFO
from pkg.Invoking import APIInvoke



class AnHuiProvinceOnlineInvest:

    item = {}
    session = requests.session()
    url = "http://www.(为保护网站安全性)"
    API = APIInvoke()

    def get_cookie(self):
        js_source = """
var _0x5e8b26 = '3000176000856006061501533003690027800375'
var getAcwScV2 = function (arg1) {
    String['prototype']['hexXor'] = function (_0x4e08d8) {
        var _0x5a5d3b = '';
        for (var _0xe89588 = 0x0; _0xe89588 < this['length'] && _0xe89588 < _0x4e08d8['length']; _0xe89588 += 0x2) {
            var _0x401af1 = parseInt(this['slice'](_0xe89588, _0xe89588 + 0x2), 0x10);
            var _0x105f59 = parseInt(_0x4e08d8['slice'](_0xe89588, _0xe89588 + 0x2), 0x10);
            var _0x189e2c = (_0x401af1 ^ _0x105f59)['toString'](0x10);
            if (_0x189e2c['length'] == 0x1) {
                _0x189e2c = '0' + _0x189e2c;
            }
            _0x5a5d3b += _0x189e2c;
        }
        return _0x5a5d3b;
    };
    String['prototype']['unsbox'] = function () {
        var _0x4b082b = [0xf, 0x23, 0x1d, 0x18, 0x21, 0x10, 0x1, 0x26, 0xa, 0x9, 0x13, 0x1f, 0x28, 0x1b, 0x16, 0x17, 0x19, 0xd, 0x6, 0xb, 0x27, 0x12, 0x14, 0x8, 0xe, 0x15, 0x20, 0x1a, 0x2, 0x1e, 0x7, 0x4, 0x11, 0x5, 0x3, 0x1c, 0x22, 0x25, 0xc, 0x24];
        var _0x4da0dc = [];
        var _0x12605e = '';
        for (var _0x20a7bf = 0x0; _0x20a7bf < this['length']; _0x20a7bf++) {
            var _0x385ee3 = this[_0x20a7bf];
            for (var _0x217721 = 0x0; _0x217721 < _0x4b082b['length']; _0x217721++) {
                if (_0x4b082b[_0x217721] == _0x20a7bf + 0x1) {
                    _0x4da0dc[_0x217721] = _0x385ee3;
                }
            }
        }
        _0x12605e = _0x4da0dc['join']('');
        return _0x12605e;
    };
    var _0x23a392 = arg1['unsbox']();
    arg2 = _0x23a392['hexXor'](_0x5e8b26);
    return arg2
};
        """


        html = self.session.get(self.url).text

        arg1 = re.search(r"var arg1='(.*)';", html).group(1)
        ctx = compile(js_source)
        acw_sc__v2 = ctx.call("getAcwScV2", arg1)
        return acw_sc__v2

    def main(self):
        # 获取cookie
        headers = {
            "Cookie": f"acw_sc__v2={self.get_cookie()};",
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'
        }
        # 拿到主页面
        response = self.session.post(url=self.url, data={
            "pageSize": "20",
            "pageNo": "1",
            "apply_project_name": "",
            "projectInfo.areaDetialCode": "",
            "projectInfo.projectAddress": "",
            "projectInfo.areaDetial": "",
            "projectInfo.industryId": "",
            "projectInfo.industry": "",
        }, headers=headers, verify=False)
        # 使用scrapy 的selector对象解析 一定要指定 text 不然会报错
        selector = Selector(text=response.text)
        for tr in selector.css("#publicInformationForm tr"):
            onclick = tr.css("td a::attr(onclick)").get()
            # 正则匹配
            pattern = re.match("window\.open\(\'(.*?)\'\)", onclick)

            if pattern is None:
                continue

            self.item['title_url'] = "http://www.(为保护网站安全性)" + str(pattern.group(1))
            self.item['title_name'] = tr.css("td a::text").get()
            self.item['title_date'] = tr.css("td:nth-child(5)::text").get()
            # 拿到详情页的数据
            detail_response = self.session.get(self.item['title_url'], headers=headers)
            detail_selector = Selector(text=detail_response.text)
            self.item['content_html'] = detail_selector.css(".content_main").get()
            # 执行写入数据库操作
            ...
        self.close_session()

    def close_session(self):
        self.session.close()


if __name__ == '__main__':
    AnHuiProvinceOnlineInvest().main()

如想单独测试 网站 可关注我的GitHub或评论

标签:--,AcwScV2,0x20a7bf,JS,0x217721,session,var,0xe89588,self
From: https://www.cnblogs.com/zichliang/p/16634375.html

相关文章

  • Flink自定义MySQLSink批量写入出现死锁解决
    一、错误日志Cause:java.sql.SQLException:Lockwaittimeoutexceeded;tryrestartingtransaction;二、原因分析在同一批次、同一事务中操作相同主键的数据,......
  • 多测师肖sir___项目讲解
    一、目的讲解流程:(讲述业务时长10-15分钟为宜)1.自我介绍礼貌用语,姓名,籍贯,学校,个人技能,经验,表现,兴趣爱好等  ,1分钟,谢谢2.介绍项目的名字,项目的背景,(涉及什么架构)3.......
  • ByteBuddy(史上最全)
    文章很长,建议收藏起来慢慢读!总目录博客园版为大家准备了更多的好文章!!!!推荐:尼恩Java面试宝典(持续更新+史上最全+面试必备)具体详情,请点击此链接尼恩Java面试宝典,34个......
  • MySQL--redo log
                ......
  • java插入PDF文件流到oracle数据库,和读取数据库文件流
    插入:Filefile=newFile("D://b9ef5e9f2ec04dfd984fa55ae6552ee6-1.pdf");if(file.exists()){InputStreamfin=newFileInputStrea......
  • 重建二叉树
    题目链接:重建二叉树_牛客题霸_牛客网(nowcoder.com)根据前序遍历和中序遍历重建二叉树,返回根节点 importjava.util.*;/***Definitionforb......
  • go语言文件处理-02
    go语言zip归档文件的读写操作Go语言的标准库提供了对几种压缩格式的支持,其中包括gzip,因此Go程序可以无缝地读写.gz扩展名的gzip压缩文件或非.gz扩展名的非压缩文......
  • SQL中Merge的用法
    MERGE的定义MERGE关键字是一个神奇的DML关键字,它能将INSERT,UPDATE,DELETE等操作并为一句,根据与源表联接的结果,对目标表执行插入、更新或删除操作。MERGE的语法MERGEINT......
  • 注解-解析注解以及注解案例
    解析注解在程序中使用(解析)注解:获取注解中定义的属性值​1.获取注解定义的位置的对象(Class,Method,Field)​2.获取指定的注解:getAnnotation(Class)//其实就......
  • VScode-TodoTree 待办事项插件的定制和使用
    VScode-TodoTree待办事项插件的定制和使用背景写代码过程中,突然发现一个Bug,但是又不想停下来手中的活,以免打断思路,怎么办?按代码编写会规范,都是建议在代码中加个TODO......