Friday 2 August 2019

Reset Kali Linux Root Password in Windows Subsystem for Linux

WSL manages the default login user from DefaultUID registry.

To edit this registry value, open Registry Editor or regedit.exe from start menu
Go to this registry path,

Double click on the DefaultUID value and change it to ZERO. Zero is for root user and 1000 (Decimal) or 3e8 (in hexadecimal) for normal users.

Open wsl.exe in command prompt. The prompt changes from $ to # (means root user). Run passwd command in Kali, change root password as usual.

Now go back to previous registry key, change Zero to previous value (or 3e8 in hex).


Tuesday 23 July 2019

Install Linux on Windows 10

1. Install Windows Subsystem for Linux using PowerShell

To ensure that the "Windows Subsystem for Linux" optional feature is enabled, Open PowerShell as Administrator and run:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Type Y to complete the installation and restart your computer.

2. Install Linux from the Microsoft Store

Open the Microsoft Store and choose your favorite Linux distribution.

Ref:- Linux Installation Guide for Windows 10

Thursday 11 July 2019

Linux Security Files for Security Administrator

File                        Description

/etc/nologin         It denies login to all users except root
/etc/passwd         This file holds user account information
/etc/shadow         secured password values

/etc/xinetd.d/*     Directory to store configuration files used by xinetd
/etc/xinetd.conf   Configuration file for xinetd
/etc/inetdconf      Configuration file for inetd

/etc/inittab           Contains initial startup table
/etc/init.d/*          Configuration file for run level
/etc/hosts.allow    list of allowed hosts
/etc/hosts.deny     list of denyed hosts

Common Computer Security Tools in Linux

Tool                       Description

chage                    Change user password expiry information
find                        search for files in a directory hierarchy
lsof                         List open files

netstat                 To see the status of the network
nmap                    Network exploration tool and security/port scanner
passwd                 To update user's authentication tokens

su                           To run a command with substitute user and group ID
sudo                      To execute a command as another user
ulimit                     Resource limits on shells can be set or viewed
usermod               modify a user account

The Process File System Information in Linux

The Process File System (/proc) give you access to information about the Linux kernel and all process currently running on your system.

Files and Directories in /proc

File Name                    Content

/proc/acpi                     Information about Advanced Configuration and 
                                     Power Interface(ACPI)
/proc/bus                      Bus-specific information for each bus type, such as PCI
/proc/cmdline              The command line used to start the Linux kernel
/proc/cpuinfo               Information about the CPU
/proc/devices               Available block and character devices

/proc/dma                    Information about DMA
/proc/driver/rtc            Information about Real Time Clock(RTC)
/proc/filesystems         List of supported file systems
/proc/ide                      Information about IDE devices
/proc/interrupts            Information about Interrupt Request(IRQ) numbers

/proc/ioports                Information about Input/Output(I/O) ports
/proc/kcore                  Image of the physical memory
/proc/kmsg                  Kernel messages
/proc/loadavg              Load average
/proc/locks                  Current kernel locks

/proc/meminfo            Information about physical memory and swap space usage
/proc/misc                   Miscellaneous information
/proc/modules             List of loaded driver modules
/proc/mounts               List of mounted file systems
/proc/net                      Directory of Information about networking

/proc/partitions            List of partitions known to Linux kernel
/proc/pci                      Information about PCI devices
/proc/scsi                     Information about SCSI devices
/proc/stat                     Overall statistics about the system

/proc/swaps                 Information about the swap space
/proc/sys                      Information about the system
/proc/uptime                Information about uptime
/proc/version               Kernel version number

The Most Popular Configuration Files in Linux System

List of the most popular configuration files and brief description

Configuration File                  Description


/boot/grub                             GRUB bootloader file
/boot/grub/menu.list             boot menu
/boot/                 Linux kernel map
/boot/vmlinuz                        Linux kernel


/etc/apache2/httpd.conf        Apache web server configuration file
/etc/apt/sources.list               lists the sources from which the APT obtains
                                              packages(Debian & Ubuntu)
/etc/at.allow                          users allowed to use the at command to 
                                              schedule jobs
/etc/at.deny                           users forbidden to use the at command
/etc/bashrc                            functions and aliases for bash shell

/etc/bash.bashrc                    functions and aliases for bash shell
                                             (Debian, SUSE & Ubuntu)
/etc/cups/cupsd.conf            The CPUS scheduler
/etc/fonts/local.conf             font configuration file
/etc/fstab                              Information about the various file system and mount
/etc/group                             Information about groups

/etc/grub.conf                       GRUB bootloader
                                             (Fedora& SUSE)
/etc/hosts                              IP address and their hostnames
/etc/hosts.allow                    Hosts allowed to access internet service
/etc/hosss.deny                     hosts forbidden to access internet services
/etc/httpd/conf/httpd.conf    Apache web server configuration file

/etc/init.d                              Directory with scripts to start and stop various servers
/etc/init.d/rcS                        Linux initialization script
                                              (Debian, SUSE & Ubuntu)
/etc/inittab                             The init process that starts all the other processes
/etc/issue                               Distribution name and the version number
/etc/lilo.conf                          Linux Loader(LILO) configuration file

/etc/login.defs                       Default information for creating user accounts
/etc/modules.conf                 Configuration file for loadable kernel module
/etc/mtab                               Information about the currently mounted file systems
/etc/passwd                           Information about all user accounts
/etc/profile                            Systemwide environment and startup file for the bash sell

/etc/profile.d                         Directory containing file that the /etc/profile script executes
/etc/rc.d/rc.sysinit                 Linux initialization script
/etc/shadow                           Secure file with encrypted passwords for all user accounts
/etc/shells                              List of all the shells on the system that the user can use
/etc/skel                                 Directory that holds .bash_logout, .bash_profile, .bashrc files

/etc/sysconfig                        Linux configuration files
                                              (Fedora & SUSE)
/etc/sysctl.conf                      Configuration file with kernel parameters
/etc/termcap                          Database of terminal capabilities and options
                                             (Fedora & SUSE)
/etc/udev                               Directory containing configuration files for udev
/etc/X11                                Directory with configuration files for X Window 

/etc/X11/xorg.conf               Configuration file for X.Org X11 the X Window System
                                             (Fedora, Ubuntu & SUSE)
/etc/xinetd.conf                    Configuration for the xinetd daemon that starts internet 
                                             service on demand
/etc/yum.conf                       Configuration for the Yum package updater and installer


/var/log/apache2                  Web-server access and error logs
/var/log/cron                        Log file with messages from the cron process that runs 
                                            scheduled jobs
/var/log/boot.msg                File with boot messages(SUSE)
/var/log/dmesg                    File with boot messages
                                            (Debian, Fedora & Ubuntu)
/var/log/httpd                      Web-server access and error logs(Fedora)
/var/log/message                 System log

APT    - Advanced Packaging Tool
CPUS - Common Unix Printing System

Basic TCP/IP Network Configuration Files

Summary of basic TCP/IP configuration files

File                                        Description
/etc/hosts                           IP address and hostnames for local network
/etc/networks                    Names and IP address of networks
/etc/host.conf                    Translate host name in to IP address
/etc/resolv.conf                 IP address of name servers
/etc/hosts.allow                 Allow which system can access internet
/etc/hosts.deny                  Deny internet access to systems
/etc/nsswitch.conf            Translate hostnames into ip address

Wednesday 10 July 2019

Common vi Commands

List of commonly used vi commands

Command              Does the following function

Insert Text
a                              Inserts text after the cursor
A                             Inserts text at the end of the current line
I                               Inserts text at the beginning of the current line
i                               Inserts text before the cursor

Delete Text
D                             Deletes up to the end of the current line
dd                           Deletes the current line
dG                          Deletes from the current line to the end of the file
dw                          Deletes the current word where the cursor presently resides
x                              Deletes the character on which the cursor rests

Change Text
C                             Changes up to the end of the current line
cc                            Changes the current line
J                              Joins the current line with the next one
rx                            Replaces the character under the cursor with x
                                (where x is any character)

Search Text       
/string                  Searches forward for a string
?string                  Searches backward for a string

Scroll Text
Ctrl+D                   Scrolls forward by half a screen
Ctrl+U                   Scrolls backward by half a creen
Ctrl+L                    Redraws/refresh the screen

Cut and Paste Text
yy                           Yanks(copies)current line to an unnamed buffer
P                             Puts the yanked line above the current line
p                             Puts the yanked line below the current line

Move Cursor     
h                              Moves one character to the left
j                               Moves one line down
k                              Moves one line up
L                              Moves to the end of the screen
l                               Moves one character to the right
w                             Moves to the beginning of the following word
b                              Moves to the beginning of the previous word

Colon commands
:!command           Executes a shell command
:q                            Quits the editor
:q!                           Quits without saving changes
:r filename             Reads the file and inserts it after the current line
:w filename           Writes a buffer to the file
:wq                         Saves changes and exits

u                             Undoes the last command
Esc                          Ends input mode and enters visual command mode
U                             Undoes resent changes to the current line

Learn more:- Vim Cheat Sheet