TicTacTech.net Forums
how to create a whitelist in python - Printable Version

+- TicTacTech.net Forums (https://tictactech.net/forum)
+-- Forum: Technology (https://tictactech.net/forum/forumdisplay.php?fid=4)
+--- Forum: Coding and Webmastering (https://tictactech.net/forum/forumdisplay.php?fid=6)
+--- Thread: how to create a whitelist in python (/showthread.php?tid=255)



how to create a whitelist in python - vac - 07-26-2024

Setup
The first step to creating a whitelist in python is to create a "database". Although this is not going to be a real database, it will act as one.

So first you need to make a account on pastebin and create a new paste.
inside of your paste it will be a table with the whitelisted ip addresses, the table should be formatted like this ["IP1", "IP2"]. Then get the raw link of your paste by pressing this button

[Image: image.png?ex=66a4ed8d&is=66a39c0d&hm=521...6f9ff9443&]

After doing this its time for the actual coding part.

Coding
First off you need to import requests, time, and os, we will be using this later in the tutorial.
After doing this you need to create a variable with a request to get the table inside of your "database"
the code to this is ,
Code:
ipdb = requests.get("link").text

Next you need to get the ip address of the person using your whitelist
to do this you type:
Code:
ip = requests.get("https://api.ipify.org").text

Create a Placeholder with the following...
Code:
i = 1

Then create a while loop
Code:
(while i < 10:)

Next you need to check if the ip is in your database...
Code:
(if ip in ipdb:)

then deactivate the loop...
Code:
i=11

then make a else for the if statement you made earlier
Code:
(else: exit())

and this should work, enjoy

Full code below...

Code:
ipdb = requests.get("link").text

ip = requests.get("https://api.ipify.org").text
i = 1
(while i < 10:)
(if ip in ipdb:)
i=11
(else: exit())



RE: how to create a whitelist in python - andrew - 07-26-2024

Excellent guide!!


RE: how to create a whitelist in python - andrew - 08-03-2024

post this to the main site at https://tictactech.net/administrator ya fool!