Skip to content

Commit 94386b6

Browse files
committed
When there's a finding, also save the method name
1 parent ee0eb40 commit 94386b6

File tree

6 files changed

+170
-85
lines changed

6 files changed

+170
-85
lines changed

python/dff/server.py

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ def _handle_client(self, conn: socket.socket, addr: str) -> None:
8585
return
8686

8787
client_name = name_bytes.decode().rstrip('\x00')
88+
89+
# Validate client name
90+
if client_name == "method" or client_name == "input":
91+
print(f"Invalid client name: {client_name} (reserved name)")
92+
conn.close()
93+
return
94+
95+
# Check for duplicate client names
96+
with self.clients_lock:
97+
if client_name in self.clients:
98+
print(f"Client {client_name} already registered (duplicate name)")
99+
conn.close()
100+
return
101+
88102
# Create output shared memory for this client
89103
output_shm_key = self.input_shm_key + len(self.clients) + 1
90104

@@ -112,11 +126,10 @@ def _handle_client(self, conn: socket.socket, addr: str) -> None:
112126

113127
# Store client
114128
with self.clients_lock:
115-
if client_name not in self.clients:
116-
self.clients[client_name] = ClientEntry(
117-
client_name, conn, output_shm.shmid, self.method
118-
)
119-
print(f"Registered new client: {client_name}")
129+
self.clients[client_name] = ClientEntry(
130+
client_name, conn, output_shm.shmid, self.method
131+
)
132+
print(f"Registered new client: {client_name}")
120133

121134
except Exception as e:
122135
print(f"Error handling client: {e}")
@@ -292,6 +305,10 @@ def signal_handler(_signum: int, _frame: object) -> None:
292305
result_hash = hashlib.sha256(result).hexdigest()
293306
print(f"Key: {name}, Value: {result_hash}")
294307

308+
# Save finding to disk
309+
if self._save_finding(self.iteration_count, inputs, results):
310+
print(f"Finding saved to: findings/{self.iteration_count}")
311+
295312
# Update statistics
296313
duration = time.perf_counter() - start_time
297314
self.iteration_count += 1
@@ -341,3 +358,31 @@ def _cleanup(self) -> None:
341358
pass
342359

343360
print("Server shutdown complete")
361+
362+
def _save_finding(self, iteration: int, inputs: List[bytes], results: Dict[str, bytes]) -> bool:
363+
"""Save finding to disk."""
364+
findings_dir = f"findings/{iteration}"
365+
try:
366+
os.makedirs(findings_dir, exist_ok=True)
367+
368+
# Save input data (concatenated)
369+
input_path = f"{findings_dir}/input"
370+
with open(input_path, "wb") as f:
371+
for input_data in inputs:
372+
f.write(input_data)
373+
374+
# Save method name
375+
method_path = f"{findings_dir}/method"
376+
with open(method_path, "w") as f:
377+
f.write(self.method)
378+
379+
# Save each client's output
380+
for client_name, output in results.items():
381+
output_path = f"{findings_dir}/{client_name}"
382+
with open(output_path, "wb") as f:
383+
f.write(output)
384+
385+
return True
386+
except Exception as e:
387+
print(f"Failed to save finding: {e}")
388+
return False

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "dff-py"
7-
version = "0.1.5"
7+
version = "0.1.6"
88
description = "A simple differential fuzzing framework"
99
readme = "README.md"
1010
authors = [{name = "Justin Traglia", email = "jtraglia@pm.me"}]

0 commit comments

Comments
 (0)