<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Kavish Gour</title>
    <description>The latest articles on Forem by Kavish Gour (@kavishgour).</description>
    <link>https://forem.com/kavishgour</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F169326%2Fbbe7d0c2-f77e-4203-9694-9f18d6e5487f.png</url>
      <title>Forem: Kavish Gour</title>
      <link>https://forem.com/kavishgour</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kavishgour"/>
    <language>en</language>
    <item>
      <title>Nmap - Introduction (Part 1)</title>
      <dc:creator>Kavish Gour</dc:creator>
      <pubDate>Wed, 28 Aug 2019 15:21:58 +0000</pubDate>
      <link>https://forem.com/kavishgour/nmap-introduction-part-1-48dn</link>
      <guid>https://forem.com/kavishgour/nmap-introduction-part-1-48dn</guid>
      <description>&lt;p&gt;In this post, I will explain what &lt;a href="https://nmap.org/"&gt;Nmap&lt;/a&gt; is all about, and a basic demonstration. I'm launching my career in Cybersecurity, and i hope this series will benefit InfoSec enthusiasts. Have fun. &lt;/p&gt;

&lt;h4&gt;
  
  
  Note: If you don't know how to install Nmap, click &lt;a href="https://nmap.org/book/install.html"&gt;here&lt;/a&gt;.
&lt;/h4&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Nmap or Network Mapper is a network scanning tool designed to audit a range of hosts (large networks) or a single host (a computer). Nmap sends TCP, UDP, SCTP, and ICMP packets to the target host and examines the response by comparing the result to its database(always use the latest version), to determine what services are running, which OS versions is installed, types of firewalls, and other cool stuff. &lt;/p&gt;

&lt;p&gt;Nmap is a very powerful, mature network scanner that will help you see everything that you need to see on your network. To get you excited, here's an analogy: You're about to go on a road trip, so basically you'll need some sort of map or an app that you would use to plane your route and be aware of what's around you, like road conditions and so forth. Well, think of Nmap like a map for you network.&lt;/p&gt;

&lt;h4&gt;
  
  
  Nmap Syntax
&lt;/h4&gt;

&lt;p&gt;The syntax is very simple, but the number of options provided are overwhelming. Always run nmap as a privileged user or root (on windows: open command prompt as administrator). &lt;/p&gt;

&lt;p&gt;The syntax: nmap [Scan Type(s)] [Options] {target specification}&lt;/p&gt;

&lt;p&gt;In this post, i'll only use nmap and a target to keep it simple. The target can be a hostname, an IP, a network range, etc. &lt;/p&gt;

&lt;p&gt;&lt;u&gt;Disclaimer&lt;/u&gt;: Use Nmap on your own networks. When being used on networks without prior authorization, and your intention was only to perform a scan, you'll look like the malicious type.&lt;/p&gt;

&lt;h4&gt;
  
  
  Let's get started
&lt;/h4&gt;

