beefproject / beefproject/beef

get_ntop_network_hosts: NetworkHost.create called with non-existent port:` attribute`

Open
#3,573 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
11k
Forks
2.4k
Avg merge
1d 1h
Merged PRs (30d)
15

Description

## First Steps
1. Confirmed issue not posted previously.
2. Confirmed wiki does not contain answers.
3. Checking FAQ.
4. BeEF Version: Latest
5. Ruby Version: 3.4.7
6. Browser Details: Firefox
7. Operating System: macOs

# Configuration
1. BeEF configuration changes? No
2. Enabled/disabled extensions? No

## Steps to Reproduce
I do not have an ntop instance available to reproduce this end-to-end. Therefore i did not reproduce running the module.

## How this was found
Static code review during the fix for PR for #3493 and #3498. While revewing every `NetworkHost.create` / `NetworkService.create` callsites

## Error Description
`modules/network/get_ntop_network_hosts/module.rb:34` calls `NetworkHost.create` with a `port:` keyword, but the `network_hosts` table has no `port` column. The migration at `core/main/ar-migrations/013_create_network_host.rb` declares the columns as: `ip, hostname, ntype, os, mac, lastseen, hooked_browser_id`.

Error line:
```ruby
# modules/network/get_ntop_network_hosts/module.rb:34
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, port: port)
```

Expected error at runtime:
I couldn't trigger this end-to-end because I don't have an ntop instance to scan, but the bug is statically obvious from the code combined with the migration.

This is the same family of bug as #3493 and #3498, which reported `type:` being passed to NetworkHost/NetworkService where the column is `ntype`. Discovered while reviewing my own PR for those two issues. Different attribute (`port:` instead of `type:`), different module, same shape.

## Suggested Fix

Drop the `port:` kwarg from the `NetworkHost.create` call. NetworkHost has no port column.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.