Showing posts with label Security. Show all posts
Showing posts with label Security. Show all posts

Monday, 3 November 2014

National Security Agency (NSA) Torn Apart {Infographics}


ABOUT NSA

Whether you like or not , your Internet activities and other telecommunication systems are being monitored every time you being online or use. Who are those spying me ??
Yes exactly, its National Security Agency (NSA) whose behind this privacy theft.
The NSA is an US intelligence agency responsible for monitoring, collection, decoding and analysis of data and information for foreign intelligence. NSA has been tied up with large gaints like Google, Microsoft, IBM, Verizon and Sprint.

NSA Infographic


Edward Snowden, an analyst/hacker worked with NSA (earning $200k/year) exposed the secrets of NSA privacy leak of 1.7 billion documents and phone calls. 
He changed the world thinking minds regarding Privacy. 
Here's the few leaks where NSA spies on us.




Hope you liked it. We will come with more on NSA on further posts. Stay tunned and please do like and share the post

Saturday, 1 November 2014

Top 7 PHP Security Vulnerabilities



Security is not a list of things you do. Security is a way of thinking, a way of looking at things, a way of dealing with the world that says “I don’t know how they’ll do it, but I know they’re going to try to screw me” and then, rather than dissolving into an existential funk, being proactive to prevent the problem. PHP has some major vulnerabilities which can be xploited and even prevented too. So lets start ..
SQL Injection
Number one on the hit list is the SQL injection attack. In this case, someone enters an SQL fragment (the classic example is a drop database statement, although there are many possibilities that don’t include deletions which could be just as destructive) as a value in your URL or web form. Never mind now how he knows what your table names are; that’s another problem entirely. You are dealing with an insidious and resourceful foe.
So, what can you do to avoid this? First and foremost you need to be suspicious of any input you accept from a user. Believe everyone is nice? Just look at your spouse’s family… they’re weird and freaky, some dangerously so.
The way to prevent this sort of thing is to use PDO Prepared Statements. I don’t want to go through a full discussion of PDO now. Suffice to say prepared statements separate the data from the instructions. In doing so, it prevents data from being treated as anything other than data.  
Must Read: So more details, read this Preventing Sql injection through prepared statements

XSS (Cross Site Scripting)

Curse the black hearts who thrive on this type of deception. Parents, talk to you children today lest they become evil XSS’ers!
The essence of any XSS attack is the injection of code (usually JavaScript code but it can be any client-side code) into the output of your PHP script. This attack is possible when you display input that was sent to you, such as you would do with a forum posting for example. The attacker may post JavaScript code in his message that does unspeakable things to your site. Please don’t make me go into detail; my heart weeps at what these brigands are capable of.
For more information and how to protect yourself, I suggest reading these fine articles on PHPMaster:

Source Code Revelation

This one has to do with people being able to see the names and content of files they shouldn’t in the event of a breakdown in Apache’s configuration. Yeah, I dig it, this is unlikely to happen, but it could and it’s fairly easy to protect yourselves, so why not?
We all know that PHP is server side – you can’t just do a view source to see a script’s code. But if something happens to Apache and all of a sudden your scripts are served as plain text, people see source code they were never meant to see. Some of that code might list accessible configuration files or have sensitive information like database credentials.
The solution centers around how you set up the directory structure for your application. That is, it isn’t so much a problem that bad people can see some code, it’s what code they can see if sensitive files are kept in a public directory. Keep important files out of the publicly-accessible directory to avoid the consequences of this blunder.

Remote File Inclusion

Hang on while I try to explain this: remote file inclusion is when remote files get included in your application. Pretty deep, eh? But why is this a problem? Because the remote file is untrusted. It could have been maliciously modified to contain code you don’t want running in your application.
Suppose you have a situation where your site at www.myplace.com includes the library www.goodpeople.com/script.php. One night, www.goodpeople.com is compromised and the contents of the file is replaced with evil code that will trash your application. Then someone visits your site, you pull in the updated code, and Bam! So how do you stop it?
Fortunately, fixing this is relatively simple. All you have to do is go to your php.ini and check the settings on these flags.
  • allow_url_fopen – indicates whether external files can be included. The default is to set this to ‘on’ but you want to turn this off.
  • allow_url_include – indicates whether the include()require()include_once(), and require_once() functions can reference remote files. The default sets this off, and setting allow_url_fopenoff forces this off too.

Session Hijacking

Session hijacking is when a ne’er-do-well steals and use someone else’s session ID, which is something like a key to a safe deposit box. When a session is set up between a client and a web server, PHP will store the session ID in a cookie on the client side probably called PHPSESSID. Sending the ID with the page request gives you access to the session info persisted on the server (which populates the super global $_SESSION array).
If someone steals a session key, is that bad? And the answer is: if you aren’t doing anything important in that session then the answer is no. But if you are using that session to authenticate a user, then it would allow some vile person to sign on and get into things. This is particularly bad if the user is important and has a lot of authority.
So how do people steal these session IDs and what can decent, God-fearing folk like us do about it?
Session IDs are commonly stolen via a XSS attack, so preventing those is a good thing that yields double benefits. It’s also important to change the session ID as often as is practical. This reduces your theft window. From within PHP you can run the session_regenerate_id() function to change the session ID and notify the client.
For those using PHP5.2 and above (you are, aren’t you?), there is a php.ini setting that will prevent JavaScript from being given access to the session id (session.cookie.httponly). Or, you can use the functionsession_set_cookie_parms().
Session IDs can also be vulnerable server-side if you’re using shared hosting services which store session information in globally accessible directories, like /tmp. You can block the problem simply by storing your session ID in a spot that only your scripts can access, either on disk or in a database.

Cross Site Request Forgery

Cross Site Request Forgery (CSRF), also known as the Brett Maverick, or Shawn Spencer, Gambit, involves tricking a rather unwitting user into issuing a request that is, shall we say, not in his best interest. But rather than me going on and on about CSRF attacks, refer to an outstanding example of just what kind of content we have here on PHPMaster: Preventing Cross-Site Request Forgeries by Martin Psinas.

Directory Traversal

This attack, like so many of the others, looks for for a site where the security is not all that it should be, and when if finds one, it causes files to be accessed that the owner did not plan to make publicly accessible. It’s also known as the ../ (dot, dot, slash) attack, the climbing attack, and the backtracking attack.
There are a few ways to protect against this attack. The first is to wish really, really hard that it won’t happen to you. Sometimes wishing on fairies and unicorns will help. Sometimes it doesn’t. The second is to define what pages can be returned for a given request using whitelisting. Another option is to convert file paths to absolute paths and make sure they’re referencing files in allowed directories.
These are Top 7 Vulnerabilities in PHP. Please do like and share this post and do join our facebook page AnonHackSociety

Saturday, 11 October 2014

How to Store Database records in an Multidimentional Array in PHP


About Array in PHP

Like any other programming languages or  web languages, array plays an important role in storing many data.
Storing single array elements in PHP in as any normal languages.
Syntax : array () ;
But to store many array within an array, there are Multidimensional Arrays. PHP have the Array of Array concept. 
Syntax: array (array());

Array in Arrays in PHP to store database values.

Well this post seems to be simple. Yes , i had an issue with storing the values in multidimensional arrays, but there haven't been any proper post till yet, of actual way of storing and dynamic looping used for storing data.

So lets start,
I want to store watches database values. For each watch there are 5 parameters (coloumns).

First I will extract the data from database using select query
$res = mysql_query("select * from watches ") or die(mysql_error());

Next, we should initialize array of array for storing data
$wat = array(array());

Now, below is the simple snippet to dynamically store values in that $wat array.

$i=0;
while($row = mysql_fetch_array($res))
{
$j=0;
  $wat[$i][$j++] = $row['brand'];
  $wat[$i][$j++] = $row['modelname'];
  $wat[$i][$j++] = $row['price'];
  $wat[$i][$j++] = $row['gender'];
  $wat[$i][$j++] = $row['movement'];
  $i++;
}

Now if we want to display all the contents of data in that array, we can do something like this.

for($i=0 ; $i<$rows ; $i++)
      for($j=0 ; $j< $columns; $j++)
      {
        echo $wat[$i][$j]."<br>";
      }
}

So we had store and displayed the data from the database successfully.
If you liked the post, do share and like us at AnonHackSociety

Monday, 1 September 2014

Security Onion

                              SECURITY ONION


What is Security Onion :
-Security Onion is a Linux distro for IDS (Intrusion Detection and NSM (Network Security Monitoring).
- Developed by Doug Burks.
-Designed to make deploying complex open source tools via a single package.
(Snort, Suricata, Sguil, Snorby, etc.)
- Allows the choice of IDS engine, analyst console, web interfaces.
- Free (Open Source) !!

What in the Onion 
Over 60 custom tools 
Snort – Signature based IDS 
Sguil – Security analyst console 
Squert - View HIDS/NIDS alerts and HTTP logs 
Snorby - View and annotate IDS alerts 
ELSA - Search logs (IDS, Bro and syslog) 
Bro - Powerful network analysis framework with highly detailed logs 
OSSEC - Monitors local logs, file integrity & rootkits

 "Network security monitoring is the collection, analysis, and escalation of indications and warnings to detect and respond to intrusions.“


Installation of Security Onion :
Installation of onion is simple , but takes time to install a pretty bunch of tools within it. 
You can find the installation procedure in the below link. 
This is the final GUI after an successful installation



Why Security Onion 
- A complete set of Network Monitoring linux distro provides a better lookout for the network analysts.
- Since its free, its feasible for the small organization for their network analysis.
- Easy to install and use.

Finally,
Where do we go now 
Download/Install
You can find videos for more on Security Onion




Sunday, 15 June 2014

Avoid sql injection in php with mysqli and prepared statement


AVOID SQL INJECTION IN PHP With MySQLi and PREPARED Statement




To avoid sql injection in php with MySQLi Prepared statement.

Prepared statements in mysqli can easily help to prevent sql injection in php.
There are basically three reasons why you should seriously consider writing prepared statements to execute your queries.

             I.      Prepared statements are more secure.
          II.      Prepared statements have better performance.
       III.      Prepared statements are more convenient to write.
Here is little introduction to mysqli queries and how to use prepared statements use


First let us see how to connect to database using MySQLi 
/*    Create a new mysqli object with database connection parameters   */
       $mysqli = new mysql('localhost', 'username', 'password', 'db');

       if(mysqli_connect_errno())
      {
            echo "Connection Failed: " . mysqli_connect_errno();
            exit();
                  } 

Now let us see Prepared Statement Example
/* Create a prepared statement */
     if($stmt = $mysqli -> prepare("SELECT priv FROM testUsers WHERE username=?
     AND password=?")) {

 /* Bind parameters  s - string, b - boolean, i - int, etc */ 
     $stmt -> bind_param("ss", $user, $pass);

 /* Execute it */
     $stmt -> execute();

 /* Bind results */
     $stmt -> bind_result($result);

 /* Fetch the value */
     $stmt -> fetch();

      echo $user . "'s level of priviledges is " . $result;

 /* Close statement */
      $stmt -> close();
             }

Here first we need to create stmt object before using the prepared statement

// Create statement object
   $stmt = $db->stmt_init();

And then call prepared statement using that stmt object

// Create Prepared statement
    $stmt->prepare();


Stmt prepared statement can directly call at time of prepare statement
// Create prepared statement
$stmt = $db->prepare();


In prepared statement query, need to pass the ? instead of passing the values. as shown in below ex.
               SELECT column1, column2 FROM table WHERE value=?


Now we have to bind the values to that “?” using following bind_param
in bind_param you need to pass value types at first in double quotes.

ex. $stmt->bind_param("s",$name);
$stmt->bind_param("ss",$name,$pass);
different value types are :
i    for integer value
s    for string value
b    for blob values
d    for double values


Now after binding the result need to execute the query
 /* Execute it */
     $stmt -> execute();


To fetch the result u need to call fetch
 /* Fetch the value */
     $stmt -> fetch();


After executing query as you are retrieving the result need to store the result.
 /* Store the Value */
     $stmt -> store_result();

Storing the result means to store the result in memory for retrieval.


After fetching the result need to free the memory
 /* Free the memory */
     $stmt -> free_result();


And need to close the statement
 /* Close stmt statement */
      $stmt -> close();



Prepared Statement Examples


Insert Example

$today = date('Y-m-d h:i:s');      // To create date time stamp
if($stmt1 = $db->prepare("INSERT INTO feedback VALUES(?, ?, ?, ?, ?, ?)"))
{
$null = NULL;
$stmt1->bind_param("isssss",$null,$name,$email,$sub,$comment,$today);
$stmt1->execute();
                        $stmt1->close();
}
Explanation: Prepared statement Insert query is passed and the values which are to be passed are marked with place holder sign. In bind_param() first we have passed the bind type as a string. Then execute it using execute(); Afte execution close the statement.
Select Example

                $searchJob = "SELECT * FROM jobpost WHERE `JobPost_Id` = ?";
                if($stmt1=$db->prepare($searchJob))
                {
                        $stmt1->bind_param("i",$jobid);
                 $stmt1->execute();
                 $stmt1->store_result();
                 $stmt1->bind_result($jobid, $jobtitle, $vacancy, $industryid, $salary,  $description);
                $stmt1->fetch();
                }
               $stmt1->free_result();
               $stmt1->close();
Explanation: First execute the query and store the result into memory and bind that stored result into respective field and remember that all the values should be included in bind_result if you are selecting them with * in select statement the maintain order of field as in database. After binding that filed with fetch() fetch out all the data. At the end free the result so you can save memory and also don't forget to close the statement object.
Update Example

$setActive = "UPDATE employer_detail SET `status` = ? WHERE `empEmail_Id` = ?";
if($stmt1 = $db->prepare($setActive))
{
$statusActive = 1;
$empEmailId = "mukund.topiwala@gmail.com";
$stmt1->bind_param("is", $statusActive, $empEmailId );
$stmt1->execute();
$stmt1->close();
}
Explanation: Here Query stored in Variable and passed it to prepare statement. If the query structure is correct and db object is correct it can be executed. In the bind param first we have passed the bind type in string format and then bind parameter variables. Then we have executed it. At the end we have closed the statement object.

Tuesday, 3 June 2014

Complete Wordpress Security

Complete Wordpress Security

Today , Wordpress has been a commonly used Content Management Systems. Due to its vast features and ease for the users, wordpress has become sophisticated. The wordpress has its own avid plugins and functionilities.

As this cyber world is dangerous,the website hacking has been a common trend for hackers. Wordpress also has been a vulnerable victim for the hackers. Most admins dont  know even their site is vulnerable.

Soo risky right??

So any solutions for the poor wordpress admins (other than coding).

Yes, Wordpress itself came with a complete solutions as a plugin named -'iThemes Security'. The easiest , most effective way to secure Wordpress in seconds.
Wow, so you get to  know, but how to implement it or where to get it.


1. After activation, iThemes Security guides you through important first steps


2.  One-click secure button enables most security features


3. Instantly scan your site and see where you can improve your security with high, medium and low priority items 

So as you see, iThemes Security provides an Complete security for future. So download it, and make your site secure from intruders
For more information, view the above download link and its features.

Thanks Abhishek Tavasalkar,
            Blog:  http://alltechtrix.com/






Sunday, 5 January 2014

Difference Between IPv4 and IPv6 ( Computer Networks ) IPv4 V/s IPv6


Difference Between IPv4 and IPv6 ( Computer Networks ) IPv4 V/s IPv6



New Topic For Networking Students Who Stdies on Computer Networks. Where they also read "Difference Between IPv4 & IPv6" and We provide very simple points for this difference between IPv4 and IPv6. You can once read and Easily keep in your mind.

For IPv4 :
  1. Adresses are 32 bit (4Bytes) in Length.
  2. Header Des Not Identify Packet Flow.
  3. Checksum Field is Available in Header.
  4. Options Field are Available in Header.
  5. Manual Configuration of IP Adresses and DHCP is required to configure the IP Adress.
  6. Broadcast Messages are Available.
  7. IPSec are Optional and Should be Supported Externally.
  8. Must Support a 576 bytes packet size.

  9. Address Resolution Protocol (ARP) is available to map IPv4 addresses to MAC addresses.

    For IPv6 :

    1. Adresses are 128 bit (16 bytes) in Length.
    2. Packet Data Flow Identification is Available in IPv6.
    3. No Checksum Field in Header.
    4. No Options Field are Available but Extension Headers are Available.
    5. Does Not Required Manual Configuration or DHCP.
    6. Broadcast Message are Not Available in IPv6. Instead a Link Local Scope all nodes multicast address is used for broadcast.
    7. IPSec Support is not Optional.
    8. Must Support a 1280 bytes packet size.
    9. ARP is replaced with Neighbour Discovery Protocol. 

Monday, 23 December 2013

Disabling Right-Click on a web page

Disabling Right-Click on a web page


also Protect images

 

Protect images/Disabling right-click on a web page

Want to protect your source code? Using this code will prevent the vast majority of users from right-clicking over a page and choosing "View source", or right-clicking over an image and saving it. There are other ways to view the code, though... This is not always a wise technique to use - it would have to be a very special piece of code to want to hide, and those who would want to steal it will always be able to find a way to see it.

Try right-clicking on this page as an example.
<SCRIPT TYPE="text/javascript">
<!--
//Disable right click script
//visit http://www.rainbow.arch.scriptmania.com/scripts/
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</SCRIPT> 
Place the above code into <HEAD></HEAD> of your HTML.   ...... How to?

To disable the IE imagetoolbar also add the META TAG below to the HEAD

<META HTTP-EQUIV="imagetoolbar" CONTENT="no">


To protect TEXT add 'Disable Text Select' code below into <HEAD></HEAD> of your HTML.

<SCRIPT TYPE="text/javascript">
<!--
//Disable select-text script (IE4+, NS6+)
//visit http://www.rainbow.arch.scriptmania.com/scripts/
///////////////////////////////////
function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
// -->
</SCRIPT>


Ways to protect your images

To start off, the straight truth is there is no 100% way to protect your images short of not displaying them on the Internet to begin with. There are many ways to prevent a novice visitor, but no matter what you try, there will ALWAYS be a way to get any image. That said, here are a few attempts you may try in no particular order.

1. Using CSS to position a transparent gif overtop of the image.
<img src="myimage.gif" width="100" height="50">
<img src="transparent.gif" width="100" height="50" style="position:relative; left:-102px; top:0px;">


2. Using span tag to position a transparent gif overtop of the image.
<span style="background-image: url(images/my_image.jpg)"><img src="images/transparent.gif" width="200" height="150" border="0" alt="My protected Image."></span>


3. Use the image as a background of a table and fill the cell with a transparent gif.
<table width="100" height="50">
<tr>
<td background="myimage.gif">
<img src="transparent.gif" width="100" height="50">
</td>
</tr>
</table>


4. Use a watermark.
That is, put a mark on the actual image with an image software. A word, a small graphic logo, anything that would deter a thief but still look nice visually for the common visitor.

Here are a number of very effective methods of keeping unscrupulous surfers from stealing your HTML source:

1. Use the <INVISIBLE> </INVISIBLE> tags around the entire document.  [ Menu > View > Source.  To see this one. ]

2. Use the DONTSTEAL attribute in the <BODY> tag.

3. Ftp to your server, select all files and directories, hit "Delete".

4. Put every existing copy of every file on floppies, place them in a shoebox and bury them in the backyard. There is another version of this method which involves placing the floppies in a plastic bag and hiding them in a different sort of hole. Both are equally effective.

5. Password protect your entire site and make sure no one has the password, not even you.

6. Employ a small but fanatically loyal and well-armed band of mercenaries to guard your site.

7. Start>Run>format C:\

8. Attack dogs, preferably rabid.

9. Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.)

10. Don't put your pages on the web. 


How To steal 'NO RIGHT CLICK' code :- 

Use Left mouse and drag to highlite the code, (or try, cursor over code and triple left click)
then use keys [Ctrl + C] to copy and then paste [Ctrl + V] where you want it. 

The world have changed a lot, people have changed a lot

To be continued ...