1. 程式人生 > >bugku---welcome to bugkuctf

bugku---welcome to bugkuctf

題目
http://123.206.87.240:8006/test1/
在這裡插入圖片描述
檢視原始碼
在這裡插入圖片描述程式碼大概講的是
需要get傳遞三個值:txt,file,password
並且
$user的檔案內容為welcome to the bugkuctf
$file為hint.php
password暫時還沒用到
file_get_contents(user,r)user,'r')函式作用是將user的檔案內容寫到字串裡
這裡涉及到php偽協議(php://input)
這個是有關於php偽協議的解釋https://blog.csdn.net/qq_27682041/article/details/73326435
接下來使用我們的bp工具進行抓包
構造txt=php://input,並且post傳值welcome to the bugkuctf
在這裡插入圖片描述


我們可以看到頁面變化
在這裡插入圖片描述
接下來
include($file)還涉及到php://filter協議
這是關於php://filter協議的解釋
https://blog.csdn.net/wy_97/article/details/77432002
構造一個file=php://filter/read=convert.base64-encode/resource=hint.php
得到hint.php網頁的base64編碼後的原始碼
在這裡插入圖片描述
解密後得到
在這裡插入圖片描述
繼續同樣的方法file=php://filter/read=convert.base64-encode/resource=index.php獲取index.php網頁base64編碼後的原始碼
在這裡插入圖片描述

解密後得到
在這裡插入圖片描述

hint.php中提示flag.php,且index.php有對關鍵詞flag進行了preg_match
hint.php中定義了一個類Flag,中間有個 __tostring 方法,將這個類作為字串執行時會自動執行的一個函式
__tostring 方法執行時,將變數$file作為檔名輸出檔案內容,結合提示flag.php,猜測flag.php檔案在此開啟
在index.php原始碼中看到了$password的作用

將hint.php中的Flag當做字串執行時,會自動執行 __tostring方法,只有echo,只能輸出一個或多個字串,所以構造password為Flag型別,其中的string變數flie=flag.php

由於存在password=unserialize(password);
執行該指令碼得到

<?php class Flag{//flag.php public $file; } $a = new Flag(); $a->file = "flag.php"; $a = serialize($a); print_r($a); ?>

需要構造序列化物件payload為
O:4:“Flag”:1:{s:4:“file”;s:8:“flag.php”;}
在這裡插入圖片描述

相關推薦

BUGKU welcome to bugkuctf

這裡記錄我花了一整天才理清題目意思的題目,因為接觸CTF時間還不長,水平還停留在各個方面都稍有了解,但是涉及的知識稍微深入一些就沒有思路了,這道題目涉及了php的程式碼審計,php的偽協議,php的序列化,php魔術方法。 因為我是小白一個,所以這道題目稍微把一些細節的地方說多一點,萬一有些朋友

bugku---welcome to bugkuctf

題目 http://123.206.87.240:8006/test1/ 檢視原始碼 程式碼大概講的是 需要get傳遞三個值:txt,file,password 並且 $user的檔案內容為welcome to the bugkuctf $file為hint.

php://filter的利用 bugku welcome to the bugkuctf

題目:welcome to the bugkuctf 網頁連結 題目描述:檢視原始碼可以發現 <!-- $user = $_GET["txt"]; $file = $_GET["file"]; $pass = $_GET["password"]

welcome to bugkuctf

ber image middle gb2 寫代碼 func ech use 序列 (題目頁面) (題目源代碼) 1.讀取到的信息: a. 用_GET方式傳遞三個參數 b. user不為空,並且

CTF/CTF練習平臺-welcome to bugkuctf【php //filter及php //input】

                原題內容: http://120.24.86.145:8006/test1/ 首先b

Welcome to the Real World

efi enter div har check trac ins where const ? Welcome to the Real World Gregor Hohpe EnginEERS liKE pRECiSion, especially

Welcome to Jekyll !!!

hub des offer pri off you eat edi clu You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see y

Welcome to GitHub Pages

red sele edit having themes syn his with jekyll Welcome to GitHub Pages You can use the editor on GitHub to maintain and preview the cont

centos7開機顯示:welcome to emergency mode 的解決方法

welcome to emergencyCentOS7.3昨天用的還好好的的,但是今天開機提示如下(如圖提示):welcome to emergency mode!after logging in ,type “journalctl -xb” to view system logs,“systemctl re

HEOI2018——welcome to NOI2018

bsp 由於 輪廓線dp 輸出 揮手 丟了 ioi welcome 現狀   我不得不和烈士和小醜走在同一道路上,   萬人都要將火熄滅,   我一人獨將此火高高舉起,   我借此火得度一生的茫茫黑夜。             —&mdash

Welcome to play Threes

tetris tst corn int ready menu res yahoo car Threes Is this 2048? No, you are wrong. This is the same popular game Threes as 2048. After

Welcome To Play Leisure Breakout

ket http ask apple tor author break it! use A casual Breakout game. Use a scooter to catch basketball and eliminate sneakers. Is it very

Welcome to play my game

tun itunes imp nes auth HERE rep sequence eps Simon Fun Play Online Simon is an fun memory game.The game is simple.1.Watch sequence2.Repe

Welcome to play Fun-Sweeper

-s tps field note follow lag online play -m A classic and fun minesweeper game. Note: Long press the minefield to insert a small red flag

CentOS7.4開機出現welcome to emergency mode 機器意外啟動錯誤

ima root centos 註釋 pro 技術 entos 輸入 text 今天使用虛擬機做實驗,在系統安裝完成後,優化一些選項後,就操作了掛載ISO鏡像文件,系統啟動後如下報錯 我試想應該是掛載引起的,而且原來系統正常啟動後是進入的圖形界面。 果然,我通過mount

Elasticsearch集群上線經驗Welcome to my ELK world!

數據分析 建立索引 海量數據 全文檢索 技術分享 生產環境 後臺 目的 商品 Elasticsearch集群搭建這麽長時間了ELK我們聽得耳朵都起繭子了。但ELK我們到底掌握的了多少呢,有或者說作為運維人員你部署的ELK是否可以到線上應用呢?下面我跟大家說說我個人的此集群上

Elasticsearch集群上線經驗技術點Welcome to my ELK world!(2)

delete 裝包 hang mailto 創建 name 筆記 product 查詢 一、安裝win上的ELK(linux的和ubuntu的請參考我的另一篇文章http://blog.51cto.com/13120271/2308902)1、安裝JDK,至少1.8.0_7

linux出現welcome to emergency mode! 解決方法

CentOS7.3昨天用的還好好的的,但是今天開機提示如下(如圖提示): welcome to emergency mode!after logging in ,type “journalctl -xb” to view system logs,“systemctl reboot” to

程式設計:在螢幕中間分別顯示綠色、綠底紅色、白底藍色的字串'welcome to masm!'

assume cs:codesg , ds:datasg , ss:stacksg datasg segment db 'welcome to masm!' db 2h , 24h , 71h datasg ends stacksg segment stack

Centos7 出現Welcome to emergency mode!

做mount掛載時,修改了  /etc/fstab 檔案,導致Centos7重啟時出現如下圖所示錯誤: Welcome to emergency mode! After logging in, type "journalctl -xb" to view system logs,"syst