You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.9 KiB

#!/usr/bin/env python3
import argparse
import re
from requests import Session
from fake_useragent import UserAgent
class SLogin(object):
url = ""
urlLogin = "load_login.php"
target = """<script language="JavaScript1.2">document.getElementById('usern').style.backgroundColor='#F3F3F3';document.getElementById('passw').style.backgroundColor='#F3F3F3'</script><script language="javascript">window.location ='/reg/'</script>"""
regex = re.compile("[a-f0-9]{32}")
def __init__(self, nim, pin, session=None): = {
'uname': nim,
'passwd': pin
self.session = session
self.user_agent = UserAgent().random
def __enter__(self):
if type(self.session) is not Session:
self.session = Session()
return self
def __exit__(self, *kwargs):
def login(self):
if type(self.session) is not Session:
raise Exception("Invalid session")
index = self.session.get(self.url)
flag = self.regex.findall(index.text)[0]{'flag': flag})
headers = {
'User-Agent': self.user_agent,
'Referer': self.url
response = + self.urlLogin,,
self.text = response.text
self.success = in self.text
return self.success
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("nim", help="NIM to try login")
parser.add_argument("pin", help="PIN to try login")
args = parser.parse_args()
with SLogin(args.nim, as conn:
if conn.login():
print('Login success')
print('Login failed')