Get me outta here!

Wednesday, February 16, 2022

Computer Graphics Basic (With Code)

 A pixel is one of the many tiny dots that make up the representation of a picture in a computer's memory.

Computer graphics can be created as either raster or vector images

1.      Raster Image - Pixel Based

2.      Vector Image - Mathematical Based

Raster image drawbacks –

·        Dpi(dots per inch)

·        Larger than vector in size

·        Less economical

Raster image advantages – User end friendly

Raster image formats – Tiff, Jpeg, Gif, Pcx, Bmp

Vector image drawbacks- Not suitable for complex graphic displays. Rasterization required for display.

Vector image advantages-

·        More malleable

·        More versatile

·        No upper or lower limit for sizing

Vector image formats- Ai, Eps, Cgm, Wmf, Pict(macOS)

Color Models- RGB and CMYK

Code

Color

W

White

R

Red

G

Green

B

Blue

C

Cyan

M

Magenta

Y

Yellow

K

Black

RGB – Additive Color

CMYK – Subtractive Color



C=G+B=W-R

M=R+B=W-G

Y=R+G=W-B

3 bit RGB = (21)3 = 8 ; [1 bit each color]

6 bit RGB = (22)3 = 64 ; [2 bit each color]

Color Code

RGB

B

001

G

010

R

110

C

011

*RGB intensity value 0 to 255
                          

Color Palette: Color palette is a finite set of colors. CMYK range is 0 to 100%.

Example:

Color

RGB

CMYK

White

255,255,255

0,0,0,0

 


(Code for understanding and comment for describe what are the works of fucntion)
#include<GL/gl.h>
#include<GL/glut.h>
void display(void)
{
    glClear (GL_COLOR_BUFFER_BIT); //clear the pixels of previous code
    glColor3f(1.0,1.0,1.0);
    glBegin(GL_TRIANGLES); //Beginning of drawing triangle
    //2d Shape
    glVertex3f(0.5f,0.7f,0.0f);
    glVertex3f(0.9f,0.75f,0.0f);
    glVertex3f(0.54f,0.73f,0.0f);
    glEnd(); //End of drawing triangle
    glFlush(); //force execution of GL commands in finite time


}
void init (void) //new function
{

    glClearColor(0.0,0.0,0.0,0.0); //Select clearing (Background) Color
    glMatrixMode(GL_PROJECTION); //The value we use, it will be initialized through this function
    glLoadIdentity(); //replaces the current matrix with the identity matrix
    glOrtho(0.0,1.0,0.0,1.0,-10.0,10.0); //size of x-y-z axis like graph paper

}
int main(int argc, char** argv) //argc stands for argument count and argv stands for argument values. These are variables passed to the main function when it starts executing
{
    glutInit(&argc, argv); //is used to initialize the GLUT library
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //display modes: Single and RGB
    glutInitWindowSize(600,600); //windows size
    glutCreateWindow("Hello"); //title of windows
    init(); //call and commit the function
    glutDisplayFunc(display); //call the display function
    glutMainLoop(); //use for change shape by keyboard
    return 0;
}

 

 

 

 

 

 

Thursday, February 10, 2022

Some Commands of Linux

pwd - It prints the current working directory

Is - This command is used to list information or content in a particular file/folder.

cd - It is used to change the current working directory. Example: cd Desktop

mkdir - Create a new folder

man - Displays the help manual for a

particular command. Example: man Is

shutdown: Shutdown or restart your system

rmdir: Used to remove/delete a directory/folder

clear: Clear the terminal

apt-get update: Update kali Linux

apt-get install: To install a new program.

Example: apt-get install leafpad

ifconfig: It is similar to the windows command ipconfig. It shows basic network details such as IP addresses, broadcast address, mac

address, and much more.

iwconfig: It is similar to the ifconfig command. It is more focussed on only wireless network

interfaces.

ping: It is usually used as a simple way to verify that a computer can communicate over the network with another computer or network device.

arp: It is used to find IP to MAC address mappings. ARP, which stands for Address Resolution Protocol, is a protocol used to map

a MAC address (or hardware address) to an IP address.

netstat: It delivers basic statistics on all network activities and informs users on which ports and addresses the corresponding connections (TCP, UDP) are running and which ports are open for tasks.

route: It fetches the routing table. It basically tells where all the network is actually routed.

grep: It is used to search a given file for patterns specified by the user. Basically 'grep' lets you enter a pattern of text and then it searches for this pattern within the text that you provide it.

tr: The tr command is used for translating or deleting characters.

cat: cat command allows us to create single or multiple files, the view containing the file, concatenate files, and redirect output in

terminal or files.

cut: It is used to extract sections from each line of input – usually from a file.

echo: It is used to print anything on the console.

If:

if [ expression

then

Statement(s) to be executed if expression is true

else

Statement(s) to be executed if expression is not true

fi

Sudo: The Sudo command allows you to run programs with the security privileges of another user (by default, as the superuser). It prompts you for your personal password and confirms your request to execute a command by checking a file, called sudoers, which the system administrator configures.

For Loop: The for loop operates on lists of items. It repeats

 a set of commands for every item in a list. It is

  used to iterate over something.

                Example:

         for var in 0 123456789

         do

          echo $var

         done

   Output: It will print numbers from 0 to 9

The Script:

Below is the IP Sweeper script,

#!/bin/bash

for ip in seq 1 254 ; do

ping -c 1 $1.$ip I grep "64 bytes" | cut -d ""-f 4||

tr -d “:" &

done

This script will execute and return the ip address

in the specified domain range that had  responded to the ping.

Write the above script in ipsweep.sh file.

Breaking down

  #!/bin/bash

It's basically a comment. We are telling the computer that, it is a bash script.

for ip in seq 1 254 ; do

This is for loop. We want to execute the command for every ip in the given network range.

Thus, we write a for loop and execute it in a range for 1-254 that is, the number of ip addresses in a

particular network.

ping -c 1 $1.$ip | grep "64 bytes" | cut -d "" -f 4|

tr -d “:" &

• ping: To ping the ip address

• -c 1: Ping one ip at a time

$1.$ip: $1 will be the user input. We will input the first three ranges of the IP and the last

 range will be taken from the for loop. Example: If user input was 192.68.1 then in the first run

of for loop $ip will be 1. Thus $1.$ip will result in 192.68.1.1 and it will ping this ip.

grep “64 bytes": Try running a ping command to an ip. If the ip responds, the result will be "64 bytes from (given_ip)". Thus, if the ip is active, it will respond and the response will contain the term "64 bytes ". Thus, grep "64 bytes" will simply filter out the ip's that responded from a total of 254 ip addresses.

ping -c 1 $1.$ip I grep "64 bytes" | cut -d ""-f 4||

tr -d “:" &

We know that if the ip is active it will respond. The demo of responding will be something like this, '64 bytes from given_ip' where given_ip will be the ip pinged too.

Thus, from the whole response now, we will need only the ip address of the responded ip.

 cut -d “" -f 4:

This command basically does the same thing. It cuts the whole response with the delimiter(-d) whitespace(“ ") and picks the 4th term(-f 4) from it, that will be the ip.

The cut command will basically produce output

             like 192.68.1.1

Here, we don't need the colon(:). We just need

    the ip, thus we run the tr command.

 tr -d “:": Here we pass colon(:) as a delimiter and tr command deletes it.

 &: This basically allows the thread to work simultaneously

  I (pipe): It basically joins all the above

 commands as a single command

How to Run?

Now save the file and hit the below command on

      the terminal to run the script.

   .lipsweep.sh [First three ranges of your ip]

     Example: ./ipsweep.sh 192.186.1

This will run the file and sweep all the active ip's

in the given range in the text file. Later we can

   perform many network-related hacking

        operations on these IPs.

Friday, February 4, 2022

Algorithms

The way how to solve problems is called Algorithms. The way how to deal with inputs and outputs is called Data Structure

Parameters to measure efficiencies of software are given below in the picture:







Wednesday, February 2, 2022

Binary to Decimal conversion

 How to convert binary to decimal

For binary number with n digits:

bn-1 ... b3 b2 b1 b0

The decimal number is equal to the sum of binary digits (dn) times their power of 2 (2n):

decimal = b0×20 + b1×21 + b2×22 + ...

Example: Binary - 001

Decimal - 1×20 + 0×21 + 0×2= 1

Binary to decimal conversion table

Binary
Number
Decimal
Number
Hex
Number
000
111
1022
1133
10044
10155
11066
11177
100088
100199
101010A
101111B
110012C
110113D
111014E
111115F
100001610
100011711
100101812
100111913
101002014
101012115
101102216
101112317
110002418
110012519
11010261A
11011271B
11100281C
11101291D
11110301E
11111311F
1000003220
10000006440
1000000012880
100000000256100