Showing posts with label hacks. Show all posts
Showing posts with label hacks. Show all posts

Monday, April 14, 2008

Cross-site Scripting (XSS)

Two days back, my shoutbox was hacked :). I was not aware that people are actually visiting this, which I made long back to have similar thing for Ethos in june, 2005. After that i haven't updated the code and many things were left in between.

What actually happened: Cross Site Scripting, when we want user to input some data (which may be html/javascript) and displays it back. So if html/script tags are not properly checked it can cause trouble. Earlier I hadn't checked for javascript, iframe inputs. So somebody just inserted an iframe as message input in my shout box. And the source of iframe contained redirection to another website. So when shouts were displayed on the page the iframe code was displayed as it is and page got redirected to other page.

Luckily I checked the page just after the day this happened, So that way i actually got chance to update this orphaned code and made some fixes.

Solution : Idea is to filter meta characters such as (< , >, ' , " etc) Which will prevent browser from processing them as part of some script, they will be processed as plain text only.
So while doing in php you can do:

$shout=str_replace("<","&lt;",$_GET["shout"]);

And to be on safer side we should also replace following characters:

replace ( with &#40;
replace ) with &#41;
replace & with &amp;
replace ' with &#39;
replace " with &#34;

Or If you are not expecting user to input these characters then you can simply replace these with null string;

So now you can enjoy Shout Box until some new bug is found or its hacked again [;)]

Related post:
SQL Attacks: Hacking (SQL injection)

Thursday, January 25, 2007

Hide data in files with easy steganography tools

Earlier I wrote about Steganography, also how data/messages can be hidden in image files in these posts :
How to hide files in JPEG's
Steganography app hides a messages in plain sight
today i find this article on lifehacker, It discusses some windows tools ( Hide in Picture ) that can be used to hide data in images.

Other free Windows tools offer more filetype support. wbStego can encode and decode files in PDF's, HTML files or bitmaps. mp3stego embeds text inside MP3 files (command line and GUI interface available.) Here are more Windows stego software options [via Webby's World].
Read More >>

Thursday, January 04, 2007

A Top 10 guide to accessing blocked websites from work

More and more companies restrict your access to certain websites. Usually it's for a good reason, however if you're pretty tech savvy and not worried about having the website "steamysingles.com" in the log file associated with your system, then this little tip site is for you. These methods includes :

read more>>
source : digg story

Monday, October 16, 2006

How to hide files in JPEG's

Create the rar file:
rar a secret.rar <your secret file>
cat img.jpg secret.rar > newimg.jpg

Now this newimage looks identical to img.jpg, but it has secret.rar contained in it :)
Pull the file back out with this command: unrar x newimg.jpg

In windows :How to hide files in JPEG's

Related Post :

Sunday, August 27, 2006

Things You Never Knew Your Cell Phone Could Do

There are a few things that can be done in times of grave emergencies. Your mobile phone can actually be a lifesaver or an emergency tool for survival. Check out the things that you can do with it.

Source : Blogcritics.org

Friday, July 28, 2006

Steganography app hides a messages in plain sight

BlackBox is an application that makes use of steganography. You have the ability to hide messages within Bitmap (BMP) files with no changes to the image or even the any of its properties, such as its file size. Useful for people who would like to send anonymous messages.

Related Post : http://burad.blogspot.com/2006/03/steganography.html
Link : http://www.spammimic.com/index.shtml

read more | digg story

Wednesday, July 05, 2006

Firefox and Thunderbird cheat sheets

A nice cheat sheet of shortcuts can be just what the doctor ordered
when you're looking to adopt a new program and get straight to
productive use.



Source: Kshitij's Blog

Friday, April 07, 2006

Useful Windows XP DOS Commands & Tricks

Typing DOS commands on the Windows Command Line prompt is a most efficient and faster way of doing things in Windows XP. Here's a run-down of the most useful DOS commands available in Windows XP. Some of these DOS commands even do not have an visual alternative. Digital Inspiration has a nice roundup of 10 very useful commands and tricks that can help you get things done quickly from the command line.
Useful Windows XP DOS Commands & Tricks [Digital Inspiration]

Related resources on Microsoft Website:
List of DOS Commands with Examples

Sunday, March 05, 2006

Shell Tweaks


Setting Alias :

Aliases are abbreviations for commands or sets of commands. Example :
alias h= 'history' now Entering h in shell will execute the history command.
alias ls ='ls -l'
you can set these in .bashrc so that every time you login these aliases will be set

