前言
用VSCode的时候总被安利JetBrains全家桶,心血来潮下载了个试试发现要激活码
插件激活好像分两种,一种是能激活很久但有版本号限制,另一种是无限试用
不过好在现在还挺多网站有发激活码的
虽然激活码和插件都不清楚来源,但感觉前者比较放心
实现
先对找到个网站下手
请求一次密码页面获取cookie,然后用cookie+密码再去请求激活码页面获取激活码,加个headers让请求看起来正常一些
import requests
from bs4 import BeautifulSoup
headers = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
"Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.7,zh-CN;q=0.3",
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"Origin": "http://lookdiv.com",
"DNT": "1",
"Referer": "http://lookdiv.com/"
}
data = {"key": "lookdiv.com"}
session = requests.session()
session.post("http://lookdiv.com/index/index/indexcode.html", headers=headers, data=data, allow_redirects=False)
res = session.get("http://lookdiv.com/index/index/indexcodeindex.html", headers=headers)
key = BeautifulSoup(res.text,'html.parser').find_all('textarea')[0].string.strip()
如果断更咋办呢(更新:果然断了😂),于是又找了一个网站
这个网站是把激活码保存到zip文件里的
思路是直接把响应加载到内存,然后用zipfile读取内容
import requests
import io
import zipfile
headers = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"}
res = requests.get("https://idea.medeming.com/a/jihuoma1.zip", headers=headers)
data = zipfile.ZipFile(io.BytesIO(res.content), 'r')
key = data.read('2018.2月之后用这个.txt'.encode('gbk').decode('cp437')).decode()
zipfile默认用cp437编码,所以直接用中文是读取不了的
用zipFile.printdir()
读2018.2月之后用这个.txt
的文件名是这样的2018.2╘┬╓«║≤╙├╒Γ╕÷.txt
虽然可以直接用那一坨乱码读,但是为了美观和可维护,还是用中文编码后再用cp437解码
本来想写个机器人每天给自己推送key,但一想费这么大周章只是复制个激活码有点脱裤子放屁
于是翻了一下jetbrains全家桶的激活文件
Linux下路径为 ~/.config/JetBrains/IntelliJIdea版本号/idea.key
Windows的不太清楚,让朋友帮忙看了一下好像是 C:\Users\Administrator\IntelliJIdea版本号\config\idea.key
用16进制查看可以看到内容是一个特殊文件头+激活码,并且每一个字符间隔都插入00
#替换为自己的全家桶路径
file = {"pycharm": "/home/user/.config/JetBrains/PyCharm2021.2/pycharm.key",
"idea": "/home/user/.config/JetBrains/IntelliJIdea2021.2/idea.key",
"golang": "/home/user/.config/JetBrains/GoLand2021.2/goland.key",
"clion": "/home/user/.config/JetBrains/CLion2021.2/clion.key",
"phpstorm": "/home/user/.config/JetBrains/PhpStorm2021.2/phpstorm.key"}
bin = [0xFF, 0xFF, 0x3C, 0x00, 0x63, 0x00, 0x65, 0x00, 0x72, 0x00,
0x74, 0x00, 0x69, 0x00, 0x66, 0x00, 0x69, 0x00, 0x63, 0x00,
0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x2D, 0x00, 0x6B, 0x00,
0x65, 0x00, 0x79, 0x00, 0x3E, 0x00, 0x0A, 0x00]
for ch in key:
tmp = ''.join(list(map(lambda x: hex(ord(x)), ch)))
bin.append(int((tmp[2] + tmp[3]), 16))
bin.append(0)
for i in file:
with open(file[i], 'wb') as f:
f.write(b''.join(map(lambda x: int.to_bytes(x, 1, 'little'), bin)))
print("更新"+i+".key完成")
效果如下
问题
目前存在的问题有:
如果旧的激活码已过期,那么更新完激活码后还是会提示一次激活码已过期,但是重启一下软件就没事了,貌似手工填激活码上去也有这个问题
完整代码
import requests
import io
import re
import zipfile
import argparse
from bs4 import BeautifulSoup
# 替换路径为自己的全家桶
file = {"pycharm": "/home/user/.config/JetBrains/PyCharm2021.2/",
"idea": "/home/user/.config/JetBrains/IntelliJIdea2021.2/",
"webstorm": "/home/user/.config/JetBrains/WebStorm2021.2/",
"golang": "/home/user/.config/JetBrains/GoLand2021.2/",
"clion": "/home/user/.config/JetBrains/CLion2021.2/",
"phpstorm": "/home/user/.config/JetBrains/PhpStorm2021.2/"}
bin = [0xFF, 0xFF, 0x3C, 0x00, 0x63, 0x00, 0x65, 0x00, 0x72, 0x00,
0x74, 0x00, 0x69, 0x00, 0x66, 0x00, 0x69, 0x00, 0x63, 0x00,
0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x2D, 0x00, 0x6B, 0x00,
0x65, 0x00, 0x79, 0x00, 0x3E, 0x00, 0x0A, 0x00]
parser = argparse.ArgumentParser()
parser.add_argument('-a', default='1', help='选择更新激活码的线路')
args = parser.parse_args()
if args.a == '1':
headers = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.7,zh-CN;q=0.3",
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"Origin": "http://lookdiv.com",
"DNT": "1",
"Referer": "http://lookdiv.com/"
}
data = {"key": "lookdiv.com"}
session = requests.session()
session.post("http://lookdiv.com/index/index/indexcode.html", headers=headers, data=data, allow_redirects=False)
res = session.get("http://lookdiv.com/index/index/indexcodeindex.html", headers=headers)
key = BeautifulSoup(res.text, 'html.parser').find_all('textarea')[0].string.strip()
elif args.a == '2':
headers = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"}
res = requests.get("https://idea.medeming.com/a/jihuoma1.zip", headers=headers)
bf = zipfile.ZipFile(io.BytesIO(res.content), 'r')
for l in range(0, len(bf.namelist())):
if re.findall('^2018.2.*', bf.namelist()[l]):
fn = bf.namelist()[l]
key = bf.read(fn).decode()
for ch in key:
tmp = ''.join(list(map(lambda x: hex(ord(x)), ch)))
bin.append(int((tmp[2] + tmp[3]), 16))
bin.append(0)
for i in file:
with open(file[i] + i + '.key', 'wb') as f:
f.write(b''.join(map(lambda x: int.to_bytes(x, 1, 'little'), bin)))
with open(file[i] + 'plugin_PCWMP.license', 'wb') as ff:
ff.write(b''.join(map(lambda x: int.to_bytes(x, 1, 'little'), bin)))
print("更新" + i + ".key完成")
转载请注明来源,欢迎对文章中的引用来源进行考证,文章可能具有时效性,欢迎指出任何有错误、已失效或不够清晰的表达 ,可通过[邮件](mailto:cnlnnn@qq.com)联系垃圾堆主人