mirror of
https://github.com/casterbyte/Sara.git
synced 2026-07-07 01:31:33 +00:00
Compare commits
No commits in common. "54dd6d1d4b290e962a0af1efeeeace1021193f62" and "848b2bbeb7d8bdcd17e32f66be0e962bce056685" have entirely different histories.
54dd6d1d4b
...
848b2bbeb7
2 changed files with 11 additions and 48 deletions
25
README.md
25
README.md
|
|
@ -176,17 +176,14 @@ caster@kali:~$ sara -h
|
||||||
Sara supports the following command line options:
|
Sara supports the following command line options:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
usage: sara.py [-h] [--ip IP] [--username USERNAME] [--password PASSWORD] [--ssh-key SSH_KEY] [--passphrase PASSPHRASE] [--port PORT]
|
usage: sara.py [-h] --ip IP --username USERNAME --password PASSWORD [--port PORT]
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--ip IP The address of your MikroTik router
|
--ip IP The address of your MikroTik router
|
||||||
--username USERNAME SSH username (RO account can be used)
|
--username USERNAME SSH username (RO account can be used)
|
||||||
--password PASSWORD SSH password
|
--password PASSWORD SSH password
|
||||||
--ssh-key SSH_KEY SSH key
|
--port PORT SSH port (default: 22)
|
||||||
--passphrase PASSPHRASE
|
|
||||||
SSH key passphrase
|
|
||||||
--port PORT SSH port (default: 22)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
1. `--ip` - this argument specifies the IP address of the MikroTik device to which Sara is connecting;
|
1. `--ip` - this argument specifies the IP address of the MikroTik device to which Sara is connecting;
|
||||||
|
|
@ -197,15 +194,7 @@ options:
|
||||||
|
|
||||||
3. `--password` - password for SSH authentication;
|
3. `--password` - password for SSH authentication;
|
||||||
|
|
||||||
4. `--ssh-key` - specifies the ssh key that should be used to access the RouterOS's shell
|
4. `--port` - allows you to specify a non-standard SSH port for connection. The default is **22**, but if you have changed the SSH port number, it must be specified manually.
|
||||||
|
|
||||||
> This is muaually exclusive with `--password`.
|
|
||||||
|
|
||||||
5. `--passphrase` - specifies the passphrase used to access the ssh-key
|
|
||||||
|
|
||||||
> This only works when using the `--ssh-key` argument.
|
|
||||||
|
|
||||||
6. `--port` - allows you to specify a non-standard SSH port for connection. The default is **22**, but if you have changed the SSH port number, it must be specified manually.
|
|
||||||
|
|
||||||
# Sara's Launch
|
# Sara's Launch
|
||||||
|
|
||||||
|
|
|
||||||
34
sara.py
34
sara.py
|
|
@ -44,15 +44,13 @@ def banner():
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Establish SSH connection to the RouterOS device using Netmiko
|
# Establish SSH connection to the RouterOS device using Netmiko
|
||||||
def connect_to_router(ip, username, password, port, key_file, passphrase):
|
def connect_to_router(ip, username, password, port):
|
||||||
device = {
|
device = {
|
||||||
"device_type": "mikrotik_routeros",
|
"device_type": "mikrotik_routeros",
|
||||||
"host": ip,
|
"host": ip,
|
||||||
"username": username,
|
"username": username,
|
||||||
"password": password,
|
"password": password,
|
||||||
"port": port,
|
"port": port,
|
||||||
"key_file": key_file,
|
|
||||||
"passphrase": passphrase,
|
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
print(Fore.GREEN + Style.BRIGHT + f"[*] Connecting to RouterOS at {ip}:{port}")
|
print(Fore.GREEN + Style.BRIGHT + f"[*] Connecting to RouterOS at {ip}:{port}")
|
||||||
|
|
@ -743,8 +741,6 @@ def main():
|
||||||
parser.add_argument("--ip", help="The address of your MikroTik router")
|
parser.add_argument("--ip", help="The address of your MikroTik router")
|
||||||
parser.add_argument("--username", help="SSH username (RO account can be used)")
|
parser.add_argument("--username", help="SSH username (RO account can be used)")
|
||||||
parser.add_argument("--password", help="SSH password")
|
parser.add_argument("--password", help="SSH password")
|
||||||
parser.add_argument("--ssh-key", help="SSH key")
|
|
||||||
parser.add_argument("--passphrase", help="SSH key passphrase")
|
|
||||||
parser.add_argument("--port", type=int, default=22, help="SSH port (default: 22)")
|
parser.add_argument("--port", type=int, default=22, help="SSH port (default: 22)")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
@ -752,40 +748,18 @@ def main():
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if not args.ip:
|
if not args.ip or not args.username or not args.password:
|
||||||
print(Fore.YELLOW + Style.BRIGHT + "[!] ERROR: Missing required arguments")
|
print(Fore.YELLOW + Style.BRIGHT + "[!] ERROR: Missing required arguments")
|
||||||
print(Fore.YELLOW + "[!] Use 'sara --help' for more information")
|
print(Fore.YELLOW + "[!] Use 'sara --help' for more information")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not args.username or (not args.password and not args.ssh_key):
|
|
||||||
print(Fore.YELLOW + Style.BRIGHT + "[!] ERROR: Missing required arguments")
|
|
||||||
print(Fore.YELLOW + "[!] Use 'sara --help' for more information")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if args.password and args.ssh_key:
|
|
||||||
print(Fore.YELLOW + Style.BRIGHT + "[!] ERROR: Can't use both password & ssh_key authentication")
|
|
||||||
print(Fore.YELLOW + "[!] Use 'sara --help' for more information")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if args.passphrase and not args.ssh_key:
|
|
||||||
print(Fore.YELLOW + Style.BRIGHT + "[!] ERROR: The passphrase argument can't be used when not specifying a ssh_key")
|
|
||||||
print(Fore.YELLOW + "[!] Use 'sara --help' for more information")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
confirm_legal_usage()
|
confirm_legal_usage()
|
||||||
|
|
||||||
# Start timer
|
# Start timer
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# Connecting to the router
|
# Connecting to the router
|
||||||
connection = connect_to_router(args.ip,
|
connection = connect_to_router(args.ip, args.username, args.password, args.port)
|
||||||
args.username,
|
|
||||||
args.password,
|
|
||||||
args.port,
|
|
||||||
args.ssh_key,
|
|
||||||
args.passphrase
|
|
||||||
)
|
|
||||||
|
|
||||||
# Execute all implemented security checks in sequence
|
# Execute all implemented security checks in sequence
|
||||||
check_routeros_version(connection)
|
check_routeros_version(connection)
|
||||||
|
|
@ -829,4 +803,4 @@ def main():
|
||||||
print(Fore.MAGENTA + Style.BRIGHT + "[*] " + Fore.WHITE + "Remember: " + Fore.RED + "Security" + Fore.WHITE + " is a " + Fore.GREEN + "process" + Fore.WHITE + ", not a " + Fore.YELLOW + "state.")
|
print(Fore.MAGENTA + Style.BRIGHT + "[*] " + Fore.WHITE + "Remember: " + Fore.RED + "Security" + Fore.WHITE + " is a " + Fore.GREEN + "process" + Fore.WHITE + ", not a " + Fore.YELLOW + "state.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue