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

[BUG] "compiling_error_syntax_/etc/strelka/yara/rules/malware/MALW_Torte_ELF.yar(31): undefined identifier "is__elf"" #474

Open
wl380zxh opened this issue Oct 14, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@wl380zxh
Copy link

Trying to do everything by instruction (QuickStart in documents).
Everything works fine, except Yara rules. Base Yara repo not working OOTB with following error "compiling_error_syntax_/etc/strelka/yara/rules/malware/MALW_Torte_ELF.yar(31): undefined identifier "is__elf""

Even turning off this rule pack not making it working.

Screenshot
image

@wl380zxh wl380zxh added the bug Something isn't working label Oct 14, 2024
@phutelmyer phutelmyer assigned skalupa and unassigned phutelmyer Oct 14, 2024
@GlennHD
Copy link

GlennHD commented Dec 23, 2024

This is because of the default settings in configs/python/backend/backend.yaml. Under 'ScanYara', the location should be set to the rules.yara file. This should prevent Strelka from attempting to recursively compile all Yara files individually without their required imports. Example below. After making this change, just bounce your docker container for it to take effect.

  'ScanYara':
    - positive:
        flavors:
          - "*"
      priority: 5
      options:
        location: "/etc/strelka/yara/rules.yara"
        compiled:
          enabled: True
          filename: "/etc/strelka/yara/rules.compiled"
        category_key: "scope"
        categories:
          collection:
            show_meta: False
          detection:
            show_meta: True
          information:
            show_meta: False
        meta_fields:
          - "author"
          - "description"
          - "hash"
          - "intel"
        show_all_meta: False
        store_offset: True
        offset_meta_key: "StrelkaHexDump"
        offset_padding: 32

Alternatively, you can delete the rules.yara file and just opt for the significantly faster compiled rules.

# create an empty for for Docker bind mount (required!)
sudo touch configs/python/backend/yara/rules.compiled

# give strelka container user (run `id` command from w/in  container to get uid) permission to generate rules.compiled
sudo chown 1001:docker configs/python/backend/yara/rules.compiled

# modify whichever docker-compose.yaml you are using and add the compiled.rules file as a bind point
nano build/docker-compose.yaml
...
  backend:
    build:
      context: ..
      dockerfile: build/python/backend/Dockerfile
    command: strelka-backend
    shm_size: 512mb  # increase as necessary, required for some scanners
    networks:
      - net
    volumes:
      - ../configs/python/backend/:/etc/strelka/:ro
      - ../configs/python/backend/yara/rules.compiled:/etc/strelka/yara/rules.compiled:rw
    restart: unless-stopped
    depends_on:
      - coordinator
...

Finally, just bounce your containers and then once the backend container is up, exec into it and compile your rules using the container to ensure there are no complications.

docker exec -it strelka-backend-1 /bin/bash -c "yarac -w /etc/strelka/yara/rules_compileme.yara /etc/strelka/yara/rules.compiled"

I am not responsible if any of this breaks your SOC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants