Showing posts with label vmware. Show all posts
Showing posts with label vmware. Show all posts

Wednesday, March 30, 2011

Set up Windows, Figure out how to list network devices in Linux

On Monday, I met with Victor and leaned that there are 2 different ways to write the API. I'm going to use Victor's ether_shell way.

Made a new to-do list:

I. Windows set things up
II. Linux: Find how to list all the network card names
III. to-do 2/4: Windows/MacOS: Find code in Wireshark that a) communicates to the ethernet, b) gets the MAC addresses in those operating systems
IV. to-do 3/4: Read POSIX socket API document


I. Windows: set things up to test on it
  1. Install Windows XP virtual machine on my computer's VM Player (victor gave me its iso)
  2. Install Ruby http://rubyinstaller.org/
    • check "add ruby executables to your PATH"
    • check "associate .rb and .rbw files with this ruby installation"
  3. Install Git http://code.google.com/p/msysgit/downloads/list
    • select "rub git from the Windows command prompt"
    • select "checkout windows-style, commit unix-style line endings"
  4. Install wireshark
    • Ignore the popup that's about enabling promiscuous mode
  5. Download my github ethernet project (that is currently is a copy/paste of Victor's ether_shell), I just want to see if the rspec can run.
    • No. When I ran rspec ethernet_spec.rb I got:
      sh.exe": rspec: command not found
      So I did, like on Linux, gem install rspec, and then rspec worked!
  6. I tried to replicate pinging Wireshark based on this blog entry, but at the rake install step, I got an error as expected, since I haven't written anything that makes things work on Windows yet!
    rake aborted!
    undefined method `write' for #<Syck::Emitter:0x11efad0>
    c:/Ruby192/lib/ruby/1.9.1/psych/visitors/emitter.rb:17:in `end_document'
    c:/Ruby192/lib/ruby/1.9.1/psych/visitors/emitter.rb:17:in `visit_Psych_Nodes_Document'
    c:/Ruby192/lib/ruby/1.9.1/psych/visitors/visitor.rb:10:in `accept'
    c:/Ruby192/lib/ruby/1.9.1/psych/visitors/emitter.rb:10:in `block in visit_Psych_Nodes_Stream'
    c:/Ruby192/lib/ruby/1.9.1/psych/visitors/emitter.rb:10:in `each'
    c:/Ruby192/lib/ruby/1.9.1/psych/visitors/emitter.rb:10:in `visit_Psych_Nodes_Stream'
    c:/Ruby192/lib/ruby/1.9.1/psych/visitors/visitor.rb:11:in `accept'
    c:/Ruby192/lib/ruby/1.9.1/psych/nodes/node.rb:36:in `to_yaml'
    c:/Ruby192/lib/ruby/1.9.1/psych.rb:166:in `dump'
    c:/Ruby192/lib/ruby/1.9.1/psych/core_ext.rb:13:in `psych_to_yaml'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:706:in `node_export'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:706:in `add'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:706:in `encode_with'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:728:in `block (2 levels) in to_yaml'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:727:in `map'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:727:in `block in to_yaml'
    c:/Ruby192/lib/ruby/1.9.1/syck.rb:401:in `call'
    c:/Ruby192/lib/ruby/1.9.1/syck.rb:401:in `emit'
    c:/Ruby192/lib/ruby/1.9.1/syck.rb:401:in `quick_emit'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:726:in `to_yaml'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:78:in `block (2 levels) in write_package'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:73:in `block (3 levels) in add_gem_contents'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_writer.rb:83:in `new'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:67:in `block (2 levels) in add_gem_contents'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:65:in `wrap'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:65:in `block in add_gem_contents'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_writer.rb:113:in `add_file'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:63:in `add_gem_contents'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:31:in `open'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/package.rb:68:in `open'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:77:in `block in write_package'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:76:in `open'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:76:in `write_package'
    c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:39:in `build'
    c:/Ruby192/lib/ruby/gems/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/build_gem.rb:16:in `run'
    c:/Ruby192/lib/ruby/gems/1.9.1/gems/jeweler-1.5.2/lib/jeweler.rb:87:in `build_gem'
    c:/Ruby192/lib/ruby/gems/1.9.1/gems/jeweler-1.5.2/lib/jeweler/tasks.rb:84:in `block in define'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `call'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `each'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `execute'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
    c:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:602:in `each'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain'
    c:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:581:in `invoke'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `each'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
    c:/Ruby192/lib/ruby/1.9.1/rake.rb:1992:in `run'
    c:/Ruby192/bin/rake:31:in `<main>'
  7. I also got the DevKit from http://rubyinstaller.org/downloads, following these directions to set up: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit (I used this to "gem install rcov --platform=ruby", but it was not necessary since the next step covers it.)
  8. bundle install which results to installing a bunch of gems and saying "Your bundle is complete!"
  9. rake install
    Successfully built RubyGem
    ...
    ...
    ERROR: Error installing ./pkg/ethernet-0.0.0.gem:
                   ERROR: Failed to build gem native extension.

                   c:/Ruby192/bin/ruby.exe extconf.rb
    checking for a bunch of stuff ...
    This is because I haven't written the Windows parts of the gem yet! :D
  10. Continued in this blog
  11. to-do 4/4: read about MSDN

II. Linux: Find how to list all the network card names
I need to look into the system calls behind ifconfig to see how it lists all the network card device names.

  • http://linux.die.net/man/2/syscalls has system calls
  • I tried strace ifconfig 2> ifctrace.txt
  • Google for "sourcecode ifconfig", found a bsd version to-do 1/4: read it to figure out how linux list devices!

Sunday, February 13, 2011

6.858 lab set up - Install VMware Player, Change Keymap (to Dvorak) on VMware Ubuntu Terninal

Part 1. Setting up 6.858 (fall 2010 version) VMware Player

Yesterday at the College Hackathon, I was talking to dcluo about 6.858, the Computer Systems Security Class I took last semester. To my dismay, I realised that I have forgotten the details behind a lot of the cool tricks I learned from the 6.858. So I want to go through all the cool labs again.

6.858 Lab 1 - a more concise version of the detailed lab instructions!


1a. Install VMware Player if you are an MIT student, you can get VMware Player for free.
Can't click to open the "VMware-Player-3.1.3-324285.1386.bundle" to install it. Clicking just shows a blank gedit.
To install do:
        1. Move the bundle to Desktop
        2. Open a terminal, cd to Desktop
        3. chmod +x VMware-Pl[tab complete]
        4. sudo ./VMware-Player-3.1.3-324285.i386.bundle


1b. Or install Virtual Box, which is free. You will also need to follow these instructions so that you can convert the VMware image below to Virtual Box image.

2. Install the 6.858 2010 course image. Move the "vm-6858.vmwarevm" to your Desktop or somewhere. Open it, and click on "vm-6858.vmx" to start the VMware :)


