Latest Post
Tampilkan postingan dengan label security. Tampilkan semua postingan
Tampilkan postingan dengan label security. Tampilkan semua postingan

Protect / Secure your Website Content using jQuery

Written By Unknown on Minggu, 08 Desember 2013 | 08.07

Now a days website owners want to protect their content from copiers. In order to avoid Plagiarism, it is very necessary to make sure the Content, Source and Images from their site is not copied. I wrote a simple jQuery code that will protect your content from copying text, dragging images, viewing source, & disables the link which having image paths.

To read more about this article Click Here

For Demo Click Here

To download files Click Here

Tips to Securing your PHP Application

Written By Unknown on Rabu, 04 Desember 2013 | 08.27

Now a days PHP Language is very popular among developers to develop large applications like facebook etc. So here I am going to tell how to secure your PHP applications in a simple steps.

File handling functions like fopenfile_get_contents, and include accept URLs as file parameters (for example:fopen('http://www.example.com/', 'r')). Even though this enables developers to access remote resources like HTTP URLs, it poses as a huge security risk if the filename is taken from user input without proper sanitization, and opens the door for remote code execution on the server. To disable this and limit file functions to local system, use the following setting in php.ini:
 
To read more about this article Click Here

Security Issues in Writing PHP Scripts

Written By Unknown on Senin, 14 Januari 2013 | 09.17

This article deals with two issues - securing your script against a possible exploit; and how to write your scripts so that they will be compatible with later versions of PHP. These apparently unrelated issues are dealt together for reasons you will see later in this article.


Security Hole


As PHP script writers already know, one of the conveniences in using PHP is that you don't have to do anything special to access variables set by your forms. For example, if your form has an <input> variable called "email", your script will automatically inherit a global variable called $email. Unfortunately, this convenience also leads to a potential security hole. 


By "security hole", I do not mean that PHP itself has a security hole. Rather, the security issue is actually created by writers of PHP scripts who inadvertently create a bug through which others can exploit. 


Take the following code as an example: 

if (input_is_okay()) {     $valid_input = 1 ; } if ($valid_input) {     show_financial_data(); } else {     show_order_form(); }
 
The code calls input_is_okay() to check whether the visitor has entered all the necessary fields in a form correctly. If he/she has, input_is_okay() would give a non-zero response, and the routine would set the variable $valid_input to 1. 


The next bit of code checks if $valid_input is non-zero. If so, it will call the function show_financial_data() which presumably displays some information that the visitor is authorized to view. Otherwise, if $valid_input is zero, the visitor will be greeted with an order form where he can pay for the service. 


The problem with the above code, as of course you will have realised, is that if an unscrupulous visitor calls your script with the variable "valid_input" set to 1, he can bypass your security checking routine input_is_okay(). This is trivial to do. For example, if your script is called stockprices.php, he can simply type 

http://yourdomain.com/stockprices.php?valid_input=1  

into his browser. In the default configuration for PHP 4.1 and below, PHP will automatically change the valid_input in the HTTP request line to a variable by the name of $valid_input, and set it to the value given, ie, 1. 


That means, that user will always be able to cause your script to display the information printed by show_financial_data() regardless of how he completed your form. 

Plugging the Security Hole (Works on All PHP Versions)


As noted earlier, this is not a problem with PHP. This is a problem with the script; or, to put it bluntly, the script is potentially buggy. If you wrote code like the above in a different programming language and ran it through a modern compiler (like a C compiler), chances are that the compiler will flag the code with a warning to the effect that you may be using an uninitialized variable in the code. 


One solution to the security hole in the above code is to make sure that you initialise every variable that you use in your script (unless of course the variable is supposed to contain input given by the visitor). For example, if you must use code like the above, you can fix the "hole" by changing the start of the code to the above. 

if (input_is_okay()) {     $valid_input = 1 ; } else {     $valid_input = 0 ; }
 
This way, even if the visitor calls the script with 
 
http://yourdomain.com/stockprices.php?valid_input=1 
 
your security checks in input_is_okay() will not be circumvented. By setting $valid_input to either 0 or 1 in your script, the $valid_input value given in the HTTP request is overridden by your internal variable assignment.

PHP 4.1.0 and Above: How it Helps


With PHP 4.1.0, the developers of PHP have provided script writers another way (yeah, yet another way!) to access global variables. For example, to access the form variable "email" in your scripts from a form submitted with the "get" action, you can simply read $_GET["email"] for the information. If your form uses the "post" action, just access the information by reading $_POST["email"]. Cookies can be accessed using the $_COOKIE array. If you don't really want to distinguish between the three types of input, simply use the $_REQUEST array, as for example, in the following statement: 

