My Scans can't stop Stop launching

Hey there,

I have a python script that automates the launching of scans with the community container version. The script automates other tools like nmap and burp. With no problem, but when it launches the gvm, the scans dont stop launching.
What i am finding even more strange is, that i am launching tha same script in another machine (in azure) and it works fine, the gvm stop launching new scans when the old one ends.

the piece of code that launches the gvm scan is this one:

def execute_gvm_cmd(cmd):
response = subprocess.run(cmd, capture_output=True, shell=True, check=True)
filter_stderr(‘gvm’, response.stderr.decode(“utf-8”))
return etree.fromstring(response.stdout.decode(“utf-8”))
# response = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True, check=True).stdout
# return etree.fromstring(response)

def create_target_gvm(target, path):
check_target_cmd = f’{GVM_CLI_CMD} --xml '<get_targets filter=“name={target}”/>'’
root = execute_gvm_cmd(check_target_cmd)
target_id = None
for target_elem in root.iterfind(‘target’):
target_id = target_elem.get(‘id’)
if target_id is not None:
print(f’Target already exists with ID: {target_id}‘)
else:
create_target_cmd = f’{GVM_CLI_CMD} --xml “<create_target>{target}{target}<port_list id=\“33d0cd82-57c6-11e1-8ed1-406186ea4fc5\”/><alive_tests>Consider Alive</alive_tests></create_target>”’
root1 = execute_gvm_cmd(create_target_cmd)
target_id = root1.attrib[‘id’]
print(f"Target created with ID: {target_id}")
# print(‘Target can be created’)
create_task_gvm(target, target_id, path)

def create_task_gvm(targetname, targetid, path):
create_task_cmd = f’{GVM_CLI_CMD} --xml “<create_task>{targetname}<config id=\“daba56c8-73ec-11df-a475-002264764cea\”/><target id =\”{targetid}\“></create_task>”’
root1 = execute_gvm_cmd(create_task_cmd)
task_id = root1.attrib[‘id’]
print(f"Task created with ID: {task_id}")
start_task_gvm(task_id, path)

def start_task_gvm(task_id, path):
start_task_cmd = f’{GVM_CLI_CMD} --xml “<start_task task_id=\”{task_id}\“/>”’
root = execute_gvm_cmd(start_task_cmd)
report_id = root.find(‘.//report_id’).text
wait_task_gvm(task_id, report_id, path)

def wait_task_gvm(task_id, report_id, path):
wait_task_cmd = f’{GVM_CLI_CMD} --xml “<get_tasks task_id=\”{task_id}\" details=\“1\”/>“’
while True:
root = execute_gvm_cmd(wait_task_cmd)
task_status = root.find(‘.//status’).text
if task_status == ‘Done’:
print(f"Task finished! Report with ID: {report_id}”)
get_report_gvm(report_id, path)
break
else:
print(f"Task status: {task_status}")
time.sleep(60)

I can’t find any error in the logic, i am not a full time developer, nor it is my speciality, but i can’t find any problem in my logic. The fact that the same script works as intended in another machine puzzle me even more.

DO you guy’s have any ideia what can be causing this behavior?

Thanks in advance

Please take a look at Start Here for existing troubleshooting guidelines and how to post messages in this forum. We kindly request that you post the terminal output in the proper format using backticks {output} before and after the stdout or code content.