tmap-agents 0.1.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.
Files changed (142) hide show
  1. tmap_agents-0.1.0/LICENSE +202 -0
  2. tmap_agents-0.1.0/NOTICE +22 -0
  3. tmap_agents-0.1.0/PKG-INFO +356 -0
  4. tmap_agents-0.1.0/README.md +325 -0
  5. tmap_agents-0.1.0/pyproject.toml +90 -0
  6. tmap_agents-0.1.0/setup.cfg +4 -0
  7. tmap_agents-0.1.0/src/tmap_agents.egg-info/PKG-INFO +356 -0
  8. tmap_agents-0.1.0/src/tmap_agents.egg-info/SOURCES.txt +140 -0
  9. tmap_agents-0.1.0/src/tmap_agents.egg-info/dependency_links.txt +1 -0
  10. tmap_agents-0.1.0/src/tmap_agents.egg-info/entry_points.txt +2 -0
  11. tmap_agents-0.1.0/src/tmap_agents.egg-info/requires.txt +12 -0
  12. tmap_agents-0.1.0/src/tmap_agents.egg-info/top_level.txt +1 -0
  13. tmap_agents-0.1.0/src/treasure_map/__init__.py +6 -0
  14. tmap_agents-0.1.0/src/treasure_map/_build_info.py +1 -0
  15. tmap_agents-0.1.0/src/treasure_map/cli/__init__.py +2 -0
  16. tmap_agents-0.1.0/src/treasure_map/cli/analyze_cli.py +249 -0
  17. tmap_agents-0.1.0/src/treasure_map/cli/doctor_cli.py +18 -0
  18. tmap_agents-0.1.0/src/treasure_map/cli/exploit_cli.py +133 -0
  19. tmap_agents-0.1.0/src/treasure_map/cli/hunt_cli.py +2709 -0
  20. tmap_agents-0.1.0/src/treasure_map/cli/init_cli.py +260 -0
  21. tmap_agents-0.1.0/src/treasure_map/cli/interrupts.py +87 -0
  22. tmap_agents-0.1.0/src/treasure_map/cli/main.py +156 -0
  23. tmap_agents-0.1.0/src/treasure_map/cli/mcp_cli.py +242 -0
  24. tmap_agents-0.1.0/src/treasure_map/cli/uninstall_cli.py +139 -0
  25. tmap_agents-0.1.0/src/treasure_map/cli/update_cli.py +91 -0
  26. tmap_agents-0.1.0/src/treasure_map/lib/__init__.py +0 -0
  27. tmap_agents-0.1.0/src/treasure_map/lib/analyze/__init__.py +0 -0
  28. tmap_agents-0.1.0/src/treasure_map/lib/analyze/db_ingest.py +305 -0
  29. tmap_agents-0.1.0/src/treasure_map/lib/analyze/elf_exports.py +73 -0
  30. tmap_agents-0.1.0/src/treasure_map/lib/analyze/elf_inventory.py +226 -0
  31. tmap_agents-0.1.0/src/treasure_map/lib/analyze/fs_names.py +21 -0
  32. tmap_agents-0.1.0/src/treasure_map/lib/analyze/ghidra/ExportFunctions.java +2908 -0
  33. tmap_agents-0.1.0/src/treasure_map/lib/analyze/ghidra/extractor_names.tsv +122 -0
  34. tmap_agents-0.1.0/src/treasure_map/lib/analyze/ghidra_ingest.py +628 -0
  35. tmap_agents-0.1.0/src/treasure_map/lib/analyze/ghidra_runner.py +1005 -0
  36. tmap_agents-0.1.0/src/treasure_map/lib/analyze/non_binary/__init__.py +49 -0
  37. tmap_agents-0.1.0/src/treasure_map/lib/analyze/non_binary/config_file.py +137 -0
  38. tmap_agents-0.1.0/src/treasure_map/lib/analyze/non_binary/credential.py +191 -0
  39. tmap_agents-0.1.0/src/treasure_map/lib/analyze/non_binary/framework.py +46 -0
  40. tmap_agents-0.1.0/src/treasure_map/lib/analyze/non_binary/orchestrator.py +188 -0
  41. tmap_agents-0.1.0/src/treasure_map/lib/analyze/non_binary/shell_script.py +143 -0
  42. tmap_agents-0.1.0/src/treasure_map/lib/analyze/non_binary/web_asset.py +223 -0
  43. tmap_agents-0.1.0/src/treasure_map/lib/analyze/pipeline.py +289 -0
  44. tmap_agents-0.1.0/src/treasure_map/lib/analyze/stub_resolve.py +287 -0
  45. tmap_agents-0.1.0/src/treasure_map/lib/analyze/symlinks.py +226 -0
  46. tmap_agents-0.1.0/src/treasure_map/lib/analyze/xrefs.py +648 -0
  47. tmap_agents-0.1.0/src/treasure_map/lib/atlas/__init__.py +40 -0
  48. tmap_agents-0.1.0/src/treasure_map/lib/atlas/connection.py +471 -0
  49. tmap_agents-0.1.0/src/treasure_map/lib/atlas/models.py +508 -0
  50. tmap_agents-0.1.0/src/treasure_map/lib/atlas/writer.py +1132 -0
  51. tmap_agents-0.1.0/src/treasure_map/lib/audit/__init__.py +0 -0
  52. tmap_agents-0.1.0/src/treasure_map/lib/binary_id.py +124 -0
  53. tmap_agents-0.1.0/src/treasure_map/lib/callsite_ref.py +93 -0
  54. tmap_agents-0.1.0/src/treasure_map/lib/config/__init__.py +21 -0
  55. tmap_agents-0.1.0/src/treasure_map/lib/config/config.py +260 -0
  56. tmap_agents-0.1.0/src/treasure_map/lib/diff/__init__.py +14 -0
  57. tmap_agents-0.1.0/src/treasure_map/lib/diff/binexport2.py +175 -0
  58. tmap_agents-0.1.0/src/treasure_map/lib/diff/callsite_facts.py +341 -0
  59. tmap_agents-0.1.0/src/treasure_map/lib/diff/code_version.py +234 -0
  60. tmap_agents-0.1.0/src/treasure_map/lib/diff/currency.py +244 -0
  61. tmap_agents-0.1.0/src/treasure_map/lib/diff/driver.py +2044 -0
  62. tmap_agents-0.1.0/src/treasure_map/lib/diff/export_report.py +141 -0
  63. tmap_agents-0.1.0/src/treasure_map/lib/diff/ghidra/ExportBinExport.java +237 -0
  64. tmap_agents-0.1.0/src/treasure_map/lib/diff/ghidra/FallbackBinExport2Builder.java +1305 -0
  65. tmap_agents-0.1.0/src/treasure_map/lib/diff/layer0.py +735 -0
  66. tmap_agents-0.1.0/src/treasure_map/lib/diff/layer2.py +709 -0
  67. tmap_agents-0.1.0/src/treasure_map/lib/diff/loader.py +90 -0
  68. tmap_agents-0.1.0/src/treasure_map/lib/diff/toolchain.py +228 -0
  69. tmap_agents-0.1.0/src/treasure_map/lib/errors.py +23 -0
  70. tmap_agents-0.1.0/src/treasure_map/lib/facts.py +1659 -0
  71. tmap_agents-0.1.0/src/treasure_map/lib/fmt_spec.py +88 -0
  72. tmap_agents-0.1.0/src/treasure_map/lib/hunt/__init__.py +19 -0
  73. tmap_agents-0.1.0/src/treasure_map/lib/hunt/analyzer2.py +2027 -0
  74. tmap_agents-0.1.0/src/treasure_map/lib/hunt/bridge.py +191 -0
  75. tmap_agents-0.1.0/src/treasure_map/lib/hunt/downweight.py +461 -0
  76. tmap_agents-0.1.0/src/treasure_map/lib/hunt/evidence.py +592 -0
  77. tmap_agents-0.1.0/src/treasure_map/lib/hunt/exec_edges.py +714 -0
  78. tmap_agents-0.1.0/src/treasure_map/lib/hunt/facts.py +257 -0
  79. tmap_agents-0.1.0/src/treasure_map/lib/hunt/fmt_provenance.py +191 -0
  80. tmap_agents-0.1.0/src/treasure_map/lib/hunt/refs.py +166 -0
  81. tmap_agents-0.1.0/src/treasure_map/lib/hunt/wrapper_propagation.py +203 -0
  82. tmap_agents-0.1.0/src/treasure_map/lib/last_run.py +77 -0
  83. tmap_agents-0.1.0/src/treasure_map/lib/machine.py +227 -0
  84. tmap_agents-0.1.0/src/treasure_map/lib/notice.py +20 -0
  85. tmap_agents-0.1.0/src/treasure_map/lib/overlay.py +868 -0
  86. tmap_agents-0.1.0/src/treasure_map/lib/pattern/__init__.py +16 -0
  87. tmap_agents-0.1.0/src/treasure_map/lib/pattern/classes.py +638 -0
  88. tmap_agents-0.1.0/src/treasure_map/lib/pattern/extractor_names.py +225 -0
  89. tmap_agents-0.1.0/src/treasure_map/lib/pattern/fingerprint.py +31 -0
  90. tmap_agents-0.1.0/src/treasure_map/lib/pattern/models.py +93 -0
  91. tmap_agents-0.1.0/src/treasure_map/lib/pattern/scanner.py +189 -0
  92. tmap_agents-0.1.0/src/treasure_map/lib/pattern/shapes.py +449 -0
  93. tmap_agents-0.1.0/src/treasure_map/lib/query/__init__.py +128 -0
  94. tmap_agents-0.1.0/src/treasure_map/lib/query/coverage.py +269 -0
  95. tmap_agents-0.1.0/src/treasure_map/lib/query/diff_align.py +1107 -0
  96. tmap_agents-0.1.0/src/treasure_map/lib/query/diff_annotations.py +462 -0
  97. tmap_agents-0.1.0/src/treasure_map/lib/query/diff_review.py +546 -0
  98. tmap_agents-0.1.0/src/treasure_map/lib/query/exec_edges.py +263 -0
  99. tmap_agents-0.1.0/src/treasure_map/lib/query/exploit_ledger.py +77 -0
  100. tmap_agents-0.1.0/src/treasure_map/lib/query/nvram.py +507 -0
  101. tmap_agents-0.1.0/src/treasure_map/lib/query/overlay_view.py +86 -0
  102. tmap_agents-0.1.0/src/treasure_map/lib/query/patch_view.py +2525 -0
  103. tmap_agents-0.1.0/src/treasure_map/lib/query/runs.py +235 -0
  104. tmap_agents-0.1.0/src/treasure_map/lib/query/sameness.py +749 -0
  105. tmap_agents-0.1.0/src/treasure_map/lib/query/sink_impact.py +127 -0
  106. tmap_agents-0.1.0/src/treasure_map/lib/query/sink_overlay.py +1716 -0
  107. tmap_agents-0.1.0/src/treasure_map/lib/query/string_edges.py +200 -0
  108. tmap_agents-0.1.0/src/treasure_map/lib/query/triage.py +3432 -0
  109. tmap_agents-0.1.0/src/treasure_map/lib/query/views.py +98 -0
  110. tmap_agents-0.1.0/src/treasure_map/lib/reachability/__init__.py +16 -0
  111. tmap_agents-0.1.0/src/treasure_map/lib/reachability/copy_size.py +412 -0
  112. tmap_agents-0.1.0/src/treasure_map/lib/reachability/filters.py +101 -0
  113. tmap_agents-0.1.0/src/treasure_map/lib/reachability/grader.py +290 -0
  114. tmap_agents-0.1.0/src/treasure_map/lib/reachability/models.py +35 -0
  115. tmap_agents-0.1.0/src/treasure_map/lib/reachability/taint.py +346 -0
  116. tmap_agents-0.1.0/src/treasure_map/lib/ro_db.py +27 -0
  117. tmap_agents-0.1.0/src/treasure_map/lib/setup/__init__.py +10 -0
  118. tmap_agents-0.1.0/src/treasure_map/lib/setup/clients.py +805 -0
  119. tmap_agents-0.1.0/src/treasure_map/lib/setup/completion.py +357 -0
  120. tmap_agents-0.1.0/src/treasure_map/lib/setup/discover.py +558 -0
  121. tmap_agents-0.1.0/src/treasure_map/lib/setup/doctor.py +506 -0
  122. tmap_agents-0.1.0/src/treasure_map/lib/setup/fetch.py +606 -0
  123. tmap_agents-0.1.0/src/treasure_map/lib/setup/initializer.py +1186 -0
  124. tmap_agents-0.1.0/src/treasure_map/lib/setup/ledger.py +154 -0
  125. tmap_agents-0.1.0/src/treasure_map/lib/setup/plan.py +325 -0
  126. tmap_agents-0.1.0/src/treasure_map/lib/setup/platform.py +178 -0
  127. tmap_agents-0.1.0/src/treasure_map/lib/setup/selector.py +190 -0
  128. tmap_agents-0.1.0/src/treasure_map/lib/setup/tmap_files.py +41 -0
  129. tmap_agents-0.1.0/src/treasure_map/lib/setup/toolchain_env.py +55 -0
  130. tmap_agents-0.1.0/src/treasure_map/lib/setup/toolchain_lock.json +82 -0
  131. tmap_agents-0.1.0/src/treasure_map/lib/setup/toolchain_lock.py +161 -0
  132. tmap_agents-0.1.0/src/treasure_map/lib/setup/uninstall.py +458 -0
  133. tmap_agents-0.1.0/src/treasure_map/lib/setup/update.py +200 -0
  134. tmap_agents-0.1.0/src/treasure_map/lib/storage/__init__.py +5 -0
  135. tmap_agents-0.1.0/src/treasure_map/lib/storage/atlas_schema.sql +861 -0
  136. tmap_agents-0.1.0/src/treasure_map/lib/storage/connection.py +158 -0
  137. tmap_agents-0.1.0/src/treasure_map/lib/storage/schema.sql +458 -0
  138. tmap_agents-0.1.0/src/treasure_map/lib/workspace/__init__.py +5 -0
  139. tmap_agents-0.1.0/src/treasure_map/lib/workspace/resolver.py +102 -0
  140. tmap_agents-0.1.0/src/treasure_map/lib/workspace/workspace.py +83 -0
  141. tmap_agents-0.1.0/src/treasure_map/mcp_app.py +3032 -0
  142. tmap_agents-0.1.0/src/treasure_map/version.py +79 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,22 @@
