lost and found ( for me ? )

Showing posts with label metasploit. Show all posts
Showing posts with label metasploit. Show all posts

run Kali Linux via vagrant and set up Metasploit

- run Kali Linux via vagrant

# vagrant init Sliim/kali-linux-2.0-amd64

# vagrant up

nnn, warning messages.
# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...

   default: Warning: Authentication failure. Retrying...
   default: Warning: Authentication failure. Retrying...
   default: Warning: Authentication failure. Retrying...
   default: Warning: Authentication failure. Retrying...
#

can not access, because I am not sure credentials..
# vagrant ssh
vagrant@127.0.0.1's password:
vagrant@127.0.0.1's password:
vagrant@127.0.0.1's password:
Permission denied (publickey,password).

stop VM
# vagrant halt

download a private key.
# wget https://raw.githubusercontent.com/Sliim/pentest-env/master/ssh-keys/pentest-env

edit Vagrant file
# egrep 'private_key|username' Vagrantfile
 config.ssh.username = "root"
 config.ssh.private_key_path = "/home/foobar/Vagrant_works/Kali_linux/pentest-env"

start VM
# vagrant up

access to the VM over ssh.
Okay, I was able to access to the VM over ssh.
# vagrant ssh

root@kali:~#

root@kali:~# cat /etc/lsb-release
DISTRIB_ID=Kali
DISTRIB_RELEASE=2.0
DISTRIB_CODENAME=sana
DISTRIB_DESCRIPTION="Kali GNU/Linux 2.0"

- set up Metasploit

Reference
http://docs.kali.org/general-use/starting-metasploit-framework-in-kali

root@kali:~# service postgresql start
root@kali:~#
root@kali:~# service postgresql status
● postgresql.service - PostgreSQL RDBMS
  Loaded: loaded (/lib/systemd/system/postgresql.service; disabled)
  Active: active (exited) since Wed 2016-05-25 08:50:35 EDT; 6s ago
 Process: 1297 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1297 (code=exited, status=0/SUCCESS)
root@kali:~#
root@kali:~# lsof -ni:5432
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
postgres 1280 postgres    6u  IPv6  18924      0t0  TCP [::1]:postgresql (LISTEN)
postgres 1280 postgres    7u  IPv4  18925      0t0  TCP 127.0.0.1:postgresql (LISTEN)
root@kali:~#

initialize DB
root@kali:~# msfdb init
Creating database user 'msf'
Enter password for new role:
Enter it again:
Creating databases 'msf' and 'msf_test'
Creating configuration file in /usr/share/metasploit-framework/config/database.yml
Creating initial database schema
root@kali:~#

root@kali:~# msfconsole

msf > db_status
[*] postgresql connected to msf
msf >

install metasploit on Ubuntu 14.04

Here are trial and error logs when installing metasploit on Ubuntu 14.04.

Reference
http://www.darkoperator.com/installing-metasploit-in-ubunt/

install required packages to run metasploit.
# apt-get install build-essential libreadline-dev libssl-dev libpq5 libpq-dev libreadline5 libsqlite3-dev libpcap-dev openjdk-7-jre git-core autoconf postgresql pgadmin3 curl zlib1g-dev libxml2-dev libxslt1-dev vncviewer libyaml-dev curl zlib1g-dev

install ruby 2.1.6
# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3


# curl -L https://get.rvm.io | bash -s stable

 * First you need to add all users that will be using rvm to 'rvm' group,
   and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.

 * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
   in all your open shell windows, in rare cases you need to reopen all shell windows.


# source /etc/profile.d/rvm.sh

