Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19
  1. #11
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Code is incredibly insecure...

    PHP Code:
    if($username == "+"){
    echo(
    "Hacking attempt.");
    exit();

    That isn't a hacking attempt. A hacking attempt is where a query sent to the database would look like:

    SELECT * FROM users WHERE username='admin' AND password='' OR 1=1

    As 1=1 is always going to return as true, it'll think the user is logged in.

    When you declare your username and password variables, use this:

    PHP Code:
    $username mysql_real_escape_string($_POST['username']);
    $password mysql_real_escape_string($_POST['password']); 
    It'll filter out nasty queries like the one above.

    Also, how are you encrypting your passwords when you store them in the database. From the login script, it looks like they're stored as plaintext, which is incredibly insecure. You should be storing them hashed with either md5 or sha1 (hopefully, with salts as well).

  2. #12
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    The passwords are MD5'd. Just after the bit that checks for the + in the password.
    PHP Code:
    $password md5($password); 
    And I'm about to change that thing you told me, I don't actaully know how to hack, so I'm not really any good at filtering out attacks.
    Last edited by lolwut; 29-10-2007 at 09:23 AM.
    i've been here for over 8 years and i don't know why

  3. #13
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Oh, escaped my eyes Sorry sorry.

    Can I suggest you salt your password hashes as well? Example:

    PHP Code:
    $salt "iohIY&8yweoi8h";
    $encrypted_password md5($_POST['password'] . $salt); 
    It's basically an extra precaution, and means that unless you use a simple salt like 'cat' or 'dog', your passwords won't be found out. MD5 rainbow table sites are becoming more common these days. They basically hold hashes for many words, so if anyone runs an md5 hash through one of them, and their password is something simple, like a dictionary word for instance, it'll most likely be in their database of hashes, and the plaintext password will be displayed.

  4. #14
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Why would you want to check if the password has a plus in it? If the password is hashed before placing it in the database it becomes impossible to use SQL injection unless you store it in a cookie (This was a exploit used in IPB as they did not clean the password cookie before using it in a SQL query and since the user can mess around with the cookie it does not necessarily contain the hash you put in it.)

    Quote Originally Posted by Imperial March View Post
    The passwords are MD5'd. Just after the bit that checks for the + in the password.
    PHP Code:
    $password md5($password); 
    And I'm about to change that thing you told me, I don't actaully know how to hack, so I'm not really any good at filtering out attacks.

  5. #15
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    Tomm; I have no idea how to hack, like I said earlier. And I thought that + was somehow used in SQL Injections. Anyway, I've changed it to mysql_real_escape_string(); like benzo said. Sorry.

    Benzo; I will probably, but right now I'm trying to focus on this stupid login error, I think it's possibly got something to do with the cookies. Any ideas?
    i've been here for over 8 years and i don't know why

  6. #16
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Okay lets take an example of Habbox Forum

    Date: Mon, 29 Oct 2007 10:01:21 GMT
    Server: Apache/1.3.37 (Unix) PHP/5.2.3 mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a
    X-Powered-By: PHP/5.2.3
    Set-Cookie: bbsessionhash=-Snip-; path=/; HttpOnly
    Set-Cookie: bblastvisit=1193652081; expires=Tue, 28-Oct-2008 10:01:21 GMT; path=/
    Set-Cookie: bblastactivity=0; expires=Tue, 28-Oct-2008 10:01:21 GMT; path=/
    Cache-Control: private
    Pragma: private
    Content-Encoding: gzip
    Content-Length: 18892
    Connection: close
    Content-Type: text/html; charset=ISO-8859-1

    This is followed by all the HTML data for the habbox forum homepage.

    Your site sends these headers as well. But if you use the header function after sending HTML then you will get that error since you can't send headers after you sent HTML.

    e.g
    <?php
    //This is okay
    header("X-Tester: Tom");
    echo "<p>Hiya</p>";
    ?>

    <?php
    //This is not okay
    echo "<p>Hiya</p>";
    header("X-Tester: Tom");
    ?>

  7. #17
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Normal characters that are used in SQL injections are ' and --. ' will cut off the quote of the query that should be processed, allowing an attacker to launch another. -- is an SQL comment, it'll block any code after it from processing correctly.

    Unsure whether this will work, considering your database dump didn't include the user's table, but try adding this to the line straight after the <?PHP tag:

    PHP Code:
    ob_start(); 
    And this after line 32 (setcookie commands):

    PHP Code:
    ob_end_flush(); 
    EDIT: Tomm, from the source I'm looking at, I can't see a header() command anywhere. He's using a meta refresh.
    Last edited by Beau; 29-10-2007 at 10:07 AM.

  8. #18
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    benz; Thanks for that thing about the SQL, I think it's abit securer now thanks to the mysql_real_escape_string() though?
    I tryed that output buffering thing out, and it WORKS! +Rep. Ily.

    Tomm; I didn't even use header(); on the index.php page, and I do already understand headers, thanks anyway.

    EDIT: Soz cant repz u but i owe u rep.
    i've been here for over 8 years and i don't know why

  9. #19
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    UPDATED LINK.
    WORKS FINE NOW.
    i've been here for over 8 years and i don't know why

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •