-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

Ritik Mishra
  • 658
  • 4
  • 15
Kuro
  • 11
  • 4
  • 2
    Does this answer your question? [Store output of subprocess.Popen call in a string](https://stackoverflow.com/questions/2502833/store-output-of-subprocess-popen-call-in-a-string) – Ritik Mishra Aug 24 '21 at 02:20

2 Answers2

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.

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

Ritik Mishra
  • 658
  • 4
  • 15
  • 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)' – Kuro Aug 24 '21 at 12:12