|
11 | 11 |
|
12 | 12 | from pwnlib.context import context
|
13 | 13 | from pwnlib.elf import ELF
|
| 14 | +from pwnlib.filesystem.path import Path |
14 | 15 | from pwnlib.log import getLogger
|
15 | 16 | from pwnlib.tubes.process import process
|
16 | 17 | from pwnlib.util.fiddling import enhex
|
@@ -126,7 +127,23 @@ def provider_local_system(hex_encoded_id, hash_type):
|
126 | 127 | return local_libc.data
|
127 | 128 | return None
|
128 | 129 |
|
129 |
| -PROVIDERS = [provider_local_system, provider_libcdb, provider_libc_rip] |
| 130 | +# Offline search https://github.com/niklasb/libc-database for hash type |
| 131 | +def provider_local_database(hex_encoded_id, hash_type): |
| 132 | + if not context.local_libcdb: |
| 133 | + return None |
| 134 | + |
| 135 | + localdb = Path(context.local_libcdb) |
| 136 | + if not localdb.is_dir(): |
| 137 | + return None |
| 138 | + |
| 139 | + log.debug("Searching local libc database, %s: %s", hash_type, hex_encoded_id) |
| 140 | + for libc_path in localdb.rglob("*.so"): |
| 141 | + if hex_encoded_id == HASHES[hash_type](libc_path): |
| 142 | + return read(libc_path) |
| 143 | + |
| 144 | + return None |
| 145 | + |
| 146 | +PROVIDERS = [provider_local_system, provider_local_database, provider_libcdb, provider_libc_rip] |
130 | 147 |
|
131 | 148 | def search_by_hash(hex_encoded_id, hash_type='build_id', unstrip=True):
|
132 | 149 | assert hash_type in HASHES, hash_type
|
|
0 commit comments