被动扫描框架Recon-ng

2017-08-03  本文已影响0人  linx255

目录

基础使用步骤

  1. 启动

recon-ng -h
recon-ng -w [name] #新建工作区
help

  1. 菜单

show modules

  1. 使用模块

search [modulename]
use [path]
show info
set ...
run

  1. 结果

show <tables> #show profiles

具体模块

  1. 侦查
  1. 发现
  1. 攻击

Search command_injector
Use path-to/command_injector
Show info #可以看到具体的参数
set base_url http://1.1.1.1/other/a.php
Set parameters cmd=<rce>
run

4.报告

自行构建模块

在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
#-*- 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

上一篇 下一篇

猜你喜欢

热点阅读