All the information on this page is for educational purposes only. The owner of the blog, nor Blogger, nor anyone associated with this blog can be held liable for illegal activities brought by this blog
Showing posts with label LFI. Show all posts
Showing posts with label LFI. Show all posts

Monday, January 30, 2012

A Double Tutorial - CSRF & SQL Column Truncation

So today we have a double tutorial...

We will be looking at 2 new hacking methods:
CSRF (Cross Site Request Forgery)
&
SQL Column Truncation

To begin we will look at CSRF, now CSRF is basically a hybrid between XSS (Cross Site Scripting) and LFI (Local File Inclusion)

Side Note: We will be looking at those 2 vulnerabilities at a later stage, this technique is very simple and straight forward, so a tutorial on XSS prior to this is not really necessary.

In CSRF, the victim is basically sent to a different page without his knowledge.

Say we have a website with a form that allows us to edit our profile, normally comprising of:
  • Avatar
  • Password
  • Email Address
  • Interests
  • etc
Remember, an image stored on a website is always stored on a server and the image is retrieved every time that image loads... 

Now say our form is set up with a text box as to where you must insert your server address for your new avatar, you need to instead of giving a server address, insert a script that will allow you to alter details of your profile.

So the first thing you will need to do, after logging in and navigating to the edit profile page, is to view the source code of the edit page.

You will notice that the form action has something similar to  
.edit/profile.php
or something to that effect
So to begin with insert that line(the form action) into the avatar text box, next you insert a ?, so the text in the text box will be:
.edit/profile.php?

The question mark is always followed by a parameter and the parameter is whatever we want to edit on the profile, so next you need to view the source code again, and look for the line that allows you to change your password and see what it's name is, remember that as that is our parameter:
.edit/profile.php?password

Now finally, add an "=" afterwards directly followed by what you would like the password to be, for example:
.edit/profile.php?password=hacked

Now, lets imagine that a victim, for example Admin, goes to view your password for some reason, when the victim's browser goes to retrieve the image (the edit page we set) it will execute the edit profile page as the victim which would change whatever information we set it to change as, in this case, the password.

This will edit any user who views your image's information.
Typically, the password access you will gain will be that of a robot or spider, but with that access, you have a very good chance that gaining admin rights will now be relatively easy.


Next up is....


***SQL COLUMN TRUNCATION***


SQL Column Truncation is also a very simple and effective technique that can be used to hack websites.
Basically, SQL Column Truncation gives you the ability to duplicate usernames in an SQL database and therefore giving you access to that user account.

To begin, let us imagine that you have discovered that the admin's username is Admin, now, regardless of the password, you will be able to log in as Admin and also make use of administrative rights, to do this you need to understand a few things first.

An SQL database does not recognize spaces, that is why on many website registrations, your username and password may not contain a space, in SQL, a space is completely ignored, for example:

Hacking is awesome
will be stored as
Hackingisawesome

Also, the database table will have rules set that will determine how many characters may be stored in a cell, if that number is exceeded, the additional characters will be dropped and only the allowed number of characters will be stored, for example:

If the database only allows for 10 characters in the cell, and a user attempts to insert 15 characters, the first 10 will be stored and the last 5 numbers will be dropped, for example:

CookieMonster

will be stored as

CookieMons

"ter" has been dropped as they have exceeded the maximum amount of characters allowed to be stored.

Now, go to register a new account, next you need to view the source of the page, as there is a character limit added onto the SQL database, the web master would have added in HTML code to the username text box a maximum number limit, say you have discovered this to be 10.

In the textbox, insert Admin followed by 5 spaces, as Admin is 5 characters long and adding another 5 spaces will make the username 10 characters in total, the text box will restrict you from adding in any more characters.

Please Note: For the next step I will be using Tamper Data (a firefox add-on), if you would like information on how to do this without using Tamper Data, comment below.

Open Tamper Data and start the tamper, tamper the request that will submit your registration form and then add an x to the end of your "Admin     " string, therefore, you will now have this:
Admin     x

