<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Archiwa Security - soban</title>
	<atom:link href="https://soban.pl/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>https://soban.pl/category/security/</link>
	<description>IT, Linux, Servers, Security</description>
	<lastBuildDate>Thu, 26 Feb 2026 13:49:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Automating the Backup Process in Proxmox: Practical Crontab Script and Configuration</title>
		<link>https://soban.pl/proxmox-backup-automation-etc/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Tue, 16 Apr 2024 11:54:48 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Proxmox]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=439</guid>

					<description><![CDATA[<p>In today&#8217;s world, where data is becoming increasingly valuable, proper backup management is crucial for the security of information systems. In this article, I present an effective way to automate the backup of key configuration files in Proxmox-based systems using a simple bash script and Crontab configuration. Bash Script for Backup of the /etc Directory [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/proxmox-backup-automation-etc/">Automating the Backup Process in Proxmox: Practical Crontab Script and Configuration</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full is-resized"><img fetchpriority="high" decoding="async" width="1024" height="1024" src="https://soban.pl/wp-content/uploads/2024/04/image.png" alt="" class="wp-image-437" style="width:412px;height:auto" srcset="https://soban.pl/wp-content/uploads/2024/04/image.png 1024w, https://soban.pl/wp-content/uploads/2024/04/image-300x300.png 300w, https://soban.pl/wp-content/uploads/2024/04/image-150x150.png 150w, https://soban.pl/wp-content/uploads/2024/04/image-768x768.png 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>In today&#8217;s world, where data is becoming increasingly valuable, proper backup management is crucial for the security of information systems. In this article, I present an effective way to automate the backup of key configuration files in Proxmox-based systems using a simple bash script and Crontab configuration.</p>



<h4 class="wp-block-heading">Bash Script for Backup of the <code>/etc</code> Directory</h4>



<p>The <code>/etc</code> file contains critical system configuration files that are essential for the proper functioning of the operating system and various applications. Loss or damage to these files can lead to serious problems. Below, I present an effective script, <code>backup-etc.sh</code>, that allows for the automated backup of this directory:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash
date_now=$(date +%Y_%m_%d-%H_%M_%S)
tar --use-compress-program zstd -cf /var/lib/vz/dump/vz-etc-$(hostname)-$date_now.tar.zst /etc/
find /var/lib/vz/dump/ -name vzup1-etc-* -type f -mtime +100 | xargs rm -f</pre></div>



<p>This script performs the following operations:</p>



<ol class="wp-block-list">
<li>Generates the current date and time, which are added to the name of the archive to easily identify individual copies.</li>



<li>Uses the <code>tar</code> program with <code>zstd</code> compression to create an archived and compressed copy of the <code>/etc</code> directory.</li>



<li>Removes archives older than 100 days from the <code>/var/lib/vz/dump/</code> location, thus ensuring optimal disk space management.</li>
</ol>



<h4 class="wp-block-heading">Adding Script to Crontab</h4>



<p>To automate the backup process, the script should be added to crontab. Below is a sample configuration that runs the script daily at 2:40 AM:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># crontab -e
40 2 * * * /root/backup-etc.sh &gt; /dev/null 2&gt;&amp;1</pre></div>



<p>Redirecting output to <code>/dev/null</code> ensures that operations are performed quietly without generating additional output to standard output.</p>



<h4 class="wp-block-heading">Download the Script from soban.pl</h4>



<p>The <code>backup-etc.sh</code> script is also available for download from the soban.pl website. You can download it using the following <code>wget</code> command and immediately save it as <code>/root/backup-etc.sh</code>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># wget -O /root/backup-etc.sh https://soban.pl/bash/backup-etc.sh &amp;&amp; chmod +x /root/backup-etc.sh</pre></div>



<p>With this simple command, the script is downloaded from the server and granted appropriate executable permissions.</p>



<h4 class="wp-block-heading">Benefits and Modifications</h4>



<p>The <code>backup-etc.sh</code> script is flexible and can be easily modified to suit different systems. It is default placed in the <code>/var/lib/vz/dump/</code> folder, which is a standard backup storage location in Proxmox environments. This simplifies backup management and can be easily integrated with existing backup solutions.</p>



<p>By keeping backups for 100 days, we ensure a balance between availability and disk space management. Old copies are automatically deleted, minimizing the risk of disk overflow and reducing data storage costs.</p>



<h4 class="wp-block-heading">Summary</h4>



<p>Automating backups using a bash script and Crontab is an effective method to secure critical system data. The <code>backup-etc.sh</code> script provides simplicity, flexibility, and efficiency, making it an excellent solution for Proxmox system administrators. I encourage you to adapt and modify this script according to your own needs to provide even better protection for your IT environment.</p>
<p>Artykuł <a href="https://soban.pl/proxmox-backup-automation-etc/">Automating the Backup Process in Proxmox: Practical Crontab Script and Configuration</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Proxy through nginx frontend to the second virtual server wordpress</title>
		<link>https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Sun, 07 Nov 2021 11:48:33 +0000</pubDate>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=315</guid>

					<description><![CDATA[<p>In a situation where we have one public IP address and we have many domains directed to that IP address, it is worth considering spreading the traffic to other servers. Proxmox, which allows you to create a pair of virtual machines, is perfect in such a situation. In my case, each virtual machine is separated [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/">Proxy through nginx frontend to the second virtual server wordpress</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In a situation where we have one public IP address and we have many domains directed to that IP address, it is worth considering spreading the traffic to other servers. Proxmox, which allows you to create a pair of virtual machines, is perfect in such a situation. In my case, each virtual machine is separated and the traffic is broken down by nginx, which distributes the traffic to other servers. The virtual machine on my website will redirect traffic, I have the IP address for wordpress: <strong>10.10.11.105 </strong>on port <strong>80</strong>. In this case, no encryption is required, but the frontend itself, which manages the traffic, will present itself with encryption and security on port <strong>443</strong>.</p>



<p>Two machines with the following configuration will participate throughout the process:<br><strong>up-page</strong> IP: <strong>10.10.14.200</strong><br><strong>soban-pl</strong> IP: <strong>10.10.11.105</strong></p>



<p>So let&#8217;s move on to the frontend that distributes traffic to other machines.<br>The frontend is done by linux debian 11 (bullseye), in addition, I have the following entry in the repository (<strong>/etc/apt/sources.list</strong>):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#...
deb http://nginx.org/packages/debian/ bullseye nginx
deb-src http://nginx.org/packages/debian/ bullseye nginx</pre></div>



<p>To install nginx, run the following commands:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt update
# apt install nginx</pre></div>



<p>You should make sure that the traffic from the frontend has the appropriate port 80 transitions. You can read how to check the network transitions here: <strong><a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/" target="_blank" rel="noreferrer noopener">Check network connection and open TCP port via netcat</a></strong>.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="469" height="154" src="https://soban.pl/wp-content/uploads/2021/11/image-18.png" alt="Screenshot of a terminal window showing a successful telnet connection to the IP address 10.10.11.105 on port 80, followed by the user exiting the telnet session with the 'quit' command." class="wp-image-317" srcset="https://soban.pl/wp-content/uploads/2021/11/image-18.png 469w, https://soban.pl/wp-content/uploads/2021/11/image-18-300x99.png 300w" sizes="(max-width: 469px) 100vw, 469px" /></figure>



<p>The configuration of the frontend that distributes the traffic is as follows (<strong>/etc/nginx/conf.d/soban.pl.ssl.conf</strong>):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">upstream soban-pl-webservers {
    server 10.10.11.105:80;
}

server {
    if ($host = www.soban.pl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = soban.pl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        server_name soban.pl www.soban.pl;
        return 301 https://soban.pl$request_uri;
}

server {
    listen 443 ssl http2;
    server_name  www.soban.pl;
    ssl_certificate /etc/letsencrypt/live/www.soban.pl/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.soban.pl/privkey.pem; # managed by Certbot
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    return 301 https://soban.pl$request_uri;
}

server {
    listen 443 ssl http2;
    server_name  soban.pl _;
    ssl_certificate /etc/letsencrypt/live/soban.pl/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/soban.pl/privkey.pem; # managed by Certbot
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
}

    location / {
        access_log /var/log/nginx/access-soban.pl.log;
        error_log /var/log/nginx/error-soban.pl.log;
        proxy_pass http://soban-pl-webservers;
        proxy_redirect https://soban-pl-webservers http://soban-pl-webservers;
        expires off;

        proxy_read_timeout       3500;
        proxy_connect_timeout    3250;

        proxy_set_header   X-Real-IP          $remote_addr;
        proxy_set_header   Host               $host;
        proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto  https;
        proxy_set_header   SSL_PROTOCOL $ssl_protocol;
        proxy_set_header   SSL_CLIENT_CERT $ssl_client_cert;
        proxy_set_header   SSL_CLIENT_VERIFY $ssl_client_verify;
        proxy_set_header   SSL_SERVER_S_DN $ssl_client_s_dn;

                proxy_set_header X-Scheme $scheme;
                proxy_ssl_session_reuse off;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
    }
      location ~ ^/(wp-admin|wp-login\.php) {
            auth_basic "Restricted";
            auth_basic_user_file /etc/nginx/conf.d/htpasswd;
           proxy_pass http://soban-pl-webservers;
           proxy_redirect https://soban-pl-webservers http://soban-pl-webservers;
           expires off;
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
           proxy_set_header        Host            $host;
           proxy_set_header        X-Real-IP       $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      }

}</pre></div>



<p>Configuration of the above-mentioned wordpress, additional authorization is also set when you try to log in to wp-admin, you can read about it here: <strong><a href="https://soban.pl/more-security-wp-admin-in-nginx/" target="_blank" rel="noreferrer noopener">More security wp-admin in nginx</a></strong>. </p>



<p>In the next step, check if the nginx configuration is correct by: </p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx configtest</pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="808" height="76" src="https://soban.pl/wp-content/uploads/2021/11/image-17.png" alt="Terminal output displaying a successful nginx configuration test with the messages: 'nginx: the configuration file /etc/nginx/nginx.conf syntax is ok' and 'nginx: configuration file /etc/nginx/nginx.conf test is successful'." class="wp-image-316" srcset="https://soban.pl/wp-content/uploads/2021/11/image-17.png 808w, https://soban.pl/wp-content/uploads/2021/11/image-17-300x28.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-17-768x72.png 768w" sizes="(max-width: 808px) 100vw, 808px" /></figure>



<p>If everything is fine, restart nginx:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx restart</pre></div>



<p>In a virtual machine with nginx it should also be installed. This is the same as debian linux 11 (bullseye), so the respository should look like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#...
deb http://nginx.org/packages/debian/ bullseye nginx
deb-src http://nginx.org/packages/debian/ bullseye nginx</pre></div>



<p>Just installing nginx looks the same as on a machine that acts as a proxy.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt update
# apt install nginx</pre></div>



<p>All configuration is in <strong>/etc/nginx/conf.d/soban.pl.conf</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">server {
    listen   80;

   client_max_body_size 20M;

    server_name soban.pl www.soban.pl;
    access_log /var/log/nginx/access-soban.pl.log; #access logi
    error_log /var/log/nginx/error-soban.log; # error logi
    port_in_redirect off;
    set_real_ip_from  10.10.11.105;
    real_ip_header    X-Forwarded-For;
    real_ip_recursive on;
       root /home/produkcja/wordpress/;
       index index.html index.php;

if ($host ~* ^www\.(.*))
{
    set $host_without_www $1;
    rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}

    error_page 404 /index.php;


        location ~ \.php$ {
                root /home/produkcja/wordpress/; # dir where is wordpress
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        }

        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location = /sitemap.xml {
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
       }

location = /favicon.ico {
  return 204;
  access_log     off;
  log_not_found  off;
}

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
        }location ~* \.(pdf)$ {
expires 30d;
}

}</pre></div>



<p>Also in this case, check the correctness of the nginx service configuration:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx configtest</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="802" height="66" src="https://soban.pl/wp-content/uploads/2021/11/image-19.png" alt="" class="wp-image-318" srcset="https://soban.pl/wp-content/uploads/2021/11/image-19.png 802w, https://soban.pl/wp-content/uploads/2021/11/image-19-300x25.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-19-768x63.png 768w" sizes="auto, (max-width: 802px) 100vw, 802px" /></figure>



<p>Everything looks fine, so let&#8217;s move on to restarting the service:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx restart</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="806" height="71" src="https://soban.pl/wp-content/uploads/2021/11/image-20.png" alt="" class="wp-image-319" srcset="https://soban.pl/wp-content/uploads/2021/11/image-20.png 806w, https://soban.pl/wp-content/uploads/2021/11/image-20-300x26.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-20-768x68.png 768w" sizes="auto, (max-width: 806px) 100vw, 806px" /></figure>



<p>If the whole configuration was done correctly, the page should be directed without encrypted traffic to the virtual machine with wordpress. A wordpress service with nginx is not the only one that can be hosted or proxied. We can direct traffic from nginx to e.g. jboss, apacha and all other web services. Of course, this requires a corresponding modification of the configuration presented above, but the general outline of the concept as an nginx proxy has been presented. You should also remember about the appropriate configuration of keys and certificates. In my case let&#8217;s encrypt works perfectly for this.</p>
<p>Artykuł <a href="https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/">Proxy through nginx frontend to the second virtual server wordpress</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</title>
		<link>https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Sat, 06 Nov 2021 13:54:17 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Oracle Linux]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Red Hat 5]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSL]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=308</guid>

					<description><![CDATA[<p>There are situations when we need to increase the encryption level on the old system &#8211; according to the PCI audit requirements. However, the old system is no longer supported, so updating the encryption level is not possible. This is not a recommended solution, because we should try to transfer the application to a new [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/">Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>There are situations when we need to increase the encryption level on the old system &#8211; according to the PCI audit requirements. However, the old system is no longer supported, so updating the encryption level is not possible. This is not a recommended solution, because we should try to transfer the application to a new system. After all, when we have little time, it is possible to hide the old version of the system and allow only the new machine to move to it. In this particular example, we will use mod_proxy as a proxy to redirect traffic to the old machine, while using iptables we will only allow communication with the new machine. It is not a recommended solution, but it works and I would like to present it here. The systems that I will be basing on in this example are the old <strong>red hat 5</strong> and the new <strong>oracle linux 7</strong>. Recently, it has become very important to use a minimum of <strong>tls 1.2</strong> and none below for banking transactions. Let&#8217;s start with the proxy server configuration <strong>oracle linux 7</strong>.</p>



<p>As of this writing, the addressing is as follows:<br><strong>new_machine</strong> IP: <strong>10.10.14.100</strong><br><strong>old_machine</strong> IP: <strong>10.10.14.101</strong><br>Traffic will be routed on port 443 from new_machine to old_machine.</p>



<p>Before we go to proxy configuration, please make sure there are network transitions from new_machine (10.10.14.100) to old_machine (10.10.14.101) to port 443. You can read how to verify network connections here: <strong><a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/" target="_blank" rel="noreferrer noopener">check network connection and open tcp port via netcat</a></strong>.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="544" height="51" src="https://soban.pl/wp-content/uploads/2021/11/image-13.png" alt="" class="wp-image-309" srcset="https://soban.pl/wp-content/uploads/2021/11/image-13.png 544w, https://soban.pl/wp-content/uploads/2021/11/image-13-300x28.png 300w" sizes="auto, (max-width: 544px) 100vw, 544px" /></figure>



<p>We go to the installation of apache and mod_proxy:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># yum install httpd mod_proxy</pre></div>



<p>After installing apache, go to the edition:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/httpd/conf.d/ssl.conf</pre></div>



<p>Below are the news on the check level, what are the updates, and ip on the next service update:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;VirtualHost _default_:443&gt;
SSLProtocol -all +TLSv1.2
SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:!NULL:!RC4:!RC2:!DES:!3DES:!SHA:!SHA256:!SHA384:!MD5+HIGH:+MEDIUM:!KRB5
#…
&lt;IfModule mod_proxy.c&gt;
SSLProxyProtocol all
SSLProxyEngine on
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyRequests On
    &lt;Proxy *&gt;
        Require all granted
    &lt;/Proxy&gt;
    # backend server and forwarded path
    ProxyPass / https://10.10.14.101/
    ProxyPassReverse / https://10.10.14.101/
&lt;/IfModule&gt;
&lt;/VirtualHost&gt;</pre></div>



<p>In order to verify the correctness of apache configuration, you can issue a command that will check it:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service httpd configtest</pre></div>



<p>If the apache configuration is correct, we can proceed to reloading apache:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service httpd restart</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="621" height="50" src="https://soban.pl/wp-content/uploads/2021/11/image-14.png" alt="" class="wp-image-310" srcset="https://soban.pl/wp-content/uploads/2021/11/image-14.png 621w, https://soban.pl/wp-content/uploads/2021/11/image-14-300x24.png 300w" sizes="auto, (max-width: 621px) 100vw, 621px" /></figure>



<p>At this point, we have a configured proxy connection. Before we move on to limiting traffic with iptables, I suggest you go to the site &#8211; with the new mod_proxy configured and test if everything is working properly and if there are any problems with the application.</p>



<p>Once everything is working fine, the network transitions are there, we can go to the iptables configuration for red hat 5. Let&#8217;s start by checking the system version:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cat /etc/redhat-release</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="663" height="48" src="https://soban.pl/wp-content/uploads/2021/11/image-15.png" alt="" class="wp-image-311" srcset="https://soban.pl/wp-content/uploads/2021/11/image-15.png 663w, https://soban.pl/wp-content/uploads/2021/11/image-15-300x22.png 300w" sizes="auto, (max-width: 663px) 100vw, 663px" /></figure>



<p>Now we are going to prepare iptables so that the network traffic is available on port 443 from the new_machine (10.10.14.100). To do this, edit the file <strong>/etc/sysconfig/iptables</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp --dport 443 -s 10.10.14.100 -j ACCEPT
-A INPUT -p tcp --dport 443 -j DROP
-A INPUT -p tcp --dport 80 -j DROP
-A INPUT -j ACCEPT
COMMIT</pre></div>



<p>After iptables settings are correct, we can reload the service:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># /etc/init.d/iptables restart</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="886" height="153" src="https://soban.pl/wp-content/uploads/2021/11/image-16.png" alt="" class="wp-image-313" srcset="https://soban.pl/wp-content/uploads/2021/11/image-16.png 886w, https://soban.pl/wp-content/uploads/2021/11/image-16-300x52.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-16-768x133.png 768w" sizes="auto, (max-width: 886px) 100vw, 886px" /></figure>



<p>In this way, we managed to cover up the weak encryption by proxying and diverting traffic to the new machine. This is not a recommended solution and you should try to transfer the application to a new environment compatible with the new system. However, in crisis situations, we can use this solution. Network traffic is not allowed by other IP addresses, so scanners will not be able to detect weak encryption on the old machine, and users using the old environment will not be able to use it. This does not change the fact that weak encryption is still set in the old environment and needs to be corrected. The example I gave is for the old <strong>red hat 5</strong> and the new <strong>oracle linux 7</strong>, but it can be assumed that a similar solution and configuration is possible for other versions of the system.</p>
<p>Artykuł <a href="https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/">Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Increasing the security of the ssh service</title>
		<link>https://soban.pl/increasing-the-security-of-the-ssh-service/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 05 Nov 2021 15:06:21 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=305</guid>

					<description><![CDATA[<p>Nowadays, many bots or hackers look for port 22 on servers and try to log in. Usually, the login attempt is made as the standard linuxe root user. In this short article, I will describe how to create a user that will be able to log in as root and change the default ssh port [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/increasing-the-security-of-the-ssh-service/">Increasing the security of the ssh service</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Nowadays, many bots or hackers look for port 22 on servers and try to log in. Usually, the login attempt is made as the standard linuxe root user. In this short article, I will describe how to create a user that will be able to log in as root and change the default ssh port 22 to 2222. Let&#8217;s go:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">useradd -m soban -s /bin/bash</pre></div>



<p>This way we created the user &#8216;soban&#8217; and assigned it the default shell &#8216;/bin/bash&#8217;. </p>



<p>We still need to set a password for the user &#8216;soban&#8217;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># passwd soban</pre></div>



<p>In the next step, let&#8217;s add it to &#8216;/etc/sudoers&#8217; so that it can become root. Keep in mind that once the user can get root, he will be able to do anything on the machine!</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/sudoers</pre></div>



<p>Please add this entry below:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#user can made sudo on root (sudo su -)
soban ALL=(ALL) NOPASSWD: ALL</pre></div>



<p>How can we test whether the user has the ability to log in as root? Nothing easier, first we&#8217;ll switch to the user we just created:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># su - soban</pre></div>



<p>To list the possible sudo commands, just type the command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ sudo -l</pre></div>



<p>Finally, to confirm whether it is possible to log in as root, you should issue the command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># sudo su -</pre></div>



<p>Now that we have a root user ready, let&#8217;s try disabling ssh logon directly and change the default port. To do this, go to the default configuration of the ssh service, which is located in &#8216;/etc/ssh/sshd_config&#8217;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/ssh/sshd_config</pre></div>



<p>We are looking for a line containing &#8216;Port&#8217; &#8211; it can be hashed, so it should be unhashed and &#8216;PermitRootLogin&#8217;. Then set them as below:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">Port 2222
PermitRootLogin no</pre></div>



<p>In this way, we changed the default port 22 to 2222 and disallowed the possibility of logging in directly to the root user. However, the ssh service still needs to be reloaded, in debian or kali linux we do it like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service sshd restart</pre></div>



<p>In this way, we have managed to create a user who can safely log into the ssh service and become root. In addition, after changing the port, we will not go out on port 22 scans, which by default is set and scanned by a potential burglar. Installing the fail2ban service is also a very good improvement in security.</p>
<p>Artykuł <a href="https://soban.pl/increasing-the-security-of-the-ssh-service/">Increasing the security of the ssh service</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>iftop as a good network traffic monitoring tool</title>
		<link>https://soban.pl/iftop-as-a-good-network-traffic-monitoring-tool/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 04 Nov 2021 15:47:42 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[iftop]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=285</guid>

					<description><![CDATA[<p>iftop is a command-line tool for real-time network bandwidth monitoring. It displays a continuously updated list of network connections along with the amount of data transferred between them. Connections are shown in a table format and can be sorted by bandwidth usage. iftop provides various filtering options, allowing you to limit the output to specific [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/iftop-as-a-good-network-traffic-monitoring-tool/">iftop as a good network traffic monitoring tool</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>iftop</strong> is a command-line tool for real-time network bandwidth monitoring. It displays a continuously updated list of network connections along with the amount of data transferred between them. Connections are shown in a table format and can be sorted by bandwidth usage.</p>



<p>iftop provides various filtering options, allowing you to limit the output to specific hosts, networks, or ports. It supports IPv6 and can display source and destination IP addresses, port numbers, and protocols.</p>



<p>It is particularly useful for monitoring traffic in real time and identifying which services or hosts consume the most bandwidth. It can also help detect network performance issues and assist in troubleshooting.</p>



<p>Overall, iftop is a lightweight yet powerful tool and a valuable addition to any network administrator’s toolkit.</p>



<p>One of the most useful network monitoring tools I use is <strong>iftop</strong>. It becomes especially helpful when the network link is saturated. In practice, it can also help detect abnormal traffic patterns, including DoS attacks. In the example below, I will transfer a large file to a remote machine with a bandwidth limit and observe the traffic using iftop.</p>



<p>First, install iftop on the local machine (in this case, Kali Linux):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># apt install iftop</pre>
</div>



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="904" height="422" src="https://soban.pl/wp-content/uploads/2021/11/image-4.png" alt="iftop installation on kali linux" class="wp-image-286" srcset="https://soban.pl/wp-content/uploads/2021/11/image-4.png 904w, https://soban.pl/wp-content/uploads/2021/11/image-4-300x140.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-4-768x359.png 768w" sizes="auto, (max-width: 904px) 100vw, 904px" />
</figure>



<p>The distribution does not matter — iftop is available in most Linux repositories, including Debian.</p>



<p>Now install iftop on the remote machine (Debian Linux):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># apt install iftop</pre>
</div>



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="928" height="396" src="https://soban.pl/wp-content/uploads/2021/11/image-6.png" alt="iftop installation on debian linux" class="wp-image-288" srcset="https://soban.pl/wp-content/uploads/2021/11/image-6.png 928w, https://soban.pl/wp-content/uploads/2021/11/image-6-300x128.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-6-768x328.png 768w" sizes="auto, (max-width: 928px) 100vw, 928px" />
</figure>



<p>To start monitoring network traffic, run iftop with the parameters <code>-PpNn</code>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># iftop -PpNn</pre>
</div>



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="963" height="509" src="https://soban.pl/wp-content/uploads/2021/11/image-9.png" alt="iftop running example" class="wp-image-292" srcset="https://soban.pl/wp-content/uploads/2021/11/image-9.png 963w, https://soban.pl/wp-content/uploads/2021/11/image-9-300x159.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-9-768x406.png 768w" sizes="auto, (max-width: 963px) 100vw, 963px" />
</figure>



<p>Since I am connected to the remote machine via SSH, I can see my active SSH session in the traffic list.</p>



<p>Now let’s go back to the local machine and create a large file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># truncate -s 1G 1G-file.txt</pre>
</div>



<p>After creating the 1GB file, let’s transfer it to the remote machine with a bandwidth limit:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># scp -l 800 -P2222 1G-file.txt soban@soban.pl:~</pre>
</div>



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="960" height="128" src="https://soban.pl/wp-content/uploads/2021/11/image-10.png" alt="scp transfer with bandwidth limit" class="wp-image-293" srcset="https://soban.pl/wp-content/uploads/2021/11/image-10.png 960w, https://soban.pl/wp-content/uploads/2021/11/image-10-300x40.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-10-768x102.png 768w" sizes="auto, (max-width: 960px) 100vw, 960px" />
</figure>



<p>In this example, the <code>-l 800</code> option limits the transfer rate to 800 Kbit/s. To convert this to KB/s, divide by 8. That gives approximately 100 KB/s (800 / 8 = 100).</p>



<p>To learn more about <code>scp</code> and secure file transfers over SSH, see: <a href="https://soban.pl/securely-copy-files-scp-tool-to-copying-files-by-ssh/" target="_blank" rel="noreferrer noopener"><strong>Securely Copy Files (scp) tool for copying files via SSH</strong></a>.</p>



<p>When sending the file, the traffic on the local machine (outgoing traffic) looks like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># iftop -PpNn</pre>
</div>



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="957" height="354" src="https://soban.pl/wp-content/uploads/2021/11/image-11.png" alt="iftop outgoing traffic" class="wp-image-294" srcset="https://soban.pl/wp-content/uploads/2021/11/image-11.png 957w, https://soban.pl/wp-content/uploads/2021/11/image-11-300x111.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-11-768x284.png 768w" sizes="auto, (max-width: 957px) 100vw, 957px" />
</figure>



<p>At the same time, on the remote machine (incoming traffic) it looks like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># iftop -PpNn</pre>
</div>



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="964" height="501" src="https://soban.pl/wp-content/uploads/2021/11/image-12.png" alt="iftop incoming traffic" class="wp-image-295" srcset="https://soban.pl/wp-content/uploads/2021/11/image-12.png 964w, https://soban.pl/wp-content/uploads/2021/11/image-12-300x156.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-12-768x399.png 768w" sizes="auto, (max-width: 964px) 100vw, 964px" />
</figure>



<p>As you can see, this approach allows you to observe both outgoing and incoming traffic in real time. Although iftop is simple, it provides powerful visibility into live network activity.</p>



<p>During brute-force attempts, you will usually observe many short-lived connections. In contrast, a DoS attack aims to saturate the bandwidth, which results in high incoming traffic. However, there are situations where traffic spikes are legitimate. In such cases, you may consider limiting connection speed — tools like iptables can help manage that effectively.</p>
<p>Artykuł <a href="https://soban.pl/iftop-as-a-good-network-traffic-monitoring-tool/">iftop as a good network traffic monitoring tool</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>sshfs great tool to mount remote file system</title>
		<link>https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 22 Oct 2021 13:30:45 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sshfs]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=243</guid>

					<description><![CDATA[<p>SSHFS (SSH File System) is a secure file transfer system that enables users to remotely access and manage files on a remote server over an encrypted SSH (Secure Shell) connection. SSHFS uses the SSH protocol to establish a secure connection between the local and remote systems, which enables users to securely transfer files between the [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/">sshfs great tool to mount remote file system</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>SSHFS (SSH File System) is a secure file transfer system that enables users to remotely access and manage files on a remote server over an encrypted SSH (Secure Shell) connection. SSHFS uses the SSH protocol to establish a secure connection between the local and remote systems, which enables users to securely transfer files between the two systems.</p>



<p>To use SSHFS, the user needs to have SSHFS installed on their local system as well as the remote system that they want to connect to. Once SSHFS is installed, the user can mount the remote system as a local directory on their system, and access the remote files as if they were stored locally.</p>



<p>SSHFS provides a secure and convenient way to access and manage files on remote systems, without the need for additional software or complicated configuration. It also enables users to access files on remote systems using standard file operations, such as copying, moving, and deleting, making it a simple and effective way to manage files on remote systems.</p>



<p><strong><strong>SSH Filesystem</strong></strong> (<strong>sshfs</strong>) is a very useful tool for remotely transferring files over the ssh protocol. An additional advantage of the whole is encryption. This is a convenient way to mount a remote folder to delete files. Below I will try to briefly introduce how to install sshfs and how to mount the folder remotely. Additionally, we will make an entry in <strong>/etc/fstab</strong> at the end, so that the resource itself is mounted after restarting the system. Let&#8217;s move on to installing the tool itself: </p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt install sshfs</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="432" src="https://soban.pl/wp-content/uploads/2021/10/image-82-1024x432.png" alt="" class="wp-image-244" srcset="https://soban.pl/wp-content/uploads/2021/10/image-82-1024x432.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-82-300x127.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-82-768x324.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-82.png 1128w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>In this case, as you can see, the installation was done on kali linuxe, however the procedure is the same on debian.</p>



<p>Let&#8217;s move on to the file mounting itself, at this point I will point out that the default port is 22. In my case, however, the port has been changed to 2222. For services such as ssh, I try to change the default ports so as not to get caught by bots and not end up in the database such as <a href="https://www.shodan.io/" target="_blank" rel="noreferrer noopener">shodan.io</a>. The command itself in this case is very simple, but first we need to create a folder: </p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ mkdir /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="402" height="65" src="https://soban.pl/wp-content/uploads/2021/10/image-83.png" alt="" class="wp-image-245" srcset="https://soban.pl/wp-content/uploads/2021/10/image-83.png 402w, https://soban.pl/wp-content/uploads/2021/10/image-83-300x49.png 300w" sizes="auto, (max-width: 402px) 100vw, 402px" /></figure>



<p>Let&#8217;s try to mount a remote folder:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ sshfs soban@soban.pl:/home/soban/ /home/kali/myremotedir -p 2222</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="148" src="https://soban.pl/wp-content/uploads/2021/10/image-84-1024x148.png" alt="" class="wp-image-246" srcset="https://soban.pl/wp-content/uploads/2021/10/image-84-1024x148.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-84-300x43.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-84-768x111.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-84.png 1089w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>During mounting, we will be asked if the fingerprint is correct. Then for the system password. The command itself can be disassembled into &#8216;<strong>soban</strong>&#8216; &#8211; this is the username. Then &#8216;<strong>soban.pl</strong>&#8216; is the domain name, you can also put the IP address here. The next &#8216;<strong>/home/soban</strong>&#8216; element is the folder that will be mounted. And after the space &#8216;<strong>/home/kali/myremotedir</strong>&#8216; we give the folder where the remote folder should be mounted. If everything went as planned, we can list &#8216;<strong>/home/kali/myremotedir</strong>&#8216; and it should list the contents of the remotely mounted folder &#8216;<strong>/home/soban</strong>&#8216;. Let&#8217;s list the contents of the &#8216;<strong>/home/kali/myremotedir</strong>&#8216; folder:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="159" src="https://soban.pl/wp-content/uploads/2021/10/image-85.png" alt="" class="wp-image-247" srcset="https://soban.pl/wp-content/uploads/2021/10/image-85.png 642w, https://soban.pl/wp-content/uploads/2021/10/image-85-300x74.png 300w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p>Let&#8217;s create a remote file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ echo 'some text' &gt; /home/kali/myremotedir/example
$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="664" height="259" src="https://soban.pl/wp-content/uploads/2021/10/image-86.png" alt="" class="wp-image-248" srcset="https://soban.pl/wp-content/uploads/2021/10/image-86.png 664w, https://soban.pl/wp-content/uploads/2021/10/image-86-300x117.png 300w" sizes="auto, (max-width: 664px) 100vw, 664px" /></figure>



<p>Now let&#8217;s unmount the remote folder and try listing it again:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ umount /home/kali/myremotedir
$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="445" height="155" src="https://soban.pl/wp-content/uploads/2021/10/image-87.png" alt="" class="wp-image-249" srcset="https://soban.pl/wp-content/uploads/2021/10/image-87.png 445w, https://soban.pl/wp-content/uploads/2021/10/image-87-300x104.png 300w" sizes="auto, (max-width: 445px) 100vw, 445px" /></figure>



<p>As expected, the folder is empty and the file we created was created on a remotely mounted drive. After unmounting as you can see the file &#8216;<strong>/home/kali/myremotedir/example</strong>&#8216;.</p>



<p>The next step is to create a private key to mount the folder without entering a password. It is very important not to send nikmou your private key. How we can generate and add a public key to a remote server can be read here: &#8220;<a href="https://soban.pl/generate-ssh-key-pair-in-linux/" target="_blank" rel="noreferrer noopener">Generate SSH key pair in Linux</a>&#8220;.</p>



<p>Now we will try to add an entry to <strong>/etc/fstab</strong> which will allow automatic mounting on startup of the remote folder system.<br>To do this, edit the <strong>/etc/fstab</strong> entry and add this entry:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#edit this entry and put correct data
sshfs#soban@soban.pl:/home/soban /home/kali/myremotedir fuse auto,user,_netdev,reconnect,identityfile=/home/kali/.ssh/id_rsa,port=2222,uid=1000,gid=1000,allow_other 0 0</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="245" src="https://soban.pl/wp-content/uploads/2021/10/image-92-1024x245.png" alt="" class="wp-image-259" srcset="https://soban.pl/wp-content/uploads/2021/10/image-92-1024x245.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-92-300x72.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-92-768x184.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-92-1536x367.png 1536w, https://soban.pl/wp-content/uploads/2021/10/image-92.png 1698w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>It is important that all data is correct, in order to verify the parameters, you can use the command for this &#8216;<strong>id</strong>&#8216;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># id kali</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="100" src="https://soban.pl/wp-content/uploads/2021/10/image-94-1024x100.png" alt="" class="wp-image-261" srcset="https://soban.pl/wp-content/uploads/2021/10/image-94-1024x100.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-94-300x29.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-94-768x75.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-94.png 1067w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Now we can move on to mounting the resource:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># mount /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="895" height="118" src="https://soban.pl/wp-content/uploads/2021/10/image-93.png" alt="" class="wp-image-260" srcset="https://soban.pl/wp-content/uploads/2021/10/image-93.png 895w, https://soban.pl/wp-content/uploads/2021/10/image-93-300x40.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-93-768x101.png 768w" sizes="auto, (max-width: 895px) 100vw, 895px" /></figure>



<p>When mounting for the first time, we may be asked to accept and confirm that the fingerprint is correct. After verifying the correctness of mounting the remote resource, we can restart the system. One note here, the system may get up longer.</p>
<p>Artykuł <a href="https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/">sshfs great tool to mount remote file system</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Generate SSH key pair in Linux</title>
		<link>https://soban.pl/generate-ssh-key-pair-in-linux/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 22 Oct 2021 12:32:08 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=251</guid>

					<description><![CDATA[<p>A very convenient way to log into remote systems via ssh is without the use of passwords. Here it is very important not to share your private key with anyone. Currently, when trying to connect, I am asked for the password to the server: During the connection, we will be asked if the fingerprint is [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/generate-ssh-key-pair-in-linux/">Generate SSH key pair in Linux</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A very convenient way to log into remote systems via ssh is without the use of passwords. Here it is very important not to share your private key with anyone. Currently, when trying to connect, I am asked for the password to the server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh soban@soban.pl -p2222</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="374" src="https://soban.pl/wp-content/uploads/2021/10/image-90-1024x374.png" alt="" class="wp-image-254" srcset="https://soban.pl/wp-content/uploads/2021/10/image-90-1024x374.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-90-300x109.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-90-768x280.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-90.png 1261w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>During the connection, we will be asked if the fingerprint is correct. Then enter the user password that is set on the remote server. During the ssh command &#8216;<strong>soban@soban.pl -p2222</strong>&#8216; I gave the username &#8216;<strong>soban</strong>&#8216; then the domain &#8216;<strong>soban.pl</strong>&#8216; and &#8216;<strong>-p2222</strong>&#8216; port <strong>&#8216;2222&#8217;</strong>. The default port after ssh is <strong>22</strong>, but in this case I changed it so that it does not come out on scans &#8211; this increases security as often bots / hackers look for port <strong>22</strong>, which is the default ssh port set. </p>



<p>Let&#8217;s move on to generating the key and copying it to the server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh-keygen -t rsa</pre></div>



<p>This is how the key generation looks like, I hit enter for each question:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="753" height="539" src="https://soban.pl/wp-content/uploads/2021/10/image-88.png" alt="" class="wp-image-252" srcset="https://soban.pl/wp-content/uploads/2021/10/image-88.png 753w, https://soban.pl/wp-content/uploads/2021/10/image-88-300x215.png 300w" sizes="auto, (max-width: 753px) 100vw, 753px" /></figure>



<p>As a result, a private key was generated: (<strong>/home/kali/.ssh/id_rsa</strong>) and a public key (<strong>/home/kali/.ssh/id_rsa</strong>)  that we will place on the remote server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh soban@soban.pl -p2222 "echo \"`cat ~/.ssh/id_rsa.pub`\" &gt;&gt; .ssh/authorized_keys"</pre></div>



<p>The last time we log in to the server by entering the password. When logging in, we will not be asked for a password now. This way we are able to add our public key (.ssh / authorized_keys) to the remote server. </p>



<p></p>
<p>Artykuł <a href="https://soban.pl/generate-ssh-key-pair-in-linux/">Generate SSH key pair in Linux</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>More security wp-admin in nginx</title>
		<link>https://soban.pl/more-security-wp-admin-in-nginx/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 21 Oct 2021 16:44:39 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=229</guid>

					<description><![CDATA[<p>Some time ago I noticed that my wordpress hacks are being hacked by logging into the backend of the website. A bot or a hacker is trying to do this using a set of passwords. I decided to secure the website&#8217;s backend by requiring additional authentication. In nginxe we can set this up by: We [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/more-security-wp-admin-in-nginx/">More security wp-admin in nginx</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Some time ago I noticed that my wordpress hacks are being hacked by logging into the backend of the website. A bot or a hacker is trying to do this using a set of passwords. I decided to secure the website&#8217;s backend by requiring additional authentication. In nginxe we can set this up by:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">location ~ ^/(wp-admin|wp-login\.php) {
           auth_basic "Restricted";
           auth_basic_user_file /etc/nginx/.htpasswd;
           proxy_pass http://upstream-webservers;
           proxy_redirect https://upstream-webservers http://upstream-webservers;
           expires off;
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
           proxy_set_header        Host            $host;
           proxy_set_header        X-Real-IP       $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      }</pre></div>



<p>We still need to provide the username for authorization and save to the file (/etc/nginx/.htpasswd) as we entered in the nginx configuration file. In &#8220;my_user_name&#8221;, replace the login of the user with which we will be authorized.:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># echo -n 'my_user_name:' &gt;&gt; /etc/nginx/.htpasswd</pre></div>



<p> And the encrypted password has been set by openssl:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># openssl passwd -apr1 &gt;&gt; /etc/nginx/.htpasswd</pre></div>



<p>Openssl will ask you to come up with a password and enter it twice:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="809" height="71" src="https://soban.pl/wp-content/uploads/2021/10/image-76.png" alt="" class="wp-image-232" srcset="https://soban.pl/wp-content/uploads/2021/10/image-76.png 809w, https://soban.pl/wp-content/uploads/2021/10/image-76-300x26.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-76-768x67.png 768w" sizes="auto, (max-width: 809px) 100vw, 809px" /></figure>



<p>As a result, we will get a file with an encrypted password:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="612" height="50" src="https://soban.pl/wp-content/uploads/2021/10/image-77.png" alt="" class="wp-image-233" srcset="https://soban.pl/wp-content/uploads/2021/10/image-77.png 612w, https://soban.pl/wp-content/uploads/2021/10/image-77-300x25.png 300w" sizes="auto, (max-width: 612px) 100vw, 612px" /></figure>



<p>Before reloading nginx, we do a configuration verification:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx configtest</pre></div>



<p>If everything is set correctly, we should receive the following message:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="811" height="83" src="https://soban.pl/wp-content/uploads/2021/10/image-81.png" alt="" class="wp-image-240" srcset="https://soban.pl/wp-content/uploads/2021/10/image-81.png 811w, https://soban.pl/wp-content/uploads/2021/10/image-81-300x31.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-81-768x79.png 768w" sizes="auto, (max-width: 811px) 100vw, 811px" /></figure>



<p>Now we can restart the service nginx:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx restart</pre></div>



<p>The final verification will be to log in to the backend (e.g. www.example-page-wordpress.pl/<strong>wp-admin</strong>/), as a result, we should be asked for the login and password that we created above:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="738" height="458" src="https://soban.pl/wp-content/uploads/2021/10/image-79.png" alt="" class="wp-image-235" srcset="https://soban.pl/wp-content/uploads/2021/10/image-79.png 738w, https://soban.pl/wp-content/uploads/2021/10/image-79-300x186.png 300w" sizes="auto, (max-width: 738px) 100vw, 738px" /></figure>



<p>This is a simple trick to protect your wordpress from bot attacks. However, it should be remembered that we do not share passwords with anyone and setting default usernames and simple passwords is asking for a problem.</p>
<p>Artykuł <a href="https://soban.pl/more-security-wp-admin-in-nginx/">More security wp-admin in nginx</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Check network connection and open TCP port via netcat</title>
		<link>https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 21 Oct 2021 10:40:49 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=197</guid>

					<description><![CDATA[<p>Netcat, also known as &#8220;nc,&#8221; is a versatile networking tool that is commonly used in Linux and other Unix-like operating systems. It is a command-line utility that can be used for various network-related tasks, such as port scanning, file transfer, and even as a lightweight web server. The primary function of Netcat is to create [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/">Check network connection and open TCP port via netcat</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Netcat, also known as &#8220;nc,&#8221; is a versatile networking tool that is commonly used in Linux and other Unix-like operating systems. It is a command-line utility that can be used for various network-related tasks, such as port scanning, file transfer, and even as a lightweight web server.</p>



<p>The primary function of Netcat is to create network connections between two hosts, allowing data to be transferred between them. It can establish a connection as a client or a server, and it supports both TCP and UDP protocols. This makes it useful for testing network services, troubleshooting network issues, and performing security assessments.</p>



<p>Netcat can be used to scan for open ports on a remote host, allowing system administrators to identify potential security vulnerabilities. It can also be used to transfer files between hosts, similar to the way that the &#8220;cp&#8221; command works in Linux. Additionally, it can be used to create a simple web server, allowing files to be served over HTTP.</p>



<p>One of the key features of Netcat is its ability to operate in both interactive and non-interactive modes. In interactive mode, it acts like a chat program, allowing users to communicate with each other in real-time. In non-interactive mode, it can be used as a background process that quietly sends or receives data without any user interaction.</p>



<p>Overall, Netcat is a powerful and flexible tool that can be used for a wide range of networking tasks. Its simplicity and ease of use make it a popular choice among system administrators, network engineers, and security professionals.</p>



<p>Sometimes network connections are blocked by various network devices. In the verification of the connection over TCP, we can use, for example, telnet. After all, before we start a server-side service like jboss, we can use a simple utility like netcat to open the port.</p>



<p>In this example we will be using two machines. However, one of them is &#8220;<strong>host-soban-pl</strong>&#8221; with the IP address: <strong>10.10.14.100</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ip a</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="241" src="https://soban.pl/wp-content/uploads/2021/10/image-66-1024x241.png" alt="" class="wp-image-208" srcset="https://soban.pl/wp-content/uploads/2021/10/image-66-1024x241.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-66-300x71.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-66-768x181.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-66.png 1249w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p> The second is &#8220;<strong>soban-pl</strong>&#8221; with the IP address: <strong>10.10.11.105</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># ip a</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="235" src="https://soban.pl/wp-content/uploads/2021/10/image-67-1024x235.png" alt="" class="wp-image-209" srcset="https://soban.pl/wp-content/uploads/2021/10/image-67-1024x235.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-67-300x69.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-67-768x176.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-67.png 1246w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Below, for example, I will show you how to check an already open tcp connection and one that is closed. On the other side, on port 80, I have an open port with nginx:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ telnet 10.10.11.105 80</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="558" height="157" src="https://soban.pl/wp-content/uploads/2021/10/image-56.png" alt="" class="wp-image-198" srcset="https://soban.pl/wp-content/uploads/2021/10/image-56.png 558w, https://soban.pl/wp-content/uploads/2021/10/image-56-300x84.png 300w" sizes="auto, (max-width: 558px) 100vw, 558px" /></figure>



<p>Nmap below confirms port opening, additionally identified the service as http:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ nmap 10.10.11.105 -p 80</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="787" height="204" src="https://soban.pl/wp-content/uploads/2021/10/image-57.png" alt="" class="wp-image-199" srcset="https://soban.pl/wp-content/uploads/2021/10/image-57.png 787w, https://soban.pl/wp-content/uploads/2021/10/image-57-300x78.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-57-768x199.png 768w" sizes="auto, (max-width: 787px) 100vw, 787px" /></figure>



<p>The conclusion is that the service has network transitions and you can correctly connect over TCP. Now it will try to open a connection that does not exist, e.g. on port 81.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ telnet 10.10.11.105 81</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="744" height="72" src="https://soban.pl/wp-content/uploads/2021/10/image-58.png" alt="" class="wp-image-200" srcset="https://soban.pl/wp-content/uploads/2021/10/image-58.png 744w, https://soban.pl/wp-content/uploads/2021/10/image-58-300x29.png 300w" sizes="auto, (max-width: 744px) 100vw, 744px" /></figure>



<p>As you can see, the connection is not possible because the port is closed. The assumption is that the port may be open, but for example the firewall blocks it. Then you need to set the appropriate rules on it.</p>



<p>After all, in this case I know that the firewall does not block anything, so it will try to open the port with netcat. First we need to install netcat in debian, it is done like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt install netcat-traditional</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="350" src="https://soban.pl/wp-content/uploads/2021/10/image-59-1024x350.png" alt="" class="wp-image-201" srcset="https://soban.pl/wp-content/uploads/2021/10/image-59-1024x350.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-59-300x103.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-59-768x263.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-59.png 1175w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Now let&#8217;s move on to running netcat on port 81:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># netcat -l -p 81 &amp;</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="427" height="45" src="https://soban.pl/wp-content/uploads/2021/10/image-60.png" alt="" class="wp-image-202" srcset="https://soban.pl/wp-content/uploads/2021/10/image-60.png 427w, https://soban.pl/wp-content/uploads/2021/10/image-60-300x32.png 300w" sizes="auto, (max-width: 427px) 100vw, 427px" /></figure>



<p>In this case, I specially gave the command &#8216;&amp;&#8217; at the end to leave the netcat process in the background. At this point, netcat is listening on port 81.</p>



<p>Now we can proceed to checking the correctness of the connection with the use of telnet:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ telnet 10.10.11.105 81</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="648" height="90" src="https://soban.pl/wp-content/uploads/2021/10/image-61.png" alt="" class="wp-image-203" srcset="https://soban.pl/wp-content/uploads/2021/10/image-61.png 648w, https://soban.pl/wp-content/uploads/2021/10/image-61-300x42.png 300w" sizes="auto, (max-width: 648px) 100vw, 648px" /></figure>



<p>In the meantime, on the server machine, we can use the netstat tool to verify the connection and check from which machine the traffic is coming:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="92" src="https://soban.pl/wp-content/uploads/2021/10/image-68-1024x92.png" alt="" class="wp-image-210" srcset="https://soban.pl/wp-content/uploads/2021/10/image-68-1024x92.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-68-300x27.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-68-768x69.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-68.png 1026w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>As you can see, a correct connection from the 10.10.14.100 host has been established with the server on 10.10.11.105 on port 81.</p>



<p>To end the call, hit &#8216;<strong>^]</strong>&#8216; (<strong>ctrl +]</strong>), then type quit and enter.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="560" height="157" src="https://soban.pl/wp-content/uploads/2021/10/image-65.png" alt="" class="wp-image-207" srcset="https://soban.pl/wp-content/uploads/2021/10/image-65.png 560w, https://soban.pl/wp-content/uploads/2021/10/image-65-300x84.png 300w" sizes="auto, (max-width: 560px) 100vw, 560px" /></figure>



<p>In this way, we can verify the correctness of the network connection and whether any firewall or other network problem is an obstacle to its correct establishment. Netcat is a very powerful and useful tool, you can use it to transfer files etc. Netstat is also very useful in situations where network congestion occurs and one of the hosts is attacked. It is then easy to notice that a large number of network connections are made.</p>
<p>Artykuł <a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/">Check network connection and open TCP port via netcat</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Netdiscover great tool for scaning and watching local network</title>
		<link>https://soban.pl/netdiscover-great-tool-for-scaning-and-watching-local-network/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Wed, 20 Oct 2021 14:50:23 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[netdiscover]]></category>
		<category><![CDATA[nmap]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=172</guid>

					<description><![CDATA[<p>Netdiscover is a popular network discovery tool that is used in Linux to identify live hosts on a network. It sends ARP (Address Resolution Protocol) requests to the network and then listens for replies from active hosts. By analyzing the replies, Netdiscover can build a list of all hosts that are currently active on the [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/netdiscover-great-tool-for-scaning-and-watching-local-network/">Netdiscover great tool for scaning and watching local network</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Netdiscover is a popular network discovery tool that is used in Linux to identify live hosts on a network. It sends ARP (Address Resolution Protocol) requests to the network and then listens for replies from active hosts. By analyzing the replies, Netdiscover can build a list of all hosts that are currently active on the network.</p>



<p>Netdiscover is typically used by network administrators to identify all devices on a network and to detect any unauthorized devices that may be connected. It can also be used to identify the IP address of a device on a network that is not responding to conventional network scanning techniques.</p>



<p>Netdiscover is a command-line tool and has a range of options that allow it to be customized for specific network environments. For example, it can be set to scan a particular subnet or to use a specific network interface. Additionally, Netdiscover can output its results in a range of formats, including CSV and XML, making it easy to integrate with other tools and applications.</p>



<p>Overall, Netdiscover is a useful tool for network administrators who need to identify all devices on a network and detect any unauthorized devices that may be connected. Its ability to output results in a range of formats and its customizable options make it a versatile and valuable addition to any network security toolkit.</p>



<p>Netdiscover is a great tool to scan your local network for locally attached devices. It is installed by default in Kali Linux. However, if you want to use it on a raspberry pi, you need to install it. You can do this as follows:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt install netdiscover</pre></div>



<p> In virtualbox I have this setup of network in Kali Linux: </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="755" src="https://soban.pl/wp-content/uploads/2021/10/image-45-1024x755.png" alt="" class="wp-image-174" srcset="https://soban.pl/wp-content/uploads/2021/10/image-45-1024x755.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-45-300x221.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-45-768x566.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-45.png 1217w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The very use of the tool requires specifying the subnetwork in which we are located. We can check it like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># ifconfig</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="543" src="https://soban.pl/wp-content/uploads/2021/10/image-48-1024x543.png" alt="" class="wp-image-178" srcset="https://soban.pl/wp-content/uploads/2021/10/image-48-1024x543.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-48-300x159.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-48-768x408.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-48.png 1029w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>In this case, we can scan network 192.168.1.0/24, so in <strong>netdiscover</strong> we can use:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># netdiscover -r 192.168.1.0/24</pre></div>



<p>The screen will show the network scanner:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="900" height="223" src="https://soban.pl/wp-content/uploads/2021/10/image-46.png" alt="" class="wp-image-175" srcset="https://soban.pl/wp-content/uploads/2021/10/image-46.png 900w, https://soban.pl/wp-content/uploads/2021/10/image-46-300x74.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-46-768x190.png 768w" sizes="auto, (max-width: 900px) 100vw, 900px" /></figure>



<p>Netdiscover also gives you the option to direct the result to a file, in this case it refreshes the scan every 2 seconds:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># netdiscover -r 192.168.1.0/24 -s 2 -P &gt;&gt; /tmp/file</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="898" height="307" src="https://soban.pl/wp-content/uploads/2021/10/image-49.png" alt="" class="wp-image-183" srcset="https://soban.pl/wp-content/uploads/2021/10/image-49.png 898w, https://soban.pl/wp-content/uploads/2021/10/image-49-300x103.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-49-768x263.png 768w" sizes="auto, (max-width: 898px) 100vw, 898px" /></figure>



<p>Now we can also use nslookup to get hostname:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ cat /tmp/file | grep '192\.' | grep -v Screen | cut -c1-14 | sort -u | nslookup | grep name | cut -f 2 | cut -c8-</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1019" height="114" src="https://soban.pl/wp-content/uploads/2021/10/image-53.png" alt="" class="wp-image-190" srcset="https://soban.pl/wp-content/uploads/2021/10/image-53.png 1019w, https://soban.pl/wp-content/uploads/2021/10/image-53-300x34.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-53-768x86.png 768w" sizes="auto, (max-width: 1019px) 100vw, 1019px" /></figure>



<p>Also we can use nmap:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nmap `cat /tmp/file | grep '192\.' | grep -v Screen | cut -c2-34 | sort -u | awk '{ print $1 }' | tr '\n' ' '`</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1021" height="502" src="https://soban.pl/wp-content/uploads/2021/10/image-55.png" alt="" class="wp-image-194" srcset="https://soban.pl/wp-content/uploads/2021/10/image-55.png 1021w, https://soban.pl/wp-content/uploads/2021/10/image-55-300x148.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-55-768x378.png 768w" sizes="auto, (max-width: 1021px) 100vw, 1021px" /></figure>



<p>You can use more parameters in nmap for more information, however this will significantly increase the scan time. Still, sometimes it&#8217;s worth the wait.</p>
<p>Artykuł <a href="https://soban.pl/netdiscover-great-tool-for-scaning-and-watching-local-network/">Netdiscover great tool for scaning and watching local network</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
