zoukankan      html  css  js  c++  java
  • TB5上正常使用msfconsole

    在TB上使用系统自带的msfconsole,给出以下错误

    [-] Failed to connect to the database: could not connect to server: Connection refused

    Is the server running on host "127.0.0.1" and accepting

    TCP/IP connections on port 7175?

     {"adapter"=>"postgresql", "database"=>"msf3", "username"=>"msf3", "password"=>"6c7159f1", "host"=>"127.0.0.1", "port"=>7175, "pool"=>75, "timeout"=>5} 

    我们可以分析msfconsole需要连接一个数据库,并且需要用7175端口连接数据库。

    Metasploit默认使用的数据库是postgresql ,可是TB5没有安装,所以我们需要安装

    执行命令

    aptitude install postgresql

    安装完成后系统会自动启动postgresql数据库,

    root@bt:~# netstat -atpn
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      818/sshd
    tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      3299/postgres
    tcp        0      0 0.0.0.0:38158           0.0.0.0:*               LISTEN      676/rpc.statd
    tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      627/portmap
    tcp        0      0 172.20.5.191:22         172.20.5.62:2149        ESTABLISHED 3800/3
    tcp6       0      0 :::22                   :::*                    LISTEN      818/sshd
    tcp6       0      0 ::1:5432                :::*                    LISTEN      3299/postgres
    我们可以看到postgresql默认使用的端口是5432,那么我们需要修改Metasploit连接数据库的端口,

    查看文件 /opt/framework3/config/database.yml

    production:
      adapter: postgresql
      database: msf3
      username: postgres  
      password: postgres
      host: 127.0.0.1
      port: 5432
      pool: 75
      timeout: 5

    我现在修改这个文件为

    production:
      adapter: postgresql
      database: msf3
      username: testuser
      password: 123
      host: 127.0.0.1
      port: 5432
      pool: 75
      timeout: 5

    端口我使用了系统postgresql数据库自带的端口

    现在我们为postgresql创建用户testuser

    以下红色命令用postgress用户执行

    root@bt:~# su - postgres
    没有目录,将以 HOME=/ 登录
    postgres@bt:/$ createdb msfs
    postgres@bt:/$ createuser  -P  -d  -a -e testuser
    为新角色输入的口令:123
    再输入一遍:123
    CREATE ROLE testuser PASSWORD 'md5947984a8e0740c3a51289292f6fa1c15' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;

    好的用户创建完成,现在可以启动msfconsole

    root@bt:~# msfconsole
    注意:  CREATE TABLE 将为 serial 字段 "hosts.id" 创建隐含序列 "hosts_id_seq"
    注意:  CREATE TABLE / PRIMARY KEY 将要为表 "hosts" 创建隐含索引 "hosts_pkey"
    注意:  CREATE TABLE 将为 serial 字段 "clients.id" 创建隐含序列 "clients_id_seq"
    注意:  CREATE TABLE / PRIMARY KEY 将要为表 "clients" 创建隐含索引 "clients_pkey"

    .....................


           =[ metasploit v3.7.0-release [core:3.7 api:1.0]
    + -- --=[ 684 exploits - 355 auxiliary
    + -- --=[ 217 payloads - 27 encoders - 8 nops
           =[ svn r12536 updated 176 days ago (2011.05.04)

    Warning: This copy of the Metasploit Framework was last updated 176 days ago.
             We recommend that you update the framework at least every other day.
             For information on updating your copy of Metasploit, please see:
                 http://www.metasploit.com/redmine/projects/framework/wiki/Updating

    msf >

    成功进入

    msf > db_driver
    [*]    Active Driver: postgresql
    [*]        Available: postgresql, mysql

    当前数据库postgresql可以使用。
    msf > quit
    root@bt:~#

    退出,拜拜

  • 相关阅读:
    网络负载均衡LVS
    JS 模仿红绿灯(控制台)
    【转】wrk 压力测试的 lua脚本
    linux开机 自动挂载和启动jar包
    【转】jprofiler linux配置需要监听的程序的端口
    时间复杂度总结
    Windows Subsystem for Linux (WSL) 安装
    敬畏用户
    Golang语言HTTP客户端实践
    Groovy入门常用语法
  • 原文地址:https://www.cnblogs.com/h4ck0ne/p/5154678.html
Copyright © 2011-2022 走看看