{"id":763,"date":"2021-03-07T11:34:54","date_gmt":"2021-03-07T11:34:54","guid":{"rendered":"https:\/\/unordnung.net\/misc\/?p=763"},"modified":"2021-09-01T16:45:27","modified_gmt":"2021-09-01T14:45:27","slug":"using-kali-in-lxc-container-the-easy-way","status":"publish","type":"post","link":"https:\/\/unordnung.net\/misc\/2021\/03\/using-kali-in-lxc-container-the-easy-way\/","title":{"rendered":"Using kali in lxc container the easy way"},"content":{"rendered":"\n<p>I bought a refurbished thinkpad x260 and the bios locked with the seller can not supply the password. Since I need at least a seperated kali for pentesting and used virtual box until today, I would need virtualization enabled. Which wasn&#8217;t unfortunately. So I am exploring ways to use kali as a lxc container.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-medium\"><a href=\"https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_121807.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"300\" height=\"169\" src=\"https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_121807-300x169.png\" alt=\"screenshot of x2go kali lxc\" class=\"wp-image-764\" srcset=\"https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_121807-300x169.png 300w, https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_121807-1024x576.png 1024w, https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_121807-768x432.png 768w, https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_121807-1536x864.png 1536w, https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_121807.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption>UI elements not showing up etc.<\/figcaption><\/figure><\/div>\n\n\n\n<p>A lot of people tend to use their lxc kali through ssh. With either running single apps through -X or setting up a monitor, which seemed quite a hassle, so I avoided it for the time being. Being lazy. Also creates routing hassle. <\/p>\n\n\n\n<p>I also tend to use it in a seperate window like with a vm. So I looked into using x2go, which I enjoyed using for remote sessions. That works pretty easily, just installing the server in the container and connecting with the client. Unfortunately it produced too much overhead and had some grafic issues.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">lxc launch images:kali\/current\/amd64 testboxname<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Running X in lxc<\/h2>\n\n\n\n<p>After playing around with using ssh -X and not being happy with it, I decided to look into vnc. I don&#8217;t like vnc a lot, dunno was always working crappy. So looking for a vnc server to try in ubuntu&#8217;s repository, i stumbled upon xrdp. Which is a rdp server for linux. Give it a try I thought.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-medium\"><a href=\"https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_123008.png\"><img decoding=\"async\" src=\"https:\/\/unordnung.net\/misc\/wp-content\/uploads\/2021\/03\/Screenshot_20210307_123008-300x169.png\" alt=\"\" class=\"wp-image-765\"\/><\/a><figcaption>Smootly running kali lxc container, vm like in window &#8211;  with xrdp<\/figcaption><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo apt install xrdp<\/code><\/pre>\n\n\n\n<p>If complaining about missing dbus-launch, a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo apt install dbus-launch<\/code><\/pre>\n\n\n\n<p>And it was up and running, using way less ressources than x2go. Since I didn&#8217;t see that option anywhere described, I thought i quickly share it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Run X applications with sudo<\/h3>\n\n\n\n<p>By default there is no X configuration for the root user, so running any x application with sudo fails with cannot open display.  To resolve this, list your users Xauth cookie by:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">xauth list $DISPLAY<\/code><\/pre>\n\n\n\n<p>which should give you such a string:<\/p>\n\n\n\n<pre id=\"block-3e912356-b685-4384-a2a4-5ac1561bb421\" class=\"wp-block-code\"><code class=\"\">precious-bug\/unix:10 MIT-MAGIC-COOKIE-1 xxxxxxxxxxxxxxxxxxxxx<\/code><\/pre>\n\n\n\n<p>This whole string one adds to root xauth<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo xauth add precious-bug\/unix:10 MIT-MAGIC-COOKIE-1 xxxxxxxxxxxxxxxxxxxxxxxxx<\/code><\/pre>\n\n\n\n<p>and exporting the display for root, which won&#8217;t work with sudo, but with sudo -s (or -i)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo -s export DISPLAY=localhost:10.0<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I bought a refurbished thinkpad x260 and the bios locked with the seller can not supply the password. Since I need at least a seperated kali for pentesting and used virtual box until today, I would need virtualization enabled. Which wasn&#8217;t unfortunately. So I am exploring ways to use kali as a lxc container. A &#8230; <a title=\"Using kali in lxc container the easy way\" class=\"read-more\" href=\"https:\/\/unordnung.net\/misc\/2021\/03\/using-kali-in-lxc-container-the-easy-way\/\">Read more<span class=\"screen-reader-text\">Using kali in lxc container the easy way<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":765,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[87,4],"tags":[98,93,46,94,95,97],"class_list":["post-763","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-tips","category-to_remember","tag-container","tag-kali","tag-linux","tag-lxc","tag-ubuntu","tag-x","post_format-post-format-aside"],"_links":{"self":[{"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/posts\/763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/comments?post=763"}],"version-history":[{"count":6,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/posts\/763\/revisions"}],"predecessor-version":[{"id":1232,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/posts\/763\/revisions\/1232"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/media\/765"}],"wp:attachment":[{"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/media?parent=763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/categories?post=763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/tags?post=763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}