|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# __author__ = "zok" [email protected] |
| 3 | +# Date: 2019-08-26 Python: 3.7 |
| 4 | + |
| 5 | +import requests |
| 6 | +import base64 |
| 7 | +from Crypto.Cipher import PKCS1_v1_5 as Cipher_pksc1_v1_5 |
| 8 | +from Crypto.PublicKey import RSA |
| 9 | + |
| 10 | + |
| 11 | +class YX(object): |
| 12 | + """ |
| 13 | + 满级网自动登陆 官网 www.manjiwang.com |
| 14 | + http://www.manjiwang.com/Logins/BuyerLogin |
| 15 | + """ |
| 16 | + |
| 17 | + def __init__(self, user, pwd): |
| 18 | + self.user = user |
| 19 | + self.pwd = pwd |
| 20 | + self.url = 'http://www.manjiwang.com/Logins/BuyerLogin' |
| 21 | + self.headers = { |
| 22 | + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36', |
| 23 | + 'Host': 'www.manjiwang.com', |
| 24 | + } |
| 25 | + self.public_key = """-----BEGIN PUBLIC KEY----- |
| 26 | + MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC4wHerJc4BSst20Zb07lY9LeZss4OEEhe+SrnLyYy8hGquX/aTQNn+5wnV/+8ierKPgqPGIXPf1ZRww5/6yON+O7dAfJ7BRx85HneIWqwPCZToLck8DN8UXsBuXLMcG7tfMunnnZKenrPsAslN0eKvkYkvz4EPGdvmPwz0NCKXQIDAQAB |
| 27 | + -----END PUBLIC KEY----- |
| 28 | + """ |
| 29 | + |
| 30 | + def make_pwd(self): |
| 31 | + rsa_key = RSA.importKey(self.public_key) |
| 32 | + cipher = Cipher_pksc1_v1_5.new(rsa_key) |
| 33 | + cipher_text = base64.b64encode(cipher.encrypt(self.pwd.encode())) |
| 34 | + return cipher_text.decode() |
| 35 | + |
| 36 | + def make_data(self): |
| 37 | + data = { |
| 38 | + 'account': self.user, |
| 39 | + 'password': self.make_pwd(), |
| 40 | + 'returnUrl': '/' |
| 41 | + } |
| 42 | + return data |
| 43 | + |
| 44 | + def login(self): |
| 45 | + """start |
| 46 | + """ |
| 47 | + data = self.make_data() |
| 48 | + response = requests.post(self.url, data=data) |
| 49 | + print(response.text) |
| 50 | + print(response.cookies) |
| 51 | + |
| 52 | + |
| 53 | +if __name__ == '__main__': |
| 54 | + username = input('请输入账号') |
| 55 | + password = input('密码') |
| 56 | + yx = YX(username, password) |
| 57 | + yx.login() |
| 58 | + |
| 59 | + |
| 60 | + |
0 commit comments