3. Log in with username: httpd, password: 6858


4. VMware tips: press SHIFT+CTRL to get out of the VMware window
Optional: For those who want to change the keymap from Qwerty to Dvorak, please go down to see Part 2 of this post.



5. SSH into the VMware so that it's much easier to work with.
SSH into VM from host:
        1. In VMware terminal do: /sbin/ifconfig eth0
        2. look at the IP address of "inet addr," e.g. 172.16.197.128
        3. Open up terminal on your host machine
        4. ssh httpd@172.16.197.128
        5. password is 6858
        6. Now you are in!


6. Retrieve the lab files: git clone http://pdos.csail.mit.edu/6.858/lab-2010.git lab
It might take a while.
- ls
- cd lab
- ls again and you should see files:
bin.tar.gz           http.c      Makefile     zoobar     zook-exstack.conf
clean-env.sh         http.h      shellcode.S  zook.conf  zookfs.c
exploit-template.py  index.html  test.sh      zookd.c    zookld.c


7. Compile the web server: make


8. Now you're ready to start Part 1: Finding buffer overflows!


Part 2. Change Keymap (to Dvorak) on New VMware Ubuntu Terminal
I'll demonstrating switching the keymap from Qwerty to Dvorak (which I use exclusively on my laptop).
  1. First I tried "setxkbmap dvorak", that had an error that told me to install:
  2. sudo apt-get install x11-xkb-utils, in Dvorak it's oger aly[i.y cboyann q11[qtx[gycno
  3. When I typed "setxkbmap dvorak" again, it told me cannot open display "default display" Solution:
  4. sudo apt-get install console-data, in Dvorak it's oger aly[i.y cboyann jrborn.[eaya. If at this point you get a cannot open display "default display", do sudo loadkeys /usr/share/keymaps/i386/dvorak/dvorak, in Dvorak it's oger nraet.fo zgopzodap.zt.fmalozc386zekrpatzekrpat
  5. Choose "Select keymap from arch list"
  6. Choose "dvorak"
  7. Be happy typing in dvorak!