12 Commits
Author SHA1 Message Date
Mr.X 25a50bd63c elf: expose nine more e_machine values (#2248)
elf.machine can hold any value from the ELF header, but the module only
named 14 of them, so a rule targeting anything else had to hardcode the
number or drop the module and match the header bytes by hand.

Add the architectures from the issue: PARISC, SPARC32PLUS, S390, MCORE,
SH, SPARCV9, ARC_COMPACT, BPF and LOONGARCH.

0x27 is exposed under both EM_MCORE and EM_RCE. EM_RCE is the name it was
originally registered under and still what some toolchains emit, so a rule
written against either name works.

Closes #2149
2026-09-23 10:04:28 +02:00
jmestwa-coder 622ea976c7 byte-swap sh_entry_count in elf symtab/dynsym link check (#2214)
Missing byte swap in the ELF symtab/dynsym link check
The SHT_SYMTAB and SHT_DYNSYM string table check compares sh_link against the raw e_shnum (sh_entry_count) while every other use in the macro byte-swaps it, so on a little-endian host reading a big-endian ELF the check accepts a link past the real section count and parses the symbol string table from an out-of-range section header. Swapped it to match the sibling reads, and added a regression test scanning a crafted big-endian ELF whose only symtab carries an out-of-range sh_link.
2026-06-30 20:20:12 +02:00
Vincent Thiberville 26cca748c1 fix telfhash computation on x64 specific functions (#1847)
The telfhash algorithm excludes x64 functions, see here:
https://github.com/trendmicro/telfhash/blob/d2a82f85a5b/telfhash/telfhash.py#L59

Looks like there was a copy paste error when porting this algorithm in
YARA, as the test for "is_bad_prefix" is copied, but this is not the
right test of "is_x86_64".

This PR properly fixes it.
2023-01-10 09:50:00 +01:00
T3LS 398359bd0c Add dynsym objects to ELF module (#1427) 2020-12-24 13:31:34 +01:00
Victor M. AlvarezandSimon Hardy-Francis cba6932759 Implement non-blocking API (#1428)
With this change the yr_scanner_scan_mem_blocks function can return ERROR_BLOCK_NOT_READY when the YR_MEMORY_BLOCK_ITERATOR that provides memory blocks to the function is not ready to return the next block. After this error the caller can retry the call to yr_scanner_scan_mem_blocks multiple times until the function succeeds or fails with some other error code.

Co-authored-by: Simon Hardy-Francis <[email protected]>
2020-12-24 10:46:09 +01:00
Victor M. Alvarez 0bce4bd74d Start using clang-format for formatting the code automatically. 2020-10-07 16:27:30 +02:00
Victor M. Alvarez 2376ca49fd Automate Bazel build with Travis CI (#1124) 2019-09-04 18:42:11 +02:00
plusvic 327d38b8b7 Do some re-styling 2017-03-16 16:52:31 +01:00
Jacob Baines d326f9c48f Expand ELF module functionality 2017-03-16 16:36:02 +01:00
Jacob Baines 8fc561b501 Use the program headers to determine the physical offset of the ELF entry point (#606) 2017-02-15 09:50:18 +01:00
Jacob Baines 0e2c3a7cf3 Fix endian issues with section name extraction (#607) 2017-02-15 09:36:45 +01:00
Hilko Bengen d272b9c742 Fix pe, elf module for big-endian architectures (related to #493) (#538)
* Fix pe module for big-endian architectures

* No longer skip pe test on big-endian architectures

(The ifdef was wrong anyhow.)

* Add tests for elf module

* Fix elf module for big-endian architectures
2016-10-16 13:01:31 +02:00