(The x is there because if it wasn't there, the username would never be passed to the SQL database, because the moment the spaces were removed it would notice the duplicate data - The x can be any other character)

Now when that username is submitted, the entire username will be added to the cell (because of the x it is not equal to admin), but because it is 11 characters, which is too large for the database to handle, according to the rules set by the admin, the database will drop the additional characters, in this case, x.

After the character has been dropped, the database will now remove the spaces and store "Admin" as the final string, but because it is actually "Admin     x", the database does not recognize it as Admin.

Finally, log in as Admin with the password you just set at registration and you will find that you are logged in with administrative rights.

--- Final Summary ---

Both these methods will get you admin access, the first thing that you should do after gaining access, should be to go and clear your logs.

Also remember, that when using the CSRF method that the victim WILL discover the password change the next time he attempts to log in, so you will have to log in immediately and attempt to grant yourself admin rights (There are multiple ways to achieve this)

Now, using the SQL column Truncation method, on the other hand, is a lot less likely to be discovered, but still is a possibility, you should also try and grant another one of your accounts admin rights and use your Admin account sparingly, also, you would have a better chance of remaining undiscovered if you clear the logs every time you log in as Admin.

Although, if the administrator were to check or clean the database, your database account may be discovered.

Well I hope you enjoyed this tutorial and please feel free to comment.
Peace Out!!!

Techno Master

Sunday, October 16, 2011

A brief overview of hacking - Part 2

Ok, so let's begin the second part of our hacking overview. There are many different methods of hacking, many different people who hack and many different reasons for the hacks. We are firstly going to look at common methods of hacking.

First, there are many different ways to hack and get access to secure information, some may be simpler than others, but generally, they can all be just as successful and useful as all the others, about 99.999999999% of the time you will HAVE to combine more than one of these methods during a hacking session to successfully complete the hack.

  • SQL Attacks
An SQL attack is the method where a hacker will breach the login form by accessing the data in the SQL database of the website, and searching through row and column names, will eventually discover a user password, preferably an Admin password. This method is more commonly used with the Information_Schema command, but it all depends how the webmaster has the set up his login site.

  • LFI / RFI
An LFI or RFI (Local File Intrusion / Remote File Intrusion) is when a hacker locally or remotely adds a dangerous script into a server, website, etc and therefore gains control to login info, sensitive info, access to all files, etc.

  • Social Engineering
Social Engineering is all about making other people give you the information you need, normally, a hacker will phone in posing as a employee who has forgotten his login details or needing confidential information  immediately, he then gets the other person to give him the information, allowing the hacker access on to the system. Social engineering has become increasingly popular as it saves time and resources.

  • Brute-Force
Brute force is a method of password cracking, when a hacker does a brute force attack, he runs a program that tests multiple passwords and encryption types until the password has been cracked. The problem with brute force is the amount of combinations available and the amount of time it can potentially require to crack the encryption.

  • Rainbow Cracking
Rainbow cracking uses rainbow tables to crack passwords, rainbow tables are lists of code with every available combination of a certain encryption, rainbow cracking is much quicker and effective, although creating your own tables is very time consuming and rainbow table files are very large files. You can purchase rainbow tables online as well.

  • Dictionary Crack
Dictionary crack is used when the hacker at least knows that the password is an actual existing word, the hacker then runs a program which tests a whole list of words in reference to the password, if the password is an actual word, this is a very quick and effective method.

There are many many more methods and I will go into most of them in more detail in later blogs, but here are a few common methods.

Another quick add-in before I end off today's post is anonymity, anonymity is making sure nobody knows who you are, this is very important in the hacking world as hacking is illegal, if you are an expert, you can build scripts to delete the log files, but there are multiple problems to this approach, the best method is to not even be logged on the site, to stay anonymous, you can hack through a proxy server, hiding your actual IP, this method works great if you understand which proxy servers you should be using. The next best thing is to use the TOR web browser, TOR is an anonymous web browser, which disguises your true IP address and also does not allow sites to store cookies or other personal information.

To get TOR visit:
https://www.torproject.org/download/download-easy.html.en

Thanks.

Techno Master
 
Back To Top