From 6ade1469bbb84f03d79bfc4d89c55317fbfd99b2 Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Thu, 19 Jul 2012 22:51:39 +0100 Subject: [PATCH 01/11] initial commit of notifications extension --- Gemfile | 3 + Gemfile.lock | 76 +++++++++++++++++++ config.yaml | 2 +- core/main/logger.rb | 9 ++- core/main/notifications.rb | 55 ++++++++++++++ extensions/metasploit/.rpcclient.rb.swp | Bin 0 -> 16384 bytes extensions/notifications/config.yaml | 28 +++++++ extensions/notifications/extension.rb | 30 ++++++++ extensions/notifications/handler.rb | 43 +++++++++++ extensions/notifications/handlers/twitter.rb | 43 +++++++++++ 10 files changed, 287 insertions(+), 2 deletions(-) create mode 100644 Gemfile.lock create mode 100644 core/main/notifications.rb create mode 100644 extensions/metasploit/.rpcclient.rb.swp create mode 100644 extensions/notifications/config.yaml create mode 100644 extensions/notifications/extension.rb create mode 100644 extensions/notifications/handler.rb create mode 100644 extensions/notifications/handlers/twitter.rb diff --git a/Gemfile b/Gemfile index cd4bb331e..155418d9b 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,9 @@ gem "erubis" gem "dm-migrations" gem "msfrpc-client" +# notifications +gem "twitter" + if ENV['BEEF_TEST'] # for running unit tests gem "test-unit" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..cddca4f41 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,76 @@ +GEM + remote: http://rubygems.org/ + specs: + addressable (2.2.8) + ansi (1.4.2) + daemons (1.1.8) + data_objects (0.10.8) + addressable (~> 2.1) + dm-core (1.2.0) + addressable (~> 2.2.6) + dm-do-adapter (1.2.0) + data_objects (~> 0.10.6) + dm-core (~> 1.2.0) + dm-migrations (1.2.0) + dm-core (~> 1.2.0) + dm-sqlite-adapter (1.2.0) + dm-do-adapter (~> 1.2.0) + do_sqlite3 (~> 0.10.6) + do_sqlite3 (0.10.8) + data_objects (= 0.10.8) + em-websocket (0.3.6) + addressable (>= 2.1.1) + eventmachine (>= 0.12.9) + erubis (2.7.0) + eventmachine (0.12.10) + faraday (0.8.1) + multipart-post (~> 1.1) + jsmin (1.0.1) + json (1.7.3) + librex (0.0.65) + msfrpc-client (1.0.1) + librex (>= 0.0.32) + msgpack (>= 0.4.5) + msgpack (0.4.7) + multi_json (1.3.6) + multipart-post (1.1.5) + parseconfig (1.0.2) + rack (1.4.1) + rack-protection (1.2.0) + rack + simple_oauth (0.1.8) + sinatra (1.3.2) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + term-ansicolor (1.0.7) + thin (1.3.1) + daemons (>= 1.0.9) + eventmachine (>= 0.12.6) + rack (>= 1.0.0) + tilt (1.3.3) + twitter (3.3.1) + faraday (~> 0.8) + multi_json (~> 1.3) + simple_oauth (~> 0.1.6) + +PLATFORMS + ruby + +DEPENDENCIES + ansi + data_objects + dm-core + dm-migrations + dm-sqlite-adapter + em-websocket (~> 0.3.6) + erubis + eventmachine (= 0.12.10) + jsmin (~> 1.0.1) + json + msfrpc-client + parseconfig + sinatra (= 1.3.2) + term-ansicolor + thin + twitter diff --git a/config.yaml b/config.yaml index b9d4f8f08..d1c2f12ae 100644 --- a/config.yaml +++ b/config.yaml @@ -17,7 +17,7 @@ beef: version: '0.4.3.6-alpha' - debug: false + debug: true restrictions: # subnet of browser ip addresses that can hook to the framework diff --git a/core/main/logger.rb b/core/main/logger.rb index f9e128d77..558ec5600 100644 --- a/core/main/logger.rb +++ b/core/main/logger.rb @@ -24,6 +24,7 @@ module Core # Constructor def initialize @logs = BeEF::Core::Models::Log + @notifications = BeEF::Extensions::Notifications end # Registers a new event in the logs @@ -34,6 +35,9 @@ module Core def register(from, event, hb = 0) # type conversion to enforce standards hb = hb.to_i + + # get time now + time_now = Time.now # arguments type checking raise Exception::TypeError, '"from" needs to be a string' if not from.string? @@ -41,7 +45,10 @@ module Core raise Exception::TypeError, '"Hooked Browser ID" needs to be an integer' if not hb.integer? # logging the new event into the database - @logs.new(:type => "#{from}", :event => "#{event}", :date => Time.now, :hooked_browser_id => hb).save + @logs.new(:type => "#{from}", :event => "#{event}", :date => time_now, :hooked_browser_id => hb).save + + # if notifications are enabled send the info there too + @notifications.new(from, event, time_now, hb) # return true diff --git a/core/main/notifications.rb b/core/main/notifications.rb new file mode 100644 index 000000000..6a99c2d19 --- /dev/null +++ b/core/main/notifications.rb @@ -0,0 +1,55 @@ +# +# 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 + + class Notifications + + include Singleton + + # Constructor + def initialize + @notifications = BeEF::Core::Models::Notifications + end + + # Registers a new event in the logs + # @param [String] from The origin of the event (i.e. Authentication, Hooked Browser) + # @param [String] event The event description + # @param [Integer] hb The id of the hooked browser affected (default = 0 if no HB) + # @return [Boolean] True if the register was successful + def register(from, event, hb = 0) + # type conversion to enforce standards + hb = hb.to_i + + # arguments type checking + raise Exception::TypeError, '"from" needs to be a string' if not from.string? + raise Exception::TypeError, '"event" needs to be a string' if not event.string? + raise Exception::TypeError, '"Hooked Browser ID" needs to be an integer' if not hb.integer? + + # logging the new event into the database + @logs.new(:type => "#{from}", :event => "#{event}", :date => Time.now, :hooked_browser_id => hb).save + + # return + true + end + + private + @logs + + end +end +end diff --git a/extensions/metasploit/.rpcclient.rb.swp b/extensions/metasploit/.rpcclient.rb.swp new file mode 100644 index 0000000000000000000000000000000000000000..9449db26428d79cdb0291e65f50f3058ef0c022c GIT binary patch literal 16384 zcmeI2ON<;x8OI9;hzBrnFmFrnc{X;>#^av#hQzS;+Fq~M@e+I2+8KLsHmg-nPt8o@ zp6;d}9xt}V;{Y+XkRVcmIB*ItZ^Z!{dL#ZT^~C)dzucI;{w}uA@*&3WB%sOd&S9;5TWnKTztFj zz|6kWR%qX@ny4I?7p3b59qGjtzuA;t zVB4;PW6ZFA+dlFNxdOQYn<=nOJTSh0Y^1o0cD(QGW|i{tT!CDHT!CDHT!CDHT!CDH zT!CDH|5F9xV2k({#FgOSdum{`&e(@e5ehxkXUU|0=7r<8Vy>|(59b5(%!K2_|upjIO ze=7*_8}NN_4J?6&!4wz=qu@TU4ZOZph~I)2!1Lg{;5zsMXoJT<4SWjh0z1Gqa5vZj z{&BYue*v$7SHO?J)8INd56*%UU^n>PJB4@=JP&>bnxGCo4W_{!@GxDRXxufrE!1y6%-f*ar(=m7SU&w$%*q_#q#(30_r>)RJf zqoPn~$R-8Ws_R>g6+ejiRgaQqbtLb@f9W;ww-Cx`$>{iv#Fde;oR-8%=+Wh?u96}_W3Gdoh_7_ybFT!Cf% zL+`v}ErC%sz2yBb!%+D6IiiRcjZb?kvp;{tG)45zIB5fuj#*8 zZM2Xpe5|%d6o`7B6`PSC#2L1N64tuL%$p0y(PE| zs>4?!Q(AVL8a`d=T;Vc?51*tZ<-%MCKi2rRuEoy1w0wK#R&8$V#CqVHIdSSy{lDm# zPewhCmF#GEH`l>lEkPV6QWbGAZ#=4@6Duv|fgE+MD7KQgjd9kTjx;^L%jHZEI$o@1 zg^X%q+cJupiA%QcdD7-UKwSq1p69m%N1YTn-Q<-`tffXUjWuYhSWrMKk`Yp%nnKDA^H$haN`Y+1~ ztwvuaOof_4HQPP$FcD6A5@bifRbhAkG+`+{$3+>2VJDJiF4_^tf%wk`aSZ82k#xw2!Wb+;h^wqdfhI7=G2UThfp9%Y%c96# zxhO+^tC7olvp!JH?$EEjw${MjBy@)M;y3o<>SI)_z^NEnD*+eJXp-fWwvw3xzZWp(t(qoXPouQHr_ipp%9Biwv#{C&K#G) zy)q}{pM%>mIdfuSV%iTS|K$@a3327}J%ngPAkUU&B;%67ZZI0|q2wxj*CahZX|;zAM%x?L9uer4a!xl+@M@V z%+XPyoG}#&zIg{zhLidhPSLylBjO0avN%c??nqzzsp@zwSH?bvH&L+R^bsut_OyCK znGVs!#ObIxF|lxF8m_4d1$;fdnH|tKE1Ah&dCm%W6k6ByRC247@DpiS#R=<$o6zX>rNZV;THo2D9O01TomJb*5U_9Y+)Nvy9nl)L7yWG{{ zZ0+Ry*%~cQEi6pU)n;d^G`~R8^K-{%YqRrn_;rG&=FZb2vvbGGBypvNHMnPh+o}6- zrxReTjnt@y6UCuZPh#0vZ#TQ*U-kTySCz))FTCp3xfv|~1h1|*D~z(Cv@lB2 z!+N!clX)8+F_a)Fp0KcnQmZ@HN<3uOk*xKDuJ@Q%OpVwiF$q&P%aKbP%Thd3u#!s- zmSf>6z9S=xwQ-ixU(uZyc3m$|1Uqq=bJ%=|*lSiV{*(q2wIp)ec7vT81yKizCmFQS$BlC$hQ zz`>mnme^`9(n7kI>M0}?xgyt_q+(Hso{(!iCN1Z>S;yMV-n8S)q)*e3+*1z3S&@;; z`Vq%f`Y*VTZp$d^FL&lE1M{knE3G{qqhCAE>z{mXtRM@wnd4(J_*pBQT|cYK9yI Date: Thu, 2 Aug 2012 11:41:24 +0100 Subject: [PATCH 02/11] working but kludgey version of notifications with twitter and email support --- config.yaml | 2 +- core/main/logger.rb | 2 +- extensions/notifications/channels/email.rb | 60 ++++++++++++++++++++++ extensions/notifications/channels/tweet.rb | 49 ++++++++++++++++++ extensions/notifications/config.yaml | 17 ++++-- extensions/notifications/extension.rb | 2 +- extensions/notifications/notifications.rb | 52 +++++++++++++++++++ 7 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 extensions/notifications/channels/email.rb create mode 100644 extensions/notifications/channels/tweet.rb create mode 100644 extensions/notifications/notifications.rb diff --git a/config.yaml b/config.yaml index d1c2f12ae..6560e8cf1 100644 --- a/config.yaml +++ b/config.yaml @@ -85,6 +85,6 @@ beef: enable: false console: shell: - enable: false + enable: true evasion: enable: false diff --git a/core/main/logger.rb b/core/main/logger.rb index 558ec5600..dbbb376c2 100644 --- a/core/main/logger.rb +++ b/core/main/logger.rb @@ -24,7 +24,7 @@ module Core # Constructor def initialize @logs = BeEF::Core::Models::Log - @notifications = BeEF::Extensions::Notifications + @notifications = BeEF::Extension::Notifications::Notifications end # Registers a new event in the logs diff --git a/extensions/notifications/channels/email.rb b/extensions/notifications/channels/email.rb new file mode 100644 index 000000000..fa49f024f --- /dev/null +++ b/extensions/notifications/channels/email.rb @@ -0,0 +1,60 @@ +# +# 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. +# +# +# +require 'net/smtp' + +module BeEF +module Extension +module Notifications +module Channels + + class Email + + # + # Constructor + # + def initialize(to_address, message) + @config = BeEF::Core::Configuration.instance + @from_address = @config.get('beef.extension.notifications.email.from_address') + @smtp_host = @config.get('beef.extension.notifications.email.smtp_host') + @smtp_port = @config.get('beef.extension.notifications.email.smtp_port') + @smtp_tls_enable = @config.get('beef.extension.notifications.email.smtp_tls_enable') + @password = @config.get('beef.extension.notifications.email.smtp_tls_password') + + # configure the email client + msg = "Subject: BeEF Notification\n\n" + message + smtp = Net::SMTP.new @smtp_host, @smtp_port + #if @smtp_tls_enable? + # smtp.enable_starttls + # smtp.start('beefproject.com', @from_address, @password, :login) do + # smtp.send_message(msg, @from_address, @to_address) + # end + #else + smtp.start do + smtp.send_message(msg, @from_address, to_address) + end + #end + + end + + end + +end +end +end +end + diff --git a/extensions/notifications/channels/tweet.rb b/extensions/notifications/channels/tweet.rb new file mode 100644 index 000000000..37ae928d6 --- /dev/null +++ b/extensions/notifications/channels/tweet.rb @@ -0,0 +1,49 @@ +# +# 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. +# +# +# +require 'twitter' + +module BeEF +module Extension +module Notifications +module Channels + + class Tweet + + # + # Constructor + # + def initialize(username, message) + @config = BeEF::Core::Configuration.instance + + # configure the Twitter client + Twitter.configure do |config| + config.consumer_key = @config.get('beef.extension.notifications.twitter.consumer_key') + config.consumer_secret = @config.get('beef.extension.notifications.twitter.consumer_secret') + config.oauth_token = @config.get('beef.extension.notifications.twitter.oauth_token') + config.oauth_token_secret = @config.get('beef.extension.notifications.twitter.oauth_token_secret') + end + + Twitter.direct_message_create(username, message) + end + end + +end +end +end +end + diff --git a/extensions/notifications/config.yaml b/extensions/notifications/config.yaml index 05461d10c..14afd864e 100644 --- a/extensions/notifications/config.yaml +++ b/extensions/notifications/config.yaml @@ -20,9 +20,20 @@ beef: name: Notifications twitter: enable: true - consumer_token: consumer_token - consumer_secret: consumer_secret + consumer_key: your_app_consumer_key + consumer_secret: your_app_consumer_secret + oauth_token: your_twitter_access_token_for_this_app + oauth_token_secret: your_twitter_access_secret_for_this_app + target_username: your_twitter_username email: enable: false - address: nobody@nobody.com + from_address: your_email_address + to_address: where_to_send_notification + smtp_host: 127.0.0.1 + smtp_port: 25 + smtp_tls_enable: false + irc: + server: irc.freenode.net + channel: #random_beef_channel_foobar + diff --git a/extensions/notifications/extension.rb b/extensions/notifications/extension.rb index eef405305..d5c5c04c8 100644 --- a/extensions/notifications/extension.rb +++ b/extensions/notifications/extension.rb @@ -27,4 +27,4 @@ end end end -require 'extensions/notifications/handler' +require 'extensions/notifications/notifications' diff --git a/extensions/notifications/notifications.rb b/extensions/notifications/notifications.rb new file mode 100644 index 000000000..e4a447b3d --- /dev/null +++ b/extensions/notifications/notifications.rb @@ -0,0 +1,52 @@ +# +# 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. + +require 'extensions/notifications/channels/tweet' +require 'extensions/notifications/channels/email' + +module BeEF +module Extension +module Notifications + + # + # Notifications class + # + class Notifications + + def initialize(from, event, time_now, hb) + @config = BeEF::Core::Configuration.instance + if @config.get('beef.extension.notifications.enable') == false + # notifications are not enabled + return nil + else + @from = from + @event = event + @time_now = time_now + @hb = hb + end + + username = @config.get('beef.extension.notifications.twitter.target_username') + to_address = @config.get('beef.extension.notifications.email.to_address') + message = "#{from} #{event} #{time_now} #{hb}" + + BeEF::Extension::Notifications::Channels::Tweet.new(username,message) + BeEF::Extension::Notifications::Channels::Email.new(to_address,message) + end + + end + +end +end +end From 1a6bf75d5770a15bce0db47ed987bd7eb7093bd1 Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Thu, 2 Aug 2012 11:50:05 +0100 Subject: [PATCH 03/11] remove now redundant handlers directory --- extensions/notifications/handlers/twitter.rb | 43 -------------------- 1 file changed, 43 deletions(-) delete mode 100644 extensions/notifications/handlers/twitter.rb diff --git a/extensions/notifications/handlers/twitter.rb b/extensions/notifications/handlers/twitter.rb deleted file mode 100644 index 244f8addf..000000000 --- a/extensions/notifications/handlers/twitter.rb +++ /dev/null @@ -1,43 +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. -# -# -# Generic Http Handler that extensions can use to register http -# controllers into the framework. -# -module BeEF -module Extension -module Notifications -module Handlers - - class Twitter - - # - # Constructor - # - def initialize - # configure the Twitter client - Twitter.configure do |config| - config.consumer_key = '' - config.consumer_secret = '' - end - end - - end - -end -end -end -end From 82dc6fee0d3d2d4c46cc68968b0c3823b137344a Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Thu, 2 Aug 2012 11:51:14 +0100 Subject: [PATCH 04/11] remove now redundant handler --- extensions/notifications/handler.rb | 43 ----------------------------- 1 file changed, 43 deletions(-) delete mode 100644 extensions/notifications/handler.rb diff --git a/extensions/notifications/handler.rb b/extensions/notifications/handler.rb deleted file mode 100644 index 9611d7813..000000000 --- a/extensions/notifications/handler.rb +++ /dev/null @@ -1,43 +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 Extension -module Notifications - - # - # The handler for notifications - # - class Handler - - def initialize - @config = BeEF::Core::Configuration.instance.get('beef.extension.notifications') - @config.inspect - - if @config.enable = false - # notifications are not enabled - return nil - end - end - - def new(from, event, time_now, hb) - print_info "#{from}:#{event}:#{time_now}:#{hb}" - end - - end - -end -end -end From 45c9f674e44cd84a7b03c140bc6198b5b21c0fbb Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Fri, 3 Aug 2012 22:00:54 +0100 Subject: [PATCH 05/11] remove IRC config, might get around to this one day --- extensions/notifications/config.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/extensions/notifications/config.yaml b/extensions/notifications/config.yaml index 14afd864e..e3957dab8 100644 --- a/extensions/notifications/config.yaml +++ b/extensions/notifications/config.yaml @@ -32,8 +32,3 @@ beef: smtp_host: 127.0.0.1 smtp_port: 25 smtp_tls_enable: false - irc: - server: irc.freenode.net - channel: #random_beef_channel_foobar - - From bd4b28ae3cd1e3a1ea17b4803a2dcb3aaf1997e9 Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Fri, 3 Aug 2012 22:04:28 +0100 Subject: [PATCH 06/11] turn off debugging in committed version --- config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 80a9bb0d1..ff55c7b43 100644 --- a/config.yaml +++ b/config.yaml @@ -17,7 +17,7 @@ beef: version: '0.4.3.6-alpha' - debug: true + debug: false restrictions: # subnet of browser ip addresses that can hook to the framework From 192eb9706d0e4606ef90e45e7c2c980d6e39baa7 Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Fri, 3 Aug 2012 22:14:20 +0100 Subject: [PATCH 07/11] disable twitter and email notifications by default --- extensions/notifications/config.yaml | 12 ++++++------ extensions/notifications/notifications.rb | 13 +++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/extensions/notifications/config.yaml b/extensions/notifications/config.yaml index e3957dab8..bac1a0318 100644 --- a/extensions/notifications/config.yaml +++ b/extensions/notifications/config.yaml @@ -19,12 +19,12 @@ beef: enable: true name: Notifications twitter: - enable: true - consumer_key: your_app_consumer_key - consumer_secret: your_app_consumer_secret - oauth_token: your_twitter_access_token_for_this_app - oauth_token_secret: your_twitter_access_secret_for_this_app - target_username: your_twitter_username + enable: false + consumer_key: consumer_key + consumer_secret: consumer_secret + oauth_token: oauth_token_for_this_app + oauth_token_secret: oauth_token_secret_for_this_app + target_username: twitter_handle_to_receive_tweet email: enable: false from_address: your_email_address diff --git a/extensions/notifications/notifications.rb b/extensions/notifications/notifications.rb index e4a447b3d..b9e5cbb94 100644 --- a/extensions/notifications/notifications.rb +++ b/extensions/notifications/notifications.rb @@ -37,12 +37,17 @@ module Notifications @hb = hb end - username = @config.get('beef.extension.notifications.twitter.target_username') - to_address = @config.get('beef.extension.notifications.email.to_address') message = "#{from} #{event} #{time_now} #{hb}" - BeEF::Extension::Notifications::Channels::Tweet.new(username,message) - BeEF::Extension::Notifications::Channels::Email.new(to_address,message) + if @config.get('beef.extension.notifications.twitter.enable') == true + username = @config.get('beef.extension.notifications.twitter.target_username') + BeEF::Extension::Notifications::Channels::Tweet.new(username,message) + end + + if @config.get('beef.extension.notifications.email.enable') == true + to_address = @config.get('beef.extension.notifications.email.to_address') + BeEF::Extension::Notifications::Channels::Email.new(to_address,message) + end end end From 0cec6b87a826dee2853263ca9944f76999611c3d Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Fri, 3 Aug 2012 23:13:58 +0100 Subject: [PATCH 08/11] fixed disabling of notifications extension --- core/main/logger.rb | 9 +++++++-- extensions/metasploit/.rpcclient.rb.swp | Bin 16384 -> 0 bytes extensions/notifications/config.yaml | 17 ++++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 extensions/metasploit/.rpcclient.rb.swp diff --git a/core/main/logger.rb b/core/main/logger.rb index dbbb376c2..623b17ba1 100644 --- a/core/main/logger.rb +++ b/core/main/logger.rb @@ -24,7 +24,10 @@ module Core # Constructor def initialize @logs = BeEF::Core::Models::Log - @notifications = BeEF::Extension::Notifications::Notifications + @config = BeEF::Core::Configuration.instance + + # if notifications are enabled create a new instance + @notifications = BeEF::Extension::Notifications::Notifications unless @config.get('beef.extension.notifications.enable') == false end # Registers a new event in the logs @@ -48,7 +51,9 @@ module Core @logs.new(:type => "#{from}", :event => "#{event}", :date => time_now, :hooked_browser_id => hb).save # if notifications are enabled send the info there too - @notifications.new(from, event, time_now, hb) + if @notifications + @notifications.new(from, event, time_now, hb) + end # return true diff --git a/extensions/metasploit/.rpcclient.rb.swp b/extensions/metasploit/.rpcclient.rb.swp deleted file mode 100644 index 9449db26428d79cdb0291e65f50f3058ef0c022c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI2ON<;x8OI9;hzBrnFmFrnc{X;>#^av#hQzS;+Fq~M@e+I2+8KLsHmg-nPt8o@ zp6;d}9xt}V;{Y+XkRVcmIB*ItZ^Z!{dL#ZT^~C)dzucI;{w}uA@*&3WB%sOd&S9;5TWnKTztFj zz|6kWR%qX@ny4I?7p3b59qGjtzuA;t zVB4;PW6ZFA+dlFNxdOQYn<=nOJTSh0Y^1o0cD(QGW|i{tT!CDHT!CDHT!CDHT!CDH zT!CDH|5F9xV2k({#FgOSdum{`&e(@e5ehxkXUU|0=7r<8Vy>|(59b5(%!K2_|upjIO ze=7*_8}NN_4J?6&!4wz=qu@TU4ZOZph~I)2!1Lg{;5zsMXoJT<4SWjh0z1Gqa5vZj z{&BYue*v$7SHO?J)8INd56*%UU^n>PJB4@=JP&>bnxGCo4W_{!@GxDRXxufrE!1y6%-f*ar(=m7SU&w$%*q_#q#(30_r>)RJf zqoPn~$R-8Ws_R>g6+ejiRgaQqbtLb@f9W;ww-Cx`$>{iv#Fde;oR-8%=+Wh?u96}_W3Gdoh_7_ybFT!Cf% zL+`v}ErC%sz2yBb!%+D6IiiRcjZb?kvp;{tG)45zIB5fuj#*8 zZM2Xpe5|%d6o`7B6`PSC#2L1N64tuL%$p0y(PE| zs>4?!Q(AVL8a`d=T;Vc?51*tZ<-%MCKi2rRuEoy1w0wK#R&8$V#CqVHIdSSy{lDm# zPewhCmF#GEH`l>lEkPV6QWbGAZ#=4@6Duv|fgE+MD7KQgjd9kTjx;^L%jHZEI$o@1 zg^X%q+cJupiA%QcdD7-UKwSq1p69m%N1YTn-Q<-`tffXUjWuYhSWrMKk`Yp%nnKDA^H$haN`Y+1~ ztwvuaOof_4HQPP$FcD6A5@bifRbhAkG+`+{$3+>2VJDJiF4_^tf%wk`aSZ82k#xw2!Wb+;h^wqdfhI7=G2UThfp9%Y%c96# zxhO+^tC7olvp!JH?$EEjw${MjBy@)M;y3o<>SI)_z^NEnD*+eJXp-fWwvw3xzZWp(t(qoXPouQHr_ipp%9Biwv#{C&K#G) zy)q}{pM%>mIdfuSV%iTS|K$@a3327}J%ngPAkUU&B;%67ZZI0|q2wxj*CahZX|;zAM%x?L9uer4a!xl+@M@V z%+XPyoG}#&zIg{zhLidhPSLylBjO0avN%c??nqzzsp@zwSH?bvH&L+R^bsut_OyCK znGVs!#ObIxF|lxF8m_4d1$;fdnH|tKE1Ah&dCm%W6k6ByRC247@DpiS#R=<$o6zX>rNZV;THo2D9O01TomJb*5U_9Y+)Nvy9nl)L7yWG{{ zZ0+Ry*%~cQEi6pU)n;d^G`~R8^K-{%YqRrn_;rG&=FZb2vvbGGBypvNHMnPh+o}6- zrxReTjnt@y6UCuZPh#0vZ#TQ*U-kTySCz))FTCp3xfv|~1h1|*D~z(Cv@lB2 z!+N!clX)8+F_a)Fp0KcnQmZ@HN<3uOk*xKDuJ@Q%OpVwiF$q&P%aKbP%Thd3u#!s- zmSf>6z9S=xwQ-ixU(uZyc3m$|1Uqq=bJ%=|*lSiV{*(q2wIp)ec7vT81yKizCmFQS$BlC$hQ zz`>mnme^`9(n7kI>M0}?xgyt_q+(Hso{(!iCN1Z>S;yMV-n8S)q)*e3+*1z3S&@;; z`Vq%f`Y*VTZp$d^FL&lE1M{knE3G{qqhCAE>z{mXtRM@wnd4(J_*pBQT|cYK9yI Date: Fri, 3 Aug 2012 23:15:43 +0100 Subject: [PATCH 09/11] remove Gemfile.lock from commit --- Gemfile.lock | 76 ---------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index cddca4f41..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,76 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - addressable (2.2.8) - ansi (1.4.2) - daemons (1.1.8) - data_objects (0.10.8) - addressable (~> 2.1) - dm-core (1.2.0) - addressable (~> 2.2.6) - dm-do-adapter (1.2.0) - data_objects (~> 0.10.6) - dm-core (~> 1.2.0) - dm-migrations (1.2.0) - dm-core (~> 1.2.0) - dm-sqlite-adapter (1.2.0) - dm-do-adapter (~> 1.2.0) - do_sqlite3 (~> 0.10.6) - do_sqlite3 (0.10.8) - data_objects (= 0.10.8) - em-websocket (0.3.6) - addressable (>= 2.1.1) - eventmachine (>= 0.12.9) - erubis (2.7.0) - eventmachine (0.12.10) - faraday (0.8.1) - multipart-post (~> 1.1) - jsmin (1.0.1) - json (1.7.3) - librex (0.0.65) - msfrpc-client (1.0.1) - librex (>= 0.0.32) - msgpack (>= 0.4.5) - msgpack (0.4.7) - multi_json (1.3.6) - multipart-post (1.1.5) - parseconfig (1.0.2) - rack (1.4.1) - rack-protection (1.2.0) - rack - simple_oauth (0.1.8) - sinatra (1.3.2) - rack (~> 1.3, >= 1.3.6) - rack-protection (~> 1.2) - tilt (~> 1.3, >= 1.3.3) - term-ansicolor (1.0.7) - thin (1.3.1) - daemons (>= 1.0.9) - eventmachine (>= 0.12.6) - rack (>= 1.0.0) - tilt (1.3.3) - twitter (3.3.1) - faraday (~> 0.8) - multi_json (~> 1.3) - simple_oauth (~> 0.1.6) - -PLATFORMS - ruby - -DEPENDENCIES - ansi - data_objects - dm-core - dm-migrations - dm-sqlite-adapter - em-websocket (~> 0.3.6) - erubis - eventmachine (= 0.12.10) - jsmin (~> 1.0.1) - json - msfrpc-client - parseconfig - sinatra (= 1.3.2) - term-ansicolor - thin - twitter From 35049466360b988acaf83e91977bc5c4eabd2b97 Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Fri, 3 Aug 2012 23:29:24 +0100 Subject: [PATCH 10/11] disable console in commited version --- config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index ff55c7b43..7b05f0f76 100644 --- a/config.yaml +++ b/config.yaml @@ -85,6 +85,6 @@ beef: enable: false console: shell: - enable: true + enable: false evasion: enable: false From 2ad1ba4fbfab65f6d42e98769f208788b99bd033 Mon Sep 17 00:00:00 2001 From: Marc Wickenden Date: Fri, 3 Aug 2012 23:59:32 +0100 Subject: [PATCH 11/11] remove superfluous notifications.rb --- core/main/notifications.rb | 55 -------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 core/main/notifications.rb diff --git a/core/main/notifications.rb b/core/main/notifications.rb deleted file mode 100644 index 6a99c2d19..000000000 --- a/core/main/notifications.rb +++ /dev/null @@ -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 - - class Notifications - - include Singleton - - # Constructor - def initialize - @notifications = BeEF::Core::Models::Notifications - end - - # Registers a new event in the logs - # @param [String] from The origin of the event (i.e. Authentication, Hooked Browser) - # @param [String] event The event description - # @param [Integer] hb The id of the hooked browser affected (default = 0 if no HB) - # @return [Boolean] True if the register was successful - def register(from, event, hb = 0) - # type conversion to enforce standards - hb = hb.to_i - - # arguments type checking - raise Exception::TypeError, '"from" needs to be a string' if not from.string? - raise Exception::TypeError, '"event" needs to be a string' if not event.string? - raise Exception::TypeError, '"Hooked Browser ID" needs to be an integer' if not hb.integer? - - # logging the new event into the database - @logs.new(:type => "#{from}", :event => "#{event}", :date => Time.now, :hooked_browser_id => hb).save - - # return - true - end - - private - @logs - - end -end -end