-1

So recently I've been working on automating my code for bug bountys but i want to have a overall out put so it shows what it got neatly

(xssstrike is for example here)

website = (input(Fore.GREEN + "enter url/website for this scan: "))
ops = (input(Fore.GREEN + "enter other operators for xxstrike here (with spaces): "))

def xssstrike():
    try:
        os.chdir("/mnt/usb/xss-strike")
        os.system(f"python3 xsstrike.py {ops}  -u {website}")
    except ValueError:
           raise print("oops! there was an error with xss strike!")

i want to put the output from os.system(f"python3 xsstrike.py {ops} -u {website}") into a variable so i can print it later at the end of the code such as

print("<><><> xss strike output results <><><>")
print(xssstrikeoutput)

forgive me if this is simple im fairly new to coding but overall but ive checked everywhere and cant seem to find a answer

1

2 Answers 2

0
variable_name = os.system(f"python3 xsstrike.py {ops}  -u {website}")

This will put the required data in variable. You will be able to print it inside this function only. If you want it to print outside the function either return it or declare it as a global function.

Sign up to request clarification or add additional context in comments.

2 Comments

I doubt this is what the OP means, this simply puts the return code
i tried this though it was not counting variable_name as a variable and when called on by print(variable_name) it did not give a output
0

You can do this with subprocess.check_output from the the built-in subprocess module

import subprocess


# instead of os.system
xssstrikeoutput_bytes: bytes = subprocess.check_output(f"python3 xsstrike.py {ops}  -u {website}", shell=True)
xssstrikeoutput = xssstrikeoutput_bytes.decode("utf-8")

This way, you will be able to see anything that your xssstrike.py prints.

subprocess.check_output documentation

1 Comment

i was hoping this would work though i got a error saying xssstrike output was not a variable 'import subprocess import os website = (input("enter url/website for this scan: ")) ops = (input("enter other operators for xxstrike here (with spaces): ")) def xssstriketool(): os.chdir("/mnt/usb/xss-strike") xssstrikeoutput_bytes: bytes = subprocess.check_output(f"python3 xsstrike.py {ops} -u {website}", shell=True) xssstrikeoutput = xssstrikeoutput_bytes.decode("utf-8") print(xssstrikeoutput)'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.