CyberKeeda In Social Media
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

How to scan IP addresses details on your network using NMAP

 


You know using Linux is a kind fun, think about a requirement and you can see a wide number opensource tools gives you wings to your idea, no hurdles just go with your goal, they all will support you..

I would like to share you, what made me search internet and write this blog post.

So within my Lab environment, it's a very frequent task to configure, update IP configuration of other virtual machines, so to tackle this task, I have already written an Ansible Role, which basically configures the IP address for the host which has existing dhcp address assigned to it.

Now still there are some information I need to provide ansible before I proceed to run the playbook and the information it needs is, I need to manually look for free IPs in my current network.

So I was curious how to scan my network for used and free IP addresses, thus I surfed the internet and found, my friendly network troubleshooting tool NMAP gives the insight about it.

Let's see what command can be used to find those details.

Using below one lines to search for used IPs within your network.

$ nmap -sP 192.168.29.0/24

Output


Starting Nmap 6.40 ( http://nmap.org ) at 2022-06-16 17:10 IST
Nmap scan report for 192.168.29.1
Host is up (0.0078s latency).
Nmap scan report for 192.168.29.9
Host is up (0.0050s latency).
Nmap scan report for 192.168.29.21
Host is up (0.0043s latency).
Nmap scan report for 192.168.29.30
Host is up (0.0015s latency).
Nmap done: 256 IP addresses (4 hosts up) scanned in 2.59 seconds

Now let's scan again the same network and look for the listening ports along with the host ip

$ sudo nmap -sT 192.168.29.0/24

Output

Starting Nmap 6.40 ( http://nmap.org ) at 2022-06-16 17:17 IST
Nmap scan report for 192.168.29.1
Host is up (0.0061s latency).
Not shown: 992 filtered ports
PORT     STATE  SERVICE
80/tcp   open   http
443/tcp  open   https
1900/tcp open   upnp
2869/tcp closed icslap
7443/tcp open   oracleas-https
8080/tcp open   http-proxy
8200/tcp closed trivnet1
8443/tcp open   https-alt
MAC Address: AA:HA:IC:PF:P3:C1 (Unknown)

Nmap scan report for 192.168.29.9
Host is up (0.0083s latency).
Not shown: 998 closed ports
PORT    STATE SERVICE
80/tcp  open  http
554/tcp open  rtsp
MAC Address: 14:07:o8:g5:7E:99 (Private)

Nmap scan report for 192.168.29.21
Host is up (0.0051s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: 08:76:20:00:75:D5 (Cadmus Computer Systems)

Nmap scan report for 192.168.29.25
Host is up (0.0057s latency).
Not shown: 999 filtered ports
PORT    STATE SERVICE
135/tcp open  msrpc
MAC Address: F0:76:30:60:8E:21 (Unknown)

Nmap scan report for 192.168.29.30
Host is up (0.0018s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
8000/tcp open  http-alt
8080/tcp open  http-proxy

Nmap done: 256 IP addresses (5 hosts up) scanned in 7.84 seconds

If you need additional details like Host OS details and some more, then run the scan again with below command

$ sudo nmap -sT -O 192.168.29.0/24

Output

Nmap scan report for 192.168.29.30
Host is up (0.00026s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
8000/tcp open  http-alt
8080/tcp open  http-proxy
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.7 - 3.9
Network Distance: 0 hops

Hope this post will help you in some sort !
Read more ...

How to enable password based ssh authentication in ec2 instance

 



EC2 Linux SSH Authentication.

By default, preferred and default way of accessing any ec2 linux instance is key based authentication.
Here in this blog post, we will know 
  • How to enable basic authentication that is password based authentication in ec2 instance.
  • How to enable root login to ec2 instance.
I will keep on updating the post as per my learnings and used in practical scenarios.

Let's go through it :)

How to enable root login on linux ec2 instance.
  • Login to ec2 linux instance using it's private key.
  • Sudo to root
  • change password for root
  • Permit root login in sshd_config file

Syntax

[ec2-user@ip-10-0-1-116 ~]$ sudo su

Change root password from below command.


[root@ip-10-0-1-116 ec2-user]# passwd root

Permit root login by un-commenting the below line in sshd_config


[root@ip-10-0-1-116 ec2-user]# vi /etc/ssh/sshd_config

From


# PermitRootLogin yes

To

PermitRootLogin yes


How to enable password based authentication for ssh user.
  • Login to ec2 linux instance using it's private key.
  • Sudo to root
  • Permit root login in sshd_config file
  • Restart sshd service

Syntax

[ec2-user@ip-10-0-1-116 ~]$ sudo su

Permit root login by un-commenting the below line in sshd_config


[root@ip-10-0-1-116 ec2-user]# vi /etc/ssh/sshd_config

From


# PasswordAuthentication yes

To

PasswordAuthentication yes

Restart SSHD service

service sshd restart


Login and check !
Read more ...

TcpDump Cheat Sheet

 

TCP Dump Cheat Sheet

When we talk about Client-Server, there is network involved and when we talk about network, every one is quite familiar with tcpdump and Wireshark.
Network knows Packets and tcpdump is a CLI tool that knows packet very well.

tcpdump is a very useful took with a lot of functions, hence filters and parameters plays a very important role to segregate what exactly we need, without going much in MAN pages,  within this blog post, we will cover mostly used tcpdump commands and their usage.


Usage 1

Capture packets from any interface and write it's output in pcap format file named as pcktdump.pack 

Syntax Template

# tcpdump -i any -w /tmp/pcktdump.pcap host 10.10.100.75

More details

  • -i any
    • i - interface
    • -i any - any interface
  • -w /tmp/pckdump.pcap
    • -w - write
    • -w /tmp/pcktdump.pcap : Write to file /tmp/pcktdump.pcap
  • host 10.10.100.75
    • Packet filter with incoming request on IP 10.10.100.75



Usage 2

Capture packets from any interface and save multiple files of fixed size.


Syntax Template

# tcpdump -i any -W 3 -C 10 -w /tmp/pcktdump.pcap host 10.10.10.75

More details

  • -i any
    • i - interface
    • -i any - any interface
  • -W 3 -C 10
    • Rotating buffer of 3 files (-W 3) and tcpdump switches to another file once the current file reaches 10,000,000 bytes ( 10Mb)
  • -w /tmp/pckdump.pcap
    • -w - write
    • -w /tmp/pcktdump.pacp: Write to file /tmp/pcktdump.pcap
  • host 10.10.100.75
    • Packet filter with incoming request on IP 10.10.10.75


Read more ...

How to disable Visual mode in VIM

Have you witnessed, suddenly your copy paste stopped working from windows box to putty terminal into VIM insert console,  more over to it, there is a strange string named as VISUAL at the bottom of the screen.

Visual mode is a feature of VIM which changes the interaction with vim when there is a mouse selection. This made copy+pasting annoying, let know it's cure here.

Open terminal and create a hidden file under your home directory as "vimrc"

# touch ~/.vimrc

# echo "set mouse-=a" >> ~/.vimrc

And yes you are done, back to usual mode no Visual :) 


Info from : GitHub


Read more ...

S3cmd - A faster way for AWS S3 Operations.


S3cmd


A very faster and reliable CLI tool for AWS object storage (S3) operations.


So this tutorial is just a walk through to
  • How to install s3cmd
  • How to configure S3cmd
  • Basic operations copy, move, list.

Requirements.
  • AWS Console access.
  • API Token for same account.
  • PIP is installed within Windows system to install python packages

Installation.

For Windows
pip install s3cmd
For Linux
sudo apt-get install s3cmd -y


Configuration.

Before we proceed to run cli commands, let configure s3cmd configuration file to authenticate.

For Linux -
Toggle to home directory of your account.

# cd ~
Create an empty hidden file named as .s3cfg

# touch .s3cfg
Add the below lines and add your own access_key and secret_key and save.

[default]

# Login credentials
access_key = AKMYOWNACCESSKEYHDEG
secret_key = 1DwMYownAccessSecretKeyoOV8

Now we are ready to do s3 operations using s3cmd cli, all cli commands are same for windows and linux operating systems.


Object Storage operations.

  • List content of your S3 Bucket.
# s3cmd ls s3://<Your AWS Bucket Name/
  • Create an new Bucket
# s3cmd mb s3://my_own_s3_newbucket/
  • Uploading content within a Bucket.
# s3cmd put myfile1.txt myimage.jpg s3://my_own_s3_newbucket/
    • Download content from Bucket.
    # s3cmd get s3://my_own_s3_newbucket/myimage.jpg myimage.jpg
    • Remove and existing Bucket
    # s3cmd rb s3://my_own_s3_newbucket/
      • Move content of one bucket(Source) to another(Destination).
      # s3cmd mv --recursive s3://failed/ s3://old_failed/



      Read more ...

      Ubuntu : How to access Android device media files through USB


      How to  access Media files from Android device, whether it's internal phone storage or external microSD card.

      Steps to access Android Devices in Ubuntu, Linux Mint.

      Here MTP stands for Media Transfer Protocol, which comes to existese when we connect our Smartphone through USB cable into computer/laptops.

      Just Install libmtp, FUSE file system for MTP enabled devices mtpfs using below commands.

      # sudo apt-get install go-mtpfs
      sudo apt-get install libmtp
      sudo apt-get install mtpfs mtp-tools
      mtp-detect 
      mtp-detect  ==> Run this command to verify your Android Device.

      • Rejack your Android device using USB cable in Ubuntu.
      • In your Android device, swipe down from above in the home screen and click Touch for more options. 
      • In the next menu, select option “Transfer File (MTP)“.
      • If required then, restart your device manager to
        sudo service udev restart

      And you are done :) 




      Read more ...

      SSH from your favourite browser using Shellinabox




      Shellinabox is perfect tool if you have any of the requirement.

      Missing Putty or SSH agent on your desktop  ?
      Looking for Client less agent to SSH ?
      Want to SSH your Linux server or desktop from mobile.

      So lets move ahead and just follow the steps to install Shellinabox.

      Video tutorial, for video lovers.


      ShellinaBox Installation on  CentOS7

      Introduction [ Shell In A Box ]

      Shell In A Box implements a web server that can export arbitrary command line tools to a web based terminal emulator. This emulator is accessible to any JavaScript and CSS enabled web browser and does not require any additional browser plugins.

      Official repository link

      More info on official git page :  https://github.com/shellinabox/shellinabox

      Installation.

      Intsall EPEL Repo.


      [root@cyberkeeda ~]# yum install epel-release 


      Install shellinabox package


      [root@cyberkeeda ~]# yum install shellinabox


      Configuration.

      Shellinabox configuration file  :    /etc/sysconfig/shellinaboxd


       Lets have a look on the file and allow and modify the important lines

      [root@cyberkeeda ~]# vim /etc/sysconfig/shellinaboxd



      # Shell in a box daemon configuration
      # For details see shellinaboxd man page

      # Basic options
      USER=shellinabox
      GROUP=shellinabox
      CERTDIR=/var/lib/shellinabox
      PORT=4200
      OPTS="--disable-ssl-menu -s /:LOGIN"
      OPTS="-t -s /:SSH:192.168.0.181"

      PORT

      PORT=4200

      Chnage PORT to some other to avoid conflict between sytem level ports 

      I will be changing it to 6162 

      SSH HOST

      OPTS="-t -s /:SSH:192.168.0.101"

      Chnage IP or Hostname to your default login host, by default shellinabox will ask to login into it, then later you can ssh and jump into n number of servers.


      My final config file would look as

      # Shell in a box daemon configuration
      # For details see shellinaboxd man page

      # Basic options
      USER=shellinabox
      GROUP=shellinabox
      CERTDIR=/var/lib/shellinabox
      PORT=6162
      OPTS="--disable-ssl-menu -s /:LOGIN"
      OPTS="-t -s /:SSH:192.168.0.101"


      Configuration Done..

      Important : 

      STOP Firewalld iptables and disable selinux 

      #    Service firewalld stop
      #    Service iptables stop

      Disable SELINUX : change status of selinux to disabled

      Finally Restart the shellinaboxd daemon.



      [root@cyberkeeda ~]# service shellinaboxd start

      Read more ...
      Designed By Jackuna