Esempio n. 1
0
	def __init__(self,dbfile=BASEDIR+'/cache/hammer.sql',conffile=BASEDIR+'/conf/hammer.yaml'):
		super(Cache, self).__init__()
		self.db   = dbfile
		self.conffile = conffile
		self.user = WebUser()
		if self.user.name:
			self.username = self.user.name + '@' + self.user.server
		else:
			self.errmsg('has not logged in, please log in first!')
			self.username = '******'

		self.initGlobal()
Esempio n. 2
0
	def __init__(self,dbfile=BASEDIR+'/cache/hammer.sql',conffile=BASEDIR+'/cache/hammer.yaml'):
		super(Cache, self).__init__()
		self.db   = dbfile
		self.conffile = conffile
		self.user = WebUser()
		if self.user.name:
			self.username = self.user.name + '@' + self.user.server
		else:
			self.errmsg('has not logged in, please log in first!')
			self.username = '******'

		self.initGlobal()
Esempio n. 3
0
        elif opt in ('--threads'):
            _threads = int(arg)
        elif opt in ('-p', '--plugin'):
            _plugin = arg
        elif opt in ('--plugin-arg'):
            _plugin_arg = arg
        elif opt in ('-T', '--target'):
            _target = arg
        elif opt in ('-l', '--listen'):
            _listen = True
        elif opt in ('-c', '--console'):
            _console = True
        else:
            pass

    user = WebUser()
    if user.server and user.token:
        _server = user.server
        _token = user.token

    if _console:
        cn = Consoler()
        cn.run()

    elif _server and _token:
        show()
        if '_pluginpath' in dir():
            # print '_pluginpath=',_pluginpath
            # print '_server=',_server
            # print '_token=',_token
            loadPlugins(_pluginpath, _server, _token)
Esempio n. 4
0
class Cache(object):
	'''consoleCache=>Class::Cache'''
	def __init__(self,dbfile=BASEDIR+'/cache/hammer.sql',conffile=BASEDIR+'/cache/hammer.yaml'):
		super(Cache, self).__init__()
		self.db   = dbfile
		self.conffile = conffile
		self.user = WebUser()
		if self.user.name:
			self.username = self.user.name + '@' + self.user.server
		else:
			self.errmsg('has not logged in, please log in first!')
			self.username = '******'

		self.initGlobal()

	def initGlobal(self):
		'''init global variables'''
		if self.user.taskid:
			pass
		else:
			self.user.refreshTaskID()
		globalVar.scan_task_dict['scanID'] = self.user.taskid
		globalVar.scan_task_dict['server'] = self.user.server
		globalVar.scan_task_dict['token'] = self.user.token

	def initTask(self):
		''' '''
		self.user.refreshTaskID()


	def start(self):
		'''start Cache'''
		color.cprint("[*] Start hammer console ..",GREEN)
		self.runsql("create table if not exists plugin(id integer primary key,type text,path text)")
		self.runsql("delete from plugin")
		self.inscache(self.getplus(p_InfoCollect),p_InfoCollect)
		self.inscache(self.getplus(p_Common),p_Common)
		self.inscache(self.getplus(p_SensitiveInfo),p_SensitiveInfo)
		self.inscache(self.getplus(p_System),p_System)
		self.inscache(self.getplus(p_WeakPassword),p_WeakPassword)
		self.inscache(self.getplus(p_WebApplications),p_WebApplications)
		self.banner()

	def getplus(self,path):
		'''get plugins list'''
		ret = []
		for plugin in listdir(BASEDIR+'/plugins/'+path):
			if plugin[-3:] == '.py' and plugin != 'dummy.py' and plugin !='__init__.py':
				ret.append(plugin)
		return ret

	def inscache(self,c,p):
		'''insert data to cache'''
		for tmp in c:
			tmp=tmp[:-3]
			self.runsql('insert into plugin(type,path) values("%s","%s/%s")'%(p,p,tmp))
					
	def runsql(self,sql):
		'''execute a sql'''
		conn=connect(self.db)
		conn.execute(sql)
		conn.commit()
		conn.close()

	def setconf(self,name,value):
		'''set config'''
		try:
			if name == 'server':
				self.user.setUserInfo(server=value)
			elif name == 'token':
				self.user.setUserInfo(token=value)
			else:
				self.usage('set')
		except Exception,e:
			color.cprint("[!] Err:%s"%e,RED)
Esempio n. 5
0
class Cache(object):
	'''consoleCache=>Class::Cache'''
	def __init__(self,dbfile=BASEDIR+'/cache/hammer.sql',conffile=BASEDIR+'/conf/hammer.yaml'):
		super(Cache, self).__init__()
		self.db   = dbfile
		self.conffile = conffile
		self.user = WebUser()
		if self.user.name:
			self.username = self.user.name + '@' + self.user.server
		else:
			self.errmsg('has not logged in, please log in first!')
			self.username = '******'

		self.initGlobal()

	def initGlobal(self):
		'''init global variables'''
		if self.user.taskid:
			pass
		else:
			self.user.refreshTaskID()
		globalVar.scan_task_dict['scanID'] = self.user.taskid
		globalVar.scan_task_dict['server'] = self.user.server
		globalVar.scan_task_dict['token'] = self.user.token

	def initTask(self):
		''' '''
		self.user.refreshTaskID()


	def start(self):
		'''start Cache'''
		color.cprint("[*] Start hammer console ..",GREEN)
		self.runsql("create table if not exists plugin(id integer primary key,type text,path text)")
		self.runsql("delete from plugin")
		self.inscache(self.getplus(p_InfoCollect),p_InfoCollect)
		self.inscache(self.getplus(p_Common),p_Common)
		self.inscache(self.getplus(p_SensitiveInfo),p_SensitiveInfo)
		self.inscache(self.getplus(p_System),p_System)
		self.inscache(self.getplus(p_WeakPassword),p_WeakPassword)
		self.inscache(self.getplus(p_WebApplications),p_WebApplications)
		self.banner()

	def getplus(self,path):
		'''get plugins list'''
		ret = []
		for plugin in listdir(BASEDIR+'/plugins/'+path):
			if plugin[-3:] == '.py' and plugin != 'dummy.py' and plugin !='__init__.py':
				ret.append(plugin)
		return ret

	def inscache(self,c,p):
		'''insert data to cache'''
		for tmp in c:
			tmp=tmp[:-3]
			self.runsql('insert into plugin(type,path) values("%s","%s/%s")'%(p,p,tmp))
					
	def runsql(self,sql):
		'''execute a sql'''
		conn=connect(self.db)
		conn.execute(sql)
		conn.commit()
		conn.close()

	def setconf(self,name,value):
		'''set config'''
		try:
			if name == 'server':
				self.user.setUserInfo(server=value)
			elif name == 'token':
				self.user.setUserInfo(token=value)
			else:
				self.usage('set')
		except Exception,e:
			color.cprint("[!] Err:%s"%e,RED)