计算机应用 ›› 2018, Vol. 38 ›› Issue (1): 201-206.DOI: 10.11772/j.issn.1001-9081.2017071692

• 网络空间安全 • 上一篇    下一篇

面向PHP应用程序的SQL注入行为检测

周颖1, 方勇2, 黄诚1, 刘亮2   

  1. 1. 四川大学 电子信息学院, 成都 610065;
    2. 四川大学 网络空间安全学院, 成都 610207
  • 收稿日期:2017-07-10 修回日期:2017-08-31 出版日期:2018-01-10 发布日期:2018-01-22
  • 通讯作者: 黄诚
  • 作者简介:周颖(1993-),女,四川成都人,硕士研究生,主要研究方向:Web安全、网络攻防;方勇(1966-),男,四川成都人,教授,博士,主要研究方向:信息安全、网络信息对抗;黄诚(1987-),男,重庆人,博士,主要研究方向:信息安全、网络攻防;刘亮(1982-),男,四川成都人,讲师,博士,主要研究方向:网络系统与信息安全。

Detection of SQL injection behaviors for PHP applications

ZHOU Ying1, FANG Yong2, HUANG Cheng1, LIU Liang2   

  1. 1. College of Electronic Information, Sichuan University, Chengdu Sichuan 610065, China;
    2. College of Cybersecurity, Sichuan University, Chengdu Sichuan 610207, China
  • Received:2017-07-10 Revised:2017-08-31 Online:2018-01-10 Published:2018-01-22

摘要: 层出不穷的SQL注入攻击使Web应用面临威胁。针对PHP应用程序中的SQL注入行为,提出了一种基于污点分析的SQL注入行为检测模型。首先,该模型使用PHP扩展技术在SQL函数执行时获取SQL语句,并记录攻击者所携带的身份信息;基于以上信息生成SQL请求日志,并将该日志作为分析源。然后,基于SQL语法和抽象语法树,实现了污点标记的SQL语法分析过程,并使用污点分析技术,提取语法树中SQL注入行为的多个特征。最后,使用随机森林分类算法实现SQL注入行为的判定。与正则匹配检测技术对比实验结果显示,通过该模型检测SQL注入行为,准确率为96.9%,准确率提高了7.2个百分点。该模型的信息获取模块能以扩展形式加载在任何PHP应用程序中,因此该模型可移植性强,在安全审计和攻击溯源中具有应用价值。

关键词: SQL注入, PHP扩展, 污点分析, 抽象语法树, 随机森林算法

Abstract: The SQL (Structured Query Language) injection attack is a threat to Web applications. Aiming at SQL injection behaviors in PHP (Hypertext Preprocessor) applications, a model of detecting SQL injection behaviors based on tainting technology was proposed. Firstly, an SQL statement was obtained when an SQL function was executed, and the identity information of the attacker was recorded through PHP extension technology. Based on the above information, the request log was generated and used as the analysis source. Secondly, the SQL parsing process with taint marking was achieved based on SQL grammar analysis and abstract syntax tree. By using tainting technology, multiple features which reflected SQL injection behaviors were extracted. Finally, the random forest algorithm was used to identify malicious SQL requests. The experimental results indicate that the proposed model gets a high accuracy of 96.9%, which is 7.2 percentage points higher than that of regular matching detection technology. The information acquisition module of the proposed model can be loaded in an extended form in any PHP application; therefore, it is transplantable and applicable in security audit and attack traceability.

Key words: SQL (Structured Query Language) injection, PHP (Hypertext Preprocessor) extension, tainting analysis, abstract syntax tree, random forest algorithm

中图分类号: