forked from smythtech/sdnpwn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsdnpwn.py
45 lines (41 loc) · 1.14 KB
/
sdnpwn.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
#!/usr/bin/python3
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
import sys
import netifaces
import errno
import modules.sdnpwn_common as com
import imp
conf.verb = 0
def main():
if(len(sys.argv) == 1):
try:
mod = imp.load_source("help", "modules/help.py")
params = sys.argv.pop(0)
filter(None, params)
mod.run(params)
del mod
except IOError:
com.message("Error importing " + modName + " as a module.", com.ERROR)
elif(len(sys.argv) > 1):
modName = sys.argv[1]
modName = modName.replace("-", "_")
params = sys.argv
filter(None, params)
params.pop(0)
try:
mod = imp.load_source(modName, "modules/" + modName + ".py")
mod.run(params)
del sys.modules[modName]
except IOError as e:
if(e == errno.EPERM):
com.message("Run as root!", com.ERROR)
except ImportError as e:
com.message("Error importing " + modName + " as a module.", com.ERROR)
print(e)
#except Exception as e:
#com.message("Something went wrong!", com.ERROR)
#print(e)
if __name__=='__main__':
main()