浮點數(shù)比較分支的混淆方法研究
doi: 10.11999/JEIT190743
-
信息工程大學(xué) 鄭州 450002
An Branch Obfuscation Research on Path Branch Which Formed by Floating-point Comparison
-
Information Engineering University, Zhengzhou 450002, China
-
摘要:
針對當(dāng)前分支混淆方法僅對整數(shù)比較分支有效的缺陷,該文分析浮點數(shù)二進(jìn)制表示與大小比較的關(guān)系,證明了浮點數(shù)二進(jìn)制區(qū)間的前綴集合與浮點數(shù)區(qū)間內(nèi)數(shù)據(jù)之間具有前綴匹配關(guān)系。使用哈希函數(shù)對前綴集合進(jìn)行保護(hù),利用哈希函數(shù)的單向性實現(xiàn)對抗符號執(zhí)行,通過哈希值比對替換浮點數(shù)比較,提出一種基于前綴哈希值比較的分支條件混淆技術(shù),實現(xiàn)了一種在符號執(zhí)行對抗和混淆還原對抗上具有較強對抗性的混淆方法。最后,通過實驗證和分析,證實了該文提出的混淆方法有消耗小、能夠有效對抗符號執(zhí)行和混淆還原的優(yōu)點,具備較好的實用性。
-
關(guān)鍵詞:
- 分支混淆 /
- 浮點數(shù)比較 /
- 前綴算法 /
- 符號執(zhí)行
Abstract:For the faultiness that the recent branch obfuscation method is only efficient on branch condition formed by integer comparison. The relations between the binary representation and big or small comparison of floats are analyzed. The idea that the floats in float interval has prefix matching relation with the prefix set which comes from the binary representation interval of the floats is proved. By protecting the prefix set with Hash function, and based on the comparison of prefix-Hash, a new branch obfuscation method which works well on the branch formed by float number comparison is proposed. The new obfuscation method is powerful on symbolic execution combating and obfuscation recovery combating. At last, the obfuscation proposed in this paper is confirmed to be practical, and is useful to be against symbolic execution and obfuscation recovery.
-
Key words:
- Branch obfuscation /
- Float number comparison /
- Prefix algorithm /
- Symbolic execution
-
算法1 前綴算法 輸入:a1a2···an//起始值a的二進(jìn)制表示 b1b2···bn//結(jié)束值b的二進(jìn)制表示 輸出:PrefixSet//區(qū)間的前綴集合 PrefixSet Get_Prefix(a1a2···an,b1b2···bn) { for (int k=1; (k<=n) && (ak==bk); k++) { if (k==(n+1)) return { a1a2···an}; } if ((akak+1···an == 00···0) && (bkbk+1···bn == 11···1)) { if (k== 1) return {*}; else return {a1a2···ak-1}; } PrefixSet1 = Get_Prefix(ak+1ak+2···an, 11···1); PrefixSet2 = Get_Prefix(00···0, bk+1bk+2···bn); Return {a1a2···ak-10+PrefixSet1, a1a2···ak-11+PrefixSet2}; } 下載: 導(dǎo)出CSV
算法2:isMatch(x, HS) //判斷輸入為x時,分支條件的取值,算
法返回值為true或者false輸入:浮點數(shù)x,浮點數(shù)區(qū)間[a, b]對應(yīng)二進(jìn)制前綴集合的sha1集
合HS1和HS2輸出:x是否屬于浮點數(shù)區(qū)間[a,b] bool isMatch(x,HS1,HS2) { char tmp[32] = {‘*’,‘*’,···,‘*’}; int Ix= *((int *)&x); char sha1out[32][24]; char sign = (Ix>>(31-i))&1; tmp[0] = sign; for(int i=1; i<32; i++){ tmp[i]=(Ix>>(31-i))&1; sha1out[i]=sha1(tmp,32); char sign = tmp[0]; if(sign == 0) {for(int j=0; j<hashNumofHS1;j++) { if(sha1out[i]==HS1[j]) return true; } } else if(sign == 1) {for(int j=0; j<hashNumofHS2;j++) { if(sha1out[i]==HS2[j]) return true; } } } return false;} 下載: 導(dǎo)出CSV
表 1 單分支混淆的消耗數(shù)據(jù)表
分支條件 空間消耗(Byte) 時間消耗(ms) 解密后前綴數(shù)據(jù)空間 Sha1算法代碼空間 isMatch算法代碼空間 if(1.0≤x ≤10.0)混淆后變?yōu)椋篿f(isMatch(x, HS1)) 4×20=80 2684 468 0.033 if((x ≤1.0)||((y>10.0)&&(1.0≤z ≤10.0))) 混淆后變?yōu)椋篿f(isMatch(x,HS2)||(isMatch (y,HS3) && isMatch(z,HS4))) (9+8+4)×20=440 2684 468 0.102 注釋:(1) 空間消耗中,只有前綴數(shù)據(jù)占用空間是每個分支混淆需要獨占的,其余空間是所有分支混淆共享的空間。(2) HS1, HS2, HS3和HS4表示前綴數(shù)據(jù)的哈希值集合。 下載: 導(dǎo)出CSV
表 2 分支混淆前后程序占用空間和執(zhí)行時間數(shù)據(jù)表
混淆前的數(shù)據(jù)處理程序 混淆后的數(shù)據(jù)處理程序 占用空間(Byte) 37376 41472 執(zhí)行時間(ms) 2 35.6 被混淆分支數(shù)(個) 1 分支執(zhí)行次數(shù)(次) 1000 下載: 導(dǎo)出CSV
表 3 混淆方法執(zhí)行效率比較
混淆方法 單分支單次執(zhí)行平均時間消耗(ms) 單分支混淆空間消耗(Byte) 實驗主機 分支類型 本文方法 0.033 4×103 CPU為Intel I5的主機 浮點數(shù)比較 王志方法 0.031 4×103 CPU為Intel I5的主機 整數(shù)大小比較 王志方法 (11312-1442.7)/(3×10000)=0.329 4×103 CPU為Intel Core2 Q9400的主機 整數(shù)大小比較 陳喆方法 220 9.8×104 CPU為Intel Core2 Q9400的主機 整數(shù)大小比較 Ma方法 750 7×103 CPU為Intel Core2 Q9400的主機 整數(shù)大小比較 下載: 導(dǎo)出CSV
表 4 混淆分支的符號執(zhí)行測試結(jié)果
利用符號執(zhí)行的程序分析工具 執(zhí)行時間(min) 結(jié)果 Angr 80 求解出使得isMatch返回值為真的分支輸入值的解個數(shù)為0 KLEE 360 共執(zhí)行593906條指令和 118個分支執(zhí)行,但求解出使得isMatch返回值為真的分支輸入值的解個數(shù)為0 下載: 導(dǎo)出CSV
-
Software Management: Security imperative, business opportunity —2018 BSA global software survey. Washington[OL]. https://ww2.bsa.org/-/media/Files/StudiesDownload/2018_BSA_GSS_Report_cn.pdf. 2018. 梁光輝, 龐建民, 單征. 基于代碼進(jìn)化的惡意代碼沙箱規(guī)避檢測技術(shù)研究[J]. 電子與信息學(xué)報, 2019, 41(2): 341–347. doi: 10.11999/JEIT180257LIANG Guanghu, PANG Jianmin, and SHAN Zheng. Malware sandbox evasion detection based on code evolution[J]. Journal of Electronics &Information Technology, 2019, 41(2): 341–347. doi: 10.11999/JEIT180257 COLLBERG C, THOMBORSON C, and LOW D. A taxonomy of obfuscating transformations[R]. Technical Report 148, 1997. 張躍軍, 潘釗, 汪鵬君, 等. 基于狀態(tài)映射的AES算法硬件混淆設(shè)計[J]. 電子與信息學(xué)報, 2018, 40(3): 750–757. doi: 10.11999/JEIT170556ZHANG Yuejun, PAN Zhao, WANG Pengjun, et al. Design of hardware obfuscation AES based on state deflection strategy[J]. Journal of Electronics &Information Technology, 2018, 40(3): 750–757. doi: 10.11999/JEIT170556 POPOV I V, DEBRAY S K, and ANDREWS G R. Binary obfuscation using signals[C]. The 16th USENIX Security Symposium, Boston, USA, 2007: 275–290. 賈春福, 王志, 劉昕, 等. 路徑模糊: 一種有效抵抗符號執(zhí)行的二進(jìn)制混淆技術(shù)[J]. 計算機研究與發(fā)展, 2011, 48(11): 2111–2119.JIA Chunfu, WANG Zhi, LIU Xin, et al. Branch obfuscation: An efficient binary code obfuscation to impede symbolic execution[J]. Journal of Computer Research and Development, 2011, 48(11): 2111–2119. SHARIF M, LANZI A, GIFFIN J, et al. Impeding malware analysis using conditional code obfuscation[C]. Network and Distributed System Security Symposium, San Diego, USA, 2008: 321–333. WANG Zhi, MING Jiang, JIA Chunfu, et al. Linear obfuscation to combat symbolic execution[C]. The 16th European Symposium on Research in Computer Security, Leuven, Belgium, 2011: 210–226. doi: 10.1007/978-3-642-23822-2_12. ZONG Nan and JIA Chunfu. Branch obfuscation using "Black Boxes"[C]. 2014 Theoretical Aspects of Software Engineering Conference, Changsha, China, 2014: 114–121. doi: 10.1109/TASE.2014.19. MA Haoyu, MA Xinjie, LIU Weijie, et al. Control flow obfuscation using neural network to fight concolic testing[C]. The 10th International Conference on Security and Privacy in Communication Networks, Beijing, China, 2014: 287–304. 王志, 賈春福, 劉偉杰, 等. 一種抵抗符號執(zhí)行的路徑分支混淆技術(shù)[J]. 電子學(xué)報, 2015, 43(5): 870–878. doi: 10.3969/j.issn.0372-2112.2015.05.006WANG Zhi, JIA Chunfu, LIU Weijie, et al. Branch obfuscation to combat symbolic execution[J]. Acta Electronica Sinica, 2015, 43(5): 870–878. doi: 10.3969/j.issn.0372-2112.2015.05.006 陳喆, 王志, 王曉初, 等. 基于代碼移動的二進(jìn)制程序控制流混淆方法[J]. 計算機研究與發(fā)展, 2015, 52(8): 1902–1909. doi: 10.7544/issn1000-1239.2015.20140607CHEN Zhe, WANG Zhi, WANG Xiaochu, et al. Using code mobility to obfuscate control flow in binary codes[J]. Journal of Computer Research and Development, 2015, 52(8): 1902–1909. doi: 10.7544/issn1000-1239.2015.20140607 陳喆, 賈春福, 宗楠, 等. 隨機森林在程序分支混淆中的應(yīng)用[J]. 電子學(xué)報, 2018, 46(10): 2458–2466. doi: 10.3969/j.issn.0372-2112.2018.10.020CHEN Zhe, JIA Chunfu, ZONG Nan, et al. Branch obfuscation using random forest[J]. Acta Electronica Sinica, 2018, 46(10): 2458–2466. doi: 10.3969/j.issn.0372-2112.2018.10.020 KING J C. Symbolic execution and program testing[J]. Communications of the ACM, 1976, 19(7): 385–394. doi: 10.1145/360248.360252 崔寶江, 梁曉兵, 王禹, 等. 基于回溯與引導(dǎo)的關(guān)鍵代碼區(qū)域覆蓋的二進(jìn)制程序測試技術(shù)研究[J]. 電子與信息學(xué)報, 2012, 34(1): 108–114. doi: 10.3724/SP.J.1146.2011.00532CUI Baojiang, LIANG Xiaobing, WANG Yu, et al. The study of binary program test techniques based on backtracking and leading for covering key code area[J]. Journal of Electronics &Information Technology, 2012, 34(1): 108–114. doi: 10.3724/SP.J.1146.2011.00532 BANESCU S, COLLBERG C, GANESH V, et al. Code obfuscation against symbolic execution attacks[C]. The 32nd Annual Conference on Computer Security Applications, Los Angeles, USA, 2016: 189–200. doi: 10.1145/2991079.2991114. BANESCU S, COLLBERG C, and PRETSCHNER A. Predicting the resilience of obfuscated code against symbolic execution attacks via machine learning[C]. The 26th USENIX Security Symposium, Vancouver, Canada, 2017: 661–678. FAN Jinliang, XU Jun, AMMAR M H, et al. Prefix-preserving IP address anonymization: measurement-based security evaluation and a new cryptography-based scheme[J]. Computer Networks, 2004, 46(2): 253–272. doi: 10.1016/j.comnet.2004.03.033 魏凌波, 馮曉兵, 張馳, 等. 基于前綴保持加密的網(wǎng)絡(luò)功能外包系統(tǒng)[J]. 通信學(xué)報, 2018, 39(4): 159–166. doi: 10.11959/j.issn.1000-436x.2018057WEI Lingbo, FENG Xiaobing, ZHANG Chi, et al. Network function outsourcing system based on prefix-preserving encryption[J]. Journal on Communications, 2018, 39(4): 159–166. doi: 10.11959/j.issn.1000-436x.2018057 -