lost and found ( for me ? )

install virtualbox, vagrant on Ubuntu 14.04

Reference
https://docs.vagrantup.com/v2/

1. install virtualbox and vagrant over apt-get.

# apt-get install virtualbox

# apt-get install vagrant

# /etc/init.d/virtualbox status
VirtualBox kernel modules are loaded.

# lsmod | grep vbox
vboxpci                23194  0
vboxnetadp             25670  0
vboxnetflt             27613  0
vboxdrv               339502  3 vboxnetadp,vboxnetflt,vboxpci


# virtualbox --help
Oracle VM VirtualBox Manager 4.3.10_Ubuntu



# dpkg-query -L virtualbox
/.
/etc
/etc/default
/etc/default/virtualbox
/etc/init.d
/etc/init.d/virtualbox
/lib
/lib/udev
/lib/udev/rules.d
/lib/udev/rules.d/40-virtualbox.rules
/lib/udev/VBoxCreateUSBNode.sh

2.  add a box image

# vagrant box add centos7-64 https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
Downloading box from URL: https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
Extracting box...te: 3288k/s, Estimated time remaining: --:--:--)
Successfully added box 'centos7-64' with provider 'virtualbox'!



list a box

# vagrant box list
centos7-64 (virtualbox)


# vagrant box list -i
centos7-64 (virtualbox)
 - url: https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
 - downloaded_at: 2015-05-27 17:07:02 UTC

3.  set up a project

make a directory for the project and initialize an environment.
# mkdir vagrant_project01

# cd vagrant_project01/


root@ubuntu:~/vagrant_project01# vagrant init
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.


root@ubuntu:~/vagrant_project01# grep -v '#' Vagrantfile | grep -v ^$
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 config.vm.box = "base"
end

edit Vagrantfile to use the box ( CentOS7 ) which I added.
# grep -v '#' Vagrantfile | grep -v ^$
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 config.vm.box = "centos7-64"
end


4. start the VM and connect to that over SSH


start the VM
root@ubuntu:~/vagrant_project01# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'centos7-64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant



# ps aux | grep virtualbox | grep -v grep
root     12770  0.7  0.0 192456  6172 ?        S    02:23   0:01 /usr/lib/virtualbox/VBoxXPCOMIPCD
root     12776  6.7  0.1 652716 11888 ?        Sl   02:23   0:09 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
root     13240 12.1  0.9 1482056 73448 ?       Sl   02:24   0:15 /usr/lib/virtualbox/VBoxHeadless --comment vagrant_project01_default_1432747444617_66875 --startvm 3ecc3d2d-7fd8-4811-9565-40f23bf32e56 --vrde config

connect to the VM.
# vagrant ssh
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$ cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)
[vagrant@localhost ~]$


shutdown the VM.
# vagrant halt
[default] Attempting graceful shutdown of VM...

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 >

configure WIFI via /etc/network/interfaces on Ubuntu 14.04

Reference

Here are logs when configuring WIFI via /etc/network/interfaces.

PC model name : HP Pavilion Desktop PC e9360jp/CT
USB WIFI adapter : Buffalo WLI-UC-GNM

OS automatically recognized this USB adapter without installing a driver in my environment, which depends on a USB adapter and/or PC model.

Here is an output of “lsusb” after inserting the USB adapter on my PC.
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty

# uname -ri
3.13.0-48-generic x86_64

# lsusb
Bus 002 Device 005: ID 0bda:0152 Realtek Semiconductor Corp. Mass Storage Device
Bus 002 Device 004: ID 0411:01a2 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNM Wireless LAN Adapter [Ralink RT8070]
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

[ configure WIFI via /etc/network/interfaces ]

I have used WPA2-PSK for an authentication.

Before editing /etc/network/interfaces, generate a WPA PSK from an ASCII passphrase.
# wpa_passphrase essid password
network={
ssid="essid"
#psk="password"
psk=6b7a04357a1882e7dad358f1ec8f5e8440fbb21e1cc49a3f11e75776bded686d
}

Then edit /etc/network/interfaces
auto wlan0
iface wlan0 inet dhcp
   wpa-ssid essid
   wpa-psk 6b7a04357a1882e7dad358f1ec8f5e8440fbb21e1cc49a3f11e75776bded686d

Finally down and up wlan0 to obtain an IP from DHCP server.

# ifdown wlan0
# ifup wlan0