echo "Your input was " . $_REQUEST["email"] ;  

The intention behind creating this plethora of arrays (there are more!) is to eventually remove the default action of automatically converting form variables into script variables. This automatic conversion is controlled by the php.ini configuration variable "register_globals". If set to 1 (which is the default even up to PHP 4.1.0), all form variables are automatically converted to global variables in the script. Future semi-major versions of PHP will not make this the default.

Secure your PHP script by hiding extensions

Written By Unknown on Kamis, 15 November 2012 | 08.08

In general, security by obscurity is one of the weakest forms of security. Suppose If I were exploiting a site, I wouldn’t check what scripting language the site runs on, because all that would matter to me is exploiting it. Hiding the fact that you use x language isn’t going to prevent me from bypassing poor security. But in some cases, every little bit of extra security is desirable.


A few simple techniques can help to hide PHP, possibly slowing down an attacker who is attempting to discover weaknesses in your system. By setting expose_php to off in your php.ini file, you reduce the amount of information available to them.

Another tactic is to configure web servers such as apache server to parse different filetypes through PHP, either with an .htaccess directive, or in the apache configuration file itself. You can then use misleading file extensions:

Hiding PHP as another language:

AddType application/x-httpd-php .asp .py .pl 

Or obscure it completely.

Using unknown types for PHP extensions:

AddType application/x-httpd-php .bop .foo .133t

Or hide it as HTML code, which has a slight performance hit because all HTML will be parsed through the PHP engine:

Using HTML types for PHP extensions:

AddType application/x-httpd-php .htm .html 

For this to work effectively, you must rename your PHP files with the above extensions. While it is a form of security through obscurity, it’s a minor preventative measure with few drawbacks.

Secure browser redirect to https (ssl) using php

Written By Unknown on Senin, 29 Oktober 2012 | 09.43

As we know that all transactions over internet uses SSL (secure socket layer) connection to transfer data to and from the payment gateway. commonly most of websites uses “HTTP” protocol but When we need to integrate payment gateways on e-commerce site or any other. Then we need to redirect the browser from common “HTTP” to Secure “HTTPS” which mean that “Hypertext Transfer Protocol over Secure Socket Layer”.

We can see the real example of HTTPS in Banks, reservation sites when we type “HTTP” it automatically converts to “HTTPS” in address bar which means this site is transferring the data over SSL protocal.


Redirect the browser to https when site is using http protocal in PHP

First of all, you will have to configure SSL on your server. After we will check that the site is using SSL or not by PHP server varriable called $_SERVER['HTTPS'] which return “ON” valuewhen the site is using SSL Connection.

PHP Function to redirect the browser to “https”

function redirectToSecureHTTPS()
{
if($_SERVER['HTTPS']!="on")
{
$redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header("Location:$redirect");
}
}

This is a very simple php fucntion, you can call this function in the page where you’ve to redirect the browser to “https”.

Redirect the browser to “https” using .htaccess

The above php function need to be call on each page to redirect the browser to “https”. But by using .htaccess file, you can redirect the whole website to use SSL connection throughout the pages.

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

You just need to copy and paste the above code in .htaccess file and the whole website will be redirected to “https”. The browser will be et redirected using url rewriting in .htaccess.

ionCude PHP encoder - Protect Your PHP Source Code

Written By Unknown on Rabu, 24 Oktober 2012 | 09.40

One of the main threat PHP developers face is that PHP is an interpreted language, means PHP source code is readable by anybody who downloads your application. We can say that it’s a drawback of PHP. But you can protect your intellectual property by encoding your PHP source code. Here in this article I will explain how to protect your PHP source code.

Actually there are many tools available for protecting php code. But here we will discuss ionCude PHP encoder tool. By this tool, you can protect your PHP 4 & 5 source code from easy observation, theft and change. So before releasing your PHP software, you can use the encoder to convert your plain-text PHP files into special encrypted files.

The ionCude PHP Encoder is available for Windows, Linux, FreeBSD and Intel OS X. All versions offer command line access for encoding, and also for creating license files using Pro or Cerberus. This feature is ideal if you wish to automate processing. The Windows Encoder also includes an easy to use GUI, and the Windows Pro and Cerberus editions include a Linux based license generator for PHP scripts too, allowing scripts to be protected using Windows and creating license files from a Linux based web server.

