blob: 19bd91248348536cb3e11aea3706f89226fb957a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# 目标感知
import subprocess
from apiflask import APIBlueprint
from apiflask.fields import String
from flask import json
bp = APIBlueprint('target_gz', __name__, url_prefix='/target_gz')
@bp.get('/<IP>')
@bp.doc("对攻击目标进行目标感知")
def execute_command(IP):
output = None
while not output:
proc = subprocess.Popen(f"./apps/TargetGZ_Client_JSON --target {IP}",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
text=True,
encoding='utf-8')
output = proc.communicate()[0].strip()
try:
json.loads(output)
return output, 200
except:
return 500
|