mirror of
https://github.com/luzhisheng/js_reverse.git
synced 2025-04-20 21:55:07 +08:00
56js加密经典入门数据加密-RSA
This commit is contained in:
parent
180d4b7f35
commit
2cd1f34a34
16729
猿人学练习/56js加密经典入门数据加密-RSA/f.js
Normal file
16729
猿人学练习/56js加密经典入门数据加密-RSA/f.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,17 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
from rsa_encrypt import RsaUtil
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def challenge59(page):
|
def decrypt_res(response_json):
|
||||||
url = "https://www.python-spider.com/api/challenge59"
|
rsa = RsaUtil()
|
||||||
|
decrypt_result = rsa.decrypt_by_private_key(response_json.get('result'))
|
||||||
|
return decrypt_result
|
||||||
|
|
||||||
|
|
||||||
|
def challenge56(page):
|
||||||
|
url = "https://www.python-spider.com/api/challenge56"
|
||||||
payload = f"page={page}"
|
payload = f"page={page}"
|
||||||
session = requests.session()
|
session = requests.session()
|
||||||
headers = {
|
headers = {
|
||||||
@ -11,18 +19,15 @@ def challenge59(page):
|
|||||||
}
|
}
|
||||||
session.headers = headers
|
session.headers = headers
|
||||||
response = session.request("POST", url, data=payload)
|
response = session.request("POST", url, data=payload)
|
||||||
return response.text
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
data_num = 0
|
data_num = 0
|
||||||
for page in range(1, 101):
|
for page in range(1, 101):
|
||||||
res_dict = json.loads(challenge59(page))
|
response_json = challenge56(page)
|
||||||
data_list = res_dict.get('data')
|
decrypt_result = decrypt_res(response_json)
|
||||||
|
data_list = json.loads(decrypt_result).get('data')
|
||||||
if page == 51:
|
|
||||||
data_list[0]['value'] = '5734\r'
|
|
||||||
|
|
||||||
data_list_num = []
|
data_list_num = []
|
||||||
for data in data_list:
|
for data in data_list:
|
||||||
data_list_num.append(int(data.get('value')))
|
data_list_num.append(int(data.get('value')))
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
# 知识点: RSA加密
|
||||||
|
|
||||||
|
## 解题思路
|
||||||
|
|
||||||
|
RSA是非对称加密算法,非对称加密算法指的是加密和解密使用不同的密钥,除了加解密的作用,还有“签名”的作用。通常来说非对称加密比对称加密要耗时间。
|
||||||
|
|
||||||
|
查看请求返回内容,发现结果加密
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
由于此题已经说明是RSA加密,这里搜索解密关键词`setPrivateKey`
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
发现`A.setPrivateKey(PVA.toString("ascii"))`;就是设置了私钥
|
||||||
|
|
||||||
|
控制台直接打印出私钥
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
私钥已经找到了,解密就是写代码的时间问题了
|
@ -12,8 +12,8 @@ class RsaUtil(object):
|
|||||||
company_pub_file=PUBLIC_KEY_PATH,
|
company_pub_file=PUBLIC_KEY_PATH,
|
||||||
company_pri_file=PRIVATE_KEY_PATH):
|
company_pri_file=PRIVATE_KEY_PATH):
|
||||||
|
|
||||||
if company_pub_file:
|
# if company_pub_file:
|
||||||
self.company_public_key = rsa.PublicKey.load_pkcs1_openssl_pem(open(company_pub_file).read())
|
# self.company_public_key = rsa.PublicKey.load_pkcs1_openssl_pem(open(company_pub_file).read())
|
||||||
if company_pri_file:
|
if company_pri_file:
|
||||||
self.company_private_key = rsa.PrivateKey.load_pkcs1(open(company_pri_file).read())
|
self.company_private_key = rsa.PrivateKey.load_pkcs1(open(company_pri_file).read())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user