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

Review WebSockets command and control channel #2781

Open
bcoles opened this issue Apr 1, 2023 · 0 comments
Open

Review WebSockets command and control channel #2781

bcoles opened this issue Apr 1, 2023 · 0 comments

Comments

@bcoles
Copy link
Collaborator

bcoles commented Apr 1, 2023

The WebSockets command and control channel was added more than 10 years ago. Very little maintenance has been performed. There is significant room for improvement and many bugs. It is effectively unusable in its current state.

There are also many TODOs:

# This will happen if you reset BeEF database (./beef -x),
# and existing zombies try to connect. These zombies will be ignored,
# as they are unknown and presumed invalid.
#
# @todo: consider fixing this. add zombies instead of ignoring them
# and report "Hooked browser X appears to have come back online"
if hooked_browser.nil?
# print_error "Could not find zombie with ID #{msg_hash['alive']}"
next
end

# @todo antisnatchor:
# @todo - re-use the pre_hook_send callback mechanisms to have a generic check for multipl extensions
# Check if new forged requests need to be sent (Requester/TunnelingProxy)
if @@config.get('beef.extension.requester.loaded')
dhook = BeEF::Extension::Requester::API::Hook.new
dhook.requester_run(hooked_browser, '')
end

/**
* Polling mechanism, to notify the BeEF server that the browser is still hooked,
* and the WebSocket channel still alive.
* todo: there is probably a more efficient way to do this. Double-check WebSocket API.
*/
alive: function (){
try {
if (beef.logger.running) {
beef.logger.queue();
}
} catch(err){}
beef.net.flush();
beef.websocket.send('{"alive":"'+beef.session.get_hook_session_id()+'"}');
setTimeout("beef.websocket.alive()", parseInt(beef.websocket.ws_poll_timeout));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant