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 # Create a Large file for Test Data Processing This below code will create 1.1GB .txt file import string from random import choice with open("large_data.txt", "w") as fp: i = 1 while i <= 1000000: word = (''.join( choice(string.ascii_uppercase + string.digits) for _ in range(10)) + "|" ) * 100 fp.write(word[:] + "\n") i += 1
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 ...
Comments
Post a Comment