Archive for June, 2009

Jun
29
2009

Linux: Umask file, directory permission settings

What is umask?
The command umask is used to set the file, directory permissions.

In linux, you can set the file or directory permission for all users by editing /etc/profile (or in /etc/bashrc) file or for specific users by editing their respective ~/.bashrc file.

For files, the default permission settings are 0666 (execute permission is disabled) and for directories it is 0777

To produce symbolic output, you can use umask with -s option
$ umask -s

(more…)

  • Share/Save/Bookmark
Jun
28
2009

PHP: Buffer Overflow

PHP Program Flow
A call that is made to execute a sequence of code in PHP program is sent to PHP core library written in C programming language which in turn would talk with the underlying operating system to get the results of its execution.

What is buffer?
A buffer is a temporary memory location to hold data for faster program execution time. The data may be stored as a heap or as a stack. Stack can be visualized as a FILO array of data and heap as a linked list of data.

Why we need to take care of buffer overflows?
Programmers who know about certain loop holes can exploit this feature in by pointing a record in the heap or stack to prewritten block of hackable code. These are called buffer overflow attacks.
(more…)

  • Share/Save/Bookmark
Jun
24
2009

Linux: How to install SSH?

How to install SSH on Linux variants?

In Ubuntu,
$ sudo apt-get install ssh

In Centos, it is
$ yum install ssh

To test if SSH is working, type

$ ssh username@hostname

(First time it will ask if you prefer storing the key values into /home/.ssh/known_hosts so that the server automatically connects at all instances)

  • Share/Save/Bookmark
Jun
23
2009

URI, URL, URN – What is their relation?

URL stands for Uniform Resource Locator, URI for Uniform Resource Indicator and URN for Uniform Resource Name.

URL indicates a very specific information about where the resource can be located and URN refers to the name of the resource. It indicates that ALL URLs are subsets of URI but not vice-versa.

A URL can be referred to as a URI but the term URL has been deprecated by IETF and W3C though it is in wide use in world wide web.
(more…)

  • Share/Save/Bookmark
Jun
22
2009

Linux: How to set the default shell?

How to set the default shell?

If you want to set a shell as a the default for all users you can set the SHELL variable

$ sudo vi ~/.bashrc

export SHELL=/bin/bash

To change the default shell for a specific user you can either use the following command
$ usermod -s /path/to/shell user_a

or, set the shell in the /etc/passwd file by changing the last column which represents the default shell for that user

user_a:x:1001:1001::/home/user_a:/bin/sh

Read more about the Linux shell

  • Share/Save/Bookmark
Jun
19
2009

Linux: Switch between shells

How to switch between shells?

sh – bourne shell
bash – bourne again shell
ksh – korne shell
csh – c shell

bash” is the default shell in most linux variants.

You can switch between shells by typing the respective shells short commands like
$csh (to switch to C shell)
$ksh (to switch to korne shell)

  • Share/Save/Bookmark
Jun
18
2009

Cross site scripting Attack – XSS

Cross-Site Scripting (XSS) is the method of code injection whereby a malicious user injects code (html, javascript) which would get executed from the site on the users browser. When Google finds this, it will show up a warning message in its search results if the users had searched for a specific term for which your site is indexed. This can harm your user base.

XSS attacks are classified as
- Persistent attacks
- Non-persistent attacks
(more…)

  • Share/Save/Bookmark
Jun
17
2009

Linux: List available shells

How to list all available shells in the system?

The command to list of available Linux shells in your system
$cat /etc/shells

  • Share/Save/Bookmark
Jun
16
2009

Linux: Know your Shell

What is a Shell?
A Shell is a program that passes the instructions to the kernel of your system for it to be interpreted when it is valid.

To learn more about the shell, click here

How to find which shell you are on?

The command to find which Linux shell you are in
$ echo $SHELL

  • Share/Save/Bookmark
Jun
14
2009

cakePHP, codeIgniter: simple method to display array data

var_dump(), print_r() are commonly used functions to display data that is passed across controllers or views when playing in MVC frameworks. As the printed data stretches as a long string, it may be difficult to manipulate the resultset in most cases.

When programming in CakePHP or CodeIgniter or other MVC frameworks when you do not want to turn on the debugger routine and want to have a clean display of Array Data you can try adding a simple method in the Controller (appController in cakePHP) as follows
(more…)

  • Share/Save/Bookmark