信息收集工具recon-ng詳細使用教程


前言:

最近在找Recon-ng詳細一點的教程,可是Google才發現資料都很零散而且不詳細,所以我打算具體寫一下。Recon-ng在滲透過程中主要扮演信息收集工作的角色,同時也可以當作滲透工具,不過相關的攻擊模塊很少,只有自己擴展。其實Recon-ng最大的優點就是模塊化,功能可以自己任意擴展。只要想象力夠豐富,這個就可以成為神器,下面為詳細教程。

0×01 安裝

1. 安裝recon-ng及依賴文件:

 

git clone https://bitbucket.org/LaNMaSteR53/recon-ng.git #然后把其中的文件移動到你希望的目錄即可,並加入path即可

 

到其目錄下運行recon-ng文件即可

./recon-ng

#第一次啟動時你可能會被告知有什么依賴沒有安裝,根據提示把依賴安裝即可

根據提示安裝依賴文件 

pip install xlsxwriter #ie

#然后根據提示安裝完即可

0×02 模塊使用

1. 啟動部分

recon-ng -h

模塊啟動 

可以看到上面的具體參數,常用的就‘-w’參數,我們這里新開一個工作區ptest

Recon-ng -w ptest

輸入help可查看幫助,下面用法已解釋得很清楚.

具體用法 

2. 模塊

Recon-ng有偵查,發現,匯報,和攻擊四大塊(import沒發現有多大的用處,所以暫時為四大塊),可用show modules查看有哪些模塊。下面我具體介紹下各板塊下比較好用的模塊和具體用法。

好用的模塊和具體用法 

(1) 偵查版塊

Profiler模塊: 查詢某個用戶名在那些網站(知名)有注冊。

可用 search profiler 查詢在具體路徑

偵查板塊 

使用模塊:use recon/profiles-profiles/profiler

使用模塊 

查看用法:show info

查看用法 

根據提示,需要設置SOURCE選項,用命令:set SOURCE cesign

然后運行:run

運行 

查看結果(根據提示更新了profiles表,查看表的命令為show <tables>):show profiles

查看結果 

這是我的用戶名,上面的網站好像我只有注冊過兩個。這個腳本是可以擴展的,所以你可以擴展你想要查找的網站,關於模塊的創建后面解釋。

Hashes_org模塊:反查哈希加密

#這個模塊需要api key才能用,下面提一下api key的添加和刪除 Keys list #查看現有的api keys

Hashes_org模塊 

Keys add hashes_api akshdkahsdhkhasdkjfhkshfdkasdf
Keys list #可看到api已被添加進去

檢查 list 

Keys delete hashes_api  #刪除key #對於delete還可以刪除表,如刪除profiles的1-2行 Delete profiles 1-2#Api被添加進去后就可以用了(api的申請我就不介紹了) Set source e13dd027be0f2152ce387ac0ea83d863 Run #可以看到被解,加密i方式為md5 

解密方法  

Metacrawler模塊:網站文件搜索(如pdf,xlsx文件等,其實就是google hack技術)

Search metacrawler
Use recon/domains-contacts/metacrawler Set source hdu.edu.cn run

Dev_diver模塊:查找某個用戶是否存在某些代碼庫

Search dev_diver
Use path-to/dev_diver Show info Set source cesign  Run #結果如圖所示

Ipinfodb模塊:查詢ip的相關信息,如地理位置(這個功能要api)

Search ipinfodb
Use path-to/ipinfodb Show info Set source 104.238.148.9 run 

Ipinfodb模塊 

Brute_hosts模塊:暴力破解子域名

Search brute_hosts
Use path-to/brute_hosts Show info Set source hdu.edu.cn Run Show hosts 

Brute_hosts模塊: 

Google_site_web模塊:相關域名查詢(子域名)

Search google_site_web
Use path-to/google_site_web Show info Set source **** Run Show options:列出可用的選

(2)發現版塊

Interesting_files模塊:查找某網站的敏感文件

命令跟前面一樣

Search interesting_files Use discovery/info_disclosure/interesting_files Show info  #查看用法,可以看到參數比較多,含義我就不解釋了 

發現版塊 

我這里嘗試一下自己的網站(可以自己添加敏感文件)

Set source jwcesign.studio Set port 80 Set protocol http Run 

結果如下(沒有敏感文件)

未發現敏感文件 

(3)攻擊版塊

command_injector模塊:命令注入,多用於木馬文件

Search command_injector
Use path-to/command_injector Show info #可以看到具體的參數 set base_url http://172.16.227.128/other/a.php 

木馬文件a.php代碼如下:

木馬文件a.php代碼 

Set parameters cmd=<rce> run

木馬文件a.php代碼 

(4)報告版塊

Html模塊:把運行的結果生成html文件

Search html
Use path-to/html Show info Set creator cesign Set customer cesign run 