install ruby 2.1.6. nn error..
# rvm install 2.1.6
Searching for binary rubies, this might take some time.
No binary rubies available for: ubuntu/14.04/x86_64/ruby-2.1.6.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating system..............
Error running 'requirements_debian_update_system ruby-2.1.6',
showing last 15 lines of /usr/local/rvm/log/1432608365_ruby-2.1.6/update_system.log
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ return 1
++ printf %b 'There has been error while updating '\''apt-get'\'', please give it some time and try again later.
404 errors should be fixed for rvm to proceed. Check your sources configured in:
   /etc/apt/sources.list
   /etc/apt/sources.list.d/*.list
\n'
There has been error while updating 'apt-get', please give it some time and try again later.
404 errors should be fixed for rvm to proceed. Check your sources configured in:
   /etc/apt/sources.list
   /etc/apt/sources.list.d/*.list

++ return 100
Requirements installation failed with status: 100.

Googling this error, this seems to be caused if there are failed links in apt repositories.

check failed links
# apt-get update  | grep –i failed
W: Failed to fetch http://ppa.launchpad.net/cjwatson/devirt/ubuntu/dists/vivid/main/source/Sources  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/cjwatson/devirt/ubuntu/dists/vivid/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/cjwatson/devirt/ubuntu/dists/vivid/main/binary-i386/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.

disable those repositories.
I disabled those by editing /etc/apt/sources.list

install ruby again.
# rvm install 2.1.6

# rvm use 2.1.6 --default
Using /usr/local/rvm/gems/ruby-2.1.6

# ruby -v
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux]

install nmap
# apt-get install -y nmap

configure postgreSQL

configure credentials for user ‘postgres’
# passwd postgresql

create a user and a table which are used for metasploit.
# sudo -s
# su postgres
$ createuser msf -P -S -R –D
$ createdb -O msf msf

install metasploit
# cd /opt/
# git clone https://github.com/rapid7/metasploit-framework.git

# cd metasploit-framework/
ruby-2.1.6 - #gemset created /usr/local/rvm/gems/ruby-2.1.6@metasploit-framework
ruby-2.1.6 - #generating metasploit-framework wrappers..........

# rvm --default use ruby-2.1.6@metasploit-framework
Using /usr/local/rvm/gems/ruby-2.1.6 with gemset metasploit-framework


# gem install bundler

# bundle install

configure metasploit so that any users can use metasploit.
# pwd
/opt/metasploit-framework

# bash -c 'for MSF in $(ls msf*); do ln -s /opt/metasploit-framework/$MSF  /usr/local/bin/$MSF;done'

DB settings so that metasploit can connect to PostgreSQL.
# vi /opt/metasploit-framework/config/database.yml

# cat /opt/metasploit-framework/config/database.yml
production:
adapter: postgresql
database: msf
username: msf
password:passowrd
host: 127.0.0.1
port: 5432
pool: 75
timeout: 5

# sh -c "echo export MSF_DATABASE_CONFIG=/opt/metasploit-framework/config/database.yml >> /etc/profile"

# source /etc/profile

run msfconsole
# ./msfconsole
[*] Starting the Metasploit Framework console...\
# cowsay++
____________
< metasploit >
------------
      \   ,__,
       \  (oo)____
          (__)    )\
             ||--|| *


      =[ metasploit v4.11.0-dev [core:4.11.0.pre.dev api:1.0.0]]
+ -- --=[ 1456 exploits - 833 auxiliary - 229 post        ]
+ -- --=[ 382 payloads - 37 encoders - 8 nops             ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

msf >

how to install / uninstall metasploint on Linux Mint

Here’s an explanation of how to install / uninstall metasploit.

[ install metasploit ]


# lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description:    Linux Mint 12 Lisa
Release:        12
Codename:       lisa

# uname -ri
3.5.0-21-generic x86_64


download metasploit

for 32bit ver.
# wget http://downloads.metasploit.com/data/releases/metasploit-latest-linux-installer.run


for 64bit ver.
# wget http://downloads.metasploit.com/data/releases/metasploit-latest-
linux-x64-installer.run

chmod u+x metasploit-latest-linux-x64-installer.run


install.
the installation is very easy , just press enter , enter …
# ./metasploit-latest-linux-x64-installer.run
<snip>
Please wait while Setup installs Metasploit on your computer.

Installing
0% ______________ 50% ______________ 100%
#########################################

----------------------------------------------------------------------------
Setup has finished installing Metasploit on your computer.

Info: To access Metasploit, go to
       https://localhost:3790 from your browser.
Press [Enter] to continue :
#


By default , metasploit will be installed under /opt/metasploit-x.x.x/ directory

update the metasploit framework
# msfupdate
[*]
[*] Attempting to update the Metasploit Framework...
[*]

[*] No updates available


start metasploit
# msfconsole
      =[ metasploit v4.5.0-release [core:4.5 api:1.0]
+ -- --=[ 1000 exploits - 562 auxiliary - 164 post
+ -- --=[ 262 payloads - 28 encoders - 8 nops

msf >
msf > use <tab>
Display all 2020 possibilities? (y or n)
use auxiliary/admin/2wire/xslt_password_reset
use auxiliary/admin/backupexec/dump
use auxiliary/admin/backupexec/registry
use auxiliary/admin/cisco/cisco_secure_acs_bypass
use auxiliary/admin/cisco/vpn_3000_ftp_bypass
use auxiliary/admin/db2/db2rcmd
use auxiliary/admin/edirectory/edirectory_dhost_cook
<snip>


[ uninstall metasploit ]

how to uninstall metasploit
# /opt/metasploit-4.5.0/uninstall
Do you want to uninstall Metasploit and all of its modules? [Y/n]: y

----------------------------------------------------------------------------
Uninstall Status

Uninstalling Metasploit
0% ______________ 50% ______________ 100%
#########################################

Info: Uninstallation completed
Press [Enter] to continue :
#