User Tools

Site Tools


opus:spring2012:skinney1:part2

Part 2

Entries

Entry 5: March 9, 2012

I just installed Fedora on a machine that i had worked on in the above experiment. Ubuntu was a large improvement over Win XP. It just still had some issues with speed and responsiveness. I notice many times it had a hard time keeping up with the visual aesthetics. It would also have to start and wait with many functions. I ran Fedora 16 live from a usb and I was very impressed. The machine ran smooth and without issues. I had used Kde in the past and found it to be a nicer GUI over the Gnome world. Performance was top notch until i started to test it against what i wanted it to do. I was used to the large developer base that comes from the Gnome world and I could tell right away that Fedora was missing a few bolts under the hood. The newest issue is with video. All of my video are ripped, stripped and converted to .avi files. Apparently one thing Fedora is not really happy with. I will be reviewing the repository and trying to make it work in an upcoming experiment.

Entry 6: March 16, 2012

Linux put the space shuttle in orbit. I was doing some looking around and it seems the NASA is sweet on linux. Discovery runs all lunix controls and most of what they are using is self written code. Nice to know that we do not have to restart the servers when we have an issue while they are in orbit. lol. The newest thing is that NASA is using a linux based vendor Wind River to support the development their New Millennium Program Space Technology 8 (ST8) Dependable Multiprocessor.

Entry 7: March 23, 2012

I did a search on admin commands that unix has to offer and came across the “w” command. This command allows you to see a list of users and there log history etc. This one is fun when you are looking for someone or just want to see when someone last came to visit.

Snippet form that help file

Different options that are given are 
        -f    file
              Tells last to use a specific file instead of /var/log/wtmp.
       -num   This is a count telling last how many lines to show.
       -n num The same.
       -t YYYYMMDDHHMMSS
              Display  the  state of logins as of the specified time.  This is
              useful, e.g., to determine easily who was logged in at a partic-
              ular  time  --  specify  that  time  with -t and look for "still
              logged in".
       -R     Suppresses the display of the hostname field.
       -a     Display the hostname in the last column. Useful  in  combination
              with the next flag.
       -d     For non-local logins, Linux stores not only the host name of the
              remote host but its IP number as well.  This  option  translates
              the IP number back into a hostname.
       -F     Print full login and logout times and dates.
       -i     This  option is like -d in that it displays the IP number of the
              remote host, but it displays the IP number  in  numbers-and-dots
              notation.
       -o     Read  an  old-type  wtmp  file  (written by linux-libc5 applica-
              tions).
       -w     Display full user and domain names in the output.
       -x     Display the system shutdown entries and run level changes.
lab46:~$ w
 12:59:04 up 72 days, 20:19, 12 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
mgough   pts/1    rrcs-69-193-122- 17Jan12  1:09m 10:18  10:18  irssi
wedge    pts/8    telstar.lair.lan 09:13    2:23m  0.14s  0.14s -bash
jjohns43 pts/24   cpe-74-65-82-173 23Jan12 28:25m 11:08  11:08  irssi
thakes3  pts/32   :pts/8:S.0       16Mar12  1:17   2:02   2:02  irssi
thakes3  pts/41   172.16.198.143:S 21Mar12 45:39m  0.28s  0.04s nano notes.txt
thakes3  pts/48   172.16.198.143:S 21Mar12  1:17   1.84s  1.83s screen -r 6463.
thakes3  pts/68   172.16.198.143:S Mon10   14.00s  0.32s  0.32s /bin/bash
skinney1 pts/74   65-124-85-125.di 10:26    0.00s  0.10s  0.01s w
thakes3  pts/70   172.16.198.143:S Sun13   46:01m  0.09s  0.09s /bin/bash
thakes3  pts/85   172.16.198.143:S Wed10    2days  0.14s  0.00s /bin/bash
nsano    pts/73   grrasp:S.0       17Feb12 39:34   5:55   5:55  irssi
jjohns43 pts/82   cpe-74-65-82-173 27Feb12 28:25m  5.79s  5.78s screen -r
lab46:~$ w last skinney1
 12:59:14 up 72 days, 20:19, 12 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
lab46:~$

Entry 8: March Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Keywords

cprog Keywords

  1. Selection Structures (if, case/switch) (done)
  2. Repetition/Iteration Structures (for, while, do while) (done)
  3. Arrays (standard notation, pointer arithmetic, single-dimensional, multi-dimensional) (done)
  4. File Access (Read, Write, Append) (done)
  5. Structures (Declaration, Accessing Elements, Pointers to) (done)
  6. typedef, enum, union (done)
  7. Functions, Parameters (Pass by: Value, Address, Reference), Return Types, Recursion, Command-line arguments (done)
  8. Compiler, Preprocessor, Flags, Assembler, Linker, Multi-file programs (how to structure, how to compile) (done)

cprog Keyword 9

Selection Structures (if, case/switch)

Definition

A selection structure allows the program to respond differently depending on users input. For example if the user is prompted a question responds “yes” a certain action is taken. On the other hand if the user responds “no” the program then goes to a part of the code the exit. A common way to set up the program to respond to input is to use the IF, or and switch statements.

Demonstration

The IF statement

int main()
{
        int num;
 
        printf("enter and number between -10 and 10: ");
        scanf("%d", &num);
 
        if (num > 0)
                printf("%d is a positive number\n", num);
 
        return (0);
}
lab46:~/src/cprog/classproject$ ./ex15.out
enter and number between -10 and 10: 10
10 is a positive number

The IF and Else statement

#include <stdio.h>

int main()
{
  int i = 6;

  if (i > 1)
    printf("We have\n");

  if (i > 10)
    printf("nice amount\n");
  else
    printf("not big enough\n");

  if (i == 5 )
  {
    printf("only got 5\n");
  }
  else if(i == 6 )
  {
    printf("just right\n");
  }
}
lab46:~/src/cprog/classproject$ ./ex17.out
We have
not big enough
just right

cprog Keyword 10

Repetition/Iteration Structures (for, while, do while)

Definition

The Repetition/Iteration Structures, also known as loops, allow the program to go through a self check to determine if it should continue the executing the program.

Demonstration
#include <stdio.h>
 
int main()
{
  int loopCount;
  printf("enter loop count: ");
  scanf("%d", &loopCount);
 
  while(loopCount > 0)
  {
    loopCount = loopCount -1;
     printf("only %d loops to go\n", loopCount);
  }
 
return (0);
}
 enter loop count: 12
only 11 loops to go
only 10 loops to go
only 9 loops to go
only 8 loops to go
only 7 loops to go
only 6 loops to go
only 5 loops to go
only 4 loops to go
only 3 loops to go
only 2 loops to go
only 1 loops to go
only 0 loops to go

cprog Keyword 11

Arrays (standard notation, pointer arithmetic, single-dimensional, multi-dimensional)

Definition

An Array is setting up place holders for values. A good way to see this is if you picture an excel spreadsheet. You have a column and a row. The Array sets the number of columns and the number of rows. This allocates memory blocks to be used by the program. When you add more rows you are adding dimensions to the array.

That standard notation for an array is;

int array[SIZE] = {Column pointer,… ,…, etc..};

Demonstration

Single dimensional array

#include <stdio.h>
#define SIZE 5
int main()
{
	int array[SIZE] = {4, 5, 6, 7, 8};	
	int i;
 
	for (i= 0; i < SIZE; i++)	
	{
		printf("%d\n", array[i]);
	}
return 0;		
}
lab46:~/src/cprog/classproject$ ./ex19.out
4
5
6
7
8

cprog Keyword 12

File Access (Read, Write, Append)

Definition

File access is when the program gets information from a file or produces an output to a file. This can be helpful in many ways. For example. With our encoding program we took input from a file converted it and then output the results to a file.

Commands used fgetc fprintf

Demonstration
int main()
{
        FILE *in;
        char *c, fname[] = "message.in";
        int i;
        int *input[255];
 
        printf("Do you want to encrypt the file: ");
        scanf("%d", input);
 
        if (*input == 'y' || *input == 'Y')
                {
                        c = fgetc(in);
                        while(c != EOF)
                        {
                        if((c >=65) && (c <= 'Z'))
                                c++;
                        else if((c >= 'a') && (c <= 'z'))
                                c++;
                        if((c == ('Z' + 1)) || (c == ('z' + 1)))
                                c = c - 26;
                        fprintf(stdout, "%c", c);
                        c = fgetc(in);
                        }
                }
                else if (*input == 'n' || *input == 'N')
                {
                        c = fgetc(in);
                        while(c != EOF)
            {
                        if((c >=65) && (c <= 'Z'))
                                c--;
                        else if((c >= 'a') && (c <= 'z'))
                                c--;
                        if((c == ('Z' + 1)) || (c == ('z' + 1)))
                                c = c - 26;
                        fprintf(stdout, "%c", c);
                        c = fgetc(in);
                        }
                }
                fclose(in);
                return (0);
}

cprog Keyword 13

Structures (Declaration, Accessing Elements, Pointers to)

Definition

Structures are a collection of variables. They are grouped together into a single thing and proved a way of keeping data and needed elements together.

Basic Syntax

Structure Declaration: struct struct-name{ type field-name; type field-name; … };

Demonstration
#include <stdio.h>
 
struct color 
 
	{
	  int id;
	  char *name;
	  float percentage;
	} 
 
	black, blue, red;
 
 
int main() 
{
  struct color st;
  black.id=1;
  blue.name = "fav";
  red.percentage = 90.5;
  printf(" Id is: %d \n", black.id);
  printf(" Name is: %s \n", blue.name);
  printf(" Percentage is: %f \n", red.percentage);
  return 0;
}
 lab46:~/src/cprog/classproject$ ./ex20.out
 Id is: 1
 Name is: fav
 Percentage is: 90.500000

cprog Keyword 14

typedef, enum, union

Definition

typedef or type define allows you to declare one type of integer as another type. When you declare this definition the name is has been “enum”.

Demonstration
For example of the enum

typedef enum x{1, 2}  Value;

int main()
{
   Value data = 20;
   if (data == BLACK)
   {
      //etc.
   }
}  

This example defines the integer aaa, bbb and ccc and sets them as arrays.

typedef int aaa, bbb, ccc;
typedef int aaa[15], bbb[9][6], ccc[2];

This example sets char to have a double place value. 

typedef int (*char)(double);

cprog Keyword 15

Functions

Definition

A function is a relation between inputs and outputs. It will return a value for use within the program. A function lists the statements that is executes.

For example the function

result = power(val, pow);

This calls the function powers and assigning the return value to variable results.

Syntax

return-type function-name ( argument)
{
    local-declarations
    statements
    return return-value;
}
Demonstration
void exchange(int a, int b)
{
    int temp;
 
    temp = a;
    a = b;
    b = temp;
    printf(" From function exchange: ");
    printf("a = %d, b = %d\n", a, b);
}

cprog Keyword 16

Compiler, Preprocessor, Flags, Assembler, Linker, Multi-file programs (how to structure, how to compile)

Definition

Compiler The compiler translate high-level languages programs into assembly language.

Assembler

The assembler converts assembly language into object files. These contain a combination of machine instructions. They also convert decimal numbers in to programmer binary.

Linker

The linker merges the object files and creates the executable file. It has basically three tasks; searched the program to find routines, determine memory locations and resolves reference among the files.

Loader

The loader is the part of the OS that takes the executable file and brings it out in the open and starts running it.

Demonstration
Source file => Assembler => Object File \
Source file => Assembler => Object File  ---> Linker ---> Executable File
Source file => Assembler => Object File /       |
                                              library

cprog Objective

cprog Objective

Break down and look at the source code for a game.

Definition

Find the source code for any game that is written in C. In my own words explain what the code does and how it performs the desired tasks.

Method

Completion comes from the written explanation.

Measurement

There are many sources for code out there. I found a code for a battleship program written by Michael Margues.

URL: http://www.cprogramming.com/cgi-bin/source/source.cgi?action=Category&CID=2

Analysis

The code is long enough to wrap around my house. So I will be taking some highlights and working through the general structure of the program.

(1) The code includes the conio.h file that is part of the DOS world. It allows the creation of text user interfaces. From this point it then declares three main voids. Mike takes and int's the lengths of the boats by allocating each part of the boat to declaration. He then uses chars to create and array that is used at the board. This serves as a very creative way to tie the required game play to the text output world.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

void checkShips();
void quitGame();
void targeting();

	int check[128];
	int target, hit = 0, i;
	int airpone, airptwo, airpthree, airpfour, airpfive;
	int destroypone, destroyptwo, destroypthree, destroypfour;
	int battlepone, battleptwo, battlepthree;
	int subpone, subptwo, subpthree;
	int patrolpone, patrolptwo;

	char rowone[50] = "11 12 13 14 15 16 17 18\n"; 
	char rowtwo[50] = "21 22 23 24 25 26 27 28\n";
	char rowthree[50] = "31 32 33 34 35 36 37 38\n";
	char rowfour[50] = "41 42 43 44 45 46 47 48\n";
	char rowfive[50] = "51 52 53 54 55 56 57 58\n";
	char rowsix[50] = "61 62 63 64 65 66 67 68\n";
	char rowseven[50] = "71 72 73 74 75 76 77 78\n";
	char roweight[50] = "81 82 83 84 85 86 87 88\n";
	char e;

	int airponetwo, airptwotwo, airpthreetwo, airpfourtwo, airpfivetwo;
	int destroyponetwo, destroyptwotwo, destroypthreetwo, destroypfourtwo;
	int battleponetwo, battleptwotwo, battlepthreetwo;
	int subponetwo, subptwotwo, subpthreetwo;
	int patrolponetwo, patrolptwotwo;

	char rowonetwo[50] = "11 12 13 14 15 16 17 18\n"; 
	char rowtwotwo[50] = "21 22 23 24 25 26 27 28\n";
	char rowthreetwo[50] = "31 32 33 34 35 36 37 38\n";
	char rowfourtwo[50] = "41 42 43 44 45 46 47 48\n";
	char rowfivetwo[50] = "51 52 53 54 55 56 57 58\n";
	char rowsixtwo[50] = "61 62 63 64 65 66 67 68\n";
	char rowseventwo[50] = "71 72 73 74 75 76 77 78\n";
	char roweighttwo[50] = "81 82 83 84 85 86 87 88\n";

(2)With everything set up for play he outputs the game board and begins getting the users input to establish the set up. This is setting data into each allocated spot on the board.

printf("Battle Ship\nBy Michael Marques\n");
	printf("These are the posible positions: \n");
	printf("11 ,12 ,13 ,14 ,15 ,16 ,17 ,18\n"); /* Displays posible ship positions */
	printf("21 ,22 ,23 ,24 ,25 ,26 ,27 ,28\n");
	printf("31 ,32 ,33 ,34 ,35 ,36 ,37 ,38\n");
	printf("41 ,42 ,43 ,44 ,45 ,46 ,47 ,48\n");
	printf("51 ,52 ,53 ,54 ,55 ,56 ,57 ,58\n");
	printf("61 ,62 ,63 ,64 ,65 ,66 ,67 ,68\n");
	printf("71 ,72 ,73 ,74 ,75 ,76 ,77 ,78\n");
	printf("81 ,82 ,83 ,84 ,85 ,86 ,87 ,88\n");

(3) The program prompts the user and allocates the selection as relevant to each ship. The program goes through this process with each piece of the game.

	printf("(3 spaces)Player 1 enter your Battle ship's poition: \n");
	printf("position1: ");     
	scanf("%d", &battlepone);
	printf("position2: ");
	scanf("%d", &battleptwo);
	printf("position3: ");
	scanf("%d", &battlepthree);

(4)

Ready to play! The user is then prompted for their input of where the enemy boats are. It runs through a long list of switch case statements for any of space that is hit.

	printf("Target: ");
	scanf("%d", &target);
	switch(target){
	case 11:
		switch(destroyponetwo) {
		case 11:
			printf("Hit!!!\n");
			hit = hit + 1;
			break;
		
			
		}
		switch(destroyptwotwo) {
		case 11:
			printf("Hit!!!\n");
			hit = hit + 1;
			break;

unix Keywords

  1. The UNIX Shell (done)
  2. Environment variable (done)
  3. $PATH (done)
  4. wildcards (done)
  5. tab completion (done)
  6. Job Control (done)
  7. The UNIX Programming Environment 9done)
  8. Compiler, Assembler, Linker, Loader (done)

unix Keyword 9

The UNIX Shell

Definition

The Unix Shell is basically a command line interpreter. This is also called a shell that gives the used and interface. The user is able to use the cell to run programs, tweak setting and many other uses. There are two main shells the Bourne shell and the C shell.

Demonstration

Example of a linux shell

unix Keyword 10

Environment variable

Definition

Environment variables are a set of named values that impact running programs and process. They set the stage for the operating environment. These variables are stored as temporary setting files. The stored values can be change but are typically established when the system starts. Tweaking these value give you control over things like your logname, mail server, pager or where your home file is.

Demonstration
lab46:~$ env EDITOR=nano
TERM=xterm
SHELL=/bin/bash
SSH_CLIENT=24.94.52.91 56204 22
SSH_TTY=/dev/pts/90
USER=skinney1
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd                                          =40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=0                                          1;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.                                          tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz                                          =01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.d                                          eb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;3                                          1:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=0                                          1;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.t                                          iff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;                                          35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4                                          v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:                                          *.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;                                          35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=                                          01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.                                          mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;3                                          6:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
MAIL=/home/skinney1/Maildir
PATH=/home/skinney1/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
LC_COLLATE=C
PWD=/home/skinney1
LANG=en_US
HISTCONTROL=ignoreboth
SHLVL=1
HOME=/home/skinney1
LOGNAME=skinney1
SSH_CONNECTION=24.94.52.91 56204 10.80.2.38 22
_=/usr/bin/env
EDITOR=nano

unix Keyword 11

$PATH

Definition

PATH is the environmental variable that is a list of files that my shell accesses, searches through, read/writes etc.

You are able to edit your path by using a PATH= command. This is highly recommended only at the administrator level. The example i found shows PATH=$PATH\:/dir/path ; export PATH

Demonstration
lab46:~$ $PATH
-bash: /home/skinney1/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games: No such file or directory
lab46:~$

unix Keyword 12

wildcards

Definition

A wildcard is basically a value that fills in as a include all value. The computer sees the wildcard as meaning it could be any value holding to what ever part is placed with it. For example a search for “*XYZ” will come back with all items that matches the XYZ at the end.

There are a few different types of wildacards; ? Matches any one character in a filename. * Matches any character or characters in a filename. [ ] Matches one of the characters included inside the [ ] symbols.

Demonstration

Example of a * wildcard search

 lab46:~/junk$ find de*
dem1.c
dem1.out
dem2.c
dem2.out
dem3.c
dem3.out
dem4.c
dem4.out

unix Keyword 13

Tab completion

Definition

Tab completion directs the shell to search the current directory and auto fill in the remainder of the name.

Demonstration

The example shows the contents of a file and the result of tab filling in the remainder of the content. The only trick with using tab completion is if there are multiple files that meet what you have entered then it will do nothing.

 lab46:~/src/cprog/classproject$ ls
6           char.out       encipherexample.c   hint1.out        script1.sh
7           cipher.txt     encipherexample1.c  message.in       script2.c
Suzy.c      color.sh       encipherexample2.c  ob1              test1.c
a.out       count.sh       encrpit.out         proj0.c          typec.c
age.sh      cprog2.c       enter.txt           project1.c       typec.out
backup.sh   date           excipherexample3.c  project1.c.save  typecast.c
bignum.c    encipher.c     exit.txt            rand.sh          typecast.out
bignum.out  encipher.out   func.c              range            var.c
bignum1.c   encipher1.c    hint1.c             range.c          var.out
char.c      encipher1.out  hint1.c.save        range.out
lab46:~/src/cprog/classproject$ ls cprog2.c

unix Keyword 14

Job Control

Definition

Job control is the ability to send running programs to the background within a shell. This can be beneficial when doing a large search quarry or when you need to do another element of a larger task. This is controlled by a list that the shell keeps that logs what is being done. This allows it to keep track of what processes are being run within the group. The

Demonstration
lab46:~$ top $

lab46:~$ % bg
top
top - 11:59:47 up 72 days, 19:20,  7 users,  load average: 0.00, 0.00, 0.00
Tasks: 329 total,   1 running, 328 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.2%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1568604k total,  1314012k used,   254592k free,   216856k buffers
Swap:   524280k total,    98664k used,   425616k free,   467392k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
17843 skinney1  38  18 11000 1432  932 R    1  0.1   0:00.08 top
    1 root      20   0  8356  700  592 S    0  0.0   0:50.92 init
    2 root      20   0     0    0    0 S    0  0.0   0:00.30 kthreadd
    3 root      RT   0     0    0    0 S    0  0.0   0:06.00 migration/0
    4 root      20   0     0    0    0 S    0  0.0   0:11.50 ksoftirqd/0
    5 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/0
    6 root      RT   0     0    0    0 S    0  0.0   0:05.07 migration/1
    7 root      20   0     0    0    0 S    0  0.0   0:04.58 ksoftirqd/1

unix Keyword 15

The UNIX Programming Environment

Definition
Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

unix Keyword 16

Compiler, Assembler, Linker, Loader

Definition

Compiler The compiler translate high-level languages programs into assembly language.

Assembler

The assembler converts assembly language into object files. These contain a combination of machine instructions. They also convert decimal numbers in to programmer binary.

Linker

The linker merges the object files and creates the executable file. It has basically three tasks; searched the program to find routines, determine memory locations and resolves reference among the files.

Loader

The loader is the part of the OS that takes the executable file and brings it out in the open and starts running it.

Demonstration
Source file => Assembler => Object File \
Source file => Assembler => Object File  ---> Linker ---> Executable File
Source file => Assembler => Object File /       |
                                              library

unix Objective

unix Objective

Connect to the lab46 server via my Droid phone.

Definition & Method

Explore the options available, install and connect.

Measurement

There are many apps and programs that allow you to connect to a server. ConnectBot, Better Terminal Emulator, Irssi ConnectBot and the list goes on. I am going to attempt the connection by using a method that stays as close to the command line as i can.

Analysis

The simplest way to connect was found with Irssi's droid app. The connection is simply added as name@lab46.corning-cc.edu:22 and off you go. The method i was after was using the typically built in Unix SSH program. This was not possible to achieve. Being Unix, on a rooted droid one should be able to download the SSH program and be off and running. I left it with what worked. Connecting with other methods seemed to be and annoying task.

Resource List

Experiments

Experiment 4

Question

Can I change the colors of different aspect of the shell from the command line?

Resources

Hypothesis

There are many times in a session that you are using a term for something and want it to stand out among your other sessions. What is the commands for changing its looks? My hypothesis is there has to be away to change these settings.

Experiment

I will be doing the needed research and documenting what i find.

Data

The main issue is that I am using a shh client. I cannot change those setting from with a host terminal as the look and feel of the ssh client is not controlled by the unix server. So error in logic when i started this little project. I did find some ways to control the output to the term by server and have listed them here.

First thing first, find you settings.

echo $PS1

You should have gotten something like

lab46:~$ echo $PS1
\h:\w\$

The logic is basically

  • \h = host name
  • \u = current username
  • \w = working directory

Changing you Bash Prompt color while using your log name. Simply change the '0;31m' to suit your needs.

export PS1="\e[0;31m[\u@\h \W]\$ \e[m "

This window will not allow me to show the color example that I have; however, here is some more color codes.

  • Black 30
  • Blue 34
  • Green 32
  • Cyan 36
  • Purple 35

Analysis

Based on the data collected:

  • Was your hypothesis correct? I was way off from the start.
  • Was your hypothesis not applicable? Correct, it was wrong.

Conclusions

Noted in research section

Experiment 5

Question

How does one hide themselves?

Resources

Hypothesis

The use of proxies allow a user to easily hide their IP/MAC from connections they make over the internet.

Experiment

not sure at this point….

Data

After reading and doing lots of research the folks at Anon/LOLSEC suggest the first step is your tractability to the physical machine. This is a little further then I want to slide into this subject. There are many ways to look at your own security. For one, paying cash for a machine and not leaving the ability to connect that machine's unique identifiers with your credit card number. From this point you take your new machine home and set up a triple virtual machine with each running a little IP and MAC change script that runs every hour. Never use this computer for anything normal… and never connect locally. The list of assignments goes on… but I am not interested in hacking the FBI. I will leave that to the script kiddies behind the masks and focus on just being hidden behind proxies.

Proxies

A proxy is like a man in the middle for the net. When you open a website your comp send your IP to the website. The site is then able to send the webpage to your comp. The proxy goes and gets that information and then sends in on to you. So the website never sees your IP but only that of the proxy. I have listed a few proxies in the research sections.

What is my IP

Windows “ipconfig”

C:\skinney>ipconfig

Windows IP Configuration

Ethernet adapter Wireless Network Connection:

        Media State . . . . . . . . . . . : Media disconnected

Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . : work stuff
        IP Address. . . . . . . . . . . . : 00.00.000.00
        Subnet Mask . . . . . . . . . . . : 255.255.000.0
        Default Gateway . . . . . . . . . : 00.00.000.0

“*”nix typically you can just call “ifconfig” and get there.. but we needed to rock out “/sbin/ifconfig”

lab46:~$ ifconfig
-bash: ifconfig: command not found
lab46:~$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3e:5d:88:d8
          inet addr:12.82.2.32  Bcast:10.80.2.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe5d:88d8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:49729834 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58369549 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9291283443 (8.6 GiB)  TX bytes:30407298791 (28.3 GiB)
          Interrupt:18

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:384756 errors:0 dropped:0 overruns:0 frame:0
          TX packets:384756 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:51742675 (49.3 MiB)  TX bytes:51742675 (49.3 MiB)

Setting up the browser to use the proxy

Look in the internet options sections. There should be a “connections” section. Once you find this in your flavor of browsing. you need to initialize using proxies. At this point you will need the IP of the proxy you wish you use and the port of their server. Enter this information and you are off and running with a one proxy connect. Keep in mind… this is one layer. When it comes to being hidden you need many layers and there is no such thing as invisible.

Proxy Chaining

There is a simple method to chaining together many proxies in your browser. As noted earlier many layers is a good thing. What if you are using one proxy and lets say our court systems says… Proxy ABC i order you to give us a list of all IPs that wen through you to Mega Up Load. Guess you are in trouble… with the other millions of people. Now if you had a chain of proxies going… chances get slimmer that you will be in that list.

Here is an example of what we are trying to accomplish

[user]>>[proxy1]>>[proxy2]>>[proxy3]>>[website]

So to do this you are going to use a linker.. “-.-”

http://www.proxy.magusnet.com/-.-proxy2 etc/-.-proxy3 etc/-.-http://www.google.com

Analysis

Based on the data collected:

  • Was your hypothesis correct? It was correct, there are many ways to go about being hidden.
  • Is there more going on than you originally thought? There are many ways.. lol. The majority seem pretty strait forward.. and there are even pay for services that can do this service for you.
  • What shortcomings might there be in your experiment? Not data driven

Conclusions

You are only as safe as you want to pretend you are. There is always new ways around preconceived notions on security.

Retest 2

Perform the following steps:

State Experiment

Whose existing experiment are you going to retest? Provide the URL, note the author, and restate their question.

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • Are there additional resources you've found that you can add to the resources list?
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • If you find a deviation in opinion, state why you think this might exist.

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • What improvements could you make to their hypothesis, if any?

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?

Data

Publish the data you have gained from your performing of the experiment here.

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • Can you explain any deviations?
  • How about any sources of error?
  • Is the stated hypothesis adequate?

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • Does the original author appear to have gotten some value out of performing the experiment?
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).
opus/spring2012/skinney1/part2.txt · Last modified: 2012/04/23 11:09 by skinney1