How To Encode PHP source files
Here we will run a php script(phpencoder.php) for encoding its source code.  We will use below command to encode this file.
/usr/local/ioncube/ioncube_encoder5 phpencoder.php -o phpencoder-enc.php

<?php
   echo “MY PHP Encoder Example!”;
?>

You can also Encode an entire project directory by using below command:
/usr/local/ioncube/ioncube_encoder5 projectDir -o build
As There are are many different options available, encoding above script (phpencoder.php) with the default options will return following PHP file.

<?php
    echo(‘Site error: the file <b>’.__FILE__.‘</b> requires the ionCube PHP Loader ’.
    basename($__ln).‘ to be installed by the site administrator.’);
?>
4+oV5BgRgd22U2z7JoK/KmKPIcszhD8pg3hvN+5vc4HFcsGMn/El/4CMYaLFFzaqguLCeb9su8xn  i0+eWxJg/kwNHRkiBvY1aMf1AvwPf14DIwCvegtJC7cbx9cN5jBjwSspVjhVsQnxFx9oBut6R0Kc    V+OLw6XBTNm5sKpbL6DVm2jqk8Wasm9oJgKLZxBtvVBeP5vZrOiod+L7SoplcmTgtyr5wzS3sEzjr7ixXPUY4H82MyuzZyjYTkSKkz9qlMzWHddrUHJX3y0zPfDqWDUeD1BibJQJ9BXkP7jb4pdKQv/hsMqhthNQQRSp6nOJHq8oDDYLE+p403GYs2As9qEI2wNAg6j6ln0BRP7shcbNTb5a8O4VjjLhGDwG
 1AYOxaM4R5QneCFr+xYdtEYSep8FW1i9IBzF1FuDa7eMoPDqaQdjTLAPsy5O831yGpAHohx3FzUK
 aewZTV+tdru=

The ionCube PHP Encoder is a commercial product, there is a limited time Trial Version available for download.

Prevent PHP Security Attacks in PHP coding

Written By Unknown on Selasa, 09 Oktober 2012 | 08.40

Security is major and essential part of any language . If we see PHP then we also need and keep in mind, all security tips and tricks to prevent our code from being attacked by hackers.

Here, i have searched and collected some types of attacks and their cure.

To read more about this article Click here

7 Useful functions to tighten the security in PHP

Written By Unknown on Rabu, 06 Oktober 2010 | 23.14


Security is a very important aspect of programming. In PHP, there are few useful functions which is very handy for preventing your website from various attacks like SQL Injection Attack , XSS attack etc.Let’s check few useful functions available in PHP to tighten the security in your project. But note that this is not a complete list, it just list of functions which I found useful for using in your project.

1) mysql_real_escape_string() - This function is very useful for preventing from SQL Injection Attack in PHP . This function adds backslashes to the special characters like quote , double quote , backslashes to make sure that the user supplied input are sanitized before using it to query. But, make sure that you are connected to the database to use this function.
2) addslashes() – This function works similar as mysql_real_escape_string(). But make sure that you don’t use this function when “magic_quotes_gpc” is “on” in php.ini. When “magic_quotes_gpc” is on in php.ini then single quote(‘) and double quotes (“) are escaped with trailing backslashes in GET, POST and COOKIE variables. You can check it using the function “get_magic_quotes_gpc()” function available in PHP.


3) htmlentities() – This function is very useful for to sanitize the user inputted data. This function converts the special characters to their html entities. Such as, when the user enters the characters like “<” then it will be converted into it’s HTML entities < so that preventing from XSS and SQL injection attack.

4) strip_tags() – This function removes all the HTML, JavaScript and php tag from the string. But you can also allow particular tags to be entered by user using the second parameter of this function. 

For example,
echo strip_tags(“<script>alert(‘test’);</script>”);
will output
alert(‘test’);

5) md5() – Some developers store plain password in the database which is not good for security point of view. This function generates md5 hash of 32 characters of the supplied string. The hash generated from md5() is not reversible i.e can’t be converted to the original string.

6) sha1() – This function is similar to md5 but it uses different algorithm and generates 40 characters hash  of a string compared to 32 characters by md5().


7) intval() – Please don’t laugh. I know this is not a security function, it is function which gets the integer value from the variable. But you can use this function to secure your php coding. Well, most the values supplied in GET method in URL are the id from the database and if you’re sure that the supplied value must be integer then you can use this function to secure your code.

$sql=”SELECT * FROM product WHERE id=”.intval($_GET['id']);

As, you can see above, if you’re sure that the input value is integer you can use intval() as a secrity function as well.
 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger