Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented readelf-like functionality. #1364

Merged
merged 5 commits into from
Jun 9, 2022
Merged

Conversation

n1073645
Copy link
Contributor

@n1073645 n1073645 commented Jun 5, 2022

The code in this PR implements readelf-like functionality into CyberChef. It utilises the stream library for most of it's processing and I have attempted to make it agnostic between 32-bit and 64-bit.

I have tested it on both 32-bit and 64-bit ELF files.

The tests are pretty thin on the ground for this one but I could create a small, totally invalid, ELF to use.

@n1073645 n1073645 requested a review from n1474335 June 5, 2022 17:36
@n1073645 n1073645 self-assigned this Jun 5, 2022
@n1073645
Copy link
Contributor Author

n1073645 commented Jun 6, 2022

The stream library has a readString functionality but it requires knowing the size of the string in advance which I do not know hence I have had to reimplement it.

@n1474335
Copy link
Member

n1474335 commented Jun 7, 2022

I think it would be reasonable to modify the Stream library's readString function to support reading until a null byte. It does currently stop at the next null byte if it occurs before the length limit. Perhaps the numBytes argument should default to -1 and if this is the value it just consumes bytes until a null is found. I don't believe this would break any existing uses of that function (though I'd recommend searching for all references to readString and confirming).

On the testing front, I'd put an ELF or two in the tests/samples directory and use some expectedMatch regexes to confirm you get expected fields. There are some provided under the MIT licence here: https://github.com/JonathanSalwan/binary-samples

@n1474335 n1474335 merged commit 23b1685 into gchq:master Jun 9, 2022
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants