def _get_device_from_model(self, model, dev_info): plugin = PluginManager.get_plugin_by_remote_name(model) if plugin: device = dev_info['callout'].split('/')[-1] set_property = partial(plugin.set_property, emit=True) set_property(MDM_INTFACE, 'Device', device) # XXX: Fix MasterDevice set_property(MDM_INTFACE, 'MasterDevice', 'iokit:com.vodafone.BMC.NotImplemented') # XXX: Fix CDMA set_property(MDM_INTFACE, 'Type', MM_MODEM_TYPE_REV['GSM']) set_property(MDM_INTFACE, 'Driver', 'notimplemented') set_property(MDM_INTFACE, 'IpMethod', MM_IP_METHOD_PPP) set_property(MDM_INTFACE, 'UnlockRequired', "") # import here else we start the dbus too early in startup from dbus import Boolean set_property(MDM_INTFACE, 'Enabled', Boolean(False)) # set to unknown set_property(NET_INTFACE, 'AccessTechnology', 0) # set to -1 so any comparison will fail and will update it set_property(NET_INTFACE, 'AllowedMode', -1) plugin.opath = self._generate_opath() plugin.ports = Ports(dev_info['callout'], dev_info['dialin']) return plugin
def identify_device_cb(model): # plugin to return ret = None if model in plugin.mapping: ret = plugin.mapping[model]() elif plugin.__remote_name__ != model: # so we basically have a device identified by vendor & product id # but we know nothing of this model try: ret = PluginManager.get_plugin_by_remote_name(model) except ex.UnknownPluginNameError: plugin.name = model if ret is not None: # we found another plugin during the process ret.patch(plugin) return check_auth_state(ret) # return the original plugin, most of the time this should work return check_auth_state(plugin)
def _get_device_from_info(self, sysfs_path, info): """Returns a `DevicePlugin` out of ``info``""" # order the ports before probing ports = info['DEVICES'] natsort(ports) query = [info.get(key) for key in [VENDOR, MODEL]] plugin = PluginManager.get_plugin_by_vendor_product_id(*query) if plugin: dport = cport = None plugin.sysfs_path = sysfs_path plugin.opath = self._generate_opath() set_property = partial(plugin.set_property, emit=False) # set DBus properties (Modem interface) set_property(consts.MDM_INTFACE, 'IpMethod', consts.MM_IP_METHOD_PPP) set_property(consts.MDM_INTFACE, 'MasterDevice', 'udev:%s' % sysfs_path) # XXX: Fix CDMA set_property(consts.MDM_INTFACE, 'Type', consts.MM_MODEM_TYPE_REV['GSM']) set_property(consts.MDM_INTFACE, 'Driver', info[DRIVER]) set_property(consts.MDM_INTFACE, 'Enabled', dbus.Boolean(False)) # set to unknown set_property(consts.NET_INTFACE, 'AccessTechnology', dbus.UInt32(0)) # set to preposterous initial number so any comparison will fail set_property(consts.NET_INTFACE, 'AllowedMode', dbus.UInt32(0xffff)) set_property(consts.NET_INTFACE, 'LastApn', '') # preprobe stuff if hasattr(plugin, 'preprobe_init'): # this plugin requires special initialisation before probing plugin.preprobe_init(ports, info) # now get the ports ports_need_probe = True if info[DRIVER] == 'hso': dport, cport = self._get_hso_ports(ports) ports_need_probe = False # if these two properties are present, use them right away and # do not probe if ('ID_MM_PORT_TYPE_MODEM' in info or 'ID_MM_PORT_TYPE_AUX' in info): try: dport = info['ID_MM_PORT_TYPE_MODEM'] log.msg("%s: ID_MM_PORT_TYPE_MODEM" % dport) except KeyError: pass try: cport = info['ID_MM_PORT_TYPE_AUX'] log.msg("%s: ID_MM_PORT_TYPE_AUX" % cport) except KeyError: pass ports_need_probe = False if ports_need_probe: # the ports were not hardcoded nor was an HSO device dport, cport = probe_ports(ports) if not dport and not cport: # this shouldn't happen msg = 'No data port and no control port with ports: %s' raise RuntimeError(msg % ports) if dport is not None: set_property(consts.MDM_INTFACE, 'Device', dport.split('/')[-1]) if info[DRIVER] == 'cdc_acm': # MBM device # XXX: Not all CDC devices support DHCP, to override see # plugin attribute 'ipmethod' # XXX: Also need to support Ericsson devices via 'hso' dialer # so that we can use the plain backend. At least F3607GW # supports a get_ip4_config() style AT command to get # network info, else we need to implement a DHCP client # set DBus properties (Modem.Gsm.Hso interface) hso_device = self._get_hso_device(sysfs_path) set_property(consts.MDM_INTFACE, 'Device', hso_device) set_property(consts.MDM_INTFACE, 'IpMethod', consts.MM_IP_METHOD_DHCP) if plugin.dialer in 'hso': # set DBus properties (Modem.Gsm.Hso interface) hso_device = self._get_hso_device(sysfs_path) set_property(consts.MDM_INTFACE, 'Device', hso_device) if hasattr(plugin, 'ipmethod'): # allows us to specify a method in a driver independent way set_property(consts.MDM_INTFACE, 'IpMethod', plugin.ipmethod) if hasattr(plugin, 'conntype') and plugin.conntype: set_property(consts.MDM_INTFACE, 'ConnType', dbus.UInt32(plugin.conntype)) else: set_property(consts.MDM_INTFACE, 'ConnType', dbus.UInt32(consts.WADER_CONNTYPE_UNKNOWN)) plugin.ports = Ports(dport, cport) return plugin log.msg("Could not find a plugin with info %s" % info) return None
class Sirai(object): """docstring for Sirai""" def __init__(self, load=False): # load if load: settings = load_settings() print( f'{date()} {name} {Fore.YELLOW}connecting to VK LongPoll...{Fore.RESET}' ) self.vk = vk_api.VkApi(token=settings['token']) self.longpoll = VkBotLongPoll(self.vk, settings['group_id']) else: print( f'{date()} {name} {Fore.RED}the connection is canceled, press "load" set to "True"{Fore.RESET}' ) # check settings settings = load_settings() pluginsys = PluginManager() # print settings def banner(self): print( f' _______ _________ _______ _______ _________ ______ _______ _________' ) print( f'( ____ \\__ __/( ____ )( ___ )\\__ __/ ( ___ \\ ( ___ )\\__ __/' ) print( f'{Fore.MAGENTA}| ( \\/ ) ( | ( )|| ( ) | ) ( | ( ) )| ( ) | ) ( {Fore.RESET}' ) print( f'{Fore.BLUE}| (_____ | | | (____)|| (___) | | | | (__/ / | | | | | | {Fore.RESET}' ) print( f'{Fore.CYAN}(_____ ) | | | __)| ___ | | | | __ ( | | | | | | {Fore.RESET}' ) print( f'{Fore.GREEN} ) | | | | (\\ ( | ( ) | | | | ( \\ \\ | | | | | | {Fore.RESET}' ) print( f'{Fore.YELLOW}/\\____) |___) (___| ) \\ \\__| ) ( |___) (___ | )___) )| (___) | | | {Fore.RESET}' ) print( f'{Fore.RED}\\_______)\\_______/|/ \\__/|/ \\|\\_______/ |/ \\___/ (_______) )_( {Fore.RESET}' ) print( '===========================================================================' ) print( f'by: {Fore.MAGENTA}salormoon_project{Fore.RESET}, {Fore.GREEN}simple bot for VK with automatic plug-ins{Fore.RESET}' ) print( '===========================================================================' ) def print_settings(self): settings = load_settings() print(f'----- < {Fore.CYAN}settings{Fore.RESET} > -----') for x in settings: arg = settings[x] print(f'{x}: {Fore.GREEN}{arg}{Fore.RESET}') print( f'{Fore.GREEN}----- {Fore.RESET}< {Fore.CYAN}settings{Fore.RESET} > {Fore.GREEN}-----{Fore.RESET}' ) # load plugins def load(self, plugin_dir): print(f'{date()} {name} {Fore.YELLOW}load plugins...{Fore.RESET}') check('folder', plugin_dir) settings = load_settings() self.pluginsys.Load(plugin_dir, settings) print(f'{date()} {name} {Fore.GREEN}load complete!{Fore.RESET}') # ----- long polling ----- def run(self, admins=False): settings = load_settings() print(f'{Fore.MAGENTA}start longpooling...{Fore.RESET}') for event in self.longpoll.listen(): if event.type == VkBotEventType.MESSAGE_NEW: data = event.object.message peer_id = data['peer_id'] from_id = data['from_id'] try: text = data['text'] except Exception as e: text = None try: reply = data['reply_message'] reply_id = reply['from_id'] except Exception as e: pass text = text.split(' ', 1) cmd = text[0] try: args = text[1] except Exception as e: args = None print( f'{date()} <{Fore.MAGENTA}{from_id}{Fore.RESET}> event text: {Fore.YELLOW}{cmd} {Fore.MAGENTA}{args}{Fore.RESET}', end=' |') # ----- обработчик комманд ----- self.pluginsys.answer(data, cmd, args, admins) if from_id == settings['main_admin'] and cmd == '/off': write_msg(data, 'выключаюсь, мой господин') print(f'{Fore.RED}[admin] bot off...{Fore.RESET}') sys.exit()
parser.add_option( "-u", "--url", action="store", dest="url", default=None, help="Url to test, mandatory." ) parser.add_option( "-O", "--output", action="store", dest="OutFile", default=None, help="Output status and result to file." ) parser.add_option( "", "--import-files", action="store", dest="ImportFiles", default=None, help="Import sensitive files list from this file." ) parser.add_option( "", "--import-dirs", action="store", dest="ImportDirs", default=None, help="Import sensitive directories list from this file." ) parser.add_option( "", "--single-mode", action="store_true", dest="SingleMode", default=False, help="Single url mode, scan only this url for vulnerabilities (the URL has to have at least one parameter)." ) (o,args) = parser.parse_args() if o.IdList == True: kb = KnowledgeBase( o.KbFile, ['*'] ) for item in kb.items: if item.id != '*': print "[%s] %s :\n%s\n" % (item.id, item.name, item.description) quit() elif o.ModList == True: pm = PluginManager( "%s/core/modules" % path, None ) pm.loadPlugins() for plugin in pm.plugins: print "[+] '%s' by %s : %s" % (plugin.name, plugin.author, plugin.description) quit() if o.url == None: parser.error( "No url specified!" ) elif not re.match( '^[^\:]+\:\/\/.+$', o.url ): o.url = "http://" + o.url o.Threads = int(o.Threads) o.CrawlDelay = int(o.CrawlDelay) o.MaxDirectoryDepth = int(o.MaxDirectoryDepth) o.ProxyPort = int(o.ProxyPort) o.KbFilter = csv2array(o.KbFilter)