Repository navigation
Expand file tree
/
Copy pathcli.py
More file actions
1317 lines (1102 loc) · 55.5 KB
/
Copy pathcli.py
File metadata and controls
1317 lines (1102 loc) · 55.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
ablation.cli: command-line interface.
Usage:
ablation analyze <binary> binary summary: arch, PLT, exports, funcs
ablation search <binary> <query> semantic search across all functions
ablation taint <binary> taint trace from network sources to sinks (arch-aware)
ablation taint <binary> --interprocedural cross-function BFS taint chains
ablation taint <binary> --flow-sensitive CFG MFP + interprocedural (most precise)
ablation overflow <binary> ARM32 integer overflow scan (MUL -> malloc without check)
ablation window <binary> <va> annotated disassembly window around a VA
ablation profile <binary> <va> full function profile: strings + call args + sinks
ablation cfg <binary> <va> control-flow graph for one function (hex VA)
ablation crypto <binary> entropy scan + XOR/AES key search
ablation corpus <binary> build or rebuild the semantic function corpus
ablation sweep <binary> run all registered patterns against a binary
ablation findings list confirmed findings in ~/.ablation/findings.db
ablation driver <binary.sys> Windows kernel driver: IOCTL, callbacks, dangerous patterns
ablation byovd <binary.sys> BYOVD risk score: signed driver + IOCTL surface + dangerous primitive
ablation fmtstr <binary> format string scan: printf/syslog with non-literal format arg
ablation news show recent updates
claude.ai workflow (no Claude Code access):
Run any command above, copy the output, paste into claude.ai.
ablation analyze gives the full binary context block to start a session.
ablation window gives disassembly you can ask claude.ai to annotate.
ablation taint gives source-to-sink findings to ask about.
"""
import argparse
import sys
from pathlib import Path
_DEFAULT_DB = Path('~/.ablation/func_id.db').expanduser()
def _require_binary(path: str) -> Path:
p = Path(path)
if not p.exists():
print(f"error: file not found: {path}", file=sys.stderr)
sys.exit(1)
return p
def _build_corpus_for(binary_path: str, db: Path) -> None:
"""Ensure func_id.db contains an up-to-date corpus entry for binary_path."""
from ablation.analyzers.corpus_builder import CorpusBuilder
product = Path(binary_path).stem
cb = CorpusBuilder(db_path=str(db))
cb.build(binary_path, product=product, version='unknown', progress=False)
def cmd_analyze(args):
from ablation.analyzers.binary_context import BinaryContext
from ablation.analyzers.entropy_mapper import EntropyMapper
ctx = BinaryContext.load_or_build(str(_require_binary(args.binary)))
print(ctx.summary())
if args.entropy:
em = EntropyMapper(str(args.binary))
regions = em.scan()
print(f"\nEntropy regions ({len(regions)} found):")
for r in regions[:20]:
print(f" {r}")
def cmd_search(args):
from ablation.analyzers.semantic_search import SemanticSearcher
p = str(_require_binary(args.binary))
db = Path(args.db).expanduser()
print(f"Building corpus for {Path(p).name} ...")
_build_corpus_for(p, db)
searcher = SemanticSearcher(str(db))
n = searcher.build_corpus()
print(f"Corpus: {n} functions. Querying ...")
results = searcher.query(args.query, top_k=args.top_k)
if not results:
print("No results.")
return
print(f"\nTop {len(results)} matches for: {args.query!r}\n")
for r in results:
name = r.name or hex(r.va)
print(f" 0x{r.va:x} {name:<50s} score={r.score:.3f}")
def cmd_taint(args):
from ablation.analyzers.binary_context import BinaryContext
p = str(_require_binary(args.binary))
ctx = BinaryContext.load_or_build(p)
if ctx.arch == 'arm32':
from ablation.analyzers.taint_tracker_arm32 import ARM32TaintTracker
tracker = ARM32TaintTracker.from_context(ctx)
findings = tracker.run_interprocedural()
if not findings:
print("No taint paths found.")
return
print(tracker.report(findings))
return
from ablation.analyzers.xref_graph import XRefGraph
from ablation.analyzers.taint_tracker_x86 import TaintTracker
xg = XRefGraph.from_path(p)
xg.build()
tracker = TaintTracker(p, xref=xg)
if getattr(args, 'flow_sensitive', False):
print("[*] Running flow-sensitive CFG taint analysis (MFP + interprocedural BFS) ...")
findings, chains = tracker.run_flow_sensitive()
if not findings and not chains:
print("No taint paths found.")
return
if findings:
print(f"{len(findings)} intraprocedural finding(s):\n")
for f in findings:
print(f)
if chains:
print(f"\n{len(chains)} interprocedural chain(s):\n")
for c in chains:
print(c)
elif getattr(args, 'interprocedural', False):
depth = getattr(args, 'depth', 4)
print(f"[*] Running interprocedural taint analysis (depth={depth}) ...")
chains = tracker.run_interprocedural(depth=depth)
if not chains:
print("No taint paths found.")
return
print(f"{len(chains)} interprocedural chain(s):\n")
for c in chains:
print(c)
else:
findings = tracker.run()
if not findings:
print("No taint paths found.")
return
print(f"{len(findings)} taint finding(s):\n")
for f in findings:
print(f)
def cmd_overflow(args):
"""ARM32 integer overflow scan: MUL/UMULL with wire-controlled operands before allocation."""
from ablation.analyzers.binary_context import BinaryContext
p = str(_require_binary(args.binary))
ctx = BinaryContext.load_or_build(p)
if ctx.arch != 'arm32':
print(f"overflow scan is ARM32-only (binary arch: {ctx.arch})")
return
from ablation.analyzers.intoverflow_scanner_arm32 import ARM32IntOverflowScanner
scanner = ARM32IntOverflowScanner.from_context(ctx)
findings = scanner.scan()
print(scanner.report(findings))
def cmd_window(args):
"""Annotated disassembly window around a VA: suitable for pasting into claude.ai."""
from ablation.analyzers.window_analyzer import WindowAnalyzer
p = str(_require_binary(args.binary))
va = int(args.va, 16)
back = args.back
window = args.window
wa = WindowAnalyzer.from_path(p)
text = wa.dump_text(va=va, window=window, align_back=back, header=True)
print(text)
if args.calls:
calls = wa.calls_in_window(va=va, window=window, align_back=back)
if calls:
print(f"\nCall sites ({len(calls)}):")
for site, target, label in calls:
tag = f" -> {label}" if label else ""
print(f" 0x{site:x} -> 0x{target:x}{tag}")
if args.funcs:
starts = wa.find_func_starts(va=va, window=window, align_back=back)
if starts:
print(f"\nFunction starts ({len(starts)}):")
for s in starts:
print(f" 0x{s:x}")
def cmd_profile(args):
"""Full function profile: strings + call site args + sink flags."""
from ablation.analyzers.binary_context import BinaryContext
from ablation.analyzers.func_profiler import FuncProfiler
p = str(_require_binary(args.binary))
va = int(args.va, 16)
ctx = BinaryContext.load_or_build(p)
fp = FuncProfiler.from_context(ctx)
profile = fp.profile(va=va)
print(profile.fmt())
if profile.sink_calls:
print(f"\nSink calls ({len(profile.sink_calls)}):")
for sc in profile.sink_calls:
print(f" 0x{sc.va:x} {sc.target_name} [SINK]")
def cmd_cfg(args):
from ablation.analyzers.cfg_builder import CFGBuilder
p = str(_require_binary(args.binary))
va = int(args.va, 16)
builder = CFGBuilder(p)
cfg = builder.build_function(va)
s = cfg.stats()
print(f"CFG for 0x{va:x}: {s['blocks']} blocks, {s['edges']} edges, {s['instructions']} instructions\n")
for bb_va, bb in sorted(cfg.blocks.items()):
succs = ', '.join(f'0x{s:x}' for s in bb.succs)
print(f" 0x{bb_va:x}..0x{bb.end:x} succs=[{succs}]")
if args.insns:
for insn_va, mnem, ops in bb.insns:
print(f" 0x{insn_va:x} {mnem} {ops}")
def cmd_crypto(args):
from ablation.core.firmware_analyzer import scan_firmware_file
from ablation.core.render import (
RED, ORANGE, YELLOW, GREEN, GRAY, BOLD, DIM, RESET,
box, sbox, section,
)
p = str(_require_binary(args.binary))
result = scan_firmware_file(p)
_SEV_COLOR = {'CRITICAL': RED, 'HIGH': RED, 'MEDIUM': ORANGE, 'LOW': YELLOW}
print(box([
BOLD + f"crypto {result['filepath']}" + RESET,
DIM + (f"size: {result['size']:,} bytes "
f"entropy sections: {len(result['entropy_sections'])} "
f"signatures: {len(result['signatures'])}") + RESET,
]))
print()
findings = result['findings']
if findings:
print(section('FINDINGS', RED))
print()
for f in findings:
c = _SEV_COLOR.get(f['severity'], GRAY)
print(sbox([
c + f"[{f['severity']}] {f['category']}" + RESET,
DIM + str(f['detail']) + RESET,
], c))
print()
else:
print(GREEN + 'No findings.' + RESET)
print()
if result['entropy_sections']:
print(section('ENTROPY TRANSITIONS', GRAY))
print()
_ETYPE_COLOR = {'encrypted': RED, 'compressed': YELLOW}
for sec in result['entropy_sections']:
ec = _ETYPE_COLOR.get(sec['type'], GRAY)
print(f" {ec}{sec['type']:<14}{RESET}"
f" {DIM}offset 0x{sec['offset']:08x} "
f"entropy {sec['entropy']:.2f}{RESET}")
print()
def cmd_corpus(args):
from ablation.analyzers.corpus_builder import CorpusBuilder
p = str(_require_binary(args.binary))
db = Path(args.db).expanduser()
product = args.product or Path(p).stem
version = args.version or 'unknown'
cb = CorpusBuilder(db_path=str(db))
n = cb.build(p, product=product, version=version, progress=True)
print(f"\nCorpus built: {n} functions indexed")
print(f"DB: {db}")
if args.sigs:
from ablation.analyzers.sig_library import SigLibrary
print("\nRunning signature matching on unnamed functions ...")
lib = SigLibrary()
renamed = lib.auto_name(str(db), dry_run=False)
if renamed:
print(f"Renamed {renamed} fn_0x* functions via signature matching")
else:
print("No unnamed functions matched known signatures")
def cmd_sweep(args):
import json as _json
from ablation.analyzers.semantic_search import SemanticSearcher
from ablation.analyzers.pattern_library import PatternLibrary
p = str(_require_binary(args.binary))
db = Path(args.db).expanduser()
print(f"Building corpus for {Path(p).name} ...")
_build_corpus_for(p, db)
searcher = SemanticSearcher(str(db))
n = searcher.build_corpus()
print(f"Corpus: {n} functions. Running pattern sweep ...")
pl = PatternLibrary()
results = pl.sweep(searcher, top_k=args.top_k, min_score=args.min_score)
if args.sarif:
from ablation.export.sarif import sweep_to_sarif
doc = sweep_to_sarif(results, binary_path=p, min_score=args.min_score)
Path(args.sarif).write_text(_json.dumps(doc, indent=2))
print(f"SARIF written to {args.sarif}")
elif args.json:
from ablation.export.json_export import sweep_to_json
doc = sweep_to_json(results, binary_path=p, min_score=args.min_score)
Path(args.json).write_text(_json.dumps(doc, indent=2))
print(f"JSON written to {args.json}")
else:
print(pl.fmt_sweep(results, binary_name=Path(p).name))
def cmd_findings(args):
import json as _json
from ablation.analyzers.finding_registry import FindingRegistry
reg = FindingRegistry()
findings = reg.list_findings()
if not findings:
print("No confirmed findings recorded.")
return
if args.sarif:
from ablation.export.sarif import findings_to_sarif
doc = findings_to_sarif(findings)
Path(args.sarif).write_text(_json.dumps(doc, indent=2))
print(f"SARIF written to {args.sarif}")
return
if args.json:
from ablation.export.json_export import findings_to_json
doc = findings_to_json(findings)
Path(args.json).write_text(_json.dumps(doc, indent=2))
print(f"JSON written to {args.json}")
return
print(f"{len(findings)} finding(s):\n")
for f in findings:
print(f" [{f.get('severity','?')}] {f.get('product','')} {f.get('title','')}")
def cmd_driver(args):
from ablation.analyzers.kernel_driver_analyzer import KernelDriverAnalyzer
import json as _json2
p = _require_binary(args.binary)
kda = KernelDriverAnalyzer.from_path(str(p))
report = kda.analyze()
if report.error:
print(f"error: {report.error}", file=sys.stderr)
sys.exit(1)
if args.json:
Path(args.json).write_text(_json2.dumps(report.summary(), indent=2))
print(f"JSON written to {args.json}")
return
print(report.fmt())
def cmd_byovd(args):
from ablation.analyzers.byovd_detector import BYOVDDetector
import json as _json3
p = _require_binary(args.binary)
det = BYOVDDetector.from_path(str(p))
report = det.analyze()
if args.json:
Path(args.json).write_text(_json3.dumps(report.summary(), indent=2))
print(f"JSON written to {args.json}")
return
print(report.fmt())
_RECENT_UPDATES = """\
v3.4.0 (2026-09-30) LoongArch64 taint tracker + decoder
ablation loongarch64 <binary> [--interprocedural] [--depth N] [--full] [--json FILE]
ablation loongarch64-decode <binary> [--base N] [--frames] [--limit N] [--json FILE]
- LoongArch64TaintTracker: lp64 ABI; $a0-$a7 args, $ra caller-saved
- Sources: recv/recvfrom/read/fgets (libc) + copy_from_user/nla_get_string (kernel)
- Sinks: system/execve/strcpy/memcpy (libc) + copy_to_user/call_usermodehelper (kernel)
- Escalation (CRITICAL): commit_creds, prepare_kernel_cred
- Syscall tracking: $a7 const-folding -> 318-entry asm-generic table; source/sink/escalation
- Exception paths: ertn (no successors), break/dbcl (trap)
- from_path_full(): .eh_frame FDE + DWARF subprogram + BTF func_info
- PLT resolution: R_LARCH_JUMP_SLOT -> exact plt_va -> sym_name (no ±16 scan)
- Targets: TencentOS 4.6 server packages, Loongson 3A5000/3C5000, kernel modules
v3.3.0 (2026-09-30) nanoMIPS taint tracker
ablation nanomips-taint <binary> [--le] [--interprocedural] [--depth N] [--json FILE]
- NanoMIPSTaintTracker: O32-compatible ABI; $a0-$a3 args, $v0 return,
$t0-$t9 caller-saved; no branch delay slots
- Sources: recv/recvfrom/read/fgets/gets/fread (return value in $v0)
- Sinks: system/execve/execl/execvp/popen/strcpy/sprintf/snprintf/memcpy/strcat/bcopy
- Two paths: capstone 6.x full decode (register-level) or conservative fallback
(frame-walk BALC target extraction + conservative $a0-$a3 taint after source call)
- BALC target decode: P32 bits[31:26]=0x2a, 26-bit signed offset; P16 bits[15:10]=0b110010, 10-bit
- Return: JRC $ra (no delay slot); Call: BALC (P16/P32), JALRC (P32)
- PLT stub size: 12 bytes (3 × P32 insns); prologue: ADDIU $sp, $sp, -N
- Targets: Ingenic X-series (JZ4780, X1000, X2000), MediaTek Helio embedded,
MIPS32r6 microcontrollers
v3.2.0 (2026-09-24) Renesas V850 taint tracker + frame decoder
ablation v850 <binary> [--be] [--interprocedural] [--depth N] [--json FILE]
ablation v850-decode <binary> [--be] [--base N] [--frames] [--limit N] [--json FILE]
- V850TaintTracker: V850 EABI ABI; r6-r9 args (4 regs only), r10 return,
r20-r29 callee-saved; pure-Python (no capstone V850)
- Sources: recv/recvfrom/read/fgets/gets/fread (return value in r10)
- Sinks: system/execve/execl/execvp/popen/strcpy/sprintf/snprintf/memcpy/strcat
- V850Decoder: mixed 16/32-bit frame walker; width discriminant: op6>=0x20 -> 32-bit
- JARL disp22, lp: direct call; JMP [lp]: return
- JARL target: sign_extend_22({hw1[15:0], hw0[15:11]<<1})
- Prologue scan: PREPARE instruction (GCC V850 EABI function entry marker)
- Default little-endian (V850ES/SJ3 GCC); --be for big-endian variants
- DisasmEngine: arch='v850' routes through V850Decoder (_v850_stream)
- Targets: Renesas RH850/G3M + G3MH (automotive ECU, AUTOSAR), V850E2R (industrial),
V850E3V5 (dual-core ASIL-D), NEC V850ES/SJ3 (power systems, white goods)
v3.1.0 (2026-09-24) RISC-V 64-bit taint tracker
ablation riscv64 <binary> [--interprocedural] [--depth N] [--json FILE]
- RISCV64TaintTracker: RISC-V Linux lp64 ABI; a0-a7 args (8 regs), a0 return,
s0-s11 callee-saved; capstone CS_ARCH_RISCV + CS_MODE_RISCV64 + CS_MODE_RISCVC
- RV64-specific ops: ld/sd, addiw, addw/subw/mulw/divw/remw, sllw/srlw/sraw,
c.ld/c.ldsp/c.addiw/c.addw/c.subw
- Call/ret detection identical to RV32: jal/jalr/ret/c.jr ra
- Targets: VisionFive 2, SiFive Unmatched, Milk-V Pioneer, SpacemiT K1,
SOPHON BM1684, OpenWrt RISC-V 64, PLCT RISC-V Linux servers
v3.0.0 (2026-09-24) RISC-V 32-bit taint tracker
ablation riscv32 <binary> [--interprocedural] [--depth N] [--json FILE]
- RISCV32TaintTracker: RISC-V Linux ilp32 ABI; a0-a7 args (8 regs), a0 return,
s0-s11 callee-saved; no delay slots; capstone CS_ARCH_RISCV + CS_MODE_RISCV32 + CS_MODE_RISCVC
- Sources: recv/recvfrom/read/fgets/gets/fread (return value in a0)
- Sinks: system/execve/execl/execvp/popen/strcpy/sprintf/snprintf/memcpy/strcat
- Call detection: jal (direct, PC-rel 21-bit), jalr (indirect), c.jal/c.jalr (RVC)
- Return detection: ret (= jalr zero, 0(ra)), c.jr ra, jr ra
- Prologue scan: addi sp, sp, -N (or c.addi16sp for RVC); function-start heuristic
- DisasmEngine: arch='riscv'/'riscv32' + CS_MODE_RISCVC (compressed always on)
- Targets: SiFive/StarFive Linux SoCs, Allwinner D1, ESP32-C3, GD32VF103, VisionFive 2,
Milk-V Duo, Kendryte K210, OpenWrt RISC-V, Sipeed Maix
v2.9.0 (2026-09-25) Synopsys DesignWare ARC taint tracker + frame decoder
ablation arc <binary> [--be] [--interprocedural] [--depth N] [--json FILE]
ablation arc-decode <binary> [--be] [--base N] [--frames] [--limit N] [--json FILE]
- ARCTaintTracker: ARC Linux ABI; r0-r7 args (8 regs), r0 return,
r13-r25 callee-saved; no delay slots; pure-Python (no capstone ARC)
- Sources: recv/recvfrom/read/fgets/gets/fread (return value in r0)
- Sinks: system/execve/execl/execvp/popen/strcpy/sprintf/snprintf/memcpy/strcat
- ARCDecoder: mixed 16/32-bit frame walker; discriminant: (hw0>>11)&0x1f >= 0x18 -> 16-bit
- BL detection: (hw0 & 0xFE00) == 0x2200 (op5=4, unconditional, link bit set)
- J[blink] return: (hw0 & 0xFE00)==0x3800 + (hw1 & 0x003F)==0x001F
- Prologue scan: push_s blink (compact 16-bit) or op5=0x18 heuristic
- Default little-endian (Linux ARC HS); --be for ARC 600/700 big-endian targets
- DisasmEngine: arch='arc'/'arc32' routes through ARCDecoder (_arc_stream)
- Targets: ARC EM/HS (IoT MCU, smart TV, storage), ARC 770D, automotive SoCs
v2.8.0 (2026-09-24) PowerPC 64-bit taint tracker
ablation ppc64 <binary> [--le] [--interprocedural] [--depth N] [--json FILE]
- PPC64TaintTracker: ELFv2 (OpenPOWER Linux) and ELFv1 (AIX/old Linux PPC64)
ABI; r3-r10 args (8 regs), r3 return, r14-r31 callee-saved; no delay slots
- Sources: recv/recvfrom/read/fgets/gets/fread (return value in r3)
- Sinks: system/execve/execl/execvp/popen/strcpy/sprintf/snprintf/memcpy/strcat
- 64-bit ops: LD/STD/STDU/MULLD/DIVD/DIVDU/SLD/SRD/RLDICL/RLDICR/EXTSW
- Prologue scan: stdu r1, -N(r1) for function-start discovery without symbols
- Interprocedural BFS: follows tainted args r3-r10 through direct bl callees
- Big-endian (IBM POWER/AIX, old OpenPOWER, Apple G5, Juniper MX/PTX)
- Little-endian: POWER8+ OpenPOWER Linux
- DisasmEngine: ppc64 arch stdu prologue detection added
v2.7.0 (2026-09-24) PowerPC 32-bit taint tracker
ablation ppc32 <binary> [--le] [--interprocedural] [--depth N] [--json FILE]
- PPC32TaintTracker: System V / EABI ABI; r3-r10 args (8 regs), r3 return,
r13-r31 callee-saved; no branch delay slots
- Sources: recv/recvfrom/read/fgets/gets/fread (return value in r3)
- Sinks: system/execve/execl/execvp/popen/strcpy/sprintf/snprintf/memcpy/strcat
- Call detection: bl (direct), bctrl (indirect via CTR for PLT stubs)
- Return detection: blr/blrl
- Prologue scan: stwu r1, -N(r1) for function-start discovery without symbols
- Interprocedural BFS: follows tainted args r3-r10 through direct bl callees
- Big-endian (Cisco IOS 7200/3700, MikroTik RB600, VxWorks)
- Little-endian: POWER LE Linux userspace
- DisasmEngine: arch='ppc'/'ppc32'/'ppc64' + endian kwarg;
_is_prologue stwu detection; stream() PPC branch/call/ret classification
v2.6.0 (2026-09-24) MIPS 32+nM and MIPS 64 support
ablation mips64 <binary> [--le] [--json FILE]
ablation nanomips <binary> [--le] [--json FILE]
- MIPS64TaintTracker: N64 ABI; 8 arg regs ($a0-$a3 + $t0-$t3 for $8-$11);
64-bit ops LD/SD/DADDU/DADDIU/DMULT; delay-slot aware; interprocedural BFS
big-endian (Cisco IOS/OCTEON) and little-endian (RouterOS 64)
- NanoMIPSDecoder: variable-length frame walker P16/P32/P48 (16/32/48-bit);
full decode with capstone 6.x; branch-hint fallback on capstone 5.x;
function-start prologue heuristic; Ingenic SoC and MediaTek embedded
- DisasmEngine: arch='mips32'/'mips64'/'mips32r6'/'nanomips' + endian kwarg;
MIPS prologue detection (addiu/daddiu $sp,$sp,-N); MIPS stream() classification
v2.5.0 (2026-09-24) HeapUAFScanner, MIPS32FuncProfiler, ByovdDetector aliases
v2.4.0 (2026-09-24) MIPS32 taint tracker + cross-binary taint + IOCTL surface
ablation mips <binary> [--le]
ablation ioctl-surface <driver.sys>
- MIPS32TaintTracker: O32 ABI; $a0-$a3 args, $v0 return; caller/callee-saved model
- Sources: recv/recvfrom/read/fgets/gets/fread
- Sinks: system/execve/execl/execvp/popen/strcpy/sprintf/memcpy/strcat/snprintf
- Load-delay slot aware (delay slot instruction executes before branch takes effect)
- Big-endian (RouterOS, Broadcom) and little-endian (embedded CPE) support
- Intraprocedural + interprocedural BFS up to depth 4
- CrossBinaryTaintTracker: follows taint across library boundaries via LibGraph;
seeds tainted return values at each export crossing
- IoctlAttackSurface: per-IOCTL handler attack surface report; pairs CTL_CODE
decode with METHOD_NEITHER flag and handler disassembly window
v2.3.0 (2026-09-24) Heap vulnerability scanner
ablation heap <binary>
- INT_OVERFLOW_BEFORE_ALLOC: IMUL/MUL/SHL result to malloc without overflow check
(TAOSSA Ch6 L6-2 width*height pattern, L6-3 nresp*sizeof pattern)
- USE_AFTER_FREE: free(ptr) then dereference of same register in same function
- DOUBLE_FREE: same register freed twice without intervening reassignment
- OFF_BY_ONE_ALLOC: strlen result to malloc without +1 for NUL terminator
v2.2.0 (2026-09-24) BYOVD detector
ablation byovd <file.sys>
- Wraps KernelDriverAnalyzer with BYOVD-specific scoring (0-100)
- 8 attack paths: PHYS_MEM_ARBITRARY_RW, MDL_KERNEL_WRITE,
MSR_LSTAR_MANIPULATION, SSDT_HOOK, TOKEN_STEALING_LPE, SMEP_BYPASS,
APC_KERNEL_INJECTION, VIRTUAL_MEM_WRITE
- Signed driver + METHOD_NEITHER IOCTL + dangerous primitive = BYOVD_CONFIRMED
- Grounded in PRE ch3 IRP walk-through: MmMapIoSpace, MapMdl sequence,
KeServiceDescriptorTable SSDT hook, MSR_LSTAR read/write
v2.1.0 (2026-09-24) Format string vulnerability scanner
ablation fmtstr <binary>
- Scans x86-64 ELF for printf/fprintf/syslog/err/warn family calls
where the format argument is not a string literal
- 28 format string sinks: printf, fprintf, sprintf, snprintf, syslog,
err, errx, warn, warnx, wprintf, fwprintf, vsnprintf, and variants
- Static backward trace from each call site: LEA [rip+offset] into
.rodata = SAFE; MOV from stack slot or arg register = VULNERABLE
- Two-hop detection: vsnprintf output buffer reused as syslog format arg
- Verdicts: VULNERABLE / SUSPICIOUS / SAFE with write instruction context
v2.0.0 (2026-09-24) Windows kernel driver RE
ablation driver <file.sys>
- IRP/IOCTL dispatch extraction (capstone DriverEntry disassembly)
- CTL_CODE decoder; METHOD_NEITHER (raw user pointer) flagged
- 40+ kernel API risk classifications across 12 classes
- 20+ callback registrations (edr_like / rootkit_risk / info)
- Pool tag extraction from MOV R8D byte pattern
- Dangerous patterns: CR0/CR4 sequences, MSR_LSTAR read/write,
L"KeServiceDescriptorTable" wide-string scan, RDMSR/WRMSR,
CLI/STI/HLT, SWAPGS, IRETQ, I/O ports
- WDM / KMDF / minifilter classification; PDB path; Authenticode
v1.9.1 (2026-09-24) see CHANGELOG.md for earlier entries
"""
def cmd_fmtstr(args):
from ablation.analyzers.format_string_scanner import FormatStringScanner
p = str(_require_binary(args.binary))
scanner = FormatStringScanner.from_path(p)
findings = scanner.scan()
if args.json:
import json
out = [f.as_dict() for f in findings if f.verdict != 'SAFE']
with open(args.json, 'w') as fh:
json.dump(out, fh, indent=2)
print(f"Wrote {len(out)} findings to {args.json}")
else:
non_safe = [f for f in findings if f.verdict != 'SAFE']
print(scanner.report(non_safe))
def cmd_heap(args):
from ablation.analyzers.heap_vuln_scanner import HeapVulnScanner
p = str(_require_binary(args.binary))
scanner = HeapVulnScanner.from_path(p)
findings = scanner.scan()
if args.json:
import json
data = [
{
'kind': f.kind, 'func_va': hex(f.func_va), 'site_va': hex(f.site_va),
'severity': f.severity, 'description': f.description,
'alloc_sym': f.alloc_sym, 'freed_at': hex(f.freed_at) if f.freed_at else '',
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(scanner.report(findings))
def cmd_mips(args):
from ablation.analyzers.taint_tracker_mips import MIPS32TaintTracker
p = str(_require_binary(args.binary))
be = not args.le
tracker = MIPS32TaintTracker.from_path(p, big_endian=be)
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va), 'sink_va': hex(f.sink_va),
'sink': f.sink, 'severity': f.severity, 'description': f.description,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_mips64(args):
from ablation.analyzers.taint_tracker_mips64 import MIPS64TaintTracker
p = str(_require_binary(args.binary))
endian = 'little' if args.le else 'big'
tracker = MIPS64TaintTracker.from_path(p, endian=endian)
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va), 'func_name': f.func_name,
'sink_va': hex(f.sink_va), 'sink_name': f.sink_name,
'tainted_args': f.tainted_args, 'source': f.source_name,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_nanomips(args):
from ablation.analyzers.nanomips_decoder import NanoMIPSDisasm
binary_path = _require_binary(args.binary)
data = binary_path.read_bytes()
endian = 'little' if args.le else 'big'
dis = NanoMIPSDisasm(endian=endian)
if args.frames:
print(dis.report_frames(data, base_addr=args.base, limit=args.limit))
return
starts = dis.find_function_starts(data, base_addr=args.base)
if args.json:
import json
out = [{'func_va': hex(va)} for va in starts]
Path(args.json).write_text(json.dumps(out, indent=2))
print(f"Wrote {len(out)} function starts to {args.json}")
else:
print(f"nanoMIPS function starts ({len(starts)} found, base={hex(args.base)}):")
for va in starts:
print(f" {hex(va)}")
if not dis.has_full_decode:
print("\nNote: install capstone 6.x for full nanoMIPS decode.")
def cmd_nanomips_taint(args):
from ablation.analyzers.taint_tracker_nanomips import NanoMIPSTaintTracker
p = str(_require_binary(args.binary))
endian = 'little' if args.le else 'big'
tracker = NanoMIPSTaintTracker.from_path(p, endian=endian)
if not tracker.has_full_decode:
print("Note: capstone 6.x not available; using conservative fallback decode.")
print(" Install capstone 6.x for register-level precision.\n")
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va) if hasattr(f, 'func_va') else hex(f.func_chain[0]),
'sink_va': hex(f.sink_va),
'sink_name': f.sink_name,
'tainted_args': f.tainted_args,
'source': f.source_name,
'full_decode': f.full_decode,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_arc(args):
from ablation.analyzers.taint_tracker_arc import ARCTaintTracker
p = str(_require_binary(args.binary))
endian = 'big' if args.be else 'little'
tracker = ARCTaintTracker.from_path(p, endian=endian)
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va), 'func_name': f.func_name,
'sink_va': hex(f.sink_va), 'sink_name': f.sink_name,
'tainted_args': f.tainted_args, 'source': f.source_name,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_arc_decode(args):
from ablation.analyzers.arc_decoder import ARCDisasm
binary_path = _require_binary(args.binary)
data = binary_path.read_bytes()
endian = 'big' if args.be else 'little'
dis = ARCDisasm(endian=endian)
if args.frames:
print(dis.report_frames(data, base_addr=args.base, limit=args.limit))
return
starts = dis.find_function_starts(data, base_addr=args.base)
if args.json:
import json
out = [{'func_va': hex(va)} for va in starts]
Path(args.json).write_text(json.dumps(out, indent=2))
print(f"Wrote {len(out)} function starts to {args.json}")
else:
print(f"ARC function starts ({len(starts)} found, base={hex(args.base)}):")
for va in starts:
print(f" {hex(va)}")
def cmd_riscv64(args):
from ablation.analyzers.taint_tracker_riscv64 import RISCV64TaintTracker
p = str(_require_binary(args.binary))
tracker = RISCV64TaintTracker.from_path(p)
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va), 'func_name': f.func_name,
'sink_va': hex(f.sink_va), 'sink_name': f.sink_name,
'tainted_args': f.tainted_args, 'source': f.source_name,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_riscv32(args):
from ablation.analyzers.taint_tracker_riscv32 import RISCV32TaintTracker
p = str(_require_binary(args.binary))
tracker = RISCV32TaintTracker.from_path(p)
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va), 'func_name': f.func_name,
'sink_va': hex(f.sink_va), 'sink_name': f.sink_name,
'tainted_args': f.tainted_args, 'source': f.source_name,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_ppc64(args):
from ablation.analyzers.taint_tracker_ppc64 import PPC64TaintTracker
p = str(_require_binary(args.binary))
endian = 'little' if args.le else 'big'
tracker = PPC64TaintTracker.from_path(p, endian=endian)
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va), 'func_name': f.func_name,
'sink_va': hex(f.sink_va), 'sink_name': f.sink_name,
'tainted_args': f.tainted_args, 'source': f.source_name,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_ppc32(args):
from ablation.analyzers.taint_tracker_ppc32 import PPC32TaintTracker
p = str(_require_binary(args.binary))
endian = 'little' if args.le else 'big'
tracker = PPC32TaintTracker.from_path(p, endian=endian)
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va), 'func_name': f.func_name,
'sink_va': hex(f.sink_va), 'sink_name': f.sink_name,
'tainted_args': f.tainted_args, 'source': f.source_name,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_v850(args):
from ablation.analyzers.taint_tracker_v850 import V850TaintTracker
p = str(_require_binary(args.binary))
endian = 'big' if args.be else 'little'
tracker = V850TaintTracker.from_path(p)
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va), 'func_name': f.func_name,
'sink_va': hex(f.sink_va), 'sink_name': f.sink_name,
'tainted_args': f.tainted_args, 'source': f.source_name,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_v850_decode(args):
from ablation.analyzers.v850_decoder import V850Disasm
binary_path = _require_binary(args.binary)
data = binary_path.read_bytes()
endian = 'big' if args.be else 'little'
dis = V850Disasm(endian=endian)
if args.frames:
print(dis.report_frames(data, base_addr=args.base, limit=args.limit))
return
starts = dis.find_function_starts(data, base_addr=args.base)
if args.json:
import json
out = [{'func_va': hex(va)} for va in starts]
Path(args.json).write_text(json.dumps(out, indent=2))
print(f"Wrote {len(out)} function starts to {args.json}")
else:
print(f"V850 function starts ({len(starts)} found, base={hex(args.base)}):")
for va in starts:
print(f" {hex(va)}")
def cmd_loongarch64(args):
from ablation.analyzers.taint_tracker_loongarch64 import LoongArch64TaintTracker
p = str(_require_binary(args.binary))
if args.full:
tracker = LoongArch64TaintTracker.from_path_full(p)
else:
tracker = LoongArch64TaintTracker.from_path(p)
if args.interprocedural:
findings = tracker.run_interprocedural(depth=args.depth)
else:
findings = tracker.run()
if args.json:
import json
data = [
{
'func_va': hex(f.func_va),
'func_name': f.func_name,
'sink_va': hex(f.sink_va),
'sink_name': f.sink_name,
'tainted_args': f.tainted_args,
'source': f.source_name,
'severity': f.severity,
}
for f in findings
]
Path(args.json).write_text(json.dumps(data, indent=2))
print(f"Wrote {len(data)} findings to {args.json}")
else:
print(tracker.report(findings))
def cmd_loongarch64_decode(args):
from ablation.analyzers.loongarch_decoder import LoongArchDecoder
binary_path = _require_binary(args.binary)
data = binary_path.read_bytes()
dec = LoongArchDecoder()
if args.frames:
frames = list(dec.decode_frames(data, base_addr=args.base))
if args.limit:
frames = frames[:args.limit]
if args.json:
import json
out = [
{
'va': hex(f.va), 'mnemonic': f.mnemonic, 'op_str': f.op_str,
'is_branch': f.is_branch, 'is_call': f.is_call,
'is_ret': f.is_ret, 'target': hex(f.target) if f.target else None,
}
for f in frames
]
Path(args.json).write_text(json.dumps(out, indent=2))
print(f"Wrote {len(out)} frames to {args.json}")