巡风探索

本文档详细介绍了巡风系统中pymongo的使用,从配置读取到数据库连接,再到信息扫描表和views模块的探索。通过NAScan.py主函数开始,解析配置文件,接着探讨了如何连接MongoDB数据库,查看不同聚集(表)的内容,包括配置表和Info扫描表,并对views模块进行了初步探索。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

模块内容包括:

├─nascan
│  │  NAScan.py # 网络资产信息抓取引擎
│  │
│  ├─lib
│  │      cidr.py 
│  │      common.py 其他方法
│  │      icmp.py  # ICMP发送类
│  │      log.py  # 日志输出
│  │      mongo.py  # 数据库连接
│  │      scan.py  # 扫描与识别
│  │      start.py  # 线程控制
│  │
│  └─plugin
│          masscan.py  # 调用Masscan脚本

从主函数NAScan.py开始,函数跑起来如下:

CONFIG_INI = get_config() # 读取配置

CONFIG_INI = get_config()  # 读取配置

结果如下(经过处理)

>>> CONFIG_INI
{u'Masscan':
 u'0|20000|/root/xunfeng/masscan/linux_64/masscan', 
 u'Discern_cms':
 [[u'phpmyadmin', u'file', u'index', u'pma_username'],
 [u'phpmyadmin', u'file', u'/phpmyadmin', u'pma_username'],
 [u'routeros', u'file', u'index', u'<title>RouterOS router configuration page<\\/title>'],
 [u'destoon', u'file', u'index', u'Powered by DESTOON'],
 [u'destoon', u'file', u'index', u'DESTOON B2B SYSTEM'],
 [u'u-mail', u'file', u'index', u'Power(ed)? by[^>]+U-Mail'],
 [u'winmail', u'file', u'index', u'Winmail Mail Server'],
 [u'coremail', u'file', u'index', u'Coremail[^>]+<\\/title>'],
 [u'winmail', u'header', u'Set-Cookie', u'magicwinmail'],
 [u'winmail', u'file', u'index', u'Powered by Winmail Server'],
 [u'turbomail', u'file', u'index', u'Powered by TurboMail'],
 [u'xmail', u'file', u'index', u'\\d{4}-\\d{4}\\s*webmail.idccenter.net'],
 [u'outlook', u'header', u'X-OWA-Version', u'.*?'],
 [u'outlook', u'file', u'index', u'Outlook Web (Access|App)\\s*(?=<\\/title>)'],
 [u'anymacro', u'header', u'Server', u'AnyWebApp'],
 [u'anymacro', u'file', u'index', u'sec.anymacro.com'],
 [u'extmail', u'file', u'index', u'powered by.*?Extmail'],
 [u'lotus', u'file',
u'index', u'IBM Lotus iNotes[^>]+(?=<\\/title>)'],
 [u'lotus', u'file', u'index', u'iwaredir.nsf'],
 [u'squirrelmail', u'file', u'index', u'SquirrelMail Project Team'],
 [u'squirrelmail', u'header', u'Set-Cookie', u'SQMSESSID'],
 [u'squirrelmail', u'file', u'index', u'SquirrelMail'],
 [u'eqmail', u'file', u'index', u'Powered by EQMail'],
 [u'tmailer', u'file', u'index', u'TMailer Collaboration Suite Web Client'],
 [u'zimbra', u'header', u'Set-Cookie', u'ZM_TEST'],
 [u'zimbra', u'file', u'index', u'zimbra[^>]+(?=<\\/title>)'],
 [u'zimbra', u'file', u'index', u'Zimbra,?\\s*Inc. All rights reserved.'],
 [u'bxemail', u'file', u'index', u'abc@bxemail.com'],
 [u'horde', u'file', u'index', u'<title>[^>]+?Horde'],
 [u'horde', u'file', u'index', u'\\/themes\\/graphics\\/horde-power1.png'],
 [u'atmail', u'file', u'index', u'powered by Atmail'],
 [u'ilohamail', u'header', u'Set-Cookie', u'IMAIL_TEST_COOKIE'],
 [u'ilohamail', u'header', u'SESS_KEY', u'.*?'],
 [u'ilohamail', u'file', u'index', u'powered by[^>]+IlohaMail'],
 [u'fangmail', u'file', u'index', u'fangmail'],
 [u'roundcube', u'file', u'index', u'Roundcube'],
 [u'mailbase', u'header', u'Set-Cookie', u'\\s*(mb_lang|mb_ui_type|mb_cus_type)'],
 [u'mailbase', u'file', u'index', u'MailBase[^<>]+(?=<\\/title>)'],
 [u'kxmail', u'file', u'index', u'Powered By\\s?<[^>]+>\\s?KXmail'],
 [u'tongda', u'file', u'index', u'href="/images/tongda\\.ico"'],
 [u'trs_wcm', u'file', u'index', u'<title[^>]+>TRS WCM[^<]+</title>'],
 [u'trs_wcm', u'file', u'index', u'href="/wcm/console/auth/reg_newuser.jsp"'],
 [u'mymps', u'file', u'index', u'powered by[^&]+Mymps.*?'],
 [u'mymps', u'file', u'index', u'wcontent="mymps'],
 [u'mailgard', u'file', u'index', u'mailgard\\swebmail'],
 [u'discuz', u'file', u'/robots.txt', u'discuz'],
 [u'discuz', u'file', u'/robots.txt', u'discuz'],
 [u'phpwind', u'file', u'/robots.txt', u'phpwind'],
 [u'phpcms', u'file', u'/robots.txt', u'phpcms'],
 [u'php168', u'file', u'/robots.txt', u'php168'],
 [u'qibosoft', u'file', u'/robots.txt', u'qibocms'],
 [u'emlog', u'file', u'/robots.txt', u'robots.txt for emlog'],
 [u'wecenter', u'file', u'/robots.txt', u'robots.txt for wecenter'],
 [u'bbsmax', u'file', u'/robots.txt', u'bbsmax'],
 [u'shopnc', u'file', u'/robots.txt', u'robots.txt for shopnc'],
 [u'hdwike', u'file', u'/robots.txt', u'robots.txt for hdwiki'],
 [u'phpdisk', u'file', u'/robots.txt', u'PHPDisk'],
 [u'dedecms', u'file', u'/data/admin/ver.txt', u'20110812'],
 [u'dedecms', u'file', u'/data/admin/ver.txt', u'20111111'],
 [u'dedecms', u'file', u'/data/admin/ver.txt', u'20120709'],
 [u'dedecms', u'file', u'/data/admin/ver.txt', u'20140814'],
 [u'dedecms', u'file', u'/data/admin/verifies.txt', u'20081204'],
 [u'dedecms', u'file', u'/data/admin/verifies.txt', u'20100324'],
 [u'dedecms', u'file', u'/data/admin/verifies.txt', u'20100514'],
 [u'dedecms', u'file', u'/data/admin/verifies.txt', u'20110216'],
 [u'wordpress', u'file', u'/robots.txt', u'wordpress'],
 [u'wordpress', u'file', u'/license.txt', u'wordpress'],
 [u'wordpress', u'file', u'/readme.txt', u'wordpress'],
 [u'wordpress', u'file', u'/help.txt', u'wordpress'],
 [u'wordpress', u'file', u'/readme.html', u'wordpress'],
 [u'wordpress', u'file', u'/wp-admin/css/colors-classic.css', u'wordpress'],
 [u'wordpress', u'file', u'/wp-admin/js/media-upload.dev.js', u'wordpress'],
 [u'wordpress', u'file', u'/wp-content/plugins/akismet/akismet.js', u'wordpress'],
 [u'wordpress', u'file', u'/wp-content/themes/classic/rtl.css', u'wordpress'],
 [u'wordpress', u'file', u'/wp-includes/css/buttons.css', u'wordpress'],
 [u'z-blog', u'file', u'/license.txt', u'z-bolg'],
 [u'z-blog', u'file', u'/SCRIPT/common.js', u'z-bolg'],
 [u'southidc', u'file', u'/Ads/left.js', u'southidc'],
 [u'southidc', u'file', u'/Css/Style.css', u'southidc'],
 [u'southidc', u'file', u'/Images/ad.js', u'southidc'],
 [u'southidc', u'file', u'/Script/Html.js', u'southidc'],
 [u'siteserver',u'file', u'/robots.txt', u'\\/SiteFiles\\/'],
 [u'siteserver', u'file', u'/SiteFiles/Inner/Register/script.js', u'stlUserRegister'],
 [u'enableq', u'file', u'/License/index.php', u'<td>EnableQ'],
 [u'enableq', u'file', u'/robots.txt', u'robots.txt for EnableQ'],
 [u'trs_wcm', u'file', u'/wcm/app/login.jsp', u'TRS WCM'],
 [u'trs_wcm', u'file', u'/wcm/app/login.jsp', u'href="/wcm/console/auth/reg_newuser.jsp"'],
 [u'mymps', u'file',u'/robots.txt', u'mymps'],
 [u'igenus', u'file', u'/help/', u'igenus'],
 [u'mailgard', u'file', u'/help/io_login.html', u'webmail']],
u'Thread':
u'200', 
u'Discern_lang':
 [[u'php', u'header', u'Server', u'php'],
 [u'php', u'header', u'X-Powered-By', u'php'],
 [u'php', u'header', u'Set-Cookie', u'PHPSSIONID'],
 [u'jsp', u'header', u'Set-Cookie', u'JSESSIONID'],
 [u'asp', u'header', u'Set-Cookie', u'ASPSESSION'],
 [u'aspx', u'header',u'Set-Cookie', u'ASP.NET_SessionId'],
 [u'aspx', u'header', u'X-AspNet-Version', u'version'],
 [u'aspx', u'file', u'index', u'<input[^>]+name=\\"__VIEWSTATE'],
 [u'aspx', u'file', u'index', u'<a[^>]*?href=(\'|")[^http].*?\\.aspx(\\?|\\1)'],
 [u'asp', u'file', u'index', u'<a[^>]*?href=(\'|")[^http].*?\\.asp(\\?|\\1)'],
 [u'php', u'file', u'index', u'<a[^>]*?href=(\'|")[^http].*?\\.php(\\?|\\1)'],
 [u'jsp', u'file', u'index', u'<a[^>]*?href=(\'|")[^http].*?\\.jsp(\\?|\\1)']],
u'Discern_con':
 [[u'jboss', u'header', u'X-Powered-By', u'jboss'],
 [u'jboss', u'file', u'jboss.css', u'youcandoit.jpg'],
 [u'jboss', u'file', u'is_test', u'JBossWeb'],
 [u'axis', u'file', u'axis2', u'axis2-web/images/axis_l.jpg'],
 [u'weblogic', u'file', u'is_test', u'Hypertext Transfer Protocol'],
 [u'weblogic', u'file', u'console/css/login.css', u'Login_GC_LoginPage_Bg.gif'],
 [u'glassfish', u'file', u'resource/js/cj.js', u'glassfish.dev.java.net'],
 [u'glassfish', u'header', u'server', u'GlassFish'],
 [u'jenkins', u'header', u'X-Jenkins', u'.*?'],
 [u'jenkins', u'file', u'index', u'\\[Jenkins\\]'],
 [u'resin', u'header', u'server', u'resin'],
 [u'tomcat', u'file', u'is_test', u'Apache Tomcat'],
 [u'apache', u'header', u'server', u'apache'],
 [u'iis', u'header', u'server', u'iis'],
 [u'jetty', u'header', u'server', u'jetty'],
 [u'nginx', u'header', u'server', u'nginx'],
 [u'cisco', u'header', u'server', u'cisco'],
 [u'couchdb', u'header', u'server', u'couchdb'],
 [u'tplink', u'header', u'WWW-Authenticate', u'TP-LINK'],
 [u'h3c', u'header', u'WWW-Authenticate', u'h3c'],
 [u'h3c', u'file', u'index', u'/web/device/login'],
 [u'huawei', u'header', u'WWW-Authenticate', u'huawei'],
 [u'netgear', u'header', u'WWW-Authenticate', u'netgear'],
 [u'hikvision', u'header', u'server', u'DNVRS-Webs'],
 [u'hikvision', u'header', u'server', u'App-webs'],
 [u'hikvision', u'header', u'server', u'DVRDVS-Webs'],
 [u'hikvision', u'header', u'server', u'Hikvision-Webs'],
 [u'tengine', u'header', u'server', u'Tengine']],
u'Scan_list':
 u'', 
u'Port_list':
u'1|21\n22\n23\n25\n53\n80\n110\n139\n143\n389\n443\n445\n465\n873\n993\n995\n1080\n1311\n1723\n1433\n1521\n3000\n3001\n3002\n3306\n3389\n3690\n4000\n5432\n5900\n6379\n7001\n8000\n8001\n8080\n8081\n8888\n9200\n9300\n9080\n9090\n9999\n11211\n27017', 
u'Timeout':
 u'8', 
u'Discern_server':
 [[u'ftp', u'21', u'banner', u'^220.*?ftp|^220-|^220 Service|^220 FileZilla'],
 [u'ssh', u'22', u'banner', u'^ssh-'],
 [u'telnet', u'23', u'banner', u'^\\xff[\\xfa-\\xfe]|^\\x54\\x65\\x6c|Telnet'],
 [u'smtp', u'25', u'banner', u'^220.*?smtp'],
 [u'dns', u'53', u'default', u''],
 [u'pop3', u'110', u'banner', u'\\+OK.*?pop3'],
 [u'netbios', u'139', u'default', u''],
 [u'imap', u'143', u'banner', u'^\\* OK.*?imap'],
 [u'ldap', u'389', u'default', u''],
 [u'smb', u'445', u'default', u''],
 [u'smtps', u'465', u'default', u''],
 [u'rsync', u'873', u'banner', u'^@RSYNCD|^@ERROR'],
 [u'imaps', u'993', u'default', u''],
 [u'pop3', u'995', u'banner', u'\\+OK'],
 [u'proxy', u'1080', u'\\x05\\x01\\x00\\x01', u'^\\x05\\x00'],
 [u'pptp', u'1723', u'default', u''],
 [u'mssql', u'1433', u'\\x12\\x01\\x00\\x34\\x00\\x00\\x00\\x00\\x00\\x00\\x15\\x00\\x06\\x01\\x00\\x1b\\x00\\x01\\x02\\x00\\x1c\\x00\\x0c\\x03\\x00\\x28\\x00\\x04\\xff\\x08\\x00\\x01\\x55\\x00\\x00\\x00\\x4d\\x53\\x53\\x51\\x4c\\x53\\x65\\x72\\x76\\x65\\x72\\x00\\x48\\x0f\\x00\\x00', u'^\\x04\\x01'],
 [u'oracle', u'1521', u'\\x00\\x3a\\x00\\x00\\x01\\x00\\x00\\x00\\x01\\x39\\x01\\x2c\\x00\\x00\\x08\\x00\\x7f\\xff\\xc6\\x0e\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x3a\\x00\\x00\\x08\\x00\\x41\\x41\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00', u'\\x00Y\\x00'],
 [u'mysql', u'3306', u'banner', u'^.\\0\\0\\0.*?mysql|^.\\0\\0\\0\\n|.*?MariaDB server'],
 [u'rdp', u'3389', u'\\x03\\x00\\x00\\x13\\x0E\\xE0\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x08\\x00\\x03\\x00\\x00\\x00', u'\\x03\\x00\\x00\\x13'],
 [u'svn', u'3690', u'default', u''],
 [u'postgresql', u'5432', u'\\x00\\x00\\x00\\x54\\x00\\x03\\x00\\x00\\x75\\x73\\x65\\x72\\x00\\x70\\x6f\\x73\\x74\\x67\\x72\\x65\\x73\\x00\\x64\\x61\\x74\\x61\\x62\\x61\\x73\\x65\\x00\\x70\\x6f\\x73\\x74\\x67\\x72\\x65\\x73\\x00\\x61\\x70\\x70\\x6c\\x69\\x63\\x61\\x74\\x69\\x6f\\x6e\\x5f\\x6e\\x61\\x6d\\x65\\x00\\x70\\x73\\x71\\x6c\\x00\\x63\\x6c\\x69\\x65\\x6e\\x74\\x5f\\x65\\x6e\\x63\\x6f\\x64\\x69\\x6e\\x67\\x00\\x55\\x54\\x46\\x38\\x00\\x00', u'^R\\x00\\x00\\x00'],
 [u'vnc', u'5900', u'banner', u'^RFB'],
 [u'redis', u'6379', u'info\\r\\n', u'redis'],
 [u'elasticsearch', u'9200', u'GET /_cat HTTP/1.1\\r\\n\\r\\n', u'/_cat/master'],
 [u'memcache', u'11211', u'\\x80\\x0b\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00', u'^\\x81\\x0b'],
 [u'mongodb', u'27017', u'\\x00\\x00\\x00\\xa7A\\x00\\x00\\x00\\x00\\x00\\x00\\xd4\\x07\\x00\\x00\\x00\\x00\\x00\\x00admin.$cmd\\x00\\x00\\x00\\x00\\x00\\xff\\xff\\xff\\xff\\x13\\x00\\x00\\x00\\x10ismaster\\x00\\x01\\x00\\x00\\x00\\x00', u'ismaster'],
 [u'zookeeper', u'2181', u'stat', u'Zookeeper version']],
u'White_list':
 u'', 
u'Cycle':
 u'1|9'}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值