1
+ Treasure Map
2
+ Copyright (C) 2026 JoeyZzZzZz
3
+
4
+ This product includes software developed by JoeyZzZzZz
5
+ (https://github.com/JoeyZzZzZz/treasure-map).
6
+
7
+ src/treasure_map/lib/diff/ghidra/FallbackBinExport2Builder.java is a modified
8
+ copy of BinExport2Builder.java from BinExport
9
+ (https://github.com/google/binexport), Copyright 2019-2024 Google LLC, licensed
10
+ under the Apache License, Version 2.0. The changes are listed at the top of the
11
+ file.
12
+
13
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
14
+ this file except in compliance with the License. You may obtain a copy of the
15
+ License at
16
+
17
+ http://www.apache.org/licenses/LICENSE-2.0
18
+
19
+ Unless required by applicable law or agreed to in writing, software distributed
20
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
21
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
22
+ specific language governing permissions and limitations under the License.
@@ -0,0 +1,356 @@
1
+ Metadata-Version: 2.4
2
+ Name: tmap-agents
3
+ Version: 0.1.0
4
+ Summary: A firmware map for your AI agent. Treasure Map draws the map; your agent finds the treasure.
5
+ Author-email: JoeyZzZzZz <86097996+JoeyZzZzZz@users.noreply.github.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/JoeyZzZzZz/treasure-map
8
+ Project-URL: Repository, https://github.com/JoeyZzZzZz/treasure-map
9
+ Project-URL: Changelog, https://github.com/JoeyZzZzZz/treasure-map/blob/main/CHANGELOG.md
10
+ Keywords: iot,firmware,security,reverse-engineering,patch-diff
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Security
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ License-File: NOTICE
19
+ Requires-Dist: pyelftools>=0.31
20
+ Requires-Dist: pydantic>=2.11
21
+ Requires-Dist: pyyaml>=6.0
22
+ Requires-Dist: click>=8.2
23
+ Requires-Dist: mcp<2,>=1.21.2
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
27
+ Requires-Dist: ruff==0.16.0; extra == "dev"
28
+ Requires-Dist: mypy<2.0,>=1.10; extra == "dev"
29
+ Requires-Dist: types-PyYAML>=6.0; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # Treasure Map
33
+
34
+ [English](README.md) | [中文](README.zh.md)
35
+
36
+ **A firmware map for your AI agent. Treasure Map draws the map; your agent finds the treasure.**
37
+
38
+ Treasure Map turns an unpacked firmware filesystem into facts your coding agent (Claude Code, Codex,
39
+ Cursor and others) reads through a bundled MCP server: every dangerous call it recognizes, where the
40
+ data reaching it comes from, and — just as important — what it could not determine. Every fact points
41
+ at an exact binary, function and address. It has no agent of its own and runs no model; deciding which
42
+ lead is a real bug is your agent's job. **Facts are the tool's job; reasoning is the model's.**
43
+
44
+ It does two things:
45
+
46
+ - **Map one firmware.** Every place the compiled code runs a shell command, copies into a memory
47
+ buffer, formats a string or opens a file by path — each marked with what is known, what is not, and
48
+ why. Your agent picks the views it needs, reads the code, and records its verdicts.
49
+ - **Diff two versions.** Every function that changed between two releases, grouped by what happened
50
+ around its dangerous calls. Instead of thousands of functions, your agent reviews the few that
51
+ changed: is this a security fix, and which 1-day does it close in the old version? Is the fix
52
+ complete, or does the same call survive somewhere else? Can the new check be bypassed?
53
+
54
+ > **Developer preview.** Commands, config, the atlas database and MCP tool fields may change
55
+ > incompatibly between versions. After upgrading, see [Upgrading](#upgrading).
56
+
57
+ ---
58
+
59
+ ## Quick start
60
+
61
+ **1. Install.** One command installs `tmap` and then runs `tmap init`, which sets up the toolchain
62
+ (JDK 21, Ghidra 11.4.3, BinExport, BinDiff 8 — reusing what you already have) and registers the MCP
63
+ server with the agents you pick. No API key is needed. Restart your agent when it finishes.
64
+
65
+ ```bash
66
+ curl -LsSf https://github.com/JoeyZzZzZz/treasure-map/releases/latest/download/install.sh | sh
67
+ ```
68
+
69
+ **2. Map a firmware.** The input is an *already-extracted* filesystem — unpack the image first with
70
+ any extraction tool you like.
71
+
72
+ ```bash
73
+ tmap scan ./firmware.extracted -w my-fw
74
+ ```
75
+
76
+ Then ask your agent:
77
+
78
+ ```text
79
+ Audit firmware my-fw using treasure-map.
80
+ Choose for yourself which views of its candidate map to review
81
+ (by sink, by data source, or by any other layer) and find the issues in them:
82
+ open a lead's pseudocode, trace where its input comes from, and judge it yourself.
83
+ The candidates are leads to verify, not confirmed bugs.
84
+ Record each conclusion with annotate so the next session starts from it.
85
+ ```
86
+
87
+ **3. Or diff two versions.**
88
+
89
+ ```bash
90
+ tmap scan ./fw_v1.extracted -w fw-v1
91
+ tmap scan ./fw_v2.extracted -w fw-v2
92
+ tmap diff --before fw-v1 --after fw-v2
93
+ ```
94
+
95
+ ```text
96
+ Review the diff fw-v1 → fw-v2 using treasure-map.
97
+ Start from the function patch view (get_diff_patch_view):
98
+ for each changed function, compare the pseudocode of both versions
99
+ and decide whether the change does something real, such as a new check or a changed bound.
100
+ Record each judgement with annotate_diff.
101
+ ```
102
+
103
+ That is all you run by hand. `scan` is the slow part — one Ghidra pass per binary, with progress shown.
104
+ Re-running with the same `-w` resumes where it stopped; a different `-w` keeps another firmware
105
+ alongside. Everything you scan and diff accumulates in one **atlas** (`~/.treasure-map/atlas.db`),
106
+ and the agent picks which firmware or diff to work on — no reconfiguration per scan.
107
+
108
+ ---
109
+
110
+ ## What your agent gets
111
+
112
+ ### The firmware map
113
+
114
+ Each candidate is one point on the map, annotated on several equal layers: where the data comes
115
+ from, how much of it an attacker controls, who wrote the value, how the spot is reached, whether
116
+ anything filters it on the way, and whether the function was fully analyzed. Each layer reads
117
+ **YES**, **NO** or an explicit **UNKNOWN** that says what is missing and why.
118
+
119
+ There is no score. The default view puts the highest-impact calls that nothing has proven safe first;
120
+ your agent can re-sort or filter by any layer. Re-sorting changes the order, never the set of
121
+ candidates. In every view, only a *proven-safe* fact can push a candidate down; an UNKNOWN never can.
122
+
123
+ Command-execution, buffer-copy and format-string calls come with in-function argument provenance.
124
+ Path and file calls are covered for detection and ranking; their controllability comes from a
125
+ text-level reading, and is marked as such.
126
+
127
+ ### The patch diff
128
+
129
+ `tmap diff` compares every binary whose content changed, in parallel, running Ghidra, BinExport and
130
+ BinDiff end to end — you never handle an intermediate file. (`--binary NAME` limits it to one.)
131
+
132
+ - **A function-level patch view.** One entry per changed function pair, grouped by what happened
133
+ around its dangerous calls: a call that now goes somewhere else, a dangerous call that is still
134
+ there, a reading that could not be decided. An optional ordering puts the entries most likely to
135
+ matter first.
136
+ - **What a similarity score misses.** BinDiff's similarity ignores constants: a function can read
137
+ `similarity=1.0` while a buffer length went from `0x40` to `0x3f`. tmap adds an
138
+ address-normalized pseudocode comparison (truly identical, or only similar) and flags a changed
139
+ length constant at a copy or format call.
140
+ - **Blind spots stated, not hidden.** A binary that could not be diffed is listed as such, never
141
+ counted as unchanged. A function with no counterpart is *undetermined* — it may have been inlined
142
+ or moved — never reported as removed or added.
143
+ - **Judgments that stay.** Your agent records on each entry whether the change does something real,
144
+ and can carry that judgment over to the affected candidate in the firmware map.
145
+
146
+ If the stored scans or diffs were made by an older tmap, `tmap diff` brings them up to date first and
147
+ says what that involves before it starts.
148
+
149
+ ---
150
+
151
+ ## Why facts, not verdicts
152
+
153
+ A scanner hands you findings and a severity score — a verdict you then have to trust or re-check. A
154
+ modern agent already reads and reasons about one function well. What it cannot do is cover a whole
155
+ root filesystem, or every changed binary between two releases, the same way twice — or say where it
156
+ did not look. That is the half Treasure Map does.
157
+
158
+ - **UNKNOWN is never "safe".** A fact it could not establish stays UNKNOWN; a binary the diff could
159
+ not analyze never reads as unchanged.
160
+ - **Leads, not verdicts.** A candidate is a lead to verify, not a confirmed vulnerability; a changed
161
+ function is a change to review, not a confirmed fix. Reachability is graded one function at a time
162
+ — this is **not** a taint-propagation engine, and it never claims a path is unreachable.
163
+ - **Judgments that accumulate.** Your agent's conclusions live in an annotation layer over the
164
+ read-only facts, so a multi-session audit picks up where it left off — with any model or agent. A
165
+ judgment is flagged for review again the moment the facts under it change.
166
+
167
+ ---
168
+
169
+ ## Install details
170
+
171
+ `tmap init` installs the toolchain for you, or reuses what you already have if it passes the checks:
172
+
173
+ | Tool | Version | Used for |
174
+ |---|---|---|
175
+ | **JDK** | 21 (a JDK, not a JRE) | running Ghidra (JDK 11/17 make Ghidra 11.4.3 fail to launch) |
176
+ | **Ghidra** | 11.4.3 | decompiling every binary, headless |
177
+ | **BinExport** | for Ghidra 11.4.3 | exporting binaries for `tmap diff` |
178
+ | **BinDiff** | 8 | matching functions between two versions |
179
+
180
+ Downloads come from pinned URLs and are checked against a pinned size and sha256 before anything is
181
+ unpacked; they go to `~/.treasure-map/toolchain/`.
182
+
183
+ | Platform | Status |
184
+ |---|---|
185
+ | Linux x86_64 (including WSL2) | supported |
186
+ | macOS on Apple Silicon | supported |
187
+ | macOS on Intel | runs the same toolchain; not acceptance-tested |
188
+ | Linux arm64, native Windows | not supported (no Ghidra decompiler / BinDiff build) — on Windows use WSL2 |
189
+
190
+ `tmap init`, step by step:
191
+
192
+ 1. **finds** an existing JDK 21, Ghidra 11.4.3, BinExport and BinDiff 8 (config, `GHIDRA_HOME`,
193
+ `JAVA_HOME`, PATH, common install locations) and checks each at file level;
194
+ 2. **asks** for a path, or offers the pinned download, for anything missing;
195
+ 3. **lists your agents** (Claude Code, Codex, Cursor, Claude Desktop, dsh), pre-selecting those
196
+ installed here — Space to unselect, Enter to confirm;
197
+ 4. **shows the plan** (every download with URL, size and sha256; every file it will change) and asks
198
+ `Apply N changes? [Y/n]`;
199
+ 5. **applies** it, runs the **doctor**, and prints the two prompts shown in [Quick start](#quick-start).
200
+
201
+ Run it again any time; an up-to-date setup reports "everything current, nothing to do".
202
+
203
+ <details>
204
+ <summary>Flags and other ways to install</summary>
205
+
206
+ - `install.sh --dry-run` prints the plan and changes nothing. The script installs
207
+ [uv](https://docs.astral.sh/uv/) if it is missing (without editing your shell rc), then `tmap`
208
+ (PyPI package `tmap-agents`) with a uv-managed Python 3.11.
209
+ - Already have uv: `uv tool install --python 3.11 tmap-agents`, then `tmap init`.
210
+ - `tmap init` flags: `--dry-run` (plan only), `--yes` (no questions, downloads included; registers
211
+ only the agents named with `--client`), `--non-interactive` (no questions, no downloads),
212
+ `--ghidra / --java-home / --bindiff PATH` (use exactly this), `--offline DIR` / `--mirror URL`
213
+ (archives from elsewhere, same checksums).
214
+ - `tmap doctor` re-runs the checks and writes nothing.
215
+
216
+ </details>
217
+
218
+ ---
219
+
220
+ ## Connect your agent
221
+
222
+ `tmap init` registers the MCP server for you; restart the agent afterwards.
223
+
224
+ ### Registering by hand
225
+
226
+ The command is always `<absolute path of tmap> mcp` (`command -v tmap` prints the path).
227
+
228
+ | Agent | Register |
229
+ |---|---|
230
+ | **Claude Code** | `claude mcp add -s user treasure-map -- "$(command -v tmap)" mcp` |
231
+ | **Codex** | `codex mcp add treasure-map -- "$(command -v tmap)" mcp` |
232
+ | **Cursor / Claude Desktop / other JSON clients** | add the block below to the client's MCP config file |
233
+ | **dsh** | `tmap init --client dsh` adds the entry to `$DSH_HOME/cordis.patch.yml` (default `~/.dsh`), the layer every profile reads |
234
+
235
+ ```json
236
+ {
237
+ "mcpServers": {
238
+ "treasure-map": {
239
+ "command": "/absolute/path/to/tmap",
240
+ "args": ["mcp"]
241
+ }
242
+ }
243
+ }
244
+ ```
245
+
246
+ Config files: Cursor `~/.cursor/mcp.json`; Claude Desktop
247
+ `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS); Windsurf
248
+ `~/.codeium/windsurf/mcp_config.json`; Gemini CLI `~/.gemini/settings.json`. With Claude Code use
249
+ `-s user`: a project-local entry of the same name hides it inside that project (`tmap doctor` points
250
+ such entries out).
251
+
252
+ ---
253
+
254
+ ## Upgrading
255
+
256
+ ```bash
257
+ tmap update # install the newest tmap
258
+ tmap rescan # re-scan every run an older tmap made
259
+ tmap diff --before fw-v1 --after fw-v2 # re-runs the diffs that are out of date
260
+ ```
261
+
262
+ `tmap update` checks PyPI for the newest version, shows its plan and asks once (`--check` only
263
+ reports, `--yes` skips the question). It replaces the installed version, names any other `tmap` on
264
+ PATH that would shadow the new one, and then starts the new version's `tmap init` by itself — you do not type it. That init also
265
+ tells you how many of your runs predate the new version. A diff made by an older tmap, or with
266
+ another toolchain, is recomputed once.
267
+
268
+ With no arguments, `tmap rescan` re-scans every run an older tmap made. To rescan a single firmware,
269
+ name its run — the `-w` name you scanned it with, unless you set `--run-id` — for example
270
+ `tmap rescan fw-v1`. `--dry-run` lists what would be rescanned and why, without running anything.
271
+
272
+ `tmap update` works on the install the one-line installer makes (`uv tool`). Installed another way,
273
+ update it the same way you installed it.
274
+
275
+ ---
276
+
277
+ ## Troubleshooting
278
+
279
+ Run `tmap doctor` first. Each check shows ✅, ⚠ (works, worth knowing), `·` (information), ❌, or `?`
280
+ (could not be determined — never shown as ✅); it exits non-zero on any ❌ or `?`.
281
+
282
+ - **`tmap: command not found`** — the tool's bin directory is not on PATH. Run
283
+ `uv tool update-shell`, then open a new shell.
284
+ - **`ghidra` / `java` / `bindiff` ❌** — run `tmap init` again for the pinned download, or pass
285
+ `--ghidra / --java-home / --bindiff PATH`. On WSL keep everything on the Linux side, not under
286
+ `/mnt/c/...`.
287
+ - **`binexport` ❌ "two copies"** — Ghidra loads extensions from both its own `Ghidra/Extensions` and
288
+ its user settings directory; remove one of the two.
289
+ - **A binary is missing from a diff** — ask your agent for `list_diff_blindspots`, which names every
290
+ binary the diff could not analyze and why. After fixing a toolchain problem,
291
+ `tmap diff … --force-retry` tries them again.
292
+ - **Your own Ghidra 11.4.3 starts with an unexpected JDK** — Ghidra remembers the JDK it last ran with
293
+ (`java_home.save` in its settings directory), and tmap's runs record the JDK tmap uses there. Set
294
+ `JAVA_HOME` when you start Ghidra yourself.
295
+
296
+ ---
297
+
298
+ ## Uninstalling
299
+
300
+ ```bash
301
+ tmap uninstall
302
+ ```
303
+
304
+ It shows its plan, asks once, then removes the treasure-map entry from each agent, removes the
305
+ toolchain `tmap init` downloaded (never a JDK, Ghidra or BinDiff you installed yourself), and offers
306
+ to remove the program itself.
307
+
308
+ **Your data stays:** `~/.treasure-map/config.yaml`, `.env`, the **atlas** and the workspaces —
309
+ reinstalling reuses all of it. `tmap uninstall --purge-data` deletes them too, after you type a
310
+ confirmation phrase (not recoverable), but only what is provably tmap's: the atlas, what a scan
311
+ wrote in each workspace directory holding a tmap `analysis.db`, and the `config.yaml` / `.env` that
312
+ `tmap init` wrote. The workspace base itself stays (unless it is the default inside
313
+ `~/.treasure-map` and left empty), and nothing in it is deleted when it is your home directory or
314
+ above it. Anything else — a file you wrote yourself, in a workspace or beside one — is kept and
315
+ listed.
316
+
317
+ <details>
318
+ <summary>Details</summary>
319
+
320
+ - An agent entry named treasure-map that does not run tmap is left alone, and so is one inside a dsh
321
+ profile's own file.
322
+ - The program is removed with `uv tool uninstall tmap-agents` when it was installed with `uv tool`;
323
+ installed another way, `tmap uninstall` tells you to remove it the same way.
324
+ - `--dry-run` prints the plan and changes nothing; `--yes` skips the questions, but never the
325
+ confirmation phrase.
326
+
327
+ </details>
328
+
329
+ ---
330
+
331
+ ## Intended use & legal
332
+
333
+ **Purpose.** Treasure Map supports defensive security auditing and vulnerability research on
334
+ firmware. It produces analysis leads; by design it does **not** generate proof-of-concept exploits,
335
+ payloads, shellcode, or other directly weaponizable output.
336
+
337
+ **Lawful use is yours to ensure.** Only analyze firmware you lawfully possess — a device you own, or
338
+ firmware made genuinely public by its vendor and obtained **without** bypassing any login, paywall
339
+ or access control. Even lawfully obtained firmware may carry license, terms-of-service or contractual
340
+ restrictions on reverse engineering; you are responsible for reviewing them.
341
+
342
+ **Findings are candidates, not verdicts.** Output requires independent human verification and is not
343
+ a confirmed vulnerability.
344
+
345
+ **No warranty.** The tool is provided "as is". You are solely responsible for how you use it and for
346
+ ensuring your activity is lawful in your jurisdiction. If unsure, consult qualified legal counsel.
347
+
348
+ ---
349
+
350
+ ## Contributing
351
+
352
+ Issues and pull requests are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).
353
+
354
+ ## License
355
+
356
+ [Apache-2.0](LICENSE).