Python für ethisches Hacken: Techniken und Tools

Dec 27 2022
.

import nmap

nm = nmap.PortScanner()

results = nm.scan('192.168.1.0/24', '1-1024')

for host in results['scan']:
    print(f'{host}: {results["scan"][host]["tcp"].keys()}')

import hashlib

def check_password_strength(password):
    if len(password) < 8:
        return False
    if not any(char.isdigit() for char in password):
        return False
    if not any(char.isupper() for char in password):
        return False
    if not any(char.islower() for char in password):
        return False
    return True

password = 'MyPassw0rd'

if check_password_strength(password):
    print('Strong password')
else:
    print('Weak password')

import requests
from bs4 import BeautifulSoup

url = 'https://www.example.com'

page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')

data = soup.find_all(class_='data')

for item in data:
    print(item.text)

import openvas_lib

manager = openvas_lib.OpenVAS.from_login_file()
target = '192.168.1.0/24'

scan_id = manager.launch_scan(target=target, profile='Full and fast')
while not manager.is_scan_complete(scan_id):
    time.sleep(10)

report_id = manager.get_report_id(scan_id)
report = manager.get_report(report_id)

print(report)