生活随笔
收集整理的這篇文章主要介紹了
REVERSE-PRACTICE-CthulhuOJ
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
REVERSE-PRACTICE-CthulhuOJ Cthulhu OJ-simple Cthulhu OJ-easy-VM
Cthulhu OJ-simple
exe程序,運行后提示輸入flag,無殼,用ida分析 main函數,輸入和下標異或,結果與已知的res數組比較 寫逆異或運算腳本即可得到flag
res
= [ 122 , 114 , 118 , 118 , 103 , 113 , 96 , 124 , 92 , 97 , 59 , 120 , 83 , 60 , 125 , 80 , 113 , 78 , 39 , 34 , 121 , 101 , 122 , 114 , 71 , 126 , 91 , 118 , 121 , 96 , 30 ]
flag
= [ ]
for i
in range ( 0 , 31 ) : flag
. append
( i
^ res
[ i
] )
print ( '' . join
( chr ( i
) for i
in flag
) )
Cthulhu OJ-easy-VM
elf文件,運行后輸入,無殼,ida分析 main函數邏輯清晰,讀取輸入,限制輸入的最大長度為32,將輸入傳入vm進行變換,將變換后的輸入與已知字符串進行比較,驗證輸入 進入start_vm函數,感覺由opcode決定的各種運算非常亂,幾個字節來回交換,也有異或運算,不太明白怎么寫逆vm腳本
__int64 __fastcall
start_vm ( const char * a1
, __int64 a2
)
{ __int64 result
; __int64 v3
; unsigned __int8 v4
; v3
= a2
; state
= a2
; while ( 1 ) { result
= ( unsigned __int8
) a1
[ ( unsigned __int8
) byte_5640DC557028
] ; v4
= a1
[ ( unsigned __int8
) byte_5640DC557028
] ; if ( ! v4
) break ; switch ( ( unsigned int ) off_5640DC355F50
) { case 1u : li ( a1
[ ( unsigned __int8
) byte_5640DC557028
+ 1 ] , ( unsigned __int8
) a1
[ ( unsigned __int8
) byte_5640DC557028
+ 2 ] ) ; break ; case 2u : lb ( a1
[ ( unsigned __int8
) byte_5640DC557028
+ 1 ] , ( unsigned __int8
) a1
[ ( unsigned __int8
) byte_5640DC557028
+ 2 ] ) ; break ; case 3u : sb ( a1
[ ( unsigned __int8
) byte_5640DC557028
+ 1 ] , a1
[ ( unsigned __int8
) byte_5640DC557028
+ 2 ] ) ; break ; case 4u : sub ( a1
[ ( unsigned __int8
) byte_5640DC557028
+ 1 ] , a1
[ ( unsigned __int8
) byte_5640DC557028
+ 2 ] , a1
[ ( unsigned __int8
) byte_5640DC557028
+ 3 ] ) ; break ; case 5u : xor ( a1
[ ( unsigned __int8
) byte_5640DC557028
+ 1 ] , a1
[ ( unsigned __int8
) byte_5640DC557028
+ 2 ] , a1
[ ( unsigned __int8
) byte_5640DC557028
+ 3 ] ) ; break ; case 6u : jmp ( a1
[ ( unsigned __int8
) byte_5640DC557028
+ 1 ] ) ; break ; case 7u : beq ( a1
[ ( unsigned __int8
) byte_5640DC557028
+ 1 ] , a1
[ ( unsigned __int8
) byte_5640DC557028
+ 2 ] , a1
[ ( unsigned __int8
) byte_5640DC557028
+ 3 ] ) ; break ; case 8u : call ( a1
[ ( unsigned __int8
) byte_5640DC557028
+ 1 ] ) ; break ; case 9u : ret ( ) ; break ; default : printf ( "unrecognized opcode: %#x\n" , v4
, v3
) ; break ; } byte_5640DC557028
+ = 4 ; } return result
;
}
動調,把最后要比較的字符串當作輸入,發現經過vm變換后直接得到了flag 需要注意的是,輸入的長度限制為32,已知的字符串不考慮轉義字符的話,其長度為33,所以調試的時候,輸入要把多出來的一個"\"去掉,經過vm即可得到flag
總結
以上是生活随笔 為你收集整理的REVERSE-PRACTICE-CthulhuOJ 的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網站內容還不錯,歡迎將生活随笔 推薦給好友。