x21

将字节转换成千字节并保留两位小数,使用格式化字符串

data2=data2.decode()
kb=int(data2)/1024
data3=f"{kb:.2f}KB"
print(data3)
s.send(data3.encode())

x22

chr来转成ascii码

data2=data2.decode()
lists=data2.split()
lists=map(int,lists)
data3=''.join(chr(num)for num in lists)
s.send(data3.encode())

x23

和前几题一样,只不过变成了5个像素和多了转ascii码的步骤

import base64
from io import BytesIO
from PIL import Image

data2=base64.b64decode(data2)
Bimage=Image.open(BytesIO(data2))
data3=''.join(str(chr(Bimage.getdata()[i][-1]))for i in range(5))
print(data3)
s.send(data3.encode())

x24

使用requests库来实现网页的访问,response是响应码,response.text能获取响应体

import requests

data2=data2.decode()
response=requests.get(data2)
data3=response.text
s.send(data3.encode())

x25

通过curl,能够得知所要得到的响应头的名字叫做Hmv-Code

import requests

data2=data2.decode()
response=requests.get(data2)
data3=response.headers.get('Hmv-Code')
print(data3)
s.send(data3.encode())

x26

这题需要读取图片中的数字,本人用的是Tesseract-OCR

安装教程: https://blog.csdn.net/weixin_42872122/article/details/123730558

import base64
from io import BytesIO
from PIL import Image
import pytesseract

data2=base64.b64decode(data2)
Bimage=Image.open(BytesIO(data2))
data3=pytesseract.image_to_string(Bimage)
print(data3)
s.send(data3.encode())

x27

提交proxy用户的UID,splitlines进行分行

import requests
data2=data2.decode()
response=requests.get(data2)
content=response.text
lines=content.splitlines()
for line in lines:
if 'proxy' in line:
content=line
break
data3=content.split(':')[2]
print(data3)
s.send(data3.encode())

x28

使用默认的key和算法

import jwt
data2=data2.decode()
print(data2)
data3=jwt.decode(data2,key='secret', algorithms=['HS256'])
data3=data3.get("HMVKey")
s.send(data3.encode())

x29

使用geopy库来计算两个经纬度之间的距离

from geopy.distance import geodesic
data2=data2.decode()
lists=data2.split()
lat1=lists[1]
lon1=lists[3]
lat2=lists[6]
lon2=lists[8]
data3 = str(geodesic((lat1,lon1), (lat2,lon2)).km)
s.send(data3.encode())

x30

给了一串16进制字符,需要与密钥’HMV’进行异或,需要扩展密钥至与所给的字符同长

key=b'HMV'
key=(key * (len(data2) // len(key))) + key[:len(data2) % len(key)]
data3=bytes(b ^ k for b, k in zip(data2, key))
print(data3)
s.send(data3)

x31

使用Pyzbar库进行二维码的读取,获取qr_code对象的data数据进行发送

import base64
from io import BytesIO
from PIL import Image
from pyzbar import pyzbar

Bimage=Image.open(BytesIO(base64.b64decode(data2)))
qr_code=pyzbar.decode(Bimage)
data3=(qr_code[0].data)
s.send(data3)

x32

使用itertools的permutations来生成字符串的全排列,生成的是每种组合情况的列表,所以需要先进行join拼接

import hashlib
import itertools

hash,string=data2.decode().split()
permutations=itertools.permutations(string)
for perm in permutations:
perm_str=''.join(perm)
string_md5=hashlib.md5(perm_str.encode()).hexdigest()
if string_md5==hash:
break
data3=perm_str
s.send(data3.encode())