Saturday, May 23, 2020

Linux terminal subsystem



The terminal subsystem consists of three layers

  • The upper layer implements the character device interface ( open, read, write, close …)
  • The line discipline
  • The lower layer which communicates with the hardware or the pseudoterminal.

The line discipline glues the upper and the lower layer together.
The tty subsystem is passive: it only reacts on either a key being pressed or the user requesting something from it.

How terminal communicate with process(file descriptor file)
Terminal read and write operation
A Unix based system processes communicate with the terminal through terminal character device file, all the text we write in the terminal are store in the input buffer of this file and then the process may read from this to get the data. 

In this mechanism file descriptor 0 SDTIN used for read data from device file and file descriptor 1 STDOUT used for writing data to the file this type of terminal are called hardware-based terminal used in the past.
Now we emulate the terminal using software, a personal computer can run terminal emulator software that replicates the function of a terminal, sometimes allowing concurrent use of local programs and access to a distant terminal host system. The terminal emulators on most Unix-like systems such as gnome-terminal, qterminal, xterm, do emulate physical terminal including support for escaping sequences. 



how process communication with the master and slave terminal system
master and slave terminal
X windows system the program that controls the display, drawing the boxes and buttons.  Suppose we open a terminal emulator in X windows and start writing text in the terminal, the text we write goes from the X window server to terminal emulator which writes the text in the input buffer of "master" pseudo-terminal character device file. The operating system copies data from master to its associated "slave" pseudo-terminal character device file to be read by the process. Each terminal emulator has its own master and slave pseudo-terminal pair.
Usually, the master is connected to a terminal emulator (such as xterm) and the slave is connected to a program being run, most commonly a shell (such as bash). Thus, the slave behaves exactly like a classical terminal.
When the master side is opened, the corresponding slave device can be used in the same manner as any TTY device. The master and the slave device are connected by the Kernel.
Pseudo terminals are used, among others, by network login services (ssh, rlogin, telnet) and to implement terminal emulators (such as xterm, script, screen, tmux, unbuffer, expect). They are also be used to send data to su or passwd (they refuse to read from pipes).

There are two APIs: BSD style and Unix 98 (System V) style.
BSD style pseudo terminals are deprecated on Linux since kernel version 2.6.4 

Unix 98 style

Master pseudo terminals: /dev/ptmx
Slave pseudo terminals: /dev/pts

BSD style

Master: /dev/ptyXY
Slave: /dev/ttyXY

/dev/pts :

When a process opens /dev/ptmx, it gets a file descriptor for a pseudoterminal master (PTM), and a pseudoterminal slave (PTS) device is created in the /dev/pts directory.  Each file descriptor obtained by opening /dev/ptmx is an independent PTM with its own associated PTS, whose path can be found bypassing the file descriptor to its name.
Before opening the pseudoterminal slave, you must pass the master's file descriptor to grantpt() and unlockpt()Once both the pseudoterminal master and slave are open, the slave provides processes with an interface that is identical to that of a real terminal. Data written to the slave is presented on the master file descriptor as input.  Data written to the master is presented to the slave as input.

/dev/tty : 

TTY is the abbreviation of Tele-Typewriter (or Tele-Type)
Originally, a TTY was physically connected to a Unix machine as an input/output device, usually on an RS-232 cable. 

The input was fed on a keyboard.In the beginning, the computer's output was going to a printer and later also to screens It is a special kind of file, it doesn't represent the character device. When a program opens /dev/tty file they get the file descriptor for the so-called controlling terminal that is terminal associated with their process. In simple words, it used for controlling the terminal file.
A TTY (or terminal) device is a special class of a character device.

A Terminal device might act as a controlling terminal for a session, such as
  • virtual consoles
  • serial ports
  • Pseudo-terminal (PTYs)
All registered TTY devices that are present in the kernel are found under sys/class/tty. The most important data structure to implement a TTY driver is the struct tty_driver.

/dev/ttyN: 

These are character device file for representing the virtual console and these virtual consoles has specific features where N represent the number. So let's say in any case if you open /dev/tty1, what you are doing is writing to the terminal of the first virtual console.

We can open six virtual terminals in Linux using CTRL+ALT+F(1 to 6) for each terminal we have one character device file like for the first terminal you have tty1.


Friday, May 22, 2020

Type of binding in IIS(Internet Information Services) in windows server



IIS web server binding types in windows 2012R2
IIS webserver 

   



Before understanding binding, you must be able to understand the concept of these terms.

IP Address:

An IP address is a number identifying a computer or another device on the Internet. IP addresses uniquely identify the source and destination of data transmitted with the Internet Protocol.

IP address is the unique identification address of your website similar to your house address in your city with the help of the IP address of your website is uniquely identifiable among other websites on the internet.

Port Number :

A port in computer networking is an access channel for communication between two devices. When a service (server program) initially is started, it is said to bind to its designated port number. As any client program wants to use that server, it also must request to bind to the designated port number.
Port represents the numbers and basically specific to the protocol. Port numbers are from 0 to 65535. Ports 0 to 1024 are reserved for use by certain privileged services whenever there are exchanges of data or communication present, there must be a port for this.

Hostname :

A hostname is a domain name that has at least one associated IP address. For example, the domain names www.example.com and example.com are two hostnames, whereas the com domain is not, In this Second-level domain is example and hostname is www.
In simpler terms the name for your website.
All hostnames have a corresponding IP Address that is mapped to it. These hostnames are resolved to their IP Address using DNS. There are four parameters that can be used in a site binding: IP Address, Port and Host Name, and type of website but with a combination of IP address and port, you may generate a fifth possibility for binding.


iis server panel in windows server 2012R2
IIS binding panel view


Website with IP address binding :

In this we specify the IP address for each of our website, Every website has a unique IP address. For example we bind IP address 192.168.43.51 with website name www.example.com whenever an HTTP request coming to 192.168.43.51 will be served by this website irrespective to the host header


website name(hostname) with ip address
website with IP address
                       


Website with hostname binding :

In this, we have the advantage of the host header we can change the host header according to our needs. For example, we are running a small business and we afford the only cost of one IP address then we host multiple hostnames using same IP address like www.example.com and example.com host on same IP address 192.168.43.51


website binding with hostname addresss
website with hostname


Website with unique port:

In this port number of every website must be different IP address or hostname may be the same. So whenever we search for a website we specify the port also like 192.168.43.50:80 or 192.168.43.50:8010

Sometimes this type of binding causes problems also like the browser default port for HTTP is 80 so www.example.com will work fine but for example.com we must specify the port as I mentioned above.


website binding with unique port
website with unique port binding



Website with Type binding:

Type binding helps us to differentiate between HTTP and https website IIS mainly have two types through which we can identify the website whether it is bind to HTTP or https. For https type SSL certificate is required and the default port for this 443 as shown below


website binding with unique type(http/https)
website with unique type(http/https) binding




Types of web Hosting

When you think about hosting your website it is important for you to consider some factor that directly affects your website hosting. Like:- Bandwidth, storage, dependability, scalability, secure site certification, malware and spam protection, etc.


how to choose which web hosting is good for you
Types of web hosting

With all the different types of web hosting available, it can be confusing to choose the right one but after gathering all the data regarding these above factors will help you to clear your view. There are lots of options currently present on the internet so let’s go one by one to each of them.



Shared hosting :

This is the first step towards hosting or we can say just the beginning of hosting a website if you are new to this area. In this type of hosting your website is hosted on a shared server as its name suggests the factors like storage, bandwidth, and many more are shared among all the clients of that shared server.

Because of this sharing sometimes a problem arises as if someone’s site has large traffic at a specific time then it will slow down your website to load and increases the response time also.
The hosting service provider provides its own system administration. If you belong to the non-technical field, needed less headache for managing your website, and having fewer visitors then shared hosting is one of the best options for you.


 Dedicated hosting :

This hosting type is totally opposite to the shared hosting, in shared hosting where we are sharing the server among all clients in this we are hosting our website in a separate server. All the resources on that server are dedicated to our website use.

In this we are responsible for our server security and its management, we have admin privileges means full access control over the server. Also, a high level of technical expertise is required for the installation and ongoing management of the server. Dedicated hosting is one of the expensive types of hosting services and it is only be chosen if your daily visitors are large enough and having large traffic on the website.

                            


VPS(virtual private server) :

This server is somewhere in the middle of a dedicated server and shared server in the functionality because we have our own server resources but the difference is that the whole server does not belong to us meaning the overall CPU time, memory, and many more resources are shared. Suppose hosting service provider has a server of size 10GB of memory whole but for you, it may reserve 4GB of memory. Resources are divided among the client virtually according to the requested arises by the client.
The resources and our own website are still in the hand of the server provider. There may be a concern of security if any of the servers misconfigure then maybe your website compromises therefore security is less as compared to a dedicated server but much more by the shared server.
This type of hosting gives less control over the server, the service provider is totally responsible for security, maintenance, and administration over our website.


Cloud-based hosting:
This is one of the latest type of hosting where we use the cloud service of any provider. In this, so many servers are presently making the clusters of servers. The resources required for maintaining your website are spread across more than one web server, reducing the chance of any downtime due to server malfunction.
Cloud-based hosting is scalable meaning if your site can grow over time, using as many resources as it requires and you only have to pay for what you need. This allows users to employ as many resources as they need without having to build and maintain their own computing infrastructure.
It’s a hosting solution that works via a network and enables companies to consume computing resources like a utility.


Self-service web hosting :

Self-service hosting means by its name itself, you have to rent a place for your server and storage. The complete web hosting is at your own responsibility. The hardware, software power, bandwidth, cooling, backups, administration are maintained by your self. It is the most expensive type of hosting because all the resources are own by us.
Then comes some of the hosting types which are not so popular but have their own importance.

Colocation web hosting :
When you opt for colocation hosting means you rent a space from a data center of any company. You provide your own server, hardware and they provide physical space, security, internet connectivity, cooling. this directly means we are owning our own server and its software so if any fault comes inside our server then it's our responsibility to replace it and take care of it. So its directly implements that we should only opt for these type of hosting types if we have some technical background or expertise. 


WordPress Hosting :

In this hosting you will get the hosting service inside the Wordpress server means Wordpress subdomain inside it. In clear words, WordPress hosting is a service where the web hosting provider will keep your WordPress installation up-to-date. It is not expensive as shared web hosting, this comes as a great option if you are a beginner to this and want no headache because Wordpress offer vary large number of plugin and themes for your website



Knowing Kali Linux for OSCP

Kali Linux is developed and maintained by the offensive security professional. It is a Debian-based Linux distribution focus at advanced Pen...