crypttrace 0.35.0__tar.gz → 0.37.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.37.0}/PKG-INFO +24 -4
- {crypttrace-0.35.0 → crypttrace-0.37.0}/README.md +23 -3
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/__init__.py +1 -1
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/case.py +85 -9
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/cli.py +26 -6
- crypttrace-0.37.0/src/crypttrace/export.py +201 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/web/index.html +82 -5
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/webapp.py +33 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0/src/crypttrace.egg-info}/PKG-INFO +24 -4
- crypttrace-0.35.0/src/crypttrace/export.py +0 -94
- {crypttrace-0.35.0 → crypttrace-0.37.0}/LICENSE +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/pyproject.toml +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/setup.cfg +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/addresses.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/analysis.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/assess.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/assets.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/bridges.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/chains.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/config.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/drain.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/evidence.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/fetchers/__init__.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/fetchers/bitcoin.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/fetchers/etherscan.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/fetchers/http.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/fetchers/solana.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/fetchers/ton.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/fetchers/tron.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/freeze.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/funder.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/gascluster.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/investigate.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/__init__.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/audit.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/bulk.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/known.json +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/labels.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/names.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/partial.json +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/tonapi.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/labels/tronscan.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/offramp.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/pdf.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/poisoning.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/prices.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/render.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/report.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/spam.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/store.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/trace.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/verify.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace/watch.py +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace.egg-info/SOURCES.txt +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace.egg-info/dependency_links.txt +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace.egg-info/entry_points.txt +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.0}/src/crypttrace.egg-info/requires.txt +0 -0
- {crypttrace-0.35.0 → crypttrace-0.37.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.37.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,23 @@ 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** and select **New case…**. Choose a network,
|
|
392
|
+
name the case and paste at least two wallet addresses, one per line. **Create case and
|
|
393
|
+
find recipients** saves the case to the local case library and searches it immediately.
|
|
394
|
+
You can reopen the case in the same tab or with `crypttrace case show NAME`.
|
|
395
|
+
|
|
376
396
|
### Watch & alerts — catching the cash-out
|
|
377
397
|
|
|
378
398
|
The only window to freeze stolen funds is the moment they reach an exchange
|
|
@@ -779,7 +799,7 @@ src/crypttrace/
|
|
|
779
799
|
case.py # investigations as files: addresses, roles, notes, snapshots
|
|
780
800
|
report.py # Markdown + JSON reports
|
|
781
801
|
pdf.py # PDF page setup and font discovery (evidence packs)
|
|
782
|
-
export.py # traced graph as
|
|
802
|
+
export.py # traced graph as GEXF (Gephi), GraphML (yEd) and edge-list CSV (Maltego)
|
|
783
803
|
prices.py # USD valuation
|
|
784
804
|
render.py # rich terminal rendering
|
|
785
805
|
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,23 @@ 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** and select **New case…**. Choose a network,
|
|
355
|
+
name the case and paste at least two wallet addresses, one per line. **Create case and
|
|
356
|
+
find recipients** saves the case to the local case library and searches it immediately.
|
|
357
|
+
You can reopen the case in the same tab or with `crypttrace case show NAME`.
|
|
358
|
+
|
|
339
359
|
### Watch & alerts — catching the cash-out
|
|
340
360
|
|
|
341
361
|
The only window to freeze stolen funds is the moment they reach an exchange
|
|
@@ -742,7 +762,7 @@ src/crypttrace/
|
|
|
742
762
|
case.py # investigations as files: addresses, roles, notes, snapshots
|
|
743
763
|
report.py # Markdown + JSON reports
|
|
744
764
|
pdf.py # PDF page setup and font discovery (evidence packs)
|
|
745
|
-
export.py # traced graph as
|
|
765
|
+
export.py # traced graph as GEXF (Gephi), GraphML (yEd) and edge-list CSV (Maltego)
|
|
746
766
|
prices.py # USD valuation
|
|
747
767
|
render.py # rich terminal rendering
|
|
748
768
|
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.37.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")
|
|
@@ -45,15 +47,24 @@ def _now() -> int:
|
|
|
45
47
|
return int(time.time())
|
|
46
48
|
|
|
47
49
|
|
|
48
|
-
def new(name: str, note: str = "") -> Path:
|
|
50
|
+
def new(name: str, note: str = "", *, entries: Optional[List[dict]] = None) -> Path:
|
|
49
51
|
p = path_for(name)
|
|
50
|
-
if p.exists():
|
|
51
|
-
raise CaseError(f"case already exists: {p}")
|
|
52
52
|
case = {"crypttrace_case": FORMAT, "name": p.stem, "created": _now(), "updated": _now(),
|
|
53
|
-
"addresses": [], "notes": []}
|
|
53
|
+
"addresses": entries or [], "notes": []}
|
|
54
54
|
if note:
|
|
55
55
|
case["notes"].append({"at": _now(), "text": note})
|
|
56
|
-
|
|
56
|
+
data = json.dumps(case, indent=2, ensure_ascii=False)
|
|
57
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
58
|
+
try:
|
|
59
|
+
stream = p.open("x", encoding="utf-8")
|
|
60
|
+
except FileExistsError:
|
|
61
|
+
raise CaseError(f"case already exists: {p.name}")
|
|
62
|
+
try:
|
|
63
|
+
with stream:
|
|
64
|
+
stream.write(data)
|
|
65
|
+
except OSError:
|
|
66
|
+
p.unlink(missing_ok=True)
|
|
67
|
+
raise
|
|
57
68
|
return p
|
|
58
69
|
|
|
59
70
|
|
|
@@ -94,23 +105,45 @@ def all_cases() -> List[dict]:
|
|
|
94
105
|
return out
|
|
95
106
|
|
|
96
107
|
|
|
97
|
-
def
|
|
108
|
+
def _address_entry(address: str, chain: str, role: str, note: str) -> dict:
|
|
98
109
|
chains.check(chain)
|
|
99
110
|
if role not in ROLES:
|
|
100
111
|
raise CaseError(f"role must be one of: {', '.join(ROLES)}")
|
|
101
112
|
ok, why = addresses.validate(address, chain)
|
|
102
113
|
if not ok:
|
|
103
114
|
raise CaseError(f"not a valid {chain} address: {why}")
|
|
104
|
-
case = load(name)
|
|
105
115
|
key = chains.norm_addr(address, chain)
|
|
116
|
+
return {"address": key, "chain": chain, "role": role, "note": note, "added": _now(), "snapshot": None}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def new_from_wallets(name: str, chain: str, wallets: List[str]) -> Path:
|
|
120
|
+
"""Create one named library case after validating all pasted wallets."""
|
|
121
|
+
if (not re.fullmatch(r"[\w-][\w.-]{0,63}", name) or name.endswith(".")
|
|
122
|
+
or name.lower().endswith(".json") or Path(name + ".json").is_reserved()):
|
|
123
|
+
raise CaseError("Use a case name of up to 64 letters, digits, dots, underscores or hyphens, without a file extension or path.")
|
|
124
|
+
chains.check(chain)
|
|
125
|
+
entries = {}
|
|
126
|
+
for i, wallet in enumerate(wallets, 1):
|
|
127
|
+
try:
|
|
128
|
+
entry = _address_entry(wallet.strip(), chain, "other", "")
|
|
129
|
+
except CaseError as e:
|
|
130
|
+
raise CaseError(f"Address {i}: {e}") from e
|
|
131
|
+
entries[entry["address"]] = entry
|
|
132
|
+
if len(entries) < 2:
|
|
133
|
+
raise CaseError("Enter at least two distinct wallet addresses.")
|
|
134
|
+
return new(str(CASES_DIR / (name + ".json")), entries=list(entries.values()))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def add(name: str, address: str, chain: str, role: str = "other", note: str = "") -> dict:
|
|
138
|
+
entry = _address_entry(address, chain, role, note)
|
|
139
|
+
case = load(name)
|
|
106
140
|
for a in case["addresses"]:
|
|
107
|
-
if a["chain"] == chain and a["address"] ==
|
|
141
|
+
if a["chain"] == chain and a["address"] == entry["address"]:
|
|
108
142
|
a["role"] = role # adding it again updates it
|
|
109
143
|
if note:
|
|
110
144
|
a["note"] = note
|
|
111
145
|
save(case)
|
|
112
146
|
return a
|
|
113
|
-
entry = {"address": key, "chain": chain, "role": role, "note": note, "added": _now(), "snapshot": None}
|
|
114
147
|
case["addresses"].append(entry)
|
|
115
148
|
save(case)
|
|
116
149
|
return entry
|
|
@@ -136,6 +169,49 @@ def note(name: str, text: str) -> dict:
|
|
|
136
169
|
return entry
|
|
137
170
|
|
|
138
171
|
|
|
172
|
+
def common_recipients(name: str, chain: str, limit: int = 200) -> dict:
|
|
173
|
+
"""Compare recent outgoing transfers from distinct case addresses on one chain."""
|
|
174
|
+
chains.check(chain)
|
|
175
|
+
sources = sorted({chains.norm_addr(a["address"], chain) for a in load(name)["addresses"]
|
|
176
|
+
if a["chain"] == chain})
|
|
177
|
+
if len(sources) < 2:
|
|
178
|
+
raise CaseError(f"The case needs at least two addresses on {chain}.")
|
|
179
|
+
|
|
180
|
+
recipients = defaultdict(lambda: defaultdict(list))
|
|
181
|
+
warnings = []
|
|
182
|
+
if chains.is_utxo(chain):
|
|
183
|
+
warnings.append("UTXO amounts are proportional input shares. Multiple senders can "
|
|
184
|
+
"belong to one transaction, and an output can be change.")
|
|
185
|
+
for source in sources:
|
|
186
|
+
for asset in ([None] if chains.is_utxo(chain) else [None, _ALL_TOKENS]):
|
|
187
|
+
try:
|
|
188
|
+
rows = chains.transfers(source, chain, limit, asset=asset)
|
|
189
|
+
except chains.ChainError as e:
|
|
190
|
+
warnings.append(f"{source} ({'tokens' if asset else 'native'}): {e}")
|
|
191
|
+
continue
|
|
192
|
+
for row in rows[:limit]:
|
|
193
|
+
recipient = chains.norm_addr(row.get("to") or "", chain)
|
|
194
|
+
if (chains.norm_addr(row.get("from") or "", chain) != source or not recipient
|
|
195
|
+
or recipient == source or row["value"] <= 0 or not row.get("hash")):
|
|
196
|
+
continue
|
|
197
|
+
recipients[recipient][source].append({
|
|
198
|
+
**row, "from": source, "url": chains.tx_url(row["hash"], chain)})
|
|
199
|
+
|
|
200
|
+
matches = []
|
|
201
|
+
for recipient, senders in recipients.items():
|
|
202
|
+
if len(senders) < 2:
|
|
203
|
+
continue
|
|
204
|
+
transfers = sorted((row for rows in senders.values() for row in rows),
|
|
205
|
+
key=lambda row: (row["timestamp"], row["from"], row["hash"]))
|
|
206
|
+
tag = labels.lookup(recipient) or {}
|
|
207
|
+
if tag.get("chain") and tag["chain"] != chain:
|
|
208
|
+
tag = {}
|
|
209
|
+
matches.append({"address": recipient, "senders": len(senders), "label": tag.get("name", ""),
|
|
210
|
+
"type": tag.get("type", "unknown"), "transfers": transfers})
|
|
211
|
+
matches.sort(key=lambda match: (-match["senders"], match["address"]))
|
|
212
|
+
return {"matches": matches, "warnings": warnings}
|
|
213
|
+
|
|
214
|
+
|
|
139
215
|
def snapshot(address: str, chain: str) -> dict:
|
|
140
216
|
"""Native balance and the time of the latest transfer, read fresh."""
|
|
141
217
|
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)
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
header .tag{color:var(--dim);font-size:13px}
|
|
45
45
|
|
|
46
46
|
.bar{position:relative;z-index:2;display:flex;gap:10px;flex-wrap:wrap;align-items:center;padding:14px 22px}
|
|
47
|
-
input,select,button{
|
|
47
|
+
input,select,button,textarea{
|
|
48
48
|
color:var(--text);font-size:14px;border-radius:12px;padding:10px 13px;
|
|
49
49
|
background:var(--glass-2);border:1px solid var(--stroke);
|
|
50
50
|
backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
|
|
@@ -66,7 +66,11 @@
|
|
|
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}
|
|
71
|
+
#new-case-fields{margin:12px 0}
|
|
72
|
+
#new-case-fields label{display:block;margin:8px 0}
|
|
73
|
+
#case-wallets{display:block;width:min(100%,65ch);box-sizing:border-box;resize:vertical}
|
|
70
74
|
.tab{font-size:13px;font-weight:600;padding:8px 15px;border-radius:12px;cursor:pointer;
|
|
71
75
|
background:var(--glass-2);border:1px solid var(--stroke);color:var(--dim);
|
|
72
76
|
backdrop-filter:blur(12px);transition:.25s cubic-bezier(.22,1,.36,1)}
|
|
@@ -230,7 +234,8 @@
|
|
|
230
234
|
<button id="go">Investigate</button>
|
|
231
235
|
<button id="fit" class="ghost" title="Fit graph to view">Fit</button>
|
|
232
236
|
<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-
|
|
237
|
+
<button id="exp-gexf" class="ghost" title="Download the graph for Gephi, with its layout and colours">Gephi</button>
|
|
238
|
+
<button id="exp-graphml" class="ghost" title="Download the graph for yEd or Cytoscape">GraphML</button>
|
|
234
239
|
<button id="exp-csv" class="ghost" title="Download the graph as an edge list for Maltego, Neo4j or a spreadsheet">CSV</button>
|
|
235
240
|
</div>
|
|
236
241
|
|
|
@@ -252,6 +257,7 @@
|
|
|
252
257
|
<button class="tab" data-view="victims">Who sent funds here</button>
|
|
253
258
|
<button class="tab" data-view="poison">Poisoning</button>
|
|
254
259
|
<button class="tab" data-view="check">Was I drained?</button>
|
|
260
|
+
<button class="tab" data-view="common">Common recipients</button>
|
|
255
261
|
</div>
|
|
256
262
|
<div class="stage">
|
|
257
263
|
<div class="loader" id="loader"></div>
|
|
@@ -263,6 +269,19 @@
|
|
|
263
269
|
<div class="view" id="v-victims"></div>
|
|
264
270
|
<div class="view" id="v-poison"></div>
|
|
265
271
|
<div class="view" id="v-check"></div>
|
|
272
|
+
<div class="view" id="v-common">
|
|
273
|
+
<form id="common-form">
|
|
274
|
+
<label>Case <select id="common-case"><option value="">New case…</option></select></label>
|
|
275
|
+
<label>Network <select id="common-chain"></select></label>
|
|
276
|
+
<div id="new-case-fields">
|
|
277
|
+
<label>Case name <input id="case-name" maxlength="64" required></label>
|
|
278
|
+
<label>Wallet addresses (one per line)<textarea id="case-wallets" rows="4" required spellcheck="false"></textarea></label>
|
|
279
|
+
</div>
|
|
280
|
+
<button id="common-submit">Create case and find recipients</button>
|
|
281
|
+
</form>
|
|
282
|
+
<div id="common-results" aria-live="polite"></div>
|
|
283
|
+
<p class="muted">Searches up to 200 recent native and 200 token transfers per wallet. Shared exchange addresses may receive unrelated deposits.</p>
|
|
284
|
+
</div>
|
|
266
285
|
<div class="scaleview" id="scaleview" style="display:none">100%</div>
|
|
267
286
|
<div class="zoomctl" id="zoomctl">
|
|
268
287
|
<button id="zin" title="Zoom in">+</button>
|
|
@@ -336,8 +355,8 @@ function setStatus(t,err,busy){
|
|
|
336
355
|
}
|
|
337
356
|
function loader(p){ $('#loader').style.width=p+'%'; if(p>=100) setTimeout(()=>$('#loader').style.width='0',500); }
|
|
338
357
|
|
|
339
|
-
async function api(path){
|
|
340
|
-
const r=await fetch(path);
|
|
358
|
+
async function api(path,options){
|
|
359
|
+
const r=await fetch(path,options);
|
|
341
360
|
const raw=await r.text();
|
|
342
361
|
let j;
|
|
343
362
|
try{ j=JSON.parse(raw); }
|
|
@@ -541,6 +560,7 @@ let currentView='graph', loaded={};
|
|
|
541
560
|
|
|
542
561
|
function showView(v){
|
|
543
562
|
currentView=v;
|
|
563
|
+
$('#hint').style.display=v==='graph'?'':'none';
|
|
544
564
|
document.querySelectorAll('.tab').forEach(t=>t.classList.toggle('on',t.dataset.view===v));
|
|
545
565
|
$('#graph').style.display = v==='graph'?'block':'none';
|
|
546
566
|
$('#zoomctl').style.display = v==='graph'?'flex':'none';
|
|
@@ -550,6 +570,8 @@ function showView(v){
|
|
|
550
570
|
$('#v-victims').classList.toggle('on',v==='victims');
|
|
551
571
|
$('#v-poison').classList.toggle('on',v==='poison');
|
|
552
572
|
$('#v-check').classList.toggle('on',v==='check');
|
|
573
|
+
$('#v-common').classList.toggle('on',v==='common');
|
|
574
|
+
if(v==='common') loadCaseNames();
|
|
553
575
|
const a=$('#addr').value.trim();
|
|
554
576
|
if(a && !loaded[v+a]) {
|
|
555
577
|
loaded[v+a]=true;
|
|
@@ -562,6 +584,60 @@ function showView(v){
|
|
|
562
584
|
}
|
|
563
585
|
document.querySelectorAll('.tab').forEach(t=>t.onclick=()=>showView(t.dataset.view));
|
|
564
586
|
|
|
587
|
+
$('#common-chain').innerHTML=$('#chain').innerHTML;
|
|
588
|
+
async function loadCaseNames(){
|
|
589
|
+
const select=$('#common-case');
|
|
590
|
+
try{
|
|
591
|
+
const names=await api('/api/cases');
|
|
592
|
+
const previous=select.value;
|
|
593
|
+
for(const name of names){
|
|
594
|
+
if(!Array.from(select.options).some(option=>option.value===name)) select.add(new Option(name,name));
|
|
595
|
+
}
|
|
596
|
+
if(!select.dataset.loaded && names.length && !previous && !$('#case-name').value && !$('#case-wallets').value) select.value=names[0];
|
|
597
|
+
select.dataset.loaded='true';
|
|
598
|
+
updateCaseForm();
|
|
599
|
+
}catch(e){ $('#common-results').textContent=e.message; }
|
|
600
|
+
}
|
|
601
|
+
const commonForm=$('#common-form'), commonResults=$('#common-results');
|
|
602
|
+
function updateCaseForm(){
|
|
603
|
+
const creating=!$('#common-case').value;
|
|
604
|
+
$('#new-case-fields').hidden=!creating;
|
|
605
|
+
$('#case-name').required=$('#case-wallets').required=creating;
|
|
606
|
+
$('#common-submit').textContent=creating?'Create case and find recipients':'Find common recipients';
|
|
607
|
+
}
|
|
608
|
+
$('#common-case').onchange=updateCaseForm;
|
|
609
|
+
commonForm.onchange=()=>{commonResults.textContent='';};
|
|
610
|
+
commonForm.onsubmit=async event=>{
|
|
611
|
+
event.preventDefault();
|
|
612
|
+
let name=$('#common-case').value;
|
|
613
|
+
const network=$('#common-chain').value;
|
|
614
|
+
for(const control of commonForm.elements) control.disabled=true;
|
|
615
|
+
commonResults.textContent='Reading recent transfers…';
|
|
616
|
+
try{
|
|
617
|
+
if(!name){
|
|
618
|
+
commonResults.textContent='Saving case…';
|
|
619
|
+
const saved=await api('/api/cases',{method:'POST',headers:{'Content-Type':'application/json'},
|
|
620
|
+
body:JSON.stringify({name:$('#case-name').value,chain:network,
|
|
621
|
+
addresses:$('#case-wallets').value.trim().split(/\s+/).filter(Boolean)})});
|
|
622
|
+
name=saved.name;
|
|
623
|
+
$('#common-case').add(new Option(name,name,true,true));
|
|
624
|
+
$('#case-name').value=$('#case-wallets').value='';
|
|
625
|
+
updateCaseForm();
|
|
626
|
+
commonResults.textContent='Case saved. Reading recent transfers…';
|
|
627
|
+
}
|
|
628
|
+
const report=await api('/api/cases/'+q(name)+'/common-recipients?chain='+q(network));
|
|
629
|
+
const warnings=report.warnings.map(w=>'<p>'+esc(w)+'</p>').join('');
|
|
630
|
+
const groups=report.matches.map(m=>`<section class="card">
|
|
631
|
+
<h3>${esc(m.label || 'Recipient')} · ${esc(m.type)} · ${m.senders} senders</h3>
|
|
632
|
+
<p>${esc(m.address)}</p>${m.transfers.map(t=>`<p>${fmtTs(t.timestamp)} UTC · ${esc(t.from)}
|
|
633
|
+
· ${esc(t.value)} ${esc(t.symbol)} ${esc(t.contract || '')}
|
|
634
|
+
· <a href="${safeUrl(t.url)}" target="_blank" rel="noopener">${esc(t.hash)}</a></p>`).join('')}
|
|
635
|
+
</section>`).join('');
|
|
636
|
+
commonResults.innerHTML=warnings+(groups||'<p>No common recipients in the available transfers.</p>');
|
|
637
|
+
}catch(e){ commonResults.textContent=e.message; }
|
|
638
|
+
finally{ for(const control of commonForm.elements) control.disabled=false; }
|
|
639
|
+
};
|
|
640
|
+
|
|
565
641
|
const dstamp=t=>t?new Date(t*1000).toISOString().slice(0,16).replace('T',' '):'—';
|
|
566
642
|
async function loadTimeline(a){
|
|
567
643
|
const el=$('#v-timeline');
|
|
@@ -806,6 +882,7 @@ async function downloadGraph(fmt){
|
|
|
806
882
|
}catch(e){ setStatus(e.message,true); }
|
|
807
883
|
finally{ b.disabled=false; }
|
|
808
884
|
}
|
|
885
|
+
$('#exp-gexf').addEventListener('click',()=>downloadGraph('gexf'));
|
|
809
886
|
$('#exp-graphml').addEventListener('click',()=>downloadGraph('graphml'));
|
|
810
887
|
$('#exp-csv').addEventListener('click',()=>downloadGraph('csv'));
|
|
811
888
|
|
|
@@ -76,6 +76,39 @@ 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.post("/api/cases")
|
|
85
|
+
def api_create_case():
|
|
86
|
+
from crypttrace import case
|
|
87
|
+
data = request.get_json()
|
|
88
|
+
if not isinstance(data, dict):
|
|
89
|
+
return jsonify(error="Expected a case name, network and addresses."), 400
|
|
90
|
+
name, chain, wallets = (data.get(key) for key in ("name", "chain", "addresses"))
|
|
91
|
+
if not (isinstance(name, str) and isinstance(chain, str) and isinstance(wallets, list)
|
|
92
|
+
and all(isinstance(wallet, str) for wallet in wallets)):
|
|
93
|
+
return jsonify(error="Expected a case name, network and a list of addresses."), 400
|
|
94
|
+
try:
|
|
95
|
+
path = case.new_from_wallets(name.strip(), chain, wallets)
|
|
96
|
+
except _KNOWN_ERRORS as e:
|
|
97
|
+
return jsonify(error=str(e)), 400
|
|
98
|
+
return jsonify(name=path.stem), 201
|
|
99
|
+
|
|
100
|
+
@app.route("/api/cases/<name>/common-recipients")
|
|
101
|
+
def api_common_recipients(name):
|
|
102
|
+
from crypttrace import case
|
|
103
|
+
# Only offer files in the local case library, never a client-supplied path.
|
|
104
|
+
paths = {Path(c["path"]).stem: c["path"] for c in case.all_cases()}
|
|
105
|
+
if name not in paths:
|
|
106
|
+
return jsonify(error="Unknown case."), 404
|
|
107
|
+
try:
|
|
108
|
+
return jsonify(case.common_recipients(paths[name], request.args.get("chain", "eth")))
|
|
109
|
+
except _KNOWN_ERRORS as e:
|
|
110
|
+
return jsonify(error=str(e)), 400
|
|
111
|
+
|
|
79
112
|
@app.route("/api/assets")
|
|
80
113
|
def api_assets():
|
|
81
114
|
"""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.37.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,23 @@ 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** and select **New case…**. Choose a network,
|
|
392
|
+
name the case and paste at least two wallet addresses, one per line. **Create case and
|
|
393
|
+
find recipients** saves the case to the local case library and searches it immediately.
|
|
394
|
+
You can reopen the case in the same tab or with `crypttrace case show NAME`.
|
|
395
|
+
|
|
376
396
|
### Watch & alerts — catching the cash-out
|
|
377
397
|
|
|
378
398
|
The only window to freeze stolen funds is the moment they reach an exchange
|
|
@@ -779,7 +799,7 @@ src/crypttrace/
|
|
|
779
799
|
case.py # investigations as files: addresses, roles, notes, snapshots
|
|
780
800
|
report.py # Markdown + JSON reports
|
|
781
801
|
pdf.py # PDF page setup and font discovery (evidence packs)
|
|
782
|
-
export.py # traced graph as
|
|
802
|
+
export.py # traced graph as GEXF (Gephi), GraphML (yEd) and edge-list CSV (Maltego)
|
|
783
803
|
prices.py # USD valuation
|
|
784
804
|
render.py # rich terminal rendering
|
|
785
805
|
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
|