to delete the previous alias definitions issue the commands:
unalias h

Defining Functions :
Functions can also be used to ensure that graphical commands always open in the background:
this can be defined in .bashrc
function gimp

{
command gimp "$@" &
}
Now every time you do gimp it will load it in backgroun automatically.

Searching history :

history n
this will print history of last n commands
for searching it CTRL + R can be user

Directory Name Typos
When changing directory small typos can be ignored by Bash
Enable this in .bashrc
shopt -s cdspell

Bash will cope with each component of the typed path having one missing character, one extra character, or a pair of characters transposed:

$ cd /vr/lgo/apaache
/var/log/apache

Directory Bookmarks
Some directories are changed to more frequently than others.
Can avoid typing their full paths if their parents are in $CDPATH
write this in .bashrc
CDPATH='.:..:../..:dir1:~:~/projects:/var/www/virtual_hosts'
now if dir2 is in projects directory then you can do
cd dir2
~/projects/dir2
It will go to dir2 due to CDPATH


env Lists all environment variable
Commands to be executed on opening shell should be written in .bashrc
Commands to be executed on logout should be written in .bash_logout
For changing the way prompt looks you can set variable PS1

Updated :
Enhancing the System Prompt change PS1 variable
More About Shell

CTRL + L will clear the screen
CTRL + T will interchange last two letter of a command

Saturday, March 04, 2006

SQL Attacks : Hacking

Yesterday I was participating an hacking competetion in which at one stage I had login on a page and after that can get to next level . When at first i randomly typed any password. then it gave an sql error that " zero row selected" and incorrect password. So I thought of using SQL string injection . SQL is poor in security issues surrounding is the login and url strings. So idea is you give these values in login form :
user : ' OR 1=1--
password : ' OR 1=1--

and voila you are in. the other possible strings for password are :

  • ' OR a=a--
  • ' or 0=0 #
  • ") or ("a"="a
  • ') or ('a'='a
So whats the funda behind this :
When you click "login" or "enter" on webpage the variables 'userid' and 'password' are to sql. The underlying query is :

SELECT * from auth_db where username = ' $userid ' AND password = '$password'

So if you have entered username = admin and password = test123 then query executed will be :
SELECT * from auth_db where username = ' admin ' AND password = 'test123 '

So in auth_db , if userid and password are correct than corresponding row will be selected and as no of rows returned is > 0 you will be granted access. But if password is incorrect than it will retun zero rows and permission won't be granted. But if you use SQL string injection like if you put ' OR 1=1-- as password and username both than query executed will be :

SELECT * from auth_db where username = ' ' OR 1=1-- ' AND password = '' OR 1=1-- '

Because a pair of hyphens designate the beginning of a comment in SQL, the query becomes simply becomes :

SELECT * from auth_db where username = '' OR 1=1

The expression 1=1 is always true for every row in the table, and a true expression or'd with another expression will always return true. So, assuming there's at least one row in the Users table, this SQL will always return a nonzero count of records.So you are logged in now. And if in some cases But many times sql tries to parse = character in input strings and didn't allow to do so, hence trick is using :
' OR userid LIKE '%%

So resultant query will be

SELECT * from auth_db where username = ' ' OR userid LIKE '%% ' AND password = '' OR userid LIKE '%% '
So every string matches '%%' so it returns non zero number of and you are granted access.
Not all SQL injection attacks involve forms authentication. All it takes is an application with some dynamically constructed SQL and untrusted user input. Most SQL-compliant databases, including SQL Server, store metadata in a series of system tables with the names sysobjects, syscolumns, sysindexes, and so on. This means that a hacker could use the system tables to ascertain schema information for a database to assist in the further compromise of the database. For example, the following text entered into the txtFilter textbox might be used to reveal the names of the user tables in the database:
' UNION SELECT id, name, '', 0 FROM sysobjects WHERE
xtype ='U' --
The UNION statement in particular is useful to a hacker because it allows him to splice the results of one query onto another. In this case, the hacker has spliced the names of the user tables in the database to the original query of the Products table. The only trick is to match the number and datatypes of the columns to the original query. The previous query might reveal that a table named Users exists in the database. So after this with multiple queries you can get control over database.

Updated :
Also visit Ten hacker tricks to exploit SQL Server systems
http://us2.php.net/mysql_real_escape_string
http://www.unixwiz.net/techtips/sql-injection.html
*******************************************************************************
WARNING: the information provided is for educationally purposes only and not to be used for malicious use. i hold no responsibility
********************************************************************************