[How-To] Prevent persistent vehicles hacked into database

Discussion in 'General Discussion' started by Doc, Dec 20, 2012.

  1. Doc

    Doc Valued Member!

    Joined:
    Nov 23, 2012
    Messages:
    355
    Likes Received:
    39
    What does the title mean?
    Sometimes, unintelligent hackers will spawn vehicles that enter your object_data table thinking you will not notice. My guide will not show you how to prevent these occurances, but rather delete the vehicle from the table during your regular restart operations.

    If you are using my Improved Vehicle Spawn Functions then this guide will be easier to follow. If you are not using them, I strongly suggest you do but you can use this (with some ammendments).

    How it works
    The concept is very simple. Every legitimate vehicle is spawned by your vehicle spawn procedure. This is either pSpawnVehicles (if you use my functions) or pMain/pSpawn if you use the default functions. What we are going to do is assign every legitimate vehicle an identification codeword. This can be anything you want 'Noodles', 'Rugby', 'alf4h8'. ie anything you want. Now we are going to set our spawning vehicles to carry this identification in a new column. Because hackers wont know your codework, their input will be blank, or simply just plain wrong. Now when the server is restarted and you execute your standard pSpawnVehicles, pCleanup or whatever maintenance procedure you use, you can make an addition which checks for vehicles that are spawned in but do not carry the correct identifier. You can then either delete them completely, or set their Instance to 0 so they will not spawn. Personally I set the instance to 0 so I can check to see what's been happening on the server, I then delete them manually after doing my investigative work.

    It is simple, and this is how we do it.

    STEP ONE
    Firstly, we have to ammend our object_data to contain a new column which we will call 'Legit'. You can call it what you like, but if you don't know what you are doing just stick to this as it's used in the code later on. To do this using Navicat, we go to object_data -> Design Table. Then use your arrow keys to go down the list of fields, and when you go past the bottom one it will create a new blank field for you to use. Set it with these parameters:
    [​IMG]

    The length can be anything you like, as long as it is greater than the length of the code word you plan to use. To set default to NULL you have to click on the row you are creating and the "Default" option will be at the bottom of the page. When this is done, press "Save" and close your table.

    Only follow the step two relevant to the type of vehicle spawn you are using. If you don't know, follow the first one, if you are using my vehicle spawn funciton, follow the second one.

    STEP TWO (IF USING default spawn functions pSpawn/pMain)
    Skip to the other step two if you are using my pSpawnVehicles!! If you are using the default spawn functions, you should consider using my version linked above because it works better for servers with more vehicles. If you are using the default spawn functions anyway, then this is what you need to do.

    Locate this in your pSpaw. I'm not sure on the line number because I heavily edited mine before writing my own.
    Code:
    INSERT INTO object_data (ObjectUID, Instance, Classname, Damage, CharacterID, Worldspace, Inventory, Hitpoints, Fuel, Datestamp)
            SELECT ot.ObjectUID, '1', ot.Classname, ot.Damage, '0', ot.Worldspace, '[]', ot.Hitpoints, '0.05', SYSDATE()
    
    Now add this onto the end of the first part, near Datestamp so it becomes
    Code:
    Datestamp, Legit)
    And edit the end of it near SYSDATE() so it looks like. Remember to replace it with your codeword
    Code:
    SYSDATE(), 'YOURCODEWORD'
    This is done, now go to step three

    STEP TWO (IF USING MY pSpawnVehicles)
    Do not do this if you followed the other step two above, only use this if you are using my pSpawnVehicles. If you do not have a codeword in mind yet, now is the time to think of it.
    Open up the pSpawnVehicles in Navicat and locate this section on lines 53 and 54:
    Code:
    INSERT INTO object_data (ObjectUID, Instance, Landmark, Classname, Damage, CharacterID, Worldspace, Inventory, Hitpoints, Fuel, Datestamp)
                                                        VALUES (@spawnUID, '1', '0', @rsClassname, @rsDamage, '0', @spawnWorldspace, @rsInventory, @rsHitpoints, @fuel, SYSDATE());
                                        
    Now replace it with this, but remember to edit "YOURCODEWORD" ad the end of it to your desired codeword. Maintain your word within the ' ' and do not include any ' in the word.
    Code:
    INSERT INTO object_data (ObjectUID, Instance, Landmark, Classname, Damage, CharacterID, Worldspace, Inventory, Hitpoints, Fuel, Datestamp, Legit)
                                                        VALUES (@spawnUID, '1', '0', @rsClassname, @rsDamage, '0', @spawnWorldspace, @rsInventory, @rsHitpoints, @fuel, SYSDATE(), 'YOURCODEWORD');
     
    
    This now ensures legitimately spawned vehicles will carry a correct identifier.

    STEP THREE
    Now we need to insert some code into pCleanup that will stop vehicles without the identifier spawning. Again, there are two versions available here. One is for those people using the default spawn system and the other is for those using my pSpawnVehicles. Follow the applicable one.

    If using default spawn
    Open pCleanup and insert this a couple of clean lines under pCleanupOOB();
    Remember to replace YOURCODEHERE.
    Code:
        UPDATE object_data
                SET Instance = '0',
                Legit = 'ILLEGAL'
                WHERE Legit != 'YOURCODEHERE'
                AND Classname != 'dummy'
                AND Classname != 'TentStorage'
                AND Classname != 'Hedgehog_DZ'
                AND Classname != 'Wire_cat1'
                AND Classname != 'Sandbag1_DZ'
                AND Classname != 'TrapBear';
    
    click save

    If using my pSpawnVehicles
    Open pCleanup and insert this a couple of clean lines under pCleanupOOB();
    Remember to replace YOURCODEHERE.
    Code:
        UPDATE object_data
                SET Instance = '0',
              Legit = 'ILLEGAL'
                WHERE Legit != 'YOURCODEHERE'
                AND Landmark = '0'
                AND Classname != 'dummy'
                AND Classname != 'TentStorage'
                AND Classname != 'Hedgehog_DZ'
                AND Classname != 'Wire_cat1'
                AND Classname != 'Sandbag1_DZ'
                AND Classname != 'TrapBear';
    
    click save


    JOB DONE
    Now every restart when your cleanup is called, any non-legit vehicles will be updated to a 0 instance (ie they wont spawn) and they will be tagged with ILLEGAL. Periodically check your object_data to see if any illegal vehicles have been spawning ;)
     
  2. Aaron J

    Aaron J Member

    Joined:
    Mar 19, 2013
    Messages:
    43
    Likes Received:
    2
    I have this issue on my server and I can't believe I stumbled upon this. Sorry to revive old threads but does anyone know if this is still worth trying? Anyway Great job Doc I will give it a shot tomorrow!
     

Share This Page