-
Notifications
You must be signed in to change notification settings - Fork 5
/
genCGA.py
executable file
·84 lines (70 loc) · 2.88 KB
/
genCGA.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/env python
"""a small tool to generate configuration file for CGA addresses"""
import warnings
import sys
from optparse import OptionParser
with warnings.catch_warnings():
warnings.filterwarnings("ignore",category=DeprecationWarning)
from NDprotector.Address import Address
from scapy6send.scapy6 import SigTypeID
import NDprotector
NDprotector.assign_addresses = False
NDprotector.default_sec_value = 1
NDprotector.default_publickey = None
NDprotector.rsa_key_size = 1024
NDprotector.retrans_timer = 1
NDprotector.SignatureAlgorithms = SigTypeID.keys()
try:
from scapy6send.ecc import ECCkey
NDprotector.ECCsupport = True
except ImportError:
NDprotector.ECCsupport = False
if __name__ == "__main__":
parser = OptionParser()
parser.add_option("-i", "--interface",
dest="interface", default='eth0',
help="interface on which the address will be assigned (opt.)")
parser.add_option("-a", "--address",
dest="address", default=None,
help="set the address (when the address is set, you have to provide the Modifier")
parser.add_option("-p", "--prefix",
dest="prefix", action="store", type="string", default = None,
help="set the prefix")
parser.add_option("-k", "--key",
dest="key", metavar="FILE", default=None,
help="set the Public Key (in PEM format)")
parser.add_option("-m", "--modifier",
dest="modifier", action="store", type="long", default = None,
help="set the prefix")
parser.add_option("-s", "--sec",
dest="sec", action="store", type="int", default=None,
help="SEC value (opt.)")
parser.add_option("-c", "--collcount",
dest="collcount", action="store", type="int", default=0,
help="set the collcount value")
parser.add_option("-e", "--ext",
dest="extensions", action="store", type="string", default="[]",
help="set the CGA PDS extensions")
parser.add_option("-d", "--dad",
dest = "do_dad", action="store_true", default= False,
help="perform a Duplicate Address Detection on the newly build address")
opt, args = parser.parse_args(sys.argv[1:])
if len(args) != 0:
print "too much arguments given"
print parser.print_help()
sys.exit(-1)
# parse the extensions
exec ( "extensions =" + opt.extensions )
NDprotector.assign_addresses = opt.do_dad
addr = Address(prefix = opt.prefix,
address = opt.address,
modifier = opt.modifier,
sec = opt.sec,
collcount = opt.collcount,
key = opt.key,
ext = extensions,
dad = opt.do_dad,
interface = opt.interface)
print addr.config_dump()
if opt.do_dad:
addr.remove()