MCPcopy
hub / github.com/Gallopsled/pwntools / query_local_database

Function query_local_database

pwnlib/libcdb.py:200–235  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

198 return None
199
200def query_local_database(params):
201 if not context.local_libcdb or not params.get("symbols"):
202 return None
203
204 localdb = Path(context.local_libcdb)
205 if not localdb.is_dir():
206 return None
207
208 res = []
209 query_syms = params["symbols"]
210
211 # Loop through each '.symbols' file in the local database
212 # Make sure `Path.rglod` order stable
213 for symbol_file in sorted(localdb.rglob("*.symbols"), key=lambda x: x.as_posix()):
214 libc_syms = _parse_libc_symbol(symbol_file)
215
216 matched = 0
217 for name, addr in query_syms.items():
218 if isinstance(addr, str):
219 addr = int(addr, 16)
220
221 # Compare last 12 bits
222 if libc_syms.get(name) and (libc_syms.get(name) & 0xfff) == (addr & 0xfff):
223 matched += 1
224 else:
225 # aborting this loop once there was a mismatch.
226 break
227
228 # Check if all symbols have been matched
229 if matched == len(query_syms):
230 libs_id = symbol_file.stem
231 libc_path = symbol_file.parent / ("%s.so" % libs_id)
232 libs_url = read(symbol_file.parent / ("%s.url" % libs_id)).decode().strip()
233 res.append(_pack_libs_info(libc_path, libs_id, libs_url, libc_syms))
234
235 return res
236
237PROVIDERS = {
238 "offline": [provider_local_system, provider_local_database],

Callers 1

search_by_symbol_offsetsFunction · 0.85

Calls 9

readFunction · 0.90
_parse_libc_symbolFunction · 0.85
_pack_libs_infoFunction · 0.85
is_dirMethod · 0.80
rglobMethod · 0.80
as_posixMethod · 0.80
itemsMethod · 0.80
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected