crypttrace 0.35.0__tar.gz → 0.36.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {crypttrace-0.35.0/src/crypttrace.egg-info → crypttrace-0.36.0}/PKG-INFO +22 -4
- {crypttrace-0.35.0 → crypttrace-0.36.0}/README.md +21 -3
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/__init__.py +1 -1
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/case.py +45 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/cli.py +26 -6
- crypttrace-0.36.0/src/crypttrace/export.py +201 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/web/index.html +49 -2
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/webapp.py +17 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0/src/crypttrace.egg-info}/PKG-INFO +22 -4
- crypttrace-0.35.0/src/crypttrace/export.py +0 -94
- {crypttrace-0.35.0 → crypttrace-0.36.0}/LICENSE +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/pyproject.toml +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/setup.cfg +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/addresses.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/analysis.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/assess.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/assets.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/bridges.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/chains.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/config.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/drain.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/evidence.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/fetchers/__init__.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/fetchers/bitcoin.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/fetchers/etherscan.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/fetchers/http.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/fetchers/solana.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/fetchers/ton.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/fetchers/tron.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/freeze.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/funder.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/gascluster.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/investigate.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/__init__.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/audit.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/bulk.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/known.json +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/labels.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/names.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/partial.json +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/tonapi.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/labels/tronscan.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/offramp.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/pdf.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/poisoning.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/prices.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/render.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/report.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/spam.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/store.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/trace.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/verify.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace/watch.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace.egg-info/SOURCES.txt +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace.egg-info/dependency_links.txt +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace.egg-info/entry_points.txt +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace.egg-info/requires.txt +0 -0
- {crypttrace-0.35.0 → crypttrace-0.36.0}/src/crypttrace.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crypttrace
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.36.0
|
|
4
4
|
Summary: OSINT toolkit for crypto investigations: trace stolen funds across Ethereum, Bitcoin, Tron, Solana and TON
|
|
5
5
|
Author: bobslayerX
|
|
6
6
|
License-Expression: MIT
|
|
@@ -214,7 +214,8 @@ and whether USDT/USDC at the address is frozen. Tabs add the assessment, the
|
|
|
214
214
|
timeline, the list of who sent funds here, and address poisoning (look-alikes
|
|
215
215
|
planted in the wallet's history, and payments lured by this address). **Case
|
|
216
216
|
file** downloads the same one-page HTML report `crypttrace report` writes;
|
|
217
|
-
**GraphML** and **CSV** download the graph for Gephi
|
|
217
|
+
**Gephi**, **GraphML** and **CSV** download the graph for Gephi (with its
|
|
218
|
+
layout and colours), yEd or Cytoscape, and Maltego. The page's
|
|
218
219
|
address is a link to the investigation
|
|
219
220
|
(`/?address=…&chain=…&direction=…&depth=…&tab=check`), ready to bookmark or
|
|
220
221
|
send. Everything runs on your machine — nothing is uploaded anywhere.
|
|
@@ -279,10 +280,18 @@ crypttrace trace 0xADDRESS --direction in
|
|
|
279
280
|
# Trace a token rather than the native coin (most thefts are stablecoins)
|
|
280
281
|
crypttrace trace 0xADDRESS --asset usdt --depth 4
|
|
281
282
|
|
|
282
|
-
# Save the traced graph
|
|
283
|
+
# Save the traced graph: Gephi (with its layout and colours), yEd / Cytoscape, Maltego / Neo4j
|
|
284
|
+
crypttrace trace 0xADDRESS --depth 4 --export case.gexf
|
|
283
285
|
crypttrace trace 0xADDRESS --depth 4 --export case.graphml
|
|
284
286
|
crypttrace trace 0xADDRESS --depth 4 --export case.csv
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
In Gephi's import dialog untick **Auto-scale** (under *More options*): it
|
|
290
|
+
stretches the positions without the node sizes, and the addresses shrink to
|
|
291
|
+
dots under their own edges. Don't run a layout either — the file already has
|
|
292
|
+
one.
|
|
285
293
|
|
|
294
|
+
```bash
|
|
286
295
|
# Token holdings, valued in USD
|
|
287
296
|
crypttrace tokens 0xADDRESS
|
|
288
297
|
|
|
@@ -367,12 +376,21 @@ crypttrace case add ronin 0x098b…2f96 --chain eth --role suspect --note "explo
|
|
|
367
376
|
crypttrace case note ronin "asked Binance for KYC on the first-gas withdrawal"
|
|
368
377
|
crypttrace case refresh ronin # what moved since the last refresh
|
|
369
378
|
crypttrace case show ronin # addresses, current labels, last snapshot, the log
|
|
379
|
+
crypttrace case common-recipients ronin --chain eth
|
|
370
380
|
```
|
|
371
381
|
|
|
372
382
|
A case is one JSON file in `~/.crypttrace/cases/`. Every `case` command also
|
|
373
383
|
takes a path to a `.json` file, so handing a case to a colleague is sending the
|
|
374
384
|
file.
|
|
375
385
|
|
|
386
|
+
**Common recipients** compares all case addresses on the selected network, regardless of role.
|
|
387
|
+
It reads up to 200 recent native and 200 recent token transfer rows per wallet, subject to
|
|
388
|
+
provider limits. Each match shows the distinct senders, individual amounts and assets, UTC
|
|
389
|
+
times, explorer links and any known recipient label. A shared exchange wallet can receive
|
|
390
|
+
unrelated deposits. On UTXO networks, input shares are estimates and outputs can be change.
|
|
391
|
+
In the web app, open **Common recipients**, choose a saved case and network, and click
|
|
392
|
+
**Find common recipients**.
|
|
393
|
+
|
|
376
394
|
### Watch & alerts — catching the cash-out
|
|
377
395
|
|
|
378
396
|
The only window to freeze stolen funds is the moment they reach an exchange
|
|
@@ -779,7 +797,7 @@ src/crypttrace/
|
|
|
779
797
|
case.py # investigations as files: addresses, roles, notes, snapshots
|
|
780
798
|
report.py # Markdown + JSON reports
|
|
781
799
|
pdf.py # PDF page setup and font discovery (evidence packs)
|
|
782
|
-
export.py # traced graph as
|
|
800
|
+
export.py # traced graph as GEXF (Gephi), GraphML (yEd) and edge-list CSV (Maltego)
|
|
783
801
|
prices.py # USD valuation
|
|
784
802
|
render.py # rich terminal rendering
|
|
785
803
|
webapp.py # Flask backend for the web UI
|
|
@@ -177,7 +177,8 @@ and whether USDT/USDC at the address is frozen. Tabs add the assessment, the
|
|
|
177
177
|
timeline, the list of who sent funds here, and address poisoning (look-alikes
|
|
178
178
|
planted in the wallet's history, and payments lured by this address). **Case
|
|
179
179
|
file** downloads the same one-page HTML report `crypttrace report` writes;
|
|
180
|
-
**GraphML** and **CSV** download the graph for Gephi
|
|
180
|
+
**Gephi**, **GraphML** and **CSV** download the graph for Gephi (with its
|
|
181
|
+
layout and colours), yEd or Cytoscape, and Maltego. The page's
|
|
181
182
|
address is a link to the investigation
|
|
182
183
|
(`/?address=…&chain=…&direction=…&depth=…&tab=check`), ready to bookmark or
|
|
183
184
|
send. Everything runs on your machine — nothing is uploaded anywhere.
|
|
@@ -242,10 +243,18 @@ crypttrace trace 0xADDRESS --direction in
|
|
|
242
243
|
# Trace a token rather than the native coin (most thefts are stablecoins)
|
|
243
244
|
crypttrace trace 0xADDRESS --asset usdt --depth 4
|
|
244
245
|
|
|
245
|
-
# Save the traced graph
|
|
246
|
+
# Save the traced graph: Gephi (with its layout and colours), yEd / Cytoscape, Maltego / Neo4j
|
|
247
|
+
crypttrace trace 0xADDRESS --depth 4 --export case.gexf
|
|
246
248
|
crypttrace trace 0xADDRESS --depth 4 --export case.graphml
|
|
247
249
|
crypttrace trace 0xADDRESS --depth 4 --export case.csv
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
In Gephi's import dialog untick **Auto-scale** (under *More options*): it
|
|
253
|
+
stretches the positions without the node sizes, and the addresses shrink to
|
|
254
|
+
dots under their own edges. Don't run a layout either — the file already has
|
|
255
|
+
one.
|
|
248
256
|
|
|
257
|
+
```bash
|
|
249
258
|
# Token holdings, valued in USD
|
|
250
259
|
crypttrace tokens 0xADDRESS
|
|
251
260
|
|
|
@@ -330,12 +339,21 @@ crypttrace case add ronin 0x098b…2f96 --chain eth --role suspect --note "explo
|
|
|
330
339
|
crypttrace case note ronin "asked Binance for KYC on the first-gas withdrawal"
|
|
331
340
|
crypttrace case refresh ronin # what moved since the last refresh
|
|
332
341
|
crypttrace case show ronin # addresses, current labels, last snapshot, the log
|
|
342
|
+
crypttrace case common-recipients ronin --chain eth
|
|
333
343
|
```
|
|
334
344
|
|
|
335
345
|
A case is one JSON file in `~/.crypttrace/cases/`. Every `case` command also
|
|
336
346
|
takes a path to a `.json` file, so handing a case to a colleague is sending the
|
|
337
347
|
file.
|
|
338
348
|
|
|
349
|
+
**Common recipients** compares all case addresses on the selected network, regardless of role.
|
|
350
|
+
It reads up to 200 recent native and 200 recent token transfer rows per wallet, subject to
|
|
351
|
+
provider limits. Each match shows the distinct senders, individual amounts and assets, UTC
|
|
352
|
+
times, explorer links and any known recipient label. A shared exchange wallet can receive
|
|
353
|
+
unrelated deposits. On UTXO networks, input shares are estimates and outputs can be change.
|
|
354
|
+
In the web app, open **Common recipients**, choose a saved case and network, and click
|
|
355
|
+
**Find common recipients**.
|
|
356
|
+
|
|
339
357
|
### Watch & alerts — catching the cash-out
|
|
340
358
|
|
|
341
359
|
The only window to freeze stolen funds is the moment they reach an exchange
|
|
@@ -742,7 +760,7 @@ src/crypttrace/
|
|
|
742
760
|
case.py # investigations as files: addresses, roles, notes, snapshots
|
|
743
761
|
report.py # Markdown + JSON reports
|
|
744
762
|
pdf.py # PDF page setup and font discovery (evidence packs)
|
|
745
|
-
export.py # traced graph as
|
|
763
|
+
export.py # traced graph as GEXF (Gephi), GraphML (yEd) and edge-list CSV (Maltego)
|
|
746
764
|
prices.py # USD valuation
|
|
747
765
|
render.py # rich terminal rendering
|
|
748
766
|
webapp.py # Flask backend for the web UI
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""crypttrace — OSINT crypto investigation CLI."""
|
|
2
|
-
__version__ = "0.
|
|
2
|
+
__version__ = "0.36.0"
|
|
@@ -17,9 +17,11 @@ import json
|
|
|
17
17
|
import re
|
|
18
18
|
import time
|
|
19
19
|
from pathlib import Path
|
|
20
|
+
from collections import defaultdict
|
|
20
21
|
from typing import Callable, List, Optional
|
|
21
22
|
|
|
22
23
|
from crypttrace import addresses, chains, config
|
|
24
|
+
from crypttrace.labels import labels
|
|
23
25
|
|
|
24
26
|
CASES_DIR = config.DATA_DIR / "cases"
|
|
25
27
|
ROLES = ("victim", "suspect", "intermediary", "exchange", "mixer", "bridge", "other")
|
|
@@ -136,6 +138,49 @@ def note(name: str, text: str) -> dict:
|
|
|
136
138
|
return entry
|
|
137
139
|
|
|
138
140
|
|
|
141
|
+
def common_recipients(name: str, chain: str, limit: int = 200) -> dict:
|
|
142
|
+
"""Compare recent outgoing transfers from distinct case addresses on one chain."""
|
|
143
|
+
chains.check(chain)
|
|
144
|
+
sources = sorted({chains.norm_addr(a["address"], chain) for a in load(name)["addresses"]
|
|
145
|
+
if a["chain"] == chain})
|
|
146
|
+
if len(sources) < 2:
|
|
147
|
+
raise CaseError(f"The case needs at least two addresses on {chain}.")
|
|
148
|
+
|
|
149
|
+
recipients = defaultdict(lambda: defaultdict(list))
|
|
150
|
+
warnings = []
|
|
151
|
+
if chains.is_utxo(chain):
|
|
152
|
+
warnings.append("UTXO amounts are proportional input shares. Multiple senders can "
|
|
153
|
+
"belong to one transaction, and an output can be change.")
|
|
154
|
+
for source in sources:
|
|
155
|
+
for asset in ([None] if chains.is_utxo(chain) else [None, _ALL_TOKENS]):
|
|
156
|
+
try:
|
|
157
|
+
rows = chains.transfers(source, chain, limit, asset=asset)
|
|
158
|
+
except chains.ChainError as e:
|
|
159
|
+
warnings.append(f"{source} ({'tokens' if asset else 'native'}): {e}")
|
|
160
|
+
continue
|
|
161
|
+
for row in rows[:limit]:
|
|
162
|
+
recipient = chains.norm_addr(row.get("to") or "", chain)
|
|
163
|
+
if (chains.norm_addr(row.get("from") or "", chain) != source or not recipient
|
|
164
|
+
or recipient == source or row["value"] <= 0 or not row.get("hash")):
|
|
165
|
+
continue
|
|
166
|
+
recipients[recipient][source].append({
|
|
167
|
+
**row, "from": source, "url": chains.tx_url(row["hash"], chain)})
|
|
168
|
+
|
|
169
|
+
matches = []
|
|
170
|
+
for recipient, senders in recipients.items():
|
|
171
|
+
if len(senders) < 2:
|
|
172
|
+
continue
|
|
173
|
+
transfers = sorted((row for rows in senders.values() for row in rows),
|
|
174
|
+
key=lambda row: (row["timestamp"], row["from"], row["hash"]))
|
|
175
|
+
tag = labels.lookup(recipient) or {}
|
|
176
|
+
if tag.get("chain") and tag["chain"] != chain:
|
|
177
|
+
tag = {}
|
|
178
|
+
matches.append({"address": recipient, "senders": len(senders), "label": tag.get("name", ""),
|
|
179
|
+
"type": tag.get("type", "unknown"), "transfers": transfers})
|
|
180
|
+
matches.sort(key=lambda match: (-match["senders"], match["address"]))
|
|
181
|
+
return {"matches": matches, "warnings": warnings}
|
|
182
|
+
|
|
183
|
+
|
|
139
184
|
def snapshot(address: str, chain: str) -> dict:
|
|
140
185
|
"""Native balance and the time of the latest transfer, read fresh."""
|
|
141
186
|
snap = {"at": _now(), "balance": None, "last_seen": None, "error": None}
|
|
@@ -225,8 +225,8 @@ def trace(
|
|
|
225
225
|
direction: str = typer.Option("out", "--direction", "-D",
|
|
226
226
|
help="'out' = where funds went, 'in' = where they came from"),
|
|
227
227
|
export: Optional[Path] = typer.Option(None, "--export", "-o",
|
|
228
|
-
help="Also save the graph: .
|
|
229
|
-
"or .csv (Maltego, Neo4j, spreadsheets)"),
|
|
228
|
+
help="Also save the graph: .gexf (Gephi), .graphml (yEd, "
|
|
229
|
+
"Cytoscape) or .csv (Maltego, Neo4j, spreadsheets)"),
|
|
230
230
|
):
|
|
231
231
|
"""Trace where funds moved, hop by hop, as a coloured tree (ETH or a token)."""
|
|
232
232
|
try:
|
|
@@ -238,8 +238,8 @@ def trace(
|
|
|
238
238
|
console.print("[red]Error:[/red] --direction must be 'out' or 'in'")
|
|
239
239
|
raise typer.Exit(1)
|
|
240
240
|
fmt = export.suffix.lower().lstrip(".") if export else None
|
|
241
|
-
if export and fmt not in ("graphml", "csv"):
|
|
242
|
-
console.print("[red]Error:[/red] --export takes a .graphml or .csv file name")
|
|
241
|
+
if export and fmt not in ("gexf", "graphml", "csv"):
|
|
242
|
+
console.print("[red]Error:[/red] --export takes a .gexf, .graphml or .csv file name")
|
|
243
243
|
raise typer.Exit(1)
|
|
244
244
|
try:
|
|
245
245
|
tree = trace_mod.build_tree(address, chain, depth, branching, asset_desc, direction)
|
|
@@ -261,8 +261,10 @@ def trace(
|
|
|
261
261
|
export.write_text(export_mod.render(graph, chain, fmt), encoding="utf-8", newline="")
|
|
262
262
|
console.print(f"\n[green]Graph saved:[/green] {export} — {len(graph['nodes'])} addresses, "
|
|
263
263
|
f"{len(graph['edges'])} transfers"
|
|
264
|
-
+
|
|
265
|
-
|
|
264
|
+
+ {"csv": " [dim](Maltego: Import Graph from Table, map from/to to an address entity)[/dim]",
|
|
265
|
+
"gexf": " [dim](Gephi: File → Open, untick Auto-scale under More options; the layout "
|
|
266
|
+
"and colours come with it)[/dim]"}
|
|
267
|
+
.get(fmt, " [dim](yEd, Cytoscape)[/dim]"))
|
|
266
268
|
|
|
267
269
|
|
|
268
270
|
@app.command()
|
|
@@ -1136,6 +1138,24 @@ def case_show(name: str = CASE_ARG):
|
|
|
1136
1138
|
console.print(f" [dim]{render._ts(str(n['at']))}[/dim] {n['text']}")
|
|
1137
1139
|
|
|
1138
1140
|
|
|
1141
|
+
@case_app.command("common-recipients")
|
|
1142
|
+
def case_common_recipients(name: str = CASE_ARG, chain: str = CHAIN_OPT):
|
|
1143
|
+
"""Find direct recipients shared by case wallets (latest 200 native and 200 token rows per wallet)."""
|
|
1144
|
+
from crypttrace import case as case_mod
|
|
1145
|
+
result = _case_call(case_mod.common_recipients, name, chain)
|
|
1146
|
+
for warning in result["warnings"]:
|
|
1147
|
+
console.print(warning, style="yellow", markup=False)
|
|
1148
|
+
if not result["matches"]:
|
|
1149
|
+
console.print("No common recipients in the available transfers.")
|
|
1150
|
+
for match in result["matches"]:
|
|
1151
|
+
console.print(f"{match['address']} {match['label']} ({match['type']})"
|
|
1152
|
+
f" · {match['senders']} senders", style="bold", markup=False)
|
|
1153
|
+
for row in match["transfers"]:
|
|
1154
|
+
when = render._ts(str(row["timestamp"])) + " UTC" if row["timestamp"] else "unknown time"
|
|
1155
|
+
console.print(f" {when} {row['from']} {row['value']} {row['symbol']} "
|
|
1156
|
+
f"{row.get('contract') or ''}\n {row['url']}", markup=False, highlight=False)
|
|
1157
|
+
|
|
1158
|
+
|
|
1139
1159
|
@case_app.command("refresh")
|
|
1140
1160
|
def case_refresh(name: str = CASE_ARG):
|
|
1141
1161
|
"""Read every address again and say what changed since the last refresh."""
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"""Export a traced fund-flow graph for the tools analysts already use.
|
|
2
|
+
|
|
3
|
+
GEXF — Gephi's own format, and the one to use with it: the layout,
|
|
4
|
+
colours, sizes and edge thickness are in its viz: elements,
|
|
5
|
+
which Gephi applies on open.
|
|
6
|
+
GraphML — yEd, Cytoscape (and Gephi): nodes keep their label, kind, hop and
|
|
7
|
+
explorer link; edges their amount, USD value, transfer count and
|
|
8
|
+
exchange memo, so a layout can be coloured and sized by them.
|
|
9
|
+
Gephi also reads the layout and look from it: each node carries
|
|
10
|
+
a position (the web UI's left-to-right flow, one column per hop),
|
|
11
|
+
a size and the web UI's colour for its kind, and each edge a
|
|
12
|
+
weight from its value, so the file opens as a readable picture
|
|
13
|
+
instead of a scatter of black dots.
|
|
14
|
+
CSV — one row per edge with both ends' labels and kinds: Maltego's
|
|
15
|
+
"Import Graph from Table" (map `from` and `to` to a
|
|
16
|
+
cryptocurrency-address entity), Neo4j's LOAD CSV, a spreadsheet.
|
|
17
|
+
|
|
18
|
+
Both take the dict `trace.build_graph` returns, the same graph the web UI draws.
|
|
19
|
+
"""
|
|
20
|
+
import csv
|
|
21
|
+
import io
|
|
22
|
+
import math
|
|
23
|
+
from collections import defaultdict
|
|
24
|
+
from typing import Dict, Tuple
|
|
25
|
+
from xml.sax.saxutils import escape, quoteattr
|
|
26
|
+
|
|
27
|
+
from crypttrace import chains
|
|
28
|
+
|
|
29
|
+
# the web UI's colours for each kind of address; "unknown" is darker than the web
|
|
30
|
+
# UI's grey, which vanishes on Gephi's white background
|
|
31
|
+
COLORS = {"exchange": (63, 223, 135), "mixer": (196, 140, 255), "sanctioned": (255, 107, 96),
|
|
32
|
+
"scam": (255, 107, 96), "bridge": (63, 216, 232), "dex": (77, 157, 255),
|
|
33
|
+
"service": (77, 157, 255), "unknown": (96, 108, 128)}
|
|
34
|
+
NOTABLE = {"exchange", "mixer", "sanctioned", "scam", "bridge"}
|
|
35
|
+
X_STEP, Y_STEP = 360.0, 150.0
|
|
36
|
+
|
|
37
|
+
# x, y, size, r, g, b (nodes) and weight (edges) are the names Gephi's GraphML
|
|
38
|
+
# importer takes as position, size, colour and edge weight
|
|
39
|
+
NODE_KEYS = [("label", "string"), ("kind", "string"), ("hop", "int"), ("root", "boolean"),
|
|
40
|
+
("trail_ends", "boolean"), ("chain", "string"), ("explorer", "string"),
|
|
41
|
+
("x", "float"), ("y", "float"), ("size", "float"), ("r", "int"), ("g", "int"), ("b", "int")]
|
|
42
|
+
EDGE_KEYS = [("amount", "double"), ("symbol", "string"), ("usd", "double"), ("transfers", "int"),
|
|
43
|
+
("memo", "string"), ("weight", "double")]
|
|
44
|
+
CSV_HEAD = ["from", "from_label", "from_kind", "to", "to_label", "to_kind", "amount", "symbol",
|
|
45
|
+
"usd", "transfers", "memo", "chain", "from_explorer", "to_explorer"]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def layout(graph: dict) -> Dict[str, Tuple[float, float]]:
|
|
49
|
+
"""Positions like the web UI's: one column per hop from the investigated
|
|
50
|
+
address, money flowing left to right, and each column ordered by where its
|
|
51
|
+
nodes' neighbours one hop closer sit, so lines cross as little as possible."""
|
|
52
|
+
level = {n["id"]: n.get("level", 0) for n in graph.get("nodes", [])}
|
|
53
|
+
closer = defaultdict(list) # node -> its neighbours one hop nearer the root
|
|
54
|
+
for e in graph.get("edges", []):
|
|
55
|
+
a, b = e["from"], e["to"]
|
|
56
|
+
if level.get(a, 0) < level.get(b, 0):
|
|
57
|
+
closer[b].append(a)
|
|
58
|
+
elif level.get(b, 0) < level.get(a, 0):
|
|
59
|
+
closer[a].append(b)
|
|
60
|
+
columns = defaultdict(list)
|
|
61
|
+
for i, lv in level.items():
|
|
62
|
+
columns[lv].append(i)
|
|
63
|
+
y: Dict[str, float] = {}
|
|
64
|
+
for lv in sorted(columns):
|
|
65
|
+
def anchor(i):
|
|
66
|
+
ys = [y[p] for p in closer[i] if p in y]
|
|
67
|
+
return sum(ys) / len(ys) if ys else 0.0
|
|
68
|
+
order = sorted(columns[lv], key=lambda i: (anchor(i), i))
|
|
69
|
+
for j, i in enumerate(order):
|
|
70
|
+
y[i] = (j - (len(order) - 1) / 2) * Y_STEP
|
|
71
|
+
# traced backwards the hops run against the money: mirror, so arrows still point right
|
|
72
|
+
sign = -1 if graph.get("direction") == "in" else 1
|
|
73
|
+
return {i: (sign * lv * X_STEP, -y[i]) for i, lv in level.items()}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _node_attrs(n: dict, chain: str, pos: Tuple[float, float]) -> dict:
|
|
77
|
+
kind = n.get("type") or "unknown"
|
|
78
|
+
r, g, b = COLORS.get(kind, COLORS["unknown"])
|
|
79
|
+
size = 50.0 if n.get("root") else 36.0 if kind in NOTABLE else 28.0
|
|
80
|
+
return {"label": n.get("label") or n.get("short") or n["id"], "kind": kind,
|
|
81
|
+
"hop": n.get("level", 0), "root": bool(n.get("root")), "trail_ends": bool(n.get("terminal")),
|
|
82
|
+
"chain": chain, "explorer": chains.explorer_url(n["id"], chain),
|
|
83
|
+
"x": round(pos[0], 1), "y": round(pos[1], 1), "size": size, "r": r, "g": g, "b": b}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _edge_attrs(e: dict, symbol: str) -> dict:
|
|
87
|
+
value = e.get("usd") if e.get("usd") is not None else (e.get("value") or 0)
|
|
88
|
+
return {"amount": e.get("value") or 0, "symbol": symbol, "usd": e.get("usd"),
|
|
89
|
+
"transfers": e.get("tx") or 0, "memo": e.get("memo") or "",
|
|
90
|
+
# thickness by order of magnitude, 0.5 ($1) to 3 ($1B): kept well under the node
|
|
91
|
+
# sizes, or a large transfer's line covers the addresses it joins
|
|
92
|
+
"weight": round(0.5 + 2.5 * min(1.0, math.log10(1 + abs(value)) / 9), 2)}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _val(v, kind: str) -> str:
|
|
96
|
+
if v is None:
|
|
97
|
+
return ""
|
|
98
|
+
if kind == "boolean":
|
|
99
|
+
return "true" if v else "false"
|
|
100
|
+
return escape(str(v))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def to_graphml(graph: dict, chain: str) -> str:
|
|
104
|
+
"""GraphML 1.0, directed: money flows along the edges."""
|
|
105
|
+
symbol = graph.get("symbol", "")
|
|
106
|
+
pos = layout(graph)
|
|
107
|
+
out = ['<?xml version="1.0" encoding="UTF-8"?>',
|
|
108
|
+
'<graphml xmlns="http://graphml.graphdrawing.org/xmlns">']
|
|
109
|
+
for k, t in NODE_KEYS:
|
|
110
|
+
out.append(f' <key id="n_{k}" for="node" attr.name="{k}" attr.type="{t}"/>')
|
|
111
|
+
for k, t in EDGE_KEYS:
|
|
112
|
+
out.append(f' <key id="e_{k}" for="edge" attr.name="{k}" attr.type="{t}"/>')
|
|
113
|
+
out.append(f' <graph id={quoteattr("crypttrace " + chain)} edgedefault="directed">')
|
|
114
|
+
for n in graph.get("nodes", []):
|
|
115
|
+
out.append(f' <node id={quoteattr(n["id"])}>')
|
|
116
|
+
for (k, t), v in zip(NODE_KEYS, _node_attrs(n, chain, pos[n["id"]]).values()):
|
|
117
|
+
if v not in (None, ""):
|
|
118
|
+
out.append(f' <data key="n_{k}">{_val(v, t)}</data>')
|
|
119
|
+
out.append(" </node>")
|
|
120
|
+
for i, e in enumerate(graph.get("edges", [])):
|
|
121
|
+
out.append(f' <edge id="e{i}" source={quoteattr(e["from"])} target={quoteattr(e["to"])}>')
|
|
122
|
+
for (k, t), v in zip(EDGE_KEYS, _edge_attrs(e, symbol).values()):
|
|
123
|
+
if v not in (None, ""):
|
|
124
|
+
out.append(f' <data key="e_{k}">{_val(v, t)}</data>')
|
|
125
|
+
out.append(" </edge>")
|
|
126
|
+
out += [" </graph>", "</graphml>", ""]
|
|
127
|
+
return "\n".join(out)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def to_gexf(graph: dict, chain: str) -> str:
|
|
131
|
+
"""GEXF, Gephi's own format: the layout, colour, size and edge thickness go in
|
|
132
|
+
its viz: elements, which Gephi always applies on open; the data rides along
|
|
133
|
+
as attributes, ready for its filters and partitions."""
|
|
134
|
+
symbol = graph.get("symbol", "")
|
|
135
|
+
pos = layout(graph)
|
|
136
|
+
node_cols = [("kind", "string"), ("hop", "integer"), ("root", "boolean"), ("trail_ends", "boolean"),
|
|
137
|
+
("chain", "string"), ("explorer", "string")]
|
|
138
|
+
edge_cols = [("amount", "double"), ("symbol", "string"), ("usd", "double"), ("transfers", "integer"),
|
|
139
|
+
("memo", "string")]
|
|
140
|
+
out = ['<?xml version="1.0" encoding="UTF-8"?>',
|
|
141
|
+
'<gexf xmlns="http://www.gexf.net/1.2draft" xmlns:viz="http://www.gexf.net/1.2draft/viz" '
|
|
142
|
+
'version="1.2">',
|
|
143
|
+
f' <meta><creator>crypttrace</creator><description>{escape(chain)} fund flow, '
|
|
144
|
+
f'{escape(graph.get("direction", "out"))}</description></meta>',
|
|
145
|
+
' <graph defaultedgetype="directed" mode="static">',
|
|
146
|
+
' <attributes class="node">']
|
|
147
|
+
out += [f' <attribute id="{k}" title="{k}" type="{t}"/>' for k, t in node_cols]
|
|
148
|
+
out += [' </attributes>', ' <attributes class="edge">']
|
|
149
|
+
out += [f' <attribute id="{k}" title="{k}" type="{t}"/>' for k, t in edge_cols]
|
|
150
|
+
out += [' </attributes>', ' <nodes>']
|
|
151
|
+
for n in graph.get("nodes", []):
|
|
152
|
+
a = _node_attrs(n, chain, pos[n["id"]])
|
|
153
|
+
out.append(f' <node id={quoteattr(n["id"])} label={quoteattr(a["label"])}>')
|
|
154
|
+
out.append(" <attvalues>" + "".join(
|
|
155
|
+
f'<attvalue for="{k}" value={quoteattr(_val(a[k], t) if t == "boolean" else str(a[k]))}/>'
|
|
156
|
+
for k, t in node_cols) + "</attvalues>")
|
|
157
|
+
out.append(f' <viz:size value="{a["size"]}"/>')
|
|
158
|
+
out.append(f' <viz:position x="{a["x"]}" y="{a["y"]}" z="0.0"/>')
|
|
159
|
+
out.append(f' <viz:color r="{a["r"]}" g="{a["g"]}" b="{a["b"]}" a="1.0"/>')
|
|
160
|
+
out.append(" </node>")
|
|
161
|
+
out += [' </nodes>', ' <edges>']
|
|
162
|
+
for i, e in enumerate(graph.get("edges", [])):
|
|
163
|
+
a = _edge_attrs(e, symbol)
|
|
164
|
+
label = f"{a['amount']:,.4f} {symbol}".rstrip()
|
|
165
|
+
out.append(f' <edge id="{i}" source={quoteattr(e["from"])} target={quoteattr(e["to"])} '
|
|
166
|
+
f'weight="{a["weight"]}" label={quoteattr(label)}>')
|
|
167
|
+
out.append(" <attvalues>" + "".join(
|
|
168
|
+
f'<attvalue for="{k}" value={quoteattr(str(a[k]))}/>' for k, _ in edge_cols
|
|
169
|
+
if a[k] not in (None, "")) + "</attvalues>")
|
|
170
|
+
out.append(f' <viz:thickness value="{a["weight"]}"/>')
|
|
171
|
+
out.append(' <viz:color r="200" g="205" b="215" a="1.0"/>') # lighter than any node
|
|
172
|
+
out.append(" </edge>")
|
|
173
|
+
out += [' </edges>', ' </graph>', '</gexf>', '']
|
|
174
|
+
return "\n".join(out)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def to_csv(graph: dict, chain: str) -> str:
|
|
178
|
+
"""One row per edge, both ends described — what a link-analysis import wants."""
|
|
179
|
+
symbol = graph.get("symbol", "")
|
|
180
|
+
nodes = {n["id"]: n for n in graph.get("nodes", [])}
|
|
181
|
+
buf = io.StringIO()
|
|
182
|
+
w = csv.writer(buf, lineterminator="\n")
|
|
183
|
+
w.writerow(CSV_HEAD)
|
|
184
|
+
for e in graph.get("edges", []):
|
|
185
|
+
a, b = nodes.get(e["from"], {"id": e["from"]}), nodes.get(e["to"], {"id": e["to"]})
|
|
186
|
+
ea = _edge_attrs(e, symbol)
|
|
187
|
+
w.writerow([e["from"], a.get("label") or "", a.get("type") or "unknown",
|
|
188
|
+
e["to"], b.get("label") or "", b.get("type") or "unknown",
|
|
189
|
+
ea["amount"], symbol, "" if ea["usd"] is None else ea["usd"], ea["transfers"],
|
|
190
|
+
ea["memo"], chain, chains.explorer_url(e["from"], chain), chains.explorer_url(e["to"], chain)])
|
|
191
|
+
return buf.getvalue()
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
FORMATS = {"gexf": (to_gexf, "application/gexf+xml"), "graphml": (to_graphml, "application/graphml+xml"),
|
|
195
|
+
"csv": (to_csv, "text/csv")}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def render(graph: dict, chain: str, fmt: str) -> str:
|
|
199
|
+
if fmt not in FORMATS:
|
|
200
|
+
raise ValueError(f"unknown export format '{fmt}' — use one of: {', '.join(FORMATS)}")
|
|
201
|
+
return FORMATS[fmt][0](graph, chain)
|
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
/* Tabs live inside the graph column, never in the header stack — that way they
|
|
67
67
|
cannot collide with the search row regardless of window size. */
|
|
68
68
|
.main{flex:1 1 auto;display:flex;flex-direction:column;min-width:0;min-height:0}
|
|
69
|
-
.tabs{flex:0 0 auto;display:flex;gap:6px;margin-bottom:10px}
|
|
69
|
+
.tabs{flex:0 0 auto;display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
|
|
70
|
+
#common-results{overflow-wrap:anywhere}
|
|
70
71
|
.tab{font-size:13px;font-weight:600;padding:8px 15px;border-radius:12px;cursor:pointer;
|
|
71
72
|
background:var(--glass-2);border:1px solid var(--stroke);color:var(--dim);
|
|
72
73
|
backdrop-filter:blur(12px);transition:.25s cubic-bezier(.22,1,.36,1)}
|
|
@@ -230,7 +231,8 @@
|
|
|
230
231
|
<button id="go">Investigate</button>
|
|
231
232
|
<button id="fit" class="ghost" title="Fit graph to view">Fit</button>
|
|
232
233
|
<button id="casefile" class="ghost" title="Download a one-page case file for an exchange or the police">Case file</button>
|
|
233
|
-
<button id="exp-
|
|
234
|
+
<button id="exp-gexf" class="ghost" title="Download the graph for Gephi, with its layout and colours">Gephi</button>
|
|
235
|
+
<button id="exp-graphml" class="ghost" title="Download the graph for yEd or Cytoscape">GraphML</button>
|
|
234
236
|
<button id="exp-csv" class="ghost" title="Download the graph as an edge list for Maltego, Neo4j or a spreadsheet">CSV</button>
|
|
235
237
|
</div>
|
|
236
238
|
|
|
@@ -252,6 +254,7 @@
|
|
|
252
254
|
<button class="tab" data-view="victims">Who sent funds here</button>
|
|
253
255
|
<button class="tab" data-view="poison">Poisoning</button>
|
|
254
256
|
<button class="tab" data-view="check">Was I drained?</button>
|
|
257
|
+
<button class="tab" data-view="common">Common recipients</button>
|
|
255
258
|
</div>
|
|
256
259
|
<div class="stage">
|
|
257
260
|
<div class="loader" id="loader"></div>
|
|
@@ -263,6 +266,15 @@
|
|
|
263
266
|
<div class="view" id="v-victims"></div>
|
|
264
267
|
<div class="view" id="v-poison"></div>
|
|
265
268
|
<div class="view" id="v-check"></div>
|
|
269
|
+
<div class="view" id="v-common">
|
|
270
|
+
<form id="common-form">
|
|
271
|
+
<label>Case <select id="common-case" required></select></label>
|
|
272
|
+
<label>Network <select id="common-chain"></select></label>
|
|
273
|
+
<button>Find common recipients</button>
|
|
274
|
+
</form>
|
|
275
|
+
<div id="common-results" aria-live="polite"></div>
|
|
276
|
+
<p class="muted">Searches up to 200 recent native and 200 token transfers per wallet. Shared exchange addresses may receive unrelated deposits.</p>
|
|
277
|
+
</div>
|
|
266
278
|
<div class="scaleview" id="scaleview" style="display:none">100%</div>
|
|
267
279
|
<div class="zoomctl" id="zoomctl">
|
|
268
280
|
<button id="zin" title="Zoom in">+</button>
|
|
@@ -541,6 +553,7 @@ let currentView='graph', loaded={};
|
|
|
541
553
|
|
|
542
554
|
function showView(v){
|
|
543
555
|
currentView=v;
|
|
556
|
+
$('#hint').style.display=v==='graph'?'':'none';
|
|
544
557
|
document.querySelectorAll('.tab').forEach(t=>t.classList.toggle('on',t.dataset.view===v));
|
|
545
558
|
$('#graph').style.display = v==='graph'?'block':'none';
|
|
546
559
|
$('#zoomctl').style.display = v==='graph'?'flex':'none';
|
|
@@ -550,6 +563,8 @@ function showView(v){
|
|
|
550
563
|
$('#v-victims').classList.toggle('on',v==='victims');
|
|
551
564
|
$('#v-poison').classList.toggle('on',v==='poison');
|
|
552
565
|
$('#v-check').classList.toggle('on',v==='check');
|
|
566
|
+
$('#v-common').classList.toggle('on',v==='common');
|
|
567
|
+
if(v==='common') loadCaseNames();
|
|
553
568
|
const a=$('#addr').value.trim();
|
|
554
569
|
if(a && !loaded[v+a]) {
|
|
555
570
|
loaded[v+a]=true;
|
|
@@ -562,6 +577,37 @@ function showView(v){
|
|
|
562
577
|
}
|
|
563
578
|
document.querySelectorAll('.tab').forEach(t=>t.onclick=()=>showView(t.dataset.view));
|
|
564
579
|
|
|
580
|
+
$('#common-chain').innerHTML=$('#chain').innerHTML;
|
|
581
|
+
async function loadCaseNames(){
|
|
582
|
+
const select=$('#common-case'), previous=select.value;
|
|
583
|
+
try{
|
|
584
|
+
const names=await api('/api/cases');
|
|
585
|
+
select.replaceChildren(...names.map(name=>new Option(name,name)));
|
|
586
|
+
if(names.includes(previous)) select.value=previous;
|
|
587
|
+
else $('#common-results').textContent=names.length?'':'Create a case with crypttrace case new and add two addresses on one network.';
|
|
588
|
+
}catch(e){ $('#common-results').textContent=e.message; }
|
|
589
|
+
}
|
|
590
|
+
const commonForm=$('#common-form'), commonResults=$('#common-results');
|
|
591
|
+
commonForm.onchange=()=>{commonResults.textContent='';};
|
|
592
|
+
commonForm.onsubmit=async event=>{
|
|
593
|
+
event.preventDefault();
|
|
594
|
+
const name=$('#common-case').value, network=$('#common-chain').value;
|
|
595
|
+
for(const control of commonForm.elements) control.disabled=true;
|
|
596
|
+
commonResults.textContent='Reading recent transfers…';
|
|
597
|
+
try{
|
|
598
|
+
const report=await api('/api/cases/'+q(name)+'/common-recipients?chain='+q(network));
|
|
599
|
+
const warnings=report.warnings.map(w=>'<p>'+esc(w)+'</p>').join('');
|
|
600
|
+
const groups=report.matches.map(m=>`<section class="card">
|
|
601
|
+
<h3>${esc(m.label || 'Recipient')} · ${esc(m.type)} · ${m.senders} senders</h3>
|
|
602
|
+
<p>${esc(m.address)}</p>${m.transfers.map(t=>`<p>${fmtTs(t.timestamp)} UTC · ${esc(t.from)}
|
|
603
|
+
· ${esc(t.value)} ${esc(t.symbol)} ${esc(t.contract || '')}
|
|
604
|
+
· <a href="${safeUrl(t.url)}" target="_blank" rel="noopener">${esc(t.hash)}</a></p>`).join('')}
|
|
605
|
+
</section>`).join('');
|
|
606
|
+
commonResults.innerHTML=warnings+(groups||'<p>No common recipients in the available transfers.</p>');
|
|
607
|
+
}catch(e){ commonResults.textContent=e.message; }
|
|
608
|
+
finally{ for(const control of commonForm.elements) control.disabled=false; }
|
|
609
|
+
};
|
|
610
|
+
|
|
565
611
|
const dstamp=t=>t?new Date(t*1000).toISOString().slice(0,16).replace('T',' '):'—';
|
|
566
612
|
async function loadTimeline(a){
|
|
567
613
|
const el=$('#v-timeline');
|
|
@@ -806,6 +852,7 @@ async function downloadGraph(fmt){
|
|
|
806
852
|
}catch(e){ setStatus(e.message,true); }
|
|
807
853
|
finally{ b.disabled=false; }
|
|
808
854
|
}
|
|
855
|
+
$('#exp-gexf').addEventListener('click',()=>downloadGraph('gexf'));
|
|
809
856
|
$('#exp-graphml').addEventListener('click',()=>downloadGraph('graphml'));
|
|
810
857
|
$('#exp-csv').addEventListener('click',()=>downloadGraph('csv'));
|
|
811
858
|
|
|
@@ -76,6 +76,23 @@ def create_app() -> Flask:
|
|
|
76
76
|
resp.headers["Cache-Control"] = "no-store"
|
|
77
77
|
return resp
|
|
78
78
|
|
|
79
|
+
@app.route("/api/cases")
|
|
80
|
+
def api_cases():
|
|
81
|
+
from crypttrace import case
|
|
82
|
+
return jsonify([Path(c["path"]).stem for c in case.all_cases()])
|
|
83
|
+
|
|
84
|
+
@app.route("/api/cases/<name>/common-recipients")
|
|
85
|
+
def api_common_recipients(name):
|
|
86
|
+
from crypttrace import case
|
|
87
|
+
# Only offer files in the local case library, never a client-supplied path.
|
|
88
|
+
paths = {Path(c["path"]).stem: c["path"] for c in case.all_cases()}
|
|
89
|
+
if name not in paths:
|
|
90
|
+
return jsonify(error="Unknown case."), 404
|
|
91
|
+
try:
|
|
92
|
+
return jsonify(case.common_recipients(paths[name], request.args.get("chain", "eth")))
|
|
93
|
+
except _KNOWN_ERRORS as e:
|
|
94
|
+
return jsonify(error=str(e)), 400
|
|
95
|
+
|
|
79
96
|
@app.route("/api/assets")
|
|
80
97
|
def api_assets():
|
|
81
98
|
"""Which assets can be traced on a given chain (drives the UI dropdown)."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crypttrace
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.36.0
|
|
4
4
|
Summary: OSINT toolkit for crypto investigations: trace stolen funds across Ethereum, Bitcoin, Tron, Solana and TON
|
|
5
5
|
Author: bobslayerX
|
|
6
6
|
License-Expression: MIT
|
|
@@ -214,7 +214,8 @@ and whether USDT/USDC at the address is frozen. Tabs add the assessment, the
|
|
|
214
214
|
timeline, the list of who sent funds here, and address poisoning (look-alikes
|
|
215
215
|
planted in the wallet's history, and payments lured by this address). **Case
|
|
216
216
|
file** downloads the same one-page HTML report `crypttrace report` writes;
|
|
217
|
-
**GraphML** and **CSV** download the graph for Gephi
|
|
217
|
+
**Gephi**, **GraphML** and **CSV** download the graph for Gephi (with its
|
|
218
|
+
layout and colours), yEd or Cytoscape, and Maltego. The page's
|
|
218
219
|
address is a link to the investigation
|
|
219
220
|
(`/?address=…&chain=…&direction=…&depth=…&tab=check`), ready to bookmark or
|
|
220
221
|
send. Everything runs on your machine — nothing is uploaded anywhere.
|
|
@@ -279,10 +280,18 @@ crypttrace trace 0xADDRESS --direction in
|
|
|
279
280
|
# Trace a token rather than the native coin (most thefts are stablecoins)
|
|
280
281
|
crypttrace trace 0xADDRESS --asset usdt --depth 4
|
|
281
282
|
|
|
282
|
-
# Save the traced graph
|
|
283
|
+
# Save the traced graph: Gephi (with its layout and colours), yEd / Cytoscape, Maltego / Neo4j
|
|
284
|
+
crypttrace trace 0xADDRESS --depth 4 --export case.gexf
|
|
283
285
|
crypttrace trace 0xADDRESS --depth 4 --export case.graphml
|
|
284
286
|
crypttrace trace 0xADDRESS --depth 4 --export case.csv
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
In Gephi's import dialog untick **Auto-scale** (under *More options*): it
|
|
290
|
+
stretches the positions without the node sizes, and the addresses shrink to
|
|
291
|
+
dots under their own edges. Don't run a layout either — the file already has
|
|
292
|
+
one.
|
|
285
293
|
|
|
294
|
+
```bash
|
|
286
295
|
# Token holdings, valued in USD
|
|
287
296
|
crypttrace tokens 0xADDRESS
|
|
288
297
|
|
|
@@ -367,12 +376,21 @@ crypttrace case add ronin 0x098b…2f96 --chain eth --role suspect --note "explo
|
|
|
367
376
|
crypttrace case note ronin "asked Binance for KYC on the first-gas withdrawal"
|
|
368
377
|
crypttrace case refresh ronin # what moved since the last refresh
|
|
369
378
|
crypttrace case show ronin # addresses, current labels, last snapshot, the log
|
|
379
|
+
crypttrace case common-recipients ronin --chain eth
|
|
370
380
|
```
|
|
371
381
|
|
|
372
382
|
A case is one JSON file in `~/.crypttrace/cases/`. Every `case` command also
|
|
373
383
|
takes a path to a `.json` file, so handing a case to a colleague is sending the
|
|
374
384
|
file.
|
|
375
385
|
|
|
386
|
+
**Common recipients** compares all case addresses on the selected network, regardless of role.
|
|
387
|
+
It reads up to 200 recent native and 200 recent token transfer rows per wallet, subject to
|
|
388
|
+
provider limits. Each match shows the distinct senders, individual amounts and assets, UTC
|
|
389
|
+
times, explorer links and any known recipient label. A shared exchange wallet can receive
|
|
390
|
+
unrelated deposits. On UTXO networks, input shares are estimates and outputs can be change.
|
|
391
|
+
In the web app, open **Common recipients**, choose a saved case and network, and click
|
|
392
|
+
**Find common recipients**.
|
|
393
|
+
|
|
376
394
|
### Watch & alerts — catching the cash-out
|
|
377
395
|
|
|
378
396
|
The only window to freeze stolen funds is the moment they reach an exchange
|
|
@@ -779,7 +797,7 @@ src/crypttrace/
|
|
|
779
797
|
case.py # investigations as files: addresses, roles, notes, snapshots
|
|
780
798
|
report.py # Markdown + JSON reports
|
|
781
799
|
pdf.py # PDF page setup and font discovery (evidence packs)
|
|
782
|
-
export.py # traced graph as
|
|
800
|
+
export.py # traced graph as GEXF (Gephi), GraphML (yEd) and edge-list CSV (Maltego)
|
|
783
801
|
prices.py # USD valuation
|
|
784
802
|
render.py # rich terminal rendering
|
|
785
803
|
webapp.py # Flask backend for the web UI
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"""Export a traced fund-flow graph for the tools analysts already use.
|
|
2
|
-
|
|
3
|
-
GraphML — Gephi, yEd, Cytoscape: nodes keep their label, kind, hop and
|
|
4
|
-
explorer link; edges their amount, USD value, transfer count and
|
|
5
|
-
exchange memo, so a layout can be coloured and sized by them.
|
|
6
|
-
CSV — one row per edge with both ends' labels and kinds: Maltego's
|
|
7
|
-
"Import Graph from Table" (map `from` and `to` to a
|
|
8
|
-
cryptocurrency-address entity), Neo4j's LOAD CSV, a spreadsheet.
|
|
9
|
-
|
|
10
|
-
Both take the dict `trace.build_graph` returns, the same graph the web UI draws.
|
|
11
|
-
"""
|
|
12
|
-
import csv
|
|
13
|
-
import io
|
|
14
|
-
from xml.sax.saxutils import escape, quoteattr
|
|
15
|
-
|
|
16
|
-
from crypttrace import chains
|
|
17
|
-
|
|
18
|
-
NODE_KEYS = [("label", "string"), ("kind", "string"), ("hop", "int"), ("root", "boolean"),
|
|
19
|
-
("trail_ends", "boolean"), ("chain", "string"), ("explorer", "string")]
|
|
20
|
-
EDGE_KEYS = [("amount", "double"), ("symbol", "string"), ("usd", "double"), ("transfers", "int"),
|
|
21
|
-
("memo", "string")]
|
|
22
|
-
CSV_HEAD = ["from", "from_label", "from_kind", "to", "to_label", "to_kind", "amount", "symbol",
|
|
23
|
-
"usd", "transfers", "memo", "chain", "from_explorer", "to_explorer"]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _node_attrs(n: dict, chain: str) -> dict:
|
|
27
|
-
return {"label": n.get("label") or n.get("short") or n["id"], "kind": n.get("type") or "unknown",
|
|
28
|
-
"hop": n.get("level", 0), "root": bool(n.get("root")), "trail_ends": bool(n.get("terminal")),
|
|
29
|
-
"chain": chain, "explorer": chains.explorer_url(n["id"], chain)}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def _edge_attrs(e: dict, symbol: str) -> dict:
|
|
33
|
-
return {"amount": e.get("value") or 0, "symbol": symbol, "usd": e.get("usd"),
|
|
34
|
-
"transfers": e.get("tx") or 0, "memo": e.get("memo") or ""}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _val(v, kind: str) -> str:
|
|
38
|
-
if v is None:
|
|
39
|
-
return ""
|
|
40
|
-
if kind == "boolean":
|
|
41
|
-
return "true" if v else "false"
|
|
42
|
-
return escape(str(v))
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def to_graphml(graph: dict, chain: str) -> str:
|
|
46
|
-
"""GraphML 1.0, directed: money flows along the edges."""
|
|
47
|
-
symbol = graph.get("symbol", "")
|
|
48
|
-
out = ['<?xml version="1.0" encoding="UTF-8"?>',
|
|
49
|
-
'<graphml xmlns="http://graphml.graphdrawing.org/xmlns">']
|
|
50
|
-
for k, t in NODE_KEYS:
|
|
51
|
-
out.append(f' <key id="n_{k}" for="node" attr.name="{k}" attr.type="{t}"/>')
|
|
52
|
-
for k, t in EDGE_KEYS:
|
|
53
|
-
out.append(f' <key id="e_{k}" for="edge" attr.name="{k}" attr.type="{t}"/>')
|
|
54
|
-
out.append(f' <graph id={quoteattr("crypttrace " + chain)} edgedefault="directed">')
|
|
55
|
-
for n in graph.get("nodes", []):
|
|
56
|
-
out.append(f' <node id={quoteattr(n["id"])}>')
|
|
57
|
-
for (k, t), v in zip(NODE_KEYS, _node_attrs(n, chain).values()):
|
|
58
|
-
if v not in (None, ""):
|
|
59
|
-
out.append(f' <data key="n_{k}">{_val(v, t)}</data>')
|
|
60
|
-
out.append(" </node>")
|
|
61
|
-
for i, e in enumerate(graph.get("edges", [])):
|
|
62
|
-
out.append(f' <edge id="e{i}" source={quoteattr(e["from"])} target={quoteattr(e["to"])}>')
|
|
63
|
-
for (k, t), v in zip(EDGE_KEYS, _edge_attrs(e, symbol).values()):
|
|
64
|
-
if v not in (None, ""):
|
|
65
|
-
out.append(f' <data key="e_{k}">{_val(v, t)}</data>')
|
|
66
|
-
out.append(" </edge>")
|
|
67
|
-
out += [" </graph>", "</graphml>", ""]
|
|
68
|
-
return "\n".join(out)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def to_csv(graph: dict, chain: str) -> str:
|
|
72
|
-
"""One row per edge, both ends described — what a link-analysis import wants."""
|
|
73
|
-
symbol = graph.get("symbol", "")
|
|
74
|
-
nodes = {n["id"]: n for n in graph.get("nodes", [])}
|
|
75
|
-
buf = io.StringIO()
|
|
76
|
-
w = csv.writer(buf, lineterminator="\n")
|
|
77
|
-
w.writerow(CSV_HEAD)
|
|
78
|
-
for e in graph.get("edges", []):
|
|
79
|
-
a, b = nodes.get(e["from"], {"id": e["from"]}), nodes.get(e["to"], {"id": e["to"]})
|
|
80
|
-
ea = _edge_attrs(e, symbol)
|
|
81
|
-
w.writerow([e["from"], a.get("label") or "", a.get("type") or "unknown",
|
|
82
|
-
e["to"], b.get("label") or "", b.get("type") or "unknown",
|
|
83
|
-
ea["amount"], symbol, "" if ea["usd"] is None else ea["usd"], ea["transfers"],
|
|
84
|
-
ea["memo"], chain, chains.explorer_url(e["from"], chain), chains.explorer_url(e["to"], chain)])
|
|
85
|
-
return buf.getvalue()
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
FORMATS = {"graphml": (to_graphml, "application/graphml+xml"), "csv": (to_csv, "text/csv")}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def render(graph: dict, chain: str, fmt: str) -> str:
|
|
92
|
-
if fmt not in FORMATS:
|
|
93
|
-
raise ValueError(f"unknown export format '{fmt}' — use one of: {', '.join(FORMATS)}")
|
|
94
|
-
return FORMATS[fmt][0](graph, chain)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|