Env files allow you to put your environment variables inside a file. You just create a new file called. env in your project and slap your variables in there on different lines. This env is used for storing your all id, password, keys all important credential so no on directly can get your data. Code Step 1: Create a virtual environment and make it active Step 2: pip install python-dotenv Step 3: Create a .env file Step 4: Create test.py in the same dir where you created .env file Now Check Code test.py from dotenv import load_dotenv load_dotenv() import os my_site = os.getenv("DOMAIN") print("Visit My website : {} ".format(my_site)) .env # a comment that will be ignored. DOMAIN= https://thepyuniverse.blogspot.com Now Run test.py Output: Visit My website : https://thepyuniverse.blogspot.com Screenshot : Quiz Level 1 Quiz Level 2 Request Me
Code Example To gain control over a compromised system, an attacker usually aims to gain interactive shell access for arbitrary command execution. With such access, they can try to elevate their privileges to obtain full control of the operating system. However, most systems are behind firewalls and direct remote shell connections are impossible. One of the methods used to circumvent this limitation is a reverse shell. # How its Work? In a typical remote system access scenario, the user is the client and the target machine is the server. The user initiates a remote shell connection and the target system listens for such connections. With a reverse shell, the roles are opposite. It is the target machine that initiates the connection to the user, and the user’s computer listens for incoming connections on a specified port. The primary reason why reverse shells are often used by attackers is the way that most firewalls are configured. Attacked servers usually allow connections only ...
Code Example SHA, ( Secure Hash Algorithms ) are set of cryptographic hash functions defined by the language to be used for various applications such as password security etc. Some variants of it are supported by Python in the “ hashlib ” library. These can be found using “algorithms_guaranteed” function of hashlib. # test.py import hashlib def Encode_SHA256(data='kuntal'): result = hashlib.sha256(data.encode()) return result.hexdigest() def Encode_SHA384(data='kuntal'): result = hashlib.sha384(data.encode()) return result.hexdigest() def Encode_SHA224(data='kuntal'): result = hashlib.sha224(data.encode()) return result.hexdigest() def Encode_SHA512(data='kuntal'): result = hashlib.sha512(data.encode()) return result.hexdigest() print("SHA256") print(Encode_SHA256(), "len is : ", len(Encode_SHA256())) print("\nSHA384") print(Encode_SHA384(), "len is : ", len(Encode_SHA...
Comments
Post a Comment