My Php Site Hacked

Discussion in 'PHP' started by h_j5005, Feb 4, 2009.

  1. #1
    Hello,
    I write a script and use that on my site, but now one hacker hack my script.

    Changed by Hacker :
    1 - change password
    2 - change some section , add some articles
    3 - add some text

    my password is in DB ,sections ,article and text also store in DB.

    I checked for Injection but I think that is safe for injection.

    Please help me to safe my script, say me another way for login or change admin password or ...:confused:

    Thanks:)
     
    h_j5005, Feb 4, 2009 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    You need to sanitize sql inputs by using addslashes();
     
    Kaizoku, Feb 4, 2009 IP
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Post here any part that you think might be the security hole?
     
    ads2help, Feb 4, 2009 IP
  4. h_j5005

    h_j5005 Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Tanx for comments,
    is there any ways to change admin pass ?
     
    h_j5005, Feb 4, 2009 IP
  5. h_j5005

    h_j5005 Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I checked log files and see hacker use this command :
    file.php?id=-1+UNION+SELECT+1,password,3,4,5,6,7,8,9,10,11,12,13,14,15,16+from+admin--

    use this injection I think , anyone can help me to find a way hacker hack my site ?
     
    h_j5005, Feb 4, 2009 IP
  6. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #6
    Run intval on the id... You didn't bother sanitizing input.

    Dan.
     
    Danltn, Feb 4, 2009 IP
  7. h_j5005

    h_j5005 Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    can u please explain more ?
    maybe with one example
     
    h_j5005, Feb 4, 2009 IP
  8. Femto

    Femto Peon

    Messages:
    23
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    $id=(int)$_GET['id'] ;

    if inserted other than number it will considered as zero
     
    Femto, Feb 4, 2009 IP
    baris22 likes this.
  9. h_j5005

    h_j5005 Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Is there any ways to login if you have username and MD5 password ?
    login form md5 password, and hacker get md5's password and username from db .
     
    h_j5005, Feb 5, 2009 IP
  10. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #10
    That is impossible, unless monkeys coded that script.
     
    Kaizoku, Feb 5, 2009 IP
  11. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Its possible depends on how your script is configured to read login session etc.
     
    atlantaazfinest, Feb 5, 2009 IP
  12. hechotonec2

    hechotonec2 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    If you have access to the DB, so use some other MD5 tool to create a new password, then change the exist password in DB with the new one and you can log in to your account.

    If other MD5 tool can not help you, set up the script again somewhere (in another directory) then create new account. Log into DB, copy that encrypted password to the old DB and now you can log in.
     
    hechotonec2, Feb 5, 2009 IP
  13. Paul Weinstock

    Paul Weinstock Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    You must know the data for the Mysql conection as: User name; password, server address; then you can with that a script to see on the data inside you database.

    Paul Weinstock
    http://theworld3rd.com/forum
     
    Paul Weinstock, Feb 5, 2009 IP
  14. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    they have just found a sql injection within your script, just use mysql_real_escape_string and that will solve your problem !
     
    dean5000v, Feb 5, 2009 IP
  15. uqur86

    uqur86 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    u can make as strtr(strtolower($yourget),array('-'=>'','admin'=>'')
     
    uqur86, Feb 6, 2009 IP