Coder Social home page Coder Social logo

Run custom box using mech about mech HOT 10 OPEN

mechboxes avatar mechboxes commented on June 15, 2024
Run custom box using mech

from mech.

Comments (10)

espoelstra avatar espoelstra commented on June 15, 2024 1

Looks like this project is currently lacking any unit or integration tests which makes trying to troubleshoot a game of cat and mouse and quite likely to lead to unintended side effects if any changes are made to how things work. I was really excited about having a Python alternative to Vagrant that doesn't cost a bunch of money, but not having any tests makes it very hard to recommend or even to try to contribute because I'll have no idea what I'm breaking when I try to fix things.

from mech.

Kronuz avatar Kronuz commented on June 15, 2024

I haven’t tried this too much, but I think you need to give it the name as well (during init). Create a new directory and inside it do:

mech init windows_2008_r2 /some/path/to/windows_2008_r2_vmware

Please let me know if this works.

from mech.

dynomite567 avatar dynomite567 commented on June 15, 2024

Hi, I have attempted this. I can say that this does not work, even with the --name option.

Simply put, the same output occurs:

$ mech init --name=metasploitable3-ub1404 /path/to/the/metasploitable3-ub1404-vmware.box
Initializing mech
A Mechfile has been initialized and placed in this directory. You
are now ready to mech up your first virtual environment!

$ mech up
Provided box name is not valid
Loading metadata for box 'metasploitable3-ub1404-vmware'
Bad response from HashiCorp's Vagrant Cloud API: 404 Client Error: Not Found for url: https://app.vagrantup.com/metasploitable3-ub1404-vmware/boxes/boxes

And for without the --name option,

$ mech init metasploitable3-ub1404 ~/mech/metasploitable3-ub1404-vmware.box
Initializing mech
A Mechfile has been initialized and placed in this directory. You
are now ready to mech up your first virtual environment!

$ mech up
Provided box name is not valid
Loading metadata for box 'metasploitable3-ub1404'
Bad response from HashiCorp's Vagrant Cloud API: 404 Client Error: Not Found for url: https://app.vagrantup.com/metasploitable3-ub1404/boxes/boxes

Here is the generated Mechfile (ran without --name):

$ cat Mechfile
{
  "box": "metasploitable3-ub1404",
  "file": "/path/to/the/metasploitable3-ub1404-vmware.box",
  "name": null
}

from mech.

espoelstra avatar espoelstra commented on June 15, 2024

You should use mech box add NAME PATH before attempting to mech init NAME. They have done a great job of keeping the CLI interface very similar to Vagrant for most operations.

See https://github.com/mechboxes/mech/blob/master/mech/mech.py#L206 for syntax or use mech box --help to see the options.

from mech.

espoelstra avatar espoelstra commented on June 15, 2024

It appears there is an issue with the tar syntax on Ubuntu 18.04, mech tries to use *.vmx but without --wildcards it gets interpreted as a filename and fails.

mech box add eval-win10 /projects/github/boxcutter-windows/box/vmware/eval-win10x64-enterprise-nocm-1.0.4.box
Checking box 'eval-win10' integrity...
tar: Pattern matching characters used in file names
tar: Use --wildcards to enable pattern matching, or --no-wildcards to suppress this warning
tar: *.vmx: Not found in archive
tar: Exiting with failure status due to previous errors

But a vmx file IS there.

tar --list -f /projects/github/boxcutter-windows/box/vmware/eval-win10x64-enterprise-nocm-1.0.4.box
Vagrantfile
disk-s001.vmdk
disk-s002.vmdk
disk-s003.vmdk
disk-s004.vmdk
disk-s005.vmdk
disk-s006.vmdk
disk-s007.vmdk
disk-s008.vmdk
disk-s009.vmdk
disk-s010.vmdk
disk-s011.vmdk
disk.vmdk
eval-win10x64-enterprise.nvram
eval-win10x64-enterprise.vmsd
eval-win10x64-enterprise.vmx
eval-win10x64-enterprise.vmxf
metadata.json

from mech.

espoelstra avatar espoelstra commented on June 15, 2024

It looks like this should be working from a glance at this function, but I haven't fully stepped through it yet. https://github.com/mechboxes/mech/blob/master/mech/utils.py#L324

from mech.

espoelstra avatar espoelstra commented on June 15, 2024

OK, it looks like the \b--wildcards\b isn't matching properly in the tar --help subprocess output, though removing the \b bits seems to have fixed it in my case and I was able to get the box properly added.

This was under Python 3.6.8 on Ubuntu 18.04 (using Pyenv to manage versions but that shouldn't matter in this case).

from mech.

espoelstra avatar espoelstra commented on June 15, 2024

Urrggggh, got the box added, but had to supply a path to the box again when doing mech init instead of just mech init JUST_ADDED_BOX_NAME so it was mech init NAME PATH, though I used the ~/.mech/boxes/NAME/FILENAME.box as the PATH, but it still won't let me mech up even though it successfully creates a Mechfile in the directory.

from mech.

espoelstra avatar espoelstra commented on June 15, 2024

So it looks like the trouble is related to local mech box add NOT properly going through the extraction of the VMX file and other bits to the ~/.mech/boxes/BOXNAME/ path so when trying to bring it up by name it doesn't have a VMX to reference and match against. If I find some more time I'll take a look deeper, but for now I'm off to manually start some VMs with vmrun.

from mech.

network-shark avatar network-shark commented on June 15, 2024

@espoelstra Do you have a pull request for this issue . I would try it :) . It seems that there is an issue with some freebsd images . I can't import them . Than I started to build my own box , but now I can't add it .... .

from mech.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.