Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Protecting a SQLite database file

  1. #1
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Protecting a SQLite database file

    So, how would you go about protecting a SQLite database file. I'm working on a couple PHP scripts using SQLite, and I'm not sure how to protect the database. It seems to me that someone could download the file since it is the directory right next to the script. How do I prevent this?

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Make an index.php for that folder and set your condition.
    For example:
    Code:
    if ($_GET["key"] != "randomstringhere") {
    dostuffhere();
    }
    I do it for redirections on my site if someone puts in a wrong page address.
    - Mike

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Move the file out of the web root.
    Last edited by Twey; 02-09-2007 at 03:18 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Why would it be in the web root in the first place? SQL files are in the MySQL/Other database's directory by default.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Not MySQL, boxxertrumps. SQLite.

    SQLite databases consist of a single file, no server, and can be placed wherever they're needed.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Yup... in fact, I have no idea where my MySql path is. That is a plus for SqlLite, but also a fault because of the security leak.
    - Mike

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    It's only a real security leak if the data is stored in the root directory (or one accessible from the web). If it was stored even one level higher than the web directory, it would be safer.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Yeah, I know. But it's still on the web one way or another. Get some super hacker and see how far she/he goes with it
    - Mike

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Another option (best used in tandem with moving it out of the web root) is to encrypt the file in some manner.
    Yeah, I know. But it's still on the web one way or another.
    Not really. It's on a server that's connected to the Internet, certainly, but it's not on the Web, per se. Besides, so is any database. It's remarkably tricky to return data when requested without storing said data
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Yea, maybe make up some kind of encryption/decryption method in one of the scripts used to access the data. That should be fairly easy (or extremely complex) depending on how you do it.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

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