2021-04-05 知了课堂js逆向Base64编码作业

Base64编码作业

目标网站:https://www.zlkt.net/training/jscrack/base6403?CourseId=1&BarId=10

import requests
from ODtools import headers
from lxml.etree import HTML

base_text = '7DusnzUrVTcKo8Q21mylZF4SMBWdfaEx+/5Xghj69iIwtGeHAPvNOpCY0LRJqbk3='

headers['cookie'] = 'zhiliao_website=73a6321cfca4408e5ce76e3d6907ea62; _xsrf=eU0wTkNXVzdzbmswN0QyUjc3TTBZQnJJTm1mV2c1dEw=|1617589636958461687|38345b77d589d5bef01934a8ecff8bc712e6fe70'
resposne = requests.get('https://www.zlkt.net/training/jscrack/base6403?CourseId=1&BarId=10', headers=headers)
doc = HTML(text=resposne.content.decode())
text = doc.xpath('//div[@id="table"]/text()')[0]
n = 0
temp = ''
while n < len(text):
    s1 = base_text.index(text[n])
    n += 1
    s2 = base_text.index(text[n])
    n += 1
    s3 = base_text.index(text[n])
    n += 1
    s4 = base_text.index(text[n])
    n += 1
    p1 = s1 << 2 | s2 >> 4
    p2 = (s2 & 15) << 4 | s3 >> 2
    p3 = (s3 & 3) << 6 | s4
    temp += chr(p1)
    if s3 != 64:
        temp += chr(p2)
    if s4 != 64:
        temp += chr(p3)

new_temp = ''
r1 = 0
r2 = 0
r3 = 0
r4 = 0
while r1 < len(temp):
    r2 = ord(temp[r1])
    if r2 < 128:
        new_temp += chr(r2)
        r1 += 1
    elif 191 < r2 < 224:
        r3 = ord(temp[r1+1])
        new_temp += chr((r2 & 31) << 6 | r3 & 63)
        r1 += 2
    else:
        r3 = ord(temp[r1 + 1])
        r4 = ord(temp[r1 + 2])
        new_temp += chr((r2 & 15) << 12 | (r3 & 63) << 6 | r4 & 63)
        r1 += 3
print(new_temp)

输出

航空 时间 路线 价格
中国国航CA1350 08:20-10:40 长沙黄花国际机场-首都国际机场T3 1900
中国国航CA1344 11:15-13:35 长沙黄花国际机场-首都国际机场T3 1600
中国国航CA1374 17:20-19:40 长沙黄花国际机场-首都国际机场T3 1500
南方航空CZ3123 07:30-09:45 长沙黄花国际机场-首都国际机场T3 1620

你可能感兴趣的:(2021-04-05 知了课堂js逆向Base64编码作业)