Fixed issue with lib loading and WebSocket server initalization
This commit is contained in:
3
beef
3
beef
@@ -112,7 +112,8 @@ BeEF::Core::Console::Banners.print_network_interfaces_routes
|
||||
#@note Prints the API key needed to use the RESTful API
|
||||
print_info "RESTful API key: #{BeEF::Core::Crypto::api_token}"
|
||||
|
||||
BeEF::Core::Websocket.initialize
|
||||
#@note Starts the WebSocket server
|
||||
BeEF::Core::Websocket::Websocket.new
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -48,4 +48,5 @@ require 'core/main/rest/handlers/logs'
|
||||
require 'core/main/rest/api'
|
||||
|
||||
## @note Include Websocket
|
||||
require 'core/main/network_stack/websocket/handlers/module'
|
||||
require 'core/main/network_stack/websocket/lib/web_socket'
|
||||
require 'core/main/network_stack/websocket/websocket'
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#
|
||||
# Copyright 2012 Wade Alcorn wade@bindshell.net
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
module BeEF
|
||||
module Core
|
||||
module Websocket
|
||||
|
||||
|
||||
def initialize
|
||||
|
||||
|
||||
print_info("Inside")
|
||||
#load the library
|
||||
$LOAD_PATH << File.dirname(__FILE__) + "../lib"
|
||||
require "web_socket"
|
||||
server = WebSocketServer.new("localhost", 6666) #we get host and port how
|
||||
server.run() do |ws|
|
||||
#@TODO debug print the path and who request for hooked browser mapping
|
||||
print_info("Path requested #{ws.path} Originis #{ws.origin}")
|
||||
if ws.path == "/"
|
||||
ws.handshake() #accept and connect
|
||||
|
||||
while true
|
||||
#command interpretation
|
||||
message=ws.receve()
|
||||
|
||||
if (message!="helo")
|
||||
#module return value case
|
||||
else
|
||||
print_info("Browser #{ws.origin} says helo! ws is running")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
51
core/main/network_stack/websocket/websocket.rb
Normal file
51
core/main/network_stack/websocket/websocket.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# Copyright 2012 Wade Alcorn wade@bindshell.net
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
module BeEF
|
||||
module Core
|
||||
module Websocket
|
||||
class Websocket
|
||||
|
||||
|
||||
def initialize
|
||||
print_info("Starting WebSockets")
|
||||
|
||||
#todo antisnatchor: add config file options for IP/port/enable websocket
|
||||
|
||||
server = WebSocketServer.new(:accepted_domains => "0.0.0.0",:port => 6666) #we get host and port
|
||||
server.run() do |ws|
|
||||
#@TODO debug print the path and who request for hooked browser mapping
|
||||
print_info("Path requested #{ws.path} Origins #{ws.origin}")
|
||||
if ws.path == "/"
|
||||
ws.handshake() #accept and connect
|
||||
|
||||
while true
|
||||
#command interpretation
|
||||
message=ws.receve()
|
||||
|
||||
if (message!="helo")
|
||||
#module return value case
|
||||
else
|
||||
print_info("Browser #{ws.origin} says helo! ws is running")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user