&lt;p&gt;Let's run 'nmap localhost':&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;MacBook-Pro:~ kavish&lt;span class="nv"&gt;$ &lt;/span&gt;nmap localhost
Starting Nmap 7.70 &lt;span class="o"&gt;(&lt;/span&gt; https://nmap.org &lt;span class="o"&gt;)&lt;/span&gt; at 2019-08-28 11:52 +04
Nmap scan report &lt;span class="k"&gt;for &lt;/span&gt;localhost &lt;span class="o"&gt;(&lt;/span&gt;127.0.0.1&lt;span class="o"&gt;)&lt;/span&gt;
Host is up &lt;span class="o"&gt;(&lt;/span&gt;0.00036s latency&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Other addresses &lt;span class="k"&gt;for &lt;/span&gt;localhost &lt;span class="o"&gt;(&lt;/span&gt;not scanned&lt;span class="o"&gt;)&lt;/span&gt;: ::1
Not shown: 993 closed ports
PORT    STATE SERVICE
88/tcp  open  kerberos-sec
110/tcp open  pop3
143/tcp open  imap
445/tcp open  microsoft-ds
548/tcp open  afp
993/tcp open  imaps
995/tcp open  pop3s

Nmap &lt;span class="k"&gt;done&lt;/span&gt;: 1 IP address &lt;span class="o"&gt;(&lt;/span&gt;1 host up&lt;span class="o"&gt;)&lt;/span&gt; scanned &lt;span class="k"&gt;in &lt;/span&gt;6.83 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The scan took approximately 6 seconds (depends on how services you got running).  &lt;/p&gt;

&lt;p&gt;Your output will be different. The main key here, is that Nmap can show you things on your network that you're not aware of. Or maybe you've no clue what services are running on your machine.&lt;/p&gt;

&lt;p&gt;From the above output, i can see that kerberos, afp, and microsoft-ds are running. I didn't start those services, and i don't know what has.&lt;/p&gt;

&lt;p&gt;Did a quick google search, and found out that those 3 services are responsible for file sharing. I disabled file sharing, and voila:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;MacBook-Pro:~ kavish&lt;span class="nv"&gt;$ &lt;/span&gt;nmap localhost
Starting Nmap 7.70 &lt;span class="o"&gt;(&lt;/span&gt; https://nmap.org &lt;span class="o"&gt;)&lt;/span&gt; at 2019-08-28 11:54 +04
Nmap scan report &lt;span class="k"&gt;for &lt;/span&gt;localhost &lt;span class="o"&gt;(&lt;/span&gt;127.0.0.1&lt;span class="o"&gt;)&lt;/span&gt;
Host is up &lt;span class="o"&gt;(&lt;/span&gt;0.00038s latency&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Other addresses &lt;span class="k"&gt;for &lt;/span&gt;localhost &lt;span class="o"&gt;(&lt;/span&gt;not scanned&lt;span class="o"&gt;)&lt;/span&gt;: ::1
Not shown: 995 closed ports
PORT    STATE SERVICE
110/tcp open  pop3
143/tcp open  imap
631/tcp open  ipp
993/tcp open  imaps
995/tcp open  pop3s

Nmap &lt;span class="k"&gt;done&lt;/span&gt;: 1 IP address &lt;span class="o"&gt;(&lt;/span&gt;1 host up&lt;span class="o"&gt;)&lt;/span&gt; scanned &lt;span class="k"&gt;in &lt;/span&gt;7.22 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A simple scan like this will not retrieve sufficient information. But it's enough to get your feet wet, and become familiar with Nmap.&lt;/p&gt;

&lt;p&gt;Stay tuned for part 2 where I explain how to run more advanced commands and, how to manipulate your results with &lt;a href="https://pypi.org/project/python-nmap/"&gt;Python-Nmap&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>nmap</category>
      <category>networking</category>
      <category>pentesting</category>
    </item>
    <item>
      <title>How to install and configure Nagios Core on CentOS 7 (without compiling)</title>
      <dc:creator>Kavish Gour</dc:creator>
      <pubDate>Sun, 11 Aug 2019 14:50:49 +0000</pubDate>
      <link>https://forem.com/kavishgour/how-to-install-and-configure-nagios-core-on-centos-7-without-compiling-fmb</link>
      <guid>https://forem.com/kavishgour/how-to-install-and-configure-nagios-core-on-centos-7-without-compiling-fmb</guid>
      <description>&lt;p&gt;&lt;a href="https://www.nagios.org/projects/nagios-core/"&gt;Nagios Core&lt;/a&gt; is an open source tool for IT insfrastructure monitoring. Nagios relies on plugins to monitor everything - databases, operating systems, applications, network equipment, protocols, and more!  &lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Update your repo and install nagios:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yum update &lt;span class="nt"&gt;-y&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; yum &lt;span class="nb"&gt;install &lt;/span&gt;nagios &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nagios depends on the Apache web server for its web interface. The previous commands will install apache. Start and enable the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl enable httpd.service
systemctl start httpd.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, lets open port 80:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;firewall-cmd &lt;span class="nt"&gt;--zone&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;public &lt;span class="nt"&gt;--add-port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;80/tcp
firewall-cmd &lt;span class="nt"&gt;--zone&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;public &lt;span class="nt"&gt;--add-port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;80/tcp &lt;span class="nt"&gt;--permanent&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install the plugins and nrpe:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;nagios-plugins nrpe nagios-plugins-nrpe
systemctl start nrpe
systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;nrpe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; NRPE, allows you to remotely execute Nagios plugins on other Linux/Unix machines and receive the output through nagios.&lt;/p&gt;

&lt;p&gt;We also need some basic plugins, that nagios needs by default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;users uptime &lt;/span&gt;ssh ping procs load http swap disk&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;nagios-plugins-&lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start and enable nrpe:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl start nrpe
systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;nrpe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The check_http plugin won't work unless we create an 'index.html' in /var/www/html. Lets'create one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;h1&amp;gt; Apache is UP and RUNNING. &amp;lt;/h1&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /var/www/html/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click &lt;a href="http://nagios-plugins.org/doc/man/index.html"&gt;here&lt;/a&gt; for more details about the plugins.&lt;/p&gt;

&lt;p&gt;Now, for apache to allow access to the web interface, we've to give the 'nagiosadmin' user a password. The user is created by default. You can change it if you want. To achieve this, let's run 'htpasswd' and input your password:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;htpasswd  /etc/nagios/passwd nagiosadmin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All is set. Let's start and enable the nagios service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl start nagios.service
systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;nagios.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go to '&lt;a href="http://localhost/nagios"&gt;http://localhost/nagios&lt;/a&gt;' or 'http://{ip-address}/nagios', enter your credentials, and that's it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In the services tab, several plugins will print status critical. Give nagios a minute or two to read its configuration and use its required plugins. &lt;/p&gt;

&lt;p&gt;You can also use the 'nagiostats' utility on the command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@centos &lt;span class="se"&gt;\~&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="c"&gt;# nagiostats | grep '^Services Ok'&lt;/span&gt;
Services Ok/Warn/Unk/Crit:              8 / 0 / 0 / 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just for fun: I wrote a &lt;a href="https://github.com/kavishgr/My-Python--Bash-Scripts/blob/master/NagiosInstall.py"&gt;python script&lt;/a&gt; to automate the installation.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>centos</category>
      <category>monitoring</category>
      <category>python</category>
    </item>
  </channel>
</rss>
