脚本

好用的python3脚本

识别Windows环境下的WIFI连接历史记录(不需要安装模块)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import subprocess

def get_previous_networks():
networks = []

try:
# 执行 netsh 命令获取历史连接过的无线网络列表
result = subprocess.run(['netsh', 'wlan', 'show', 'profiles'], capture_output=True, text=True)

# 解析输出,提取历史无线网络名称
output_lines = result.stdout.splitlines()
for line in output_lines:
if "所有用户配置文件" in line:
ssid = line.split(":")[1].strip()
networks.append(ssid)

except Exception as e:
print("获取历史无线网络失败:", e)

return networks

# 输出历史连接过的无线网络
networks = get_previous_networks()
print("历史上连接过的无线网络:")
for network in networks:
print(network)

图片定位,调用高德地图API(需原始图片,GPS信息未被抹除)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import requests
import exifread

def get_geolocation_from_image(image_path):
with open(image_path, 'rb') as image_file:
tags = exifread.process_file(image_file)

if 'GPS GPSLatitude' in tags and 'GPS GPSLongitude' in tags:
latitude = tags['GPS GPSLatitude']
longitude = tags['GPS GPSLongitude']

lat_ref = str(tags['GPS GPSLatitudeRef'])
lng_ref = str(tags['GPS GPSLongitudeRef'])

lat_degrees = latitude.values[0].num / latitude.values[0].den
lat_minutes = latitude.values[1].num / latitude.values[1].den
lat_seconds = latitude.values[2].num / latitude.values[2].den

lng_degrees = longitude.values[0].num / longitude.values[0].den
lng_minutes = longitude.values[1].num / longitude.values[1].den
lng_seconds = longitude.values[2].num / longitude.values[2].den

# 转换为度(Decimal Degrees)格式
lat_decimal_degrees = lat_degrees + lat_minutes / 60 + lat_seconds / 3600
lng_decimal_degrees = lng_degrees + lng_minutes / 60 + lng_seconds / 3600

# 转换为负值,如果经纬度方向是南或西
if lat_ref == 'S':
lat_decimal_degrees = -lat_decimal_degrees
if lng_ref == 'W':
lng_decimal_degrees = -lng_decimal_degrees

return lat_decimal_degrees, lng_decimal_degrees
else:
return None

def geocode_analysis(lat, lng, api_key):
url = f'https://restapi.amap.com/v3/geocode/regeo?location={lng},{lat}&key={api_key}&output=json'
response = requests.get(url)
data = response.json()

if data['status'] == '1' and data['info'] == 'OK':
address = data['regeocode']['formatted_address']
print(f'经度: {lng}, 纬度: {lat}')
print(f'地址: {address}')
else:
print('无法获取地址信息')

if __name__ == '__main__':
# 在这里填入你的高德地图API密钥
api_key = '高德api调用'

# 假设你有一个图片的路径
image_path = '图片路径'

geolocation = get_geolocation_from_image(image_path)
if geolocation:
latitude, longitude = geolocation
geocode_analysis(latitude, longitude, api_key)
else:
print('无法获取')

隐写:基础的PNG图片高度宽度恢复脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import binascii
import struct

# 读取修改后的图片文件
with open('高度宽度损坏图片路径', 'rb') as file:
modified_data = file.read()

crcbp = open("F:\\.vscode\\class.py\\2.png", "rb").read() # 打开图片
crc32frombp = int(crcbp[29:33].hex(), 16) # 读取图片中的CRC校验值
print('crc:', crc32frombp)

found_solution = False

for height in range(4000): # 宽度1-4000进行枚举
for width in range(4000): # 高度1-4000进行枚举
data = crcbp[12:16] + \
struct.pack('>i', height) + struct.pack('>i', width) + crcbp[24:29]
crc32 = binascii.crc32(data) & 0xffffffff
if crc32 == crc32frombp:
# 计算修改后的图片数据的起始位置
data_start = modified_data.find(b'\x49\x44\x41\x54') # IDAT 块的起始标识

# 读取修改后的图片数据
modified_image_data = modified_data[data_start:] # 从起始位置之后的数据为修改后的图片数据

# 写入修改后的数据到新文件
with open('修复后的图片存放路径', 'wb') as file:
# 重新构建 PNG 文件头
file.write(crcbp[:16])
file.write(struct.pack('!I', height))
file.write(struct.pack('!I', width))
file.write(crcbp[24:data_start])
file.write(modified_image_data)

print("图片还原完成!原始图片的高度为:", height, "宽度为:", width)
found_solution = True
break # 结束内层循环
if found_solution:
break # 结束外层循环

提取json文件中的question属性

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json
import pandas as pd

def extract_questions_from_json(json_file_path):
# 读取JSON文件
with open(json_file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
# 从数据中提取question字段
questions = [entry["question"] for entry in data]
return questions

def save_to_excel(questions):
# 创建一个pandas DataFrame
df = pd.DataFrame(questions, columns=["Question"])
# 保存DataFrame为Excel文件
df.to_excel("Excel文件名", index=False, engine='openpyxl')

# 使用函数
questions = extract_questions_from_json("F://") # 请替换为您的JSON文件路径
save_to_excel(questions)

print("已保存为questions.xlsx")

** 本项目基于开源,用于讨论和技术探讨,如果使用者用其做任何违法或者不正当行为,均尤其使用者自己承担。**


脚本
http://example.com/2023/06/01/脚本/
作者
发布于
2023年6月1日
许可协议