From 0dcadb6f00cee08759cdac1bdebe6685457bee6c Mon Sep 17 00:00:00 2001 From: Mike McCabe Date: Thu, 18 Sep 2014 18:53:30 -0600 Subject: [PATCH 1/3] adding vagrant and docker files --- Dockerfile | 12 ++++++++++++ Vagrantfile | 13 +++++++++++++ Vagrantfile.proxy | 10 ++++++++++ script/start | 5 +++++ 4 files changed, 40 insertions(+) create mode 100644 Dockerfile create mode 100644 Vagrantfile create mode 100644 Vagrantfile.proxy create mode 100644 script/start diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..686cbae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM rails:onbuild +MAINTAINER mccabe615 + +ADD script/start /start + +RUN chmod a+x /start + +user root + +ENV RAILS_ENV development + +CMD /start diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..4c9b21a --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,13 @@ +VAGRANTFILE_API_VERSION = "2" +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.define "web" do |web| + web.vm.provider "docker" do |d| + config.vm.box = "hashicorp/precise64" + d.image = "mccabe615/railsgoat" + d.name = "web" + d.ports = ["3000:3000"] + d.vagrant_vagrantfile = "./Vagrantfile.proxy" + end + end + +end diff --git a/Vagrantfile.proxy b/Vagrantfile.proxy new file mode 100644 index 0000000..ac72dfc --- /dev/null +++ b/Vagrantfile.proxy @@ -0,0 +1,10 @@ +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.box = "hashicorp/precise64" + config.vm.provision "docker" + config.vm.provision "shell", inline: + "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill" + + config.vm.network :forwarded_port, guest: 3000, host: 3000 +end diff --git a/script/start b/script/start new file mode 100644 index 0000000..1e5761c --- /dev/null +++ b/script/start @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +rake db:setup +rails server From 1e81b43a0cae3e9dcfbb733b6bc7566912b496d1 Mon Sep 17 00:00:00 2001 From: Mike McCabe Date: Fri, 19 Sep 2014 16:13:05 -0600 Subject: [PATCH 2/3] modifying vagrantfile to specify provider --- Vagrantfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 4c9b21a..b526aa9 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,10 +1,10 @@ VAGRANTFILE_API_VERSION = "2" +ENV['VAGRANT_DEFAULT_PROVIDER'] ||= 'docker' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.define "web" do |web| - web.vm.provider "docker" do |d| - config.vm.box = "hashicorp/precise64" + config.vm.define "railsgoat" do |rg| + rg.vm.provider "docker" do |d| d.image = "mccabe615/railsgoat" - d.name = "web" + d.name = "railsgoat" d.ports = ["3000:3000"] d.vagrant_vagrantfile = "./Vagrantfile.proxy" end From 1466c696162e8799b703b429e3813db946eaf493 Mon Sep 17 00:00:00 2001 From: Mike McCabe Date: Sun, 21 Sep 2014 14:34:00 -0400 Subject: [PATCH 3/3] Update README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 5a48e4c..24bf2ce 100755 --- a/README.md +++ b/README.md @@ -42,6 +42,25 @@ $ rails server Open your favorite browser, navigate to `http://localhost:3000` and start hacking! +## Vagrant Install + +To run Railsgoat with Vagrant you must first have [Vagrant](https://www.vagrantup.com/) and [Virtualbox](https://www.virtualbox.org/) installed. Once those dependencies are installed cd into the Railsgoat directory where you've cloned the code and run. + +``` +#~/code/railsgoat +$ vagrant up +... + railsgoat: Port: 3000:3000 + railsgoat: + railsgoat: Container created: 3084633a81675346 +==> railsgoat: Starting container... +==> railsgoat: Provisioners will not be run since container doesn't support SSH. +$ +``` +Once you see the preceeding message Railsgoat is running on your localhost on port 3000. + +Open your favorite browser, navigate to `http://localhost:3000` and start hacking! + ## Capybara Tests RailsGoat now includes a set of failing Capybara RSpecs, each one indicating that a separate vulnerability exists in the application. To run them, you first need to install [PhantomJS](https://github.com/jonleighton/poltergeist#installing-phantomjs), which is required by the Poltergeist Capybara driver. Upon installation, simply run the following rake task: