Learn Cyber Security, How to InfoSec, Tutorials, and more about CyberSecurity!

Tuesday, 27 October 2015

Sockets





Maybe you heard before or not about sockets. Today I am gonna talk a little about this subject

What is a socket?
You may have heard some UNIX hacker state, "Jeez, everything in UNIX is a file!". What that person may have been talking about is the fact that when UNIX programs do any sort of I/O (input/output), they do it by reading or writing to a file descriptor. A file descriptor is simply an integer associated with an open file. But, that file can be a network connection, a FIFO, a pipe, a terminal, a real on-the-disk file, or just about anything else. Everything in UNIX is a file! So when you want to communicate with another program over the Internet you're gonna do it through a file descriptor.
You make a call to the socket() system routine. It returns the socket descriptor, and you communicate through it using the specialized send() and recv() socket calls.

Question: "If it's a file descriptor why can't I just use the normal read() and write() calls to communicate through the socket?"
Answer: You ca, but send() and recv() offer much greater control over your data transmission.

There are all kinds of sockets:
- Internet Sockets
- UNIX Sockets
- X.25 Sockets
- etc.

There are a lot of Internet sockets, but I am gonna talk about only two in this post:
- Stream Sockets (SOCK_STREAM)
- Datagram Sockets (SOCK_DGRAM) or Connectionless Sockets

Stream sockets are reliable two-way connected communication streams. If you output two items into the socket in the order "1, 2", they will arrive in the order "1, 2" at the opposite end. They will also be error-free.

Question: "What uses stream sockets?"
Answer: Well, you may have heard of the telnet application; it uses stream sockets. All the characters you type need to arrive in the same order you type them. Also, web browsers use the HTTP protocol which uses stream sockets to get pages.

Question: "How do stream sockets achieve this high level of data transmission quality?"
Answer: They use a protocol called "The Transmission Control Protocol" otherwise knows as TCP. TCP makes sure your data arrives sequentially and error-free. You may have heard "TCP" before as the better half of "TCP/IP" where IP (Internet Protocol) deals primarily with Internet routing and is not generally responsible for data integrity.

Datagram sockets: if you send a datagram, it may arrive. It may arrive out of order. If it arrives, the data whithin the packet will be error-free.
Datagram sockets also use IP for routing, but they don't use TCP; they use the "User Datagram Protocol" (UDP).

Question: Why are Datagram sockets connectionless?
Answer: Well, basically, it's because you don't have to maintain an open connection as you do with stream sockets. You just build a packet, slap an IP header on it with destination information, and send it out. No connection needed. They are generally used either when a TCP stack is unavailable or when a few dropped packets here and there don't mean the end of the Universe.
Sample applications: tftp(trivial file transfer protocol), dhcpcd(a DHCP client), multiplayer games, streaming audio, video conferencing, etc.
The TFTP and similar programs have their own protocol on top of UDP. For example, the TFTP protocol says that for each packet that gets sent, the recipient has to send back a packet that says, "I got it!"(an ACK packet). If the sender of the original packet gets no reply in a limited time, he'll re-transmit the packet until he finally gets an ACK. The acknowledgment procedure is very important when implementing reliable SOCK_DGRAM applications.
For unreliable applications like games, audio or video, you just ignore the dropped packets, or perhaps try to cleverly compensate for them.

Question: Why would you use an ureliable underlying protocol?
It's way faster to fire-and-forget than it is to keep track of what has arrived safely and make sure it's in order and all that. If you're sending chat messages, TCP is great; if you're sending 40 positional updates per second of the players in the world, maybe it doesn't matter so much if one or two get dropped, and UDP is a good choice.

References:
1. Beej's Guide to Network Programming - Copyright © 2015 Brian “Beej Jorgensen” Hall

Monday, 26 October 2015

Transmission Control Protocol (TCP)





As strategic and tactical computer communication networks are developed and deployed, it is essential to provide means of interconnecting them and to provide standard interprocess communication protocols which can support a broad range of applications. In anticipation of the need for such standards, the Deputy Undersecretary of Defense for Research and Engineering has declared the Transmission Control Protocol(TCP) described herein to be a basis for DoD-wide inter-process communication protocol standardization.
TCP is a connection-oriented, end-to-end reliable protocol designed to fit into a layered hierarchy of protocols which support multi-network applications. The TCP provides for reliable inter-process communication between pairs of processes in host computers attached to distinct but interconnected computer communication networks. Very few assumptions are made as the reliability of the communication protocols below the TCP layer.
TCP assumes it can obtain a simple, potentially unreliable datagram service from the lower level protocols. In principle, the TCP should be able to operate above a wide spectrum of communication systems ranging from hard-wired connections to packet-switched or circuit-switched networks.
The TCP fits into a layered protocol architecture just above a basic Internet Protocol which provides a way for the TCP to send and receive variable-length segments of information enclosed in internet datagram "envelopes". The internet datagram provides a meas for addressing source and destionation TCPs in different networks. The internet protocol also deals with any fragmentation or reassembly of the TCP segments required to achieve transport and delivery through multiple networks and interconnecting gateways. The internet protocol also carries information on the precedence, security classification and compartmentation of the TCP segments, so this information can be communicated end-to-end across multiple networks.

References:
1. http://tools.ietf.org/html/rfc793 

Saturday, 24 October 2015

BIOS - Component Information







Now we are going to talk a little about BIOS component information.
On almost all computers when you press the "Turn On" button you will wait a little and after that it will boot into your operating system. Before it boots, you will have a down-bar where you can see something like: "Press F2 to enter Setup" or "Press Esc to enter Setup" or something similar. On major manufactures you have to press F2 button to enter into BIOS, but can be different from manufacturer to manufacturer.

Ok, we are in BIOS... Here we can use the BIOS information to learn which components are installed in the computer and some of their attributes. This information can be useful when troubleshooting hardware that is not working properly and to determinate upgrade options. These are some of the common components infomartion items that are displayed in the BIOS:
1. CPU - Displays the CPU manufacturer and speed. The number of installed processors is also displayed.
2. RAM - Displays the RAM manufacturer and speed. The number of slots and which slots the RAM modules are installed in might also be displayed.
3. Hard Drive - Displays the manufacturer, size, and type of the hard drives. The type and number of hard disk controllers might also be displayed.
4. Optical Drive - Displays the manufacturer and type of optical drives.

References:
1. https://www.chabotcollege.edu 

Monday, 19 October 2015

BIOS - Install updates







Your BIOS download probably came in an archive. Extract the contents of that file. You'll find some sort of BIOS file.
The archive should also contain a README file that will walk you through updating to the new BIOS. You should check out this file for instructions that apply specifically to your hardware, but we'll try to cover the basics that work across all hardware here.

a) Updating in Windows
Most newer PCs have a fairly easy BIOS update procedure: Just download the .exe file from your PC manufacturer's Website, quit all open program, run the .exe and let it handle the patch.
However, this isn't always the case, even for new motherboards or laptops, and it's possible that you will have to create a bootable CD or USB drive and copy the files to that. Even if the BIOS update is designed to be run from a floppy disk you can usually use a USB flash drive, but you may need to first enter the BIOS to tell it to boot from the CD or USB drive instead of the hard drive.

b) Update with a USB flash drive
To make a USB drive bootable, you will need a utility such as Rufus or Unetbootin. You will need a ISO image as well, and FreeDOS is the most appropriate for installing BIOS updates. Once you have the bootable drive, copy all necessary BIOS and update utility files onto it which you downloaded from the manufacturer's website.

BIOS - Find Update






Different motherboards use different utilities and procedurest, so there's no one-size-fits-all set of instructions here. However, you'll perform the same basic process on all motherboards.
The easiest way to identify the make and model of your motherboard is to look in the user manual of your mainboard. Additionally, the full model name (such as P5E3 Deluxe) is usually found somewhere on the board itself. It's important to get the full name as there are usually subtly different versions. Plus, you should note down the revision number (for example REV 1.03G) as it may require a different BIOS file to previous revisions.
If you have a laptop, you need only to find that make and exact model of the machine itself.








Next step is to visit your manufacturer's support page and check its listings for your PC, because if you download and install a BIOS intended for a different model, your PC probably won't work (although most BIOS updaters are smart enough to notice if you try to install them on the wrong hardware). If there is a BIOS update file available, grab it along with any documentation it comes with, because often warnings and specific instructions are contained in the "Read me" docs.

Also, remember, when you want to update BIOS be sure that you're PC can finish it. For this you must have an UPS (Uninterruptible Power Supplies) to be sure that if your electricy go down, your PC will have a second Power Source. For laptops, be sure that you keep your battery in your device and also make sure that is pluged in.

BIOS - Determinate Version






a) WindowsYour compute's BIOS version is displayed in the BIOS setup menu itself, but you don't have to reboot to check this version number. There are several ways to see your BIOS version from within Windows, and they work the same on PCs with a traditional BIOS or a newer UEFI firmware.
To use a command, open a Command Prompt windows - press Windows Key + R, type "cmd" into the Run dialog, and press Enter. Run the following command:



wmic bios get smbiosbiosversion


You will see the version number of the BIOS or UEFI firmware in your current PC. It should look something like this:









b) Linux
To find out BIOS version under Linux operating systems use the dmidecode command which is a tool to analyse BIOS data. You must login as root to run dmidecode command:

dmidecode | less







c) MAC
For Apple Notebooks you can follow next steps:
- Open System Information
- Select the Hardware section to view the Model Identifier, Boot ROM version, and SMC version numbers





If the firmware version you see in System Information is newer than what's listed for your MAC, you don't need to apply the updates listed for that model. If you try to use a manual updater that's not designed for your MAC, or if it's not needed, the installer alerts you and the software isn't installed.

BIOS - Introduction



BIOS (Basic Input/Output System) is the program a personal computer's microprocessor uses to get the computer system started after you turn it on. It also manages data flow between the computer's operating system and attached devices such as the hard disk, video adapter, keyboard, mouse and printer.
BIOS is an integral part of your computer and comes with it when you bring it home. BIOS is a program that is made accesible to the microprocessor on an erasable programmable read-only memory(EPROM) chip. When you turn on your computer, the microprocessor passes control to the BIOS program, which is always located at the same place on EPROM.
When BIOS boots up (starts up) your computer, it first determines whether all of the attachaments are in place and operational and then it loads the operating system (or key parts of it) into your computer's random access memory (RAM) from your hard disk or diskette drive.
With BIOS, your operating system and its applications are freed from having to understand exact details (such as hardware addresses) about the attached input/output devices. When device details change, only the BIOS program need to be changed. Sometimes this change can be made during your system setup. In any case, neither your operating system or any applications you use need to be changed.
Although BIOS is theoretically always the intermediary between the microprocessor and input/output device control information and data flow, in some cases, BIOS can arrange for data to flow directly to memory from devices (such as video cards) that require faster data flow to be effective.
Most BIOS implementations are specifically designed to work with particular computer or motherboard model, by interfacing with various devices that make up the complementary system chipset. Originally, BIOS firmware was stored in a ROM chip on the PC motherboard; in modern computer systems, the BIOS contents are stored on flash memory so it can be rewritten without removing the chip from the motherboard. This allows easy updates to the BIOS firmware so new features can be added or bugs can be fixed, but it also creates a possibility for the computer to become infected with BIOS rootkits.

References:
1. http://www.howtogeek.com
2. https://wikipedia.org

Popular Posts

Recent Posts

Powered by Blogger.