把運行的結果生成html文件 

0×03 模塊的構建

前面都是軟件自帶的模塊,如果我們想自己建立模塊,該怎么辦呢?

下面是教程

如果要建立自己的模塊,在home目錄下的’.recon-ng’下建立modules文件夾,然后在分別根據模塊屬性來建立文件,如建立偵查板塊,需要建立recon文件夾,下面以我建立一個模塊為例:

Cd ~ Cd .rcon-ng Mkdir modules Cd modules Mkdir recon Cd recon Mkdir findproxy Cd findproxy Vim find_proxy.py 

模塊文件主要的格式就是

from recon.core.module import BaseModule class Module(BaseModule): meta = { 'name''something...', 'author': ‘something...’, 'description''something...', 'query': something...'    ##這個最好寫清楚,方便別人查看用法 }         def mudule_run(self[,type]):         #some code,self參數可以用來獲取一些api key等, type含有source的數據         Pass

下面是我具體的代碼,這是一個找代理的模塊(http proxy,https proxy,socks4 proxy,sockts5 proxy )

#-*- coding: utf-8 -*- from recon.core.module import BaseModule import re from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from bs4 import BeautifulSoup import subprocess import os import urllib import copy import time import jsbeautifier   class Module(BaseModule): meta = { 'name': 'Find free proxy...', 'author': 'Cesign', 'description': 'find defferent proxy, there are four kinds of proxy,http,https,socks4 and socks5, and the code is h,s,4,5....Enjoy!!!', 'query': 'find defferent proxy, there are four kinds of proxy,http,https,socks4 and socks5, and the code is h,s,4,5....Enjoy!!!' }   def module_run(self,type): STYLE = {         'fore':         {   # 前景色             'black'    : 30,   #  黑色             'red'      : 31,   #  紅色             'green'    : 32,   #  綠色             'yellow'   : 33,   #  黃色             'blue'     : 34,   #  藍色             'purple'   : 35,   #  紫紅色             'cyan'     : 36,   #  青藍色             'white'    : 37,   #  白色         },           'back' :         {   # 背景             'black'     : 40,  #  黑色             'red'       : 41,  #  紅色             'green'     : 42,  #  綠色             'yellow'    : 43,  #  黃色             'blue'      : 44,  #  藍色             'purple'    : 45,  #  紫紅色             'cyan'      : 46,  #  青藍色             'white'     : 47,  #  白色         },           'mode' :         {   # 顯示模式             'mormal'    : 0,   #  終端默認設置             'bold'      : 1,   #  高亮顯示             'underline' : 4,   #  使用下划線             'blink'     : 5,   #  閃爍             'invert'    : 7,   #  反白顯示             'hide'      : 8,   #  不可見         },           'default' :         {             'end' : 0,         }, }     def UseStyle(string, mode = '', fore = '', back = ''):       mode  = '%s' % STYLE['mode'][mode] if STYLE['mode'].has_key(mode) else ''       fore  = '%s' % STYLE['fore'][fore] if STYLE['fore'].has_key(fore) else ''       back  = '%s' % STYLE['back'][back] if STYLE['back'].has_key(back) else ''       style = ';'.join([s for s in [mode, fore, back] if s])       style = '\033[%sm' % style if style else ''       end   = '\033[%sm' % STYLE['default']['end'] if style else ''       return '%s%s%s' % (style, string, end)   print '[*] Please wait, it will take about 2 minutes...' dcap = dict(DesiredCapabilities.PHANTOMJS) dcap["phantomjs.page.settings.userAgent"] = ( "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" ) driver = webdriver.PhantomJS(desired_capabilities=dcap,service_log_path=r"/home/cesign/watchlog.log") driver.set_window_size(1920, 1080)   driver.get('https://hidemy.name/en/proxy-list/?type='+str(type[0])+'#list') time.sleep(1)   soup=BeautifulSoup(driver.page_source,'html.parser') allurl=soup.find_all(name='td')   result={ 'h':lambda x:'http', 's':lambda x:'https', '4':lambda x:'socks4', '5':lambda x:'socks5', } i = 0 print UseStyle('[*] Search proxy: type:'+result[str(type[0])]('hello'),fore='blue') print UseStyle('[*] IP adress---Port---Country,City---Speed---Type---Anonymity---Last check',fore='blue') while True: try: part = [] part = allurl[i:i+7] i = i+7 print UseStyle('[*]'+part[0].text+'---'+part[1].text+'---'+part[2].text+'---'+part[3].text+'---'+part[4].text+'---'+part[5].text+'---'+part[6].text,fore='green') except: break driver.quit()   

然后調用模塊:

Reload
Search find_proxy
Use path-to/find_proxy Show info Set source h Run

實現匿名 

可以看到如此多的http代理,匿名做事就不成問題了

0×04 感言

這款軟件擴展性比較大,自帶的模塊功能有限。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM