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

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

内容简介:参考文章:这篇文章提供一个方法可以快速爆破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爆破插件与备份扫描


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

查看所有标签

猜你喜欢:

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

Web API的设计与开发

Web API的设计与开发

[日] 水野贵明 / 盛荣 / 人民邮电出版社 / 2017-6 / 52.00元

本书结合丰富的实例,详细讲解了Web API的设计、开发与运维相关的知识。第1章介绍Web API的概要;第2章详述端点的设计与请求的形式;第3章介绍响应数据的设计;第4章介绍如何充分利用HTTP协议规范;第5章介绍如何开发方便更改设计的Web API;第6章介绍如何开发牢固的Web API。 本书不仅适合在工作中需要设计、开发或修改Web API的技术人员阅读,对想了解技术细节的产品经理、运维人......一起来看看 《Web API的设计与开发》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具