![]() |
|
Hi i would need some help with python - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Python (https://sinister.li/Forum-Python) +--- Thread: Hi i would need some help with python (/Thread-Hi-i-would-need-some-help-with-python) |
Hi i would need some help with python - lolrol - 12-12-2023 Hi, im trying to make a python script that would send a packet to a website with login information and preform an action. is this allowed? if yes how could i archive that? Thank you for any informative responses I receive.
RE: Hi i would need some help with python - iKmn0T - 12-15-2023 i widely depends what side, what information and what action lol. generally it is possible, sure. how's your coding level right now? for scripts like that you can also just ask chatgpt to write it for you, honestly. just be aware that they might log your request, so don't ask for anything you already know is illegal. RE: Hi i would need some help with python - lolrol - 12-16-2023 (12-15-2023, 10:49 AM)iKmn0T Wrote: i widely depends what side, what information and what action lol. my coding skill is low i started recently and the thing is i found a scam website but it really pays you as long as you dont put any money into it so i wanted to try to get that crypto every day with multiple accounts is it illegal? RE: Hi i would need some help with python - soul_hunter - 12-20-2023 (12-16-2023, 10:40 AM)lolrol Wrote:why do you care if its legal or not if its scam page? would need to see the site to tell exactly how to achieve it. but you could do it via requests or if it needs interactions you can do it with selenium(12-15-2023, 10:49 AM)iKmn0T Wrote: i widely depends what side, what information and what action lol. RE: Hi i would need some help with python - MilieWolf - 12-22-2023 Customization goes beyond just looks; it's about making sure your website functions seamlessly and offers an excellent user experience. With custom development, you're in control of choosing the features and design elements that match your needs perfectly. This approach ensures that your website not only exists but thrives. It's fast, responsive, and engages users effectively. Navigation becomes a breeze, content resonates with your audience, and interactions are smooth. If you're still hunting for more insights or considering custom website development, you might want to hire dedicated developers. They can provide personalized advice and help you create a digital masterpiece that truly stands out. RE: Hi i would need some help with python - MaxMart - 12-22-2023 If the website offers APIs for such actions, it's the safest and most proper way to interact with it programmatically. Look for API documentation and use libraries like requests in Python to send other requests. RE: Hi i would need some help with python - asdkrew - 01-16-2024 probably you should learn about web forms and how the encoded in http req RE: Hi i would need some help with python - rickmother - 04-06-2024 well just use requests library and check if the method is get or post or you can use chat gpt if you are reaaaaaalyy super duper noob you can use it then try write an good prompt and dont forget to write the full form of html and if the login process is not with html you can check network on the developer option on the browser to see what the browser sent to the server if not you can use burpsuite t attack RE: Hi i would need some help with python - Catw3lk - 09-23-2024 Look for API documentation and use libraries like requests in Python to send other requests. RE: Hi i would need some help with python - ElysianSignals - 09-26-2024 Here's an example of sending a package to your website for login purposes. Depending on what you want to do on the website, you may want to extend the code. Feel free to ask if you need help understanding the program. Code: import os
import requests
from requests.exceptions import RequestException
# Function to handle login logic
def login(username, password, login_url):
try:
payload = {"username": username, "password": password}
session = requests.Session()
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
}
# POST request to login URL
response = session.post(login_url, data=payload, headers=headers)
# Check if the login was successful
response.raise_for_status()
if "login failed" in response.text.lower():
print("Login failed. Please check your credentials.")
return None
else:
print("Login successful!")
return session # Return session object for further requests
except RequestException as e:
print(f"An error occurred during login: {e}")
return None
# Function to perform post-login actions
def perform_action(session, action_url, action_payload):
try:
headers = {"Content-Type": "application/json"}
response = session.post(action_url, json=action_payload, headers=headers)
response.raise_for_status() # Raise exception for any 4xx/5xx errors
print("Action performed successfully!")
return response.json() # Return the server's response (optional)
except RequestException as e:
print(f"An error occurred while performing the action: {e}")
return None
# Example usage
login_url = "https://example.com/login"
action_url = "https://example.com/action"
# Load credentials from environment variables
username = os.getenv("USERNAME", "default_username") # Default for testing
password = os.getenv("PASSWORD", "default_password")
# Ensure environment variables are not empty
if not username or not password:
raise ValueError("Username and password must be set in environment variables.")
# Log in and maintain the session
session = login(username, password, login_url)
if session is not None:
# Define the payload for the action after logging in
action_payload = {"key": "value"}
# Perform the desired action
perform_action(session, action_url, action_payload)
# Important security note:
# Never hardcode sensitive information such as passwords.
# Use environment variables or secure credential storage mechanisms instead. |