Lavalair (hack Protection)

Started on the old forum in September 2008 · view the original in the archive · old links redirect here

54 replies · 8,908 views · started 18 years ago · 1 min read

TL;DR · summary of 54 replies
  • $who=mysql_real_escape_string($_GET["$who"]); is not secure enough for SQL injection protection.
  • Using get_magic_quotes_gpc() might help, but it's not a complete solution and can be bypassed.
  • Hiding the .htaccess file could prevent some attacks, but it doesn't protect against all vulnerabilities.
  • Regular backups are recommended to mitigate damage from hacks.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

18 participants
djlee Developer · 224 posts #21

no script is 100% unhackable .. ive worked with some of the best PHP coders you will ever find and there scripts will grow an extra 1000 lines from a basic security while adding all the extra security stuff and still i have been able to exploit scripts

the thing to think about is how can someone hack ur site .. well the two most common ways are SQL injection and XSS exploits.

XSS exploits are generally performed by the user running javascript on a page. Now they cant directly affect your site. Javscript is client side and is managed by the browser after the server has sent the page to you. However they can grab details from you. How about if i use an unprotected form field to write a javascript redirect refresh header to my server. Ive done this before to test the theory and it works. i simply send the user to a file on my server which grabs there SID, saves it to a file then sends them back to the users online page. Now i have that users SID to access the site (if there an owner im now using an owner account with all the goodies).

Ofcourse this was just a thoery practice.. With a little messing about i could instead send the user back to my user page and have it display as normal and they wouldnt have the faintest idea about the script.

So how do you protect against XSS .. well for javascript and most other basic XSS atacks you use the htmlspecialchars() function built into PHP. this will stop the script tags being passed correctly to the browser and will show up as < script > instead of < script >


SQL is a lot more complicated .. there are 2 main rules of thumb here:

  1. NEVER USE MAGIC QUOTES !

magic quotes are bad... period. if you wanna know why then use google but basically u shudnt rely on them. This is proven by the fact php dev's are removing them from php6 and above (i think php 5 will support magic quotes throughout the minor updates).

  1. SANTIZE ALL DATA !

any data that the user enters must be sanitised. If you expect a number then make sure its a number. If its a string then make sure all "bad" chars are escaped.

for example

$id = $_GET['id'];

that is bad .. what happens if i enter ?id=djlee .. when the sql is run it will run the £id as djlee not a number and will cause an error. obviously from here the hacker knows you have not secured the script and can populate the ID with some sql statements in order to delete tables or make themselves owner.

to protect it is simple

$id = 0 + $_GET['id'];

i prefer to use 0 + however (int) works fine too. so now lets check what happens . $id = 0 + djlee .. $id = 0; .. any string that is added/subtracted/divided/multiplied by a number must be type casted to a integer. as $_get['id'] is not a valid number when it is type casted it becomes 0 and 0 + 0 = 0


to protect strings then as stated before use the mysql_real_escape_string() function at least


these are just basic preventions though. other things you need to do is go over php.ini, my.cnf and httpd.conf and secure them.. they are not secure on 99% of servers.

also remember that i can encode things too. if you have the username in the GET request $user = $_GET['user'] i can use html encoded characters to avoid your protection... urldecode () will decode html encoded characters so that any other protection methods will function correctly.


Protecting your site from hackers will never stop. its an ongoing thing. however it is important you protect ur site the scope your experience will allow you to do so. There will always be others out there that have figured a way to get around ever protective measure on a site. and as soon as they tell you (if they are a community developer and not a hacker ofcourse) you will patch it and someone else will come along with a new working idea to hack past it all

personally id learn how to script PHP properly and build your own site from the ground up .. mostly because lavalair is shit and is by fair over used .. its bout time we had a few more wapsites that didnt look like the other 1000 already out there

amylee Principal · 1,092 posts #22

well most people on wap dont have any originality or even a small bit or creativity to create a new script and what not so they join the ever so shitty trend of copying everyone else and here we have a thousand odd clone sites looking exactly the same as each other

plus its not the script that only needs the protection its the server also this is why i never use my scripts on a server i don't have 100% total control over and most idiots running lava script don't realise hacking doesnt end with the just the script as with no server you have no script asn with no server ans script you have no site

djlee Developer · 224 posts #23

well if u wanted to be perdantic about the matter you could say you cant HACK a script .. you hack the server .. you exploit the script .. two common misconceptions about how the two words are used interchangeably .. the same as hacking and cracking are completly two different things with each warrenting their own titles as hackers and crackers respectively ... but i dont wanna go confusing the newbies

jaijithjg Newbie · 3 posts #24

so you say that anyone can be hacked :sad: ........??? how do ppl hack anyhow.....???

GumSlone Administrator Principal · 1,690 posts #25

you can try a function like this

function replace_for_mysql($text){
      $text = preg_replace('/[^[:alnum:]\_\-\^]/','',$text);
      return $text;
 }

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

djlee Developer · 224 posts #26

so you say that anyone can be hacked :sad: ........??? how do ppl hack anyhow.....???

with plenty of hard work, time and more f*ck ups imaginable ... you cant be taught how to hack .. its something you learn off your own back .. and its not easy .. takes years of work just to understand the fundamentals .. and then you need to be able to spot holes in software and protocols. if you want to learn then install the oldest version of an irc server you can find .. thats where hacking really become mainstream in the underground networks and those that have the knowledge still use IRC today to manage such things as botnets.

you may also want to try ip spoofing to darkspace. if you can temporarily assign and "tag" a darknet ip to your own then go buy urself a medal as its not easy to get to grips with

Guest #27
if( !get_magic_quotes_gpc() )
{
    if( is_array($_GET) )
    {
        while( list($k, $v) = each($_GET) )
        {
            if( is_array($_GET[$k]) )
            {
                while( list($k2, $v2) = each($_GET[$k]) )
                {
                    $_GET[$k][$k2] = addslashes($v2);
                }
                @reset($_GET[$k]);
            }
            else
            {
                $_GET[$k] = addslashes($v);
            }
        }
        @reset($_GET);
    }

    if( is_array($_POST) )
    {
        while( list($k, $v) = each($_POST) )
        {
            if( is_array($_POST[$k]) )
            {
                while( list($k2, $v2) = each($_POST[$k]) )
                {
                    $_POST[$k][$k2] = addslashes($v2);
                }
                @reset($_POST[$k]);
            }
            else
            {
                $_POST[$k] = addslashes($v);
            }
        }
        @reset($_POST);
    }
}

i use dis code hehe 😀

djlee Developer · 224 posts #28

^^ wouldnt bother .. global quick fixes are noobish and a waste of time . your basically enabling magic quotes .. well ur probably less protected with that than with magic quotes on .. u may as well just turn magic q's on in php.ini or htaccess and be done with it . the only way to protect a script is to go through it line by line making sure all user inputted data is sanitised e.c.t

sweetangel Lead · 885 posts #29

I use the code like this:

function magicQuotesRemove(&$array) {

   if(!get_magic_quotes_gpc())

       return;

   foreach($array as $key => $elem) {

       if(is_array($elem))

           magicQuotesRemove($elem);

       else

           $array[$key] = stripslashes($elem);

   }

}

magicQuotesRemove($_GET);

magicQuotesRemove($_POST);

magicQuotesRemove($_COOKIE);

if like my post click:

External image (may be gone)

friend Developer · 112 posts #30

How to prevent any one hacking our userid? They hack userid like they playing with toys.

subzero Super moderator Fellow · 3,954 posts #31

dont let users upload or have in user profiles a php images

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

friend Developer · 112 posts #32

Thanks u subzero :smile3:

subzero Super moderator Fellow · 3,954 posts #33

only thing is ok is gif,jpg also make sure file name has no php in it

you can block it by replace text.

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

subzero Super moderator Fellow · 3,954 posts #35

php i can tell it has / no gif

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

Guest #38

wat r u doin mates??r u nt wastin ur times..??lolz lavalair iz always hackable as itz the crap one!!..the best way to prevent hackin is nt usin dat lavalair script!!!..its being hacked ol day long and here iz nobody who can give da solution...:P

looony Developer · 95 posts #39

haha phpthumps a secure uploader and and a few str_replace functions and lavalair is secure unless u actually get attacked by a real hacker not the noobs that hijack sessions

External image (may be gone)

if(isset($_SESSION['username'])) { print "everybody is a little loony inside"; } else { print"You should be shot"; }

something else Fellow · 2,296 posts #40

QUOTE (prohor @ Oct 13 2008, 08:04 AM) <{POST_SNAPBACK}>

wat r u doin mates??r u nt wastin ur times..??lolz lavalair iz always hackable as itz the crap one!!..the best way to prevent hackin is nt usin dat lavalair script!!!..its being hacked ol day long and here iz nobody who can give da solution...:P

Place your site address here prohor i bet your site is as safe as lava! lol

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close