未加星标

Automating Red Team Homelabs: Part 1 Kali Automation

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏

Homelab infrastructure got you down? Well, not anymore! This is the first post of a 3-part series that will talk about how to automate your home lab, from your kali box to all your vulnerable and domain-joined test vms. It will teach you how to keep your infrastructure dynamic, idempotent , and resilient (a necessity for when you crash all those services during exploitation). You can even take these practices to your pentesting job, because all the tools that will be included in these posts can be used with public cloud infrastructure as well!

Starting with the basics

To start out, we will need something to do pentesting with, and as anyone in security knows that usually means we start out with kali (except for web applications, then it is SamuraiWTF ). As you scour the web there are countless videos on how to install kali, and normally they include the process of updating your system (i.e. apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y), but it becomes difficult to regularly maintain (I like at least monthly updates). Depending on your Internet connection, how many packages you have to install, computer quality, etc.. it could take a long time. When a repetitive task takes me more than a total of 10 minutes, my answer is to always script it! Wait…script an installation? Why yes, script an installation…in a way.

Tools

We have our great friends at Hashicorp to thank for the majority of these tools to help automate our installation process. These tools were originally designed for devops engineers, but why not have the devops community support tools the red team community can use to attack them faster than before? Tons of people use these tools in the devops community for production environments, so these tools should be here for the foreseeable future.

For this blog post, we will go over the tools packer and vagrant , and then I will give you links for things to play with for the next post. Packer is used for “scripting” the installation process (from iso to ova), while vagrant is the ecosystem we are putting our kali image into and pulling down from the vagrant cloud.

Process

Here is what it would look like.


Automating Red Team Homelabs: Part 1   Kali Automation
packer vagrant ecosystem

You build your customized kali linux image with packer, fully up to date with all of the latest tools you want, and after you are done provisioning, you would push the image up to vagrant cloud . Once there is a new image available on vagrant cloud for your kali machine, you will get a message that notifies you the next time you start your virtual machine (vagrant checks every time you start a vm to see if there is an updated one so you can be notified if there is). When you get the notification, you would run the box update command to pull down the new image, while still using the one you have downloaded. Then once the new image is downloaded, you can destroy the one you are currently using and use the freshly updated kali box.

Resources

When dealing with vagrant boxes it is best not to reinvent the wheel, so vagrant cloud is amazing. Some common vagrant boxes that have been created are made are ubuntu (from canonical), hashicorp (the people who created these tools), and bento (made and maintained by chef). We aren’t getting into the nitty gritty of things this time, but we will get acquainted with the tools first. Naturally for any technical blog, good documentation is king, packer and vagrant aren’t exceptions. They are extremely well documented! So if you have any questions that I don’t address in the documentation on my github repo , then checkout their documentation. If you have further questions, submit an issue on github to me. I will be more than happy to help!

I know I am a hands on learner, so before we wrap this up I am going to give you some basic commands you can use to play with vagrant. Once we have a box we like (*cough**cough*…like the one I built , and will show you how to build), then we will initialize the vagrant environment.

…till next time

CAUTION: When dealing with vagrant and pulling down vms, or creating development environments, it can get out of hand quickly…your Vagrantfiles will be everywhere! So, initially, I would have a centralized location where you put all your Vagrantfiles (which is created when you initialize your environment). Also, these are boxes built by other people, so be sure to inspect their source code before installing them on your machine(s). We don’t want another docker incident. This is why I am showing you how to build your own.

So once you install vagrant and virtualbox, run these two commands:

$ vagrant plugin install vagrant-vbguest $ vagrant init elrey741/kali-linux_amd64
The first command will install a plugin to manage the virtualbox guest additions installed in the vagrant box you download, if it has a different version. The second will prepare you to download the box while giving you a message that says something like this: 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.
So far we have the following directory structure: /home/$USER/vagrant └── blog_post └── Vagrantfile
From here, check out the Vagrantfile that was created. This is what vagrant uses to control your vm, and you can do more configuration to your vm through this file. You would want to do this to ensure that if you destroy the box then it will still have the same configuration the next time you start up the vm. So let’s provision this box a bit. In the Vagrantfile there should be a line that looks like this: # config.vm.provision "shell", inline: <<-SHELL Edit the line to m

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

tags: vagrant,your,will,tools
分页:12
转载请注明
本文标题:Automating Red Team Homelabs: Part 1 Kali Automation
本站链接:https://www.codesec.net/view/597029.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(12)