Skip to content

Instantly share code, notes, and snippets.

@littlebear0729
Created March 20, 2021 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save littlebear0729/3b4a210c037f4eb07963791db58b9e98 to your computer and use it in GitHub Desktop.
Save littlebear0729/3b4a210c037f4eb07963791db58b9e98 to your computer and use it in GitHub Desktop.
Login to BJUT network with ipv4 and ipv6.
import requests
import getpass
import sys
username = input('username=')
password = getpass.getpass('password=')
headers = {
'Connection': 'keep-alive',
'Cache-Control': 'max-age=0',
'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'Origin': 'http://lgn6.bjut.edu.cn',
'Upgrade-Insecure-Requests': '1',
'DNT': '1',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Sec-Fetch-Site': 'cross-site',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Referer': 'http://lgn6.bjut.edu.cn/',
'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7',
}
params = (
('https://lgn.bjut.edu.cn', ''),
)
data = {
'DDDDD': username,
'upass': password,
'v46s': '0',
'v6ip': '',
'f4serip': '172.30.201.10',
'0MKKey': ''
}
try:
response = requests.post('https://lgn6.bjut.edu.cn/V6?https://lgn.bjut.edu.cn', headers=headers, data=data)
print(response.text)
except:
input('something went wrong...')
sys.exit()
tmp = response.text.split('value=')
v6ip = tmp[-1].split('\'')[1]
headers = {
'Connection': 'keep-alive',
'Cache-Control': 'max-age=0',
'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'Origin': 'https://lgn6.bjut.edu.cn',
'Upgrade-Insecure-Requests': '1',
'DNT': '1',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Sec-Fetch-Site': 'same-site',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Dest': 'document',
'Referer': 'https://lgn6.bjut.edu.cn/',
'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7',
}
data = {
'DDDDD': username,
'upass': password,
'0MKKey': 'Login',
'v6ip': v6ip
}
try:
response = requests.post('https://lgn.bjut.edu.cn/', headers=headers, data=data)
print(response.text)
except:
input('something went wrong...')
sys.exit()
if 'You have successfully logged into our system.' in response.text:
print('***Login successful***')
print('***Login successful***')
print('***Login successful***')
print('***Login successful***')
print('***Login successful***')
print('***Login successful***')
print('***Login successful***')
print('***Login successful***')
input('press any key to continue...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment