基于爬虫开发WebShell爆破插件与备份扫描

栏目: 服务器 · 发布时间: 5年前

内容简介:参考文章:这篇文章提供一个方法可以快速爆破WebShell的1000个密码,利用这个思路,我们的WebShell爆破插件将可以很快检测,不需要多少时间上面的文章需要反复看,看懂了再看下面的代码。在

参考文章: 秒爆十万字典:奇葩技巧快速枚举“一句话后门”密码

这篇文章提供一个方法可以快速爆破WebShell的1000个密码,利用这个思路,我们的WebShell爆破插件将可以很快检测,不需要多少时间

代码编写

上面的文章需要反复看,看懂了再看下面的代码。在 script 目录中新建 webshell_check.py 文件

# __author__ = 'mathor'

# Blast the end of every.php file with one sentence
import sys, os
from lib.core.Download import Downloader

filename = os.path.join(sys.path[0], 'data', 'web_shell.dic')
payload = []
f = open(filename)
a = 0
for i in f:
    payload.append(i.strip())
    a += 1
    if (a == 999):
        break

class spider:
    def run(self, url, html):
        if (not url.endswith('.php')):
            return False
        print("[WebShell check:]", url)
        post_data = {}
        for _payload in payload:
            post_data[_payload] = 'echo "password is %s";' % _payload
            r = Downloader.post(url, post_data)
            if r:
                print("webshell:%s" % r)
                return True
        return False

字典文件随意找个top1000弱密码放到data目录中,命名为web_shell.dic

1
2
3
4
5
6
7
8
9
10
404
data
tools
index0
sh3ll
shell
shel
she
shell1
shell99
root
rootshell
bypass
anonym0us
anonymous
shellnymous
fuck
system
a
b
c
abc
d
e
f
g
h
i
j
k
l
m
n
o
p
y
z
webshell
hack
h4ck

基于爬虫的备份扫描器

已经有前辈为我们造好了轮子: https://github.com/secfree/bcrpscan

我们只需要修改其中生成路径的部分,使输入一个网站路径就可以得出备份文件地址。在 script 目录下新建 bak_check.py

# __author__ = 'mathor'

import sys, os
from lib.core.Download import Downloader
from urllib.parse import urlparse

DIR_PROBE_EXTS = ['.tar.gz', '.zip', '.rar', '.tar.gz2']
FILE_PROBE_EXTS = ['.bak', '.swp', '.1']
download = Downloader()

def get_parent_paths(path):
    paths = []
    if not path or path[0] != '/':
        return paths
    paths.append(path)
    tph = path
    if path[-1] == '/':
        tph = path[:-1]
    while tph:
        tph = tph[:tph.rfind('/') + 1]
        paths.append(tph)
        tph = tph[:-1]
    return paths

class spider:
    def run(self, url, html):
        pr = urlparse(url)
        paths = get_parent_paths(pr.path)
        web_paths = []
        for p in paths:
            if p == '/':
                for ext in DIR_PROBE_EXTS:
                    u = '%s://%s%s%s' % (pr.scheme, pr.netloc, p, pr.netloc + ext)
            else:
                if p[-1] == '/':
                    for ext in DIR_PROBE_EXTS:
                        u = '%s://%s%s%s' % (pr.scheme, pr.netloc, p[:-1], ext)
                else:
                    for ext in FILE_PROBE_EXTS:
                        u = '%s://%s%s%s' % (pr.scheme, pr.netloc, p, ext)
            web_paths.append(u)
        for path in web_paths:
            print("[web path]:%s" % path)
            if (download.get(path) is not None):
                print("[+] bak file has found: %s" % path)
        return False

基于爬虫开发WebShell爆破插件与备份扫描


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

解密搜索引擎技术实战

解密搜索引擎技术实战

罗刚 / 2011-6 / 69.80元

《解密搜索引擎技术实战-Lucene&Java精华版(附盘)》,本书主要包括总体介绍部分、爬虫部分、自然语言处理部分、全文检索部分以及相关案例分析。爬虫部分介绍了网页遍历方法和如何实现增量抓取,并介绍了从网页等各种格式的文档中提取主要内容的方法。自然语言处理部分从统计机器学习的原理出发,包括了中文分词与词性标注的理论与实现以及在搜索引擎中的实用等细节,同时对文档排重、文本分类、自动聚类、句法分析树......一起来看看 《解密搜索引擎技术实战》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具