Post: Server-sided auth code using keys (Elite or custom licensing)
01-25-2016, 03:22 AM #1
Tustin
Balls of Steel
(adsbygoogle = window.adsbygoogle || []).push({}); Sup?

I wrote this code for The Tesseract re-release but that never happened, so here we are. I had also originally posted this in the Gaming Squad section, but I figured it could be useful for everyone. You can use this code to either authenticate your app for Elite or using a custom key system - it's all up to you. The example uses Elite auth by default but you can change it pretty easily by just getting rid of the validate_elite_key function call. Follow the steps below for installing this on your server.

Prerequisites:

  • A server
  • A web server installed (nginx, apache2, it doesn't matter)
  • MySQL installed
  • PHP installed
  • Root login info for MySQL


How to setup:

  1. Download zip and extract contents to a location on your PC
  2. Open up 'autoload.php' and add a name for the DATABASE_NAME constant at the top.
  3. In the same file, add the credentials for your MySQL login. This user should have permissions to create tables and databases (so ideally use root)
  4. Save file, and upload all the files to a directory on your server.
  5. Go to the directory in your browser and load the setup.php script first.
  6. If you used proper MySQL credentials, it will successfully create both a database and two tables in said database.
  7. DELETE setup.php from your server
  8. Create a new MySQL user with only the required permissions (SELECT, INSERT, UPDATE, etc) and replace your root user's credentials inside `autoload.php` with this new MySQL user information (thanks to JB for catching this error)
  9. To test, access auth.php with a GET request for key using your NGU Elite key (example: You must login or register to view this content.)
  10. If the setup worked properly, it should output "Some useful information" (hilarious, right?) and if you check your log and users table, you should see your Elite key there.


It's a basic system for getting your app up and running. However this does do automatic banning for users who share multiple keys under so many different IPs in a certain period of time (like 24 hrs I think). The ban check is done each time the auth script executes, so unless your app gets little to no traffic, it should do just fine. If you really want you can setup a cron job to run the unban/ban process every so often.

You must login or register to view this content.

Enjoy and let me know if you have any issues or just need help with it.

The following 27 users say thank you to Tustin for this useful post:

BaSs_HaXoR, BaumHF1, Sabotage, Discrepancy, Egzec, endojunky, Father Luckeyy, Frosty, Geo, Kam, Kronos, Kryptus, JokerRey, Norway-_-1999, Darth Saul, Pink Guy, ProfoundModz, Rath, Adrian, Sloth, Specter, Swaqq, Wu., xK ELITE GaminG
01-25-2016, 02:41 PM #2
Default Avatar
Kas
Guest
Originally posted by Tustin View Post
Sup?

This is some code I wrote for what was going to be The Tesseract and Riptide for Elite, but things fell through on those so here we are. I'm going to be sharing the code for all of you that aren't really familiar with the server side of auth so you can get a head start with your apps that you want to use it on. At the moment, I'm currently only providing the code for this. It's up to you to find a server to run this on. I suggest you check out OVH for a cheap VPS with some DDoS protection (because we all know people in this scene love that shit, right?). In the future I may set up a server for you guys to use for your apps. Anyways, onto the code itself.

It isn't anything spectacular and surely won't blow the doors off anything, but it does a bit more than just your run-of-the-mill key check. It will automatically check logs on each login to check for key sharing and it will auto ban accordingly. I've made it very easy to setup, as long as you can follow a few simple steps Drack.


  1. Download zip and extract contents to a location on your PC
  2. Open up 'autoload.php' and add a name for the DATABASE_NAME constant at the top.
  3. In the same file, add the credentials for your MySQL login. This user should have permissions to create tables and databases (so ideally use root)
  4. Save file, and upload all the files to a directory on your server.
  5. Go to the directory in your browser and load the setup.php script first.
  6. If you used proper MySQL credentials, it will successfully create both a database and two tables in said database.
  7. DELETE setup.php from your server
  8. To test, access auth.php with a GET request for key using your NGU Elite key (example: You must login or register to view this content.)
  9. If the setup worked properly, it should output "Some useful information" (hilarious, right?) and if you check your log and users table, you should see your Elite key there.


That's the basic gist of it. Like I said, this script by default does Elite authentication. If you don't want this, you should be more than capable of removing the validate_elite_key check in auth.php and replacing it with is_key_present. This is assuming that when you have users purchasing your app, they automatically have a key generated for them and inserted into the database.

Also a quick side note: I mentioned using your root MySQL user when you run the setup script. You should change this afterwards to a user that doesn't have that many permissions, but you can keep it as root if you like. This script is free of any SQL injection so you won't have to worry about some fancy DROP query being executed!

You must login or register to view this content.

Enjoy and let me know if you have any issues or just need help with it.


Great release man, 100% needed. Thanks bro.
01-31-2016, 12:30 PM #3
Sabotage
Gaming Squad
Originally posted by Kas View Post
Great release man, 100% needed. Thanks bro.


Great release kas, always trying to help the community.

The following user thanked Sabotage for this useful post:

Algebra
01-31-2016, 04:47 PM #4
Specter
Pro Memer
Originally posted by sabotage View Post
great release kas, always trying to help the community.


he's alive
02-20-2016, 04:58 AM #5
Tustin
Balls of Steel
Moved this out of the GS section and into the public forums. Hopefully you guys can make use of this!

The following 3 users say thank you to Tustin for this useful post:

FireMaggot, Kryptus, Passion
02-23-2016, 05:20 PM #6
JB
[i]Remember, no Russian.[/i]
Originally posted by Tustin View Post
Sup?

I wrote this code for The Tesseract re-release but that never happened, so here we are. I had also originally posted this in the Gaming Squad section, but I figured it could be useful for everyone. You can use this code to either authenticate your app for Elite or using a custom key system - it's all up to you. The example uses Elite auth by default but you can change it pretty easily by just getting rid of the validate_elite_key function call. Follow the steps below for installing this on your server.

Prerequisites:

  • A server
  • A web server installed (nginx, apache2, it doesn't matter)
  • MySQL installed
  • PHP installed
  • Root login info for MySQL


How to setup:

  1. Download zip and extract contents to a location on your PC
  2. Open up 'autoload.php' and add a name for the DATABASE_NAME constant at the top.
  3. In the same file, add the credentials for your MySQL login. This user should have permissions to create tables and databases (so ideally use root)
  4. Save file, and upload all the files to a directory on your server.
  5. Go to the directory in your browser and load the setup.php script first.
  6. If you used proper MySQL credentials, it will successfully create both a database and two tables in said database.
  7. DELETE setup.php from your server
  8. To test, access auth.php with a GET request for key using your NGU Elite key (example: You must login or register to view this content.)
  9. If the setup worked properly, it should output "Some useful information" (hilarious, right?) and if you check your log and users table, you should see your Elite key there.


It's a basic system for getting your app up and running. However this does do automatic banning for users who share multiple keys under so many different IPs in a certain period of time (like 24 hrs I think). The ban check is done each time the auth script executes, so unless your app gets little to no traffic, it should do just fine. If you really want you can setup a cron job to run the unban/ban process every so often.

You must login or register to view this content.

Enjoy and let me know if you have any issues or just need help with it.


I can't believe you're actually suggesting people use the root MySQL credentials. It's a terrible idea, always create a unique user with the required permissions.

Otherwise, it's all good.
02-23-2016, 05:58 PM #7
will some help me install it please
02-23-2016, 06:02 PM #8
hey does any one know what lexicongta.com is using or You must login or register to view this content. is using for the key
02-23-2016, 06:04 PM #9
Tustin
Balls of Steel
Originally posted by JB View Post
I can't believe you're actually suggesting people use the root MySQL credentials. It's a terrible idea, always create a unique user with the required permissions.

Otherwise, it's all good.

I only suggested it because I wasn't sure if the people who would want to set something up like this would know how to do that. Considering the setup should be deleted afterwards, it really wouldn't matter. I completely forgot to mention to change the details to a user other than root after the setup. I'll change that right now. The whole purpose of me saying to use root was so it could create the tables and database without permission errors, not for root to be used for everything :p.
02-23-2016, 06:13 PM #10
JB
[i]Remember, no Russian.[/i]
Originally posted by Tustin View Post
I only suggested it because I wasn't sure if the people who would want to set something up like this would know how to do that. Considering the setup should be deleted afterwards, it really wouldn't matter. I completely forgot to mention to change the details to a user other than root after the setup. I'll change that right now. The whole purpose of me saying to use root was so it could create the tables and database without permission errors, not for root to be used for everything :p.


That's all good then. Leaked root MySQL credentials are ingredients for a nightmare!

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo