POST: purl2sym, extracting symbols from sources for fun and for profit
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- content, documentation
Hướng nghiên cứu
Repository được mô tả là dựa trên Docusaurus/Markdown, nhưng không có tệp đích hoặc thư mục nội dung nào được nêu tên. Hãy bắt đầu bằng cách xác định cấu trúc bài viết hiện có của trang web và so sánh cấu trúc đó với các tài liệu tham khảo được liên kết là purl2sym và Symbols and Strings in PURLdb. Công việc được xem là hoàn tất khi bản nháp này được xuất bản ở vị trí phù hợp trên trang web, với các liên kết và nhận định kỹ thuật được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Lightweight reverse-engineering of open source binaries with purl2sym
TL;DR
- Got binary code? Got source code?
- Need to know what open source packages it came from?
- Use purl2sym to extract and then index symbols, like function names, and strings.
- Extract strings from the binary and match them back to actual source packages.
Context
As an open source developer, I further rely on open source every day. But what happens when that code is shipped as a binary, like when embedded in devices (a car, a phone, or a toaster) or in container images where the original corresponding source code is not present?
You get a blob. Maybe a stripped ELF file. How can you figure out what is inside, what is it made off, what is the source, and where is the "open" source?
This is where purl2sym comes in. It is one of the AboutCode https://aboutcode.org projects, funded by NLnet https://nlnet.nl/project/purl2sym and it extracts and indexes symbols from source code so you can match these back to binary symbols of open source packages, keyed by PURL https://github.com/package-url/purl-spec. It can help turn otherwise mostly obscure and opaque symbols and strings found in binaries into traceable references to specific open source code packages and specific versions.
Problems
If you have ever faced some of these use cases, then purl2sym could help:
- Analyzed a binary firmware blob to find which open source packages it embeds
- Tried to comply with FOSS license obligations post-compilation, to find what the actual code that is effectively compiled and shipped (as opposed to the 10x more code used in development and testing)
- Hunted down the source code of a vulnerability found in a binary
- Built SBOMs, working from compiled codebase
Solution
purl2sym extract symbols from source code and builds indexes of symbols and strings extracted from multiple tech stacks and programing languages, like C, C++, Java, Python JavaScript, packaged in Linux distros like Debian or Alpine, or application packages like PyPI, Maven and more. You can fetch the symbols by PURL (Package-URL) and cross-reference these with binary symbols to get back matches to potential packages and versions indexed in the PrulDB.
How it works
purl2sym is a combo of low level libraries, scripted pipelines and high level APIs. When you call the high level REST API, you request the symbols for a PURL, and the tool:
- Downloads and extracts the source package
- Extracts symbols and strings from the code using tools like
gettext,treesitter, orpygments. - Stores those symbols keyed by PURL (e.g.,
pkg:deb/debian/[email protected]). - Returns a JSON doc with the symbols and metadata for further integration, alongside hashes and fingerprints.
With this, I can analyze unknown binary blobs by extracting their symbols and finding their original sources, using symbol matching. Or determine if the symbols of a code vulnerability may be present or used in a given source or binary. (Assuming we know which code segment is the trigger for a vulnerability, but this another thing, handled in another project)/
It is designed to work with and power binary analysis tools like BANG https://github.com/armijnhemel/binaryanalysis-ng/ that can then detect reused code chunks across binaries.
In practice
Let’s say you are working with the firmware blob of a commercial device. It includes a statically linked C executable, but it is not obvious what libraries are linked in the binary. You could pull a few function names using strings (or commoncode's string functions) , or maybe extract a specific ELF section.
You can feed that into a tool powered by purl2sym. Voila: it will suggests that OpenSSL 1.1.1d from Debian is linked in the exe, and you can further lookup in the PurlDB for complete licensing metadata and in Vulnerable for CVEs. You now have a clear path towards automating a security and license compliance.
Get Started
- Project homepage: https://nlnet.nl/project/purl2sym
- Docs on symbol extraction: Symbols and Strings in PURLdb
- Install ScanCode.io to run locally
- Binary analysis with BANG: https://github.com/nexB/bang
- Ngôn ngữ chính
- JavaScript
- Star
- 9
- Fork
- 17
- Merge trung bình
- 7 giờ 55 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aboutcode-org/www.aboutcode.org
-
Making all post button.Có thể đã có người làm @sarthaklole đã nhận 70 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aboutcode-org/www.aboutcode.org#117 · 3 bình luận ·
-
WWW: Reduce frequency of update-releasesCó thể làm lại được @johnmhoran đã nhận 51 ngày trước và không có pull request nào đang mở. Đang mởci-workflow
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
aboutcode-org/www.aboutcode.org#180 · 1 người được giao ·
-
DOCS: Create new AboutCode stack diagram(s)Có thể làm lại được @hixvikas đã nhận 52 ngày trước và không có pull request nào đang mở. Đang mởdocumentation
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
aboutcode-org/www.aboutcode.org#166 · 1 bình luận ·
-
WWW: Create About top level page?Có thể đã có người làm @pombredanne đã nhận 154 ngày trước. Đang mởwebsite
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
aboutcode-org/www.aboutcode.org#164 · 1 reaction · 1 người được giao ·
-
WWW: Add Initiatives and grant ProjectsCó thể làm lại được @mjherzog đã nhận 241 ngày trước và không có pull request nào đang mở. Đang mởenhancement needs design website
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
aboutcode-org/www.aboutcode.org#141 · 1 người được giao ·
Tất cả issue của aboutcode-org/www.aboutcode.org
Issue tương tự
-
step.duration reflects only the last retry attempt (HelperStep.run() overwrites startTime)Có thể đã có người làm @mirao đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
codeceptjs/CodeceptJS#5774 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Status: Unconfirmed
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
AllTheMods/ATM10-Aeronautics#151 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
feimacode/open-design-agent-kit#66 ·
Maintainer thường phản hồi trong vòng 1 ngày