使用gvm_cli命令来实现
先创建一个空的配置
copy_id = '085569ce-73ed-11df-83c3-002264764cea'
new_config = '''
<create_config>
<copy>{}</copy>
<name>{}</name>
</create_config>
'''.format(copy_id,target_name)
gvm-cli socket --sockpath /var/run/gvmd.sock --gmp-username usr --gmp-password 'pass' -xml new_config
再往配置里面修改添加需要扫描的项的oid和所属的family
modify_config = <modify_config config_id="{}">
<nvt_selection>
<family>Web Servers</family>
<nvt oid="{}"/>
<family>Denial of Service</family>
<nvt oid="{}"/>
<family>General</family>
<nvt oid="{}"/>
</nvt_selection>
</modify_config>
gvm-cli socket --sockpath /var/run/gvmd.sock --gmp-username usr --gmp-password 'pass' -xml modify_config
最后添加两个必须得基础项 ping,nasl namp.nasl
oid1 = '1.3.6.1.4.1.25623.1.0.14259'
oid2 = '1.3.6.1.4.1.25623.1.0.100315'
modify_config = '''
<modify_config config_id="{}">
<nvt_selection>
<family>Port scanners</family>
<nvt oid="{}"/>
<nvt oid="{}"/>
</nvt_selection>
</modify_config>
'''.format(config_id, oid1, oid2)
gvm-cli socket --sockpath /var/run/gvmd.sock --gmp-username usr --gmp-password 'pass' -xml modify_config
官网链接 https://docs.greenbone.net/API/GMP/gmp-7.0.html#command_modify_config
还有两个博客也是这方面的知识
https://github.com/greenbone/gvm-tools/blob/master/scripts/start-nvt-scan.gmp.py