From b337f31f79fef016ea15d656ebdb9455a5a85f4d Mon Sep 17 00:00:00 2001 From: xntrik Date: Sat, 12 Mar 2011 09:31:35 +0000 Subject: [PATCH] issue 246 : deleting duplicate UI functionality git-svn-id: https://beef.googlecode.com/svn/trunk@789 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- lib/ui/zombies/zombies.rb | 104 -------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 lib/ui/zombies/zombies.rb diff --git a/lib/ui/zombies/zombies.rb b/lib/ui/zombies/zombies.rb deleted file mode 100644 index 2cbc34a48..000000000 --- a/lib/ui/zombies/zombies.rb +++ /dev/null @@ -1,104 +0,0 @@ -=begin -module BeEF -module UI - -# -# -# -class Zombies < BeEF::HttpController - - def initialize - super({ - 'paths' => { - '/select/all/complete.json' => method(:select_all), - '/select/online/complete.json' => method(:select_online), - '/select/offline/complete.json' => method(:select_offline), - - '/select/online/simple.json' => method(:select_online_simple), - '/select/all/simple.json' => method(:select_all_simple), - '/select/offline/simple.json' => method(:select_offline_simple) - } - }) - end - - # Selects all the zombies and returns them in a JSON array. - def select_all; @body = zombies2json(BeEF::Models::Zombie.all); end - - # Selects all the zombies (IPs only) and returns them in JSON format - def select_all_simple; @body = zombies2json_simple(BeEF::Models::Zombie.all); end - - # Selects all online zombies and returns them in a JSON array. - def select_online; @body = zombies2json(BeEF::Models::Zombie.all(:lastseen.gte => (Time.new.to_i - 30))); end - - # Selects all online zombies (IPs only) and returns them in a JSON array - def select_online_simple; @body = zombies2json_simple(BeEF::Models::Zombie.all(:lastseen.gte => (Time.new.to_i - 30))); end - - # Selects all the offline zombies and returns them in a JSON array. - def select_offline; @body = zombies2json(BeEF::Models::Zombie.all(:lastseen.lt => (Time.new.to_i - 30))); end - - # Selects all the offline zombies (IPs only) and returns them in a JSON array. - def select_offline_simple; @body = zombies2json_simple(BeEF::Models::Zombie.all(:lastseen.lt => (Time.new.to_i - 30))); end - - private - - # Takes a list of zombies and format the results in a JSON array. - def zombies2json(zombies) - zombies_hash = {} - - zombies.each do |zombie| - - # create hash of zombie details - zombies_hash[zombie.session] = get_hooked_browser_hash(zombie) - - end - - zombies_hash.to_json - end - - # Takes a list of zombies and format the results in a JSON array. - def zombies2json_simple(zombies) - zombies_hash = {} - - zombies.each do |zombie| - - # create hash of zombie details - zombies_hash[zombie.session] = get_simple_hooked_browser_hash(zombie) - - end - - zombies_hash.to_json - end - - # create a hash of simple hooked browser details - def get_simple_hooked_browser_hash(hooked_browser) - - browser_icon = BeEF::Models::BrowserDetails.browser_icon(hooked_browser.session) - os_icon = BeEF::Models::BrowserDetails.os_icon(hooked_browser.session) - domain = BeEF::Models::BrowserDetails.get(hooked_browser.session, 'HostName') - - return { - 'session' => hooked_browser.session, - 'ip' => hooked_browser.ip, - 'domain' => domain, - 'browser_icon' => browser_icon, - 'os_icon' => os_icon - } - - end - - # create a hash of hooked browser details - def get_hooked_browser_hash(hooked_browser) - - hooked_browser_hash = get_simple_hooked_browser_hash(zombie) - return hooked_browser_hash.merge( { - 'lastseen' => zombie.lastseen, - 'httpheaders' => JSON.parse(zombie.httpheaders) - }) - - end - -end - -end -end -=end