1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Security Issue ... can you hack ?

Discussion in 'PHP' started by commandos, Dec 20, 2008.

  1. #1
    this is a little script i messed with and i wanted to add it to my site ...

    http://www.codes.tutorials4php.com/

    can you find any security flaws ?

    Thanks

    the data get inserted in a db ...
     
    commandos, Dec 20, 2008 IP
  2. jaob70

    jaob70 Guest

    Messages:
    135
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I once had a site hacked a while back, was a pain to get it all sorted out. Ruined my traffic, I had to scrap the whole project.
     
    jaob70, Dec 20, 2008 IP
  3. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #3
    i dont see where that answers my question :)

    for the other ppl reading ... i cant add functions like "mysql_real_escape_string" because i cant mess with the data sent to the database ... since i need to show it again when they request and it will look messed up ..

    maybe a solution would be to add : stripslashes after the usage of mysql escape ...
     
    commandos, Dec 20, 2008 IP
  4. sandstorm140

    sandstorm140 Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Commandos,
    mysql_real_escape_string and stripslashes helps keep noob hackers away, like me lol. Otherwise, no site can ever be completely hack-proof. Alot could depend on your php.ini setup. Usually it's just a hole somewhere in large scripts. This site of yours isn't a large script, but if someone really wanted to hack ya, they could.
     
    sandstorm140, Dec 21, 2008 IP
  5. RRWH

    RRWH Active Member

    Messages:
    821
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    70
    #5
    What I do is to be the hacker against my own site and go after it with common methodology.

    If I can break anything myself then the code I wrote is shite!

    So, I look at everything that goes into a db and ensure that it cannot be used for evil purposes.

    So, the usual suspects that get checked for are XSS, Sql injection and just simple data validation for everything that has been input.

    XSS - check the referer - yep, can be spoofed, but still check.
    SQL Injection - I found http://www.securiteam.com/securityreviews/5DP0N1P76E.html to be a pretty good resource that has helped me to write a couple of data validation functions to protect whenever anything gets put into a database.
    Finally, the validation - I ensure that n othing but the expected characters/data types go into a field other than what is expected - eg, numeric files are checked, username/password fields are checked to be a single word etc.

    I have no interest in trying to "exploit" your script, but you should take all possible steps to do so and anytime you are able to input bad or incorrect data from either your site or another site then it is time to look at your code and start working on it again.
     
    RRWH, Dec 21, 2008 IP
  6. tobydawson13

    tobydawson13 Active Member

    Messages:
    645
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #6
    tobydawson13, Dec 21, 2008 IP
  7. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #7
    How about u open ur own thread and ask about it ?
     
    commandos, Dec 21, 2008 IP