您的位置 首页 php

Python 之 MySql“未解之谜”16 — sql 注入的风险

Python 之 MySql“未解之谜”16 -- sql 注入的风险

Python 之 MySql“未解之谜”16 -- sql 注入的风险


一、 Python 使用 Mysql

1、Python 代码:

Python 之 MySql“未解之谜”16 -- sql 注入的风险

2、Python 输出结果:

Python 之 MySql“未解之谜”16 -- sql 注入的风险

3、分析

① 当用户名和密码正确时,发现可以正常打印字段数据

Python 之 MySql“未解之谜”16 -- sql 注入的风险

② 当用户名或密码错误时,输出“账号或密码错误”

Python 之 MySql“未解之谜”16 -- sql 注入的风险

③ 当用户名输入”python’ — Python大星到此一游”,密码为空,仍然可以正常打印数据

Python 之 MySql“未解之谜”16 -- sql 注入的风险

④ 当用户名输入”****’ or 1 = 1 — Python大星到此一游” 密码为空,打印了所有用户信息

Python 之 MySql“未解之谜”16 -- sql 注入的风险

其中第 ③ 和 ④ 条就是由于 加上 — 注释 ,sql 注入导致的

4、优化

execute可以自动识别sql语句中的 %s ,它可以帮助你过滤特殊的字符,避免 sql注入 的问题

Python 之 MySql“未解之谜”16 -- sql 注入的风险

Python 之 MySql“未解之谜”16 -- sql 注入的风险

输出结果


二、如何防止 sql 注入

1、永远不要信任用户的输入

对用户的输入进行校验,可以通过正则表达式,或限制长度;对单引号和 双 ‘-‘ 进行转换等。

2、 永远不要使用动态拼装 sql

可以使用参数化的 sql 或者直接使用存储过程进行数据查询存取

3、永远不要使用管理员权限的数据库连接,为每个应用使用单独的权限有限的数据库连接

4、不要把机密信息直接存放

加密或者 hash 掉密码和敏感的信息

5、应用的异常信息应该给出尽可能少的提示

最好使用自定义的错误信息对原始错误信息进行包装


>>>

文章来源:智云一二三科技

文章标题:Python 之 MySql“未解之谜”16 — sql 注入的风险

文章地址:https://www.zhihuclub.com/78646.shtml

关于作者: 智云科技

热门文章

评论已关闭

33条评论

  1. Can I get treatment if I haven t been diagnosed with hyperhidrosis by a doctor before

  2. But, light spotting and mild cramps could also be signs that implantation has occurred.

  3. If you re younger than 35, it s perfectly normal for it to take six months to a year to conceive.

  4. In contrast, increased TDM1 efficacy occurs in vitro after enhancing CAV1 expression by metformin 20.

  5. Security forces clamped down on the demonstration, and health officials say 149 people were killed in the ensuing violence First, it may reflect differences in the cell lines used

  6. Time magazine named Xingchen Technology as the most influential company of the year, and also unceremoniously satirized the Steel Straight how to last longer in bed men health Boys

  7. However, next generation SERMs have not replaced tamoxifen for treatment of breast cancer due to decades of safety data on tamoxifen, and we would argue lack of a targeted resistance allele for newly presenting patient stratification

  8. Overall, there was no association between weight change categories and recurrence risk LogRank p 0

  9. 4 LVIDs LVIDs 3, FS 100 LVIDd LVIDs LVIDd, EF 100 LV vol d LV vol s LV vol d, and corrected LV mass 0

  10. On the other hand, drinking coffee, especially unfiltered coffee such as espresso, can raise cholesterol levels

  11. Here, we used highly curated data obtained from validated in vitro U van Leeuwen FE, Benraadt J, Coebergh JWW, Kiemeney LALM, GimbrГЁre CHF, Otter R, Schouten LJ, Damhuis RAM, Bontenbal M, Diepenhorst FW, van den Belt Dusebout AW, van Tintere H Risk of endometrial cancer after tamoxifen treatment of breast cancer

  12. Awareness of these findings may prevent misinterpretation The patient s EEG and brain imaging studies were reported as normal

  13. 2A 2D show validation results of the prognostic model frozen samples in the discovery dataset

  14. We hypothesized that combining ERОІ agonists with an ERО± antagonist would increase their activity and eliminate their stimulatory effects at low concentrations First, if you are diagnosed with a high risk marker lesion in your breast, you should be undergoing increased surveillance just like Rita was, meaning adding MRIs and often ultrasounds to the mammogram every year

  15. After all exclusions, 111 patients were included for evaluation, with a total of 635 endometrial biopsies, all performed in the office by Dr

  16. Recent position statements call for novel means for diagnosis, risk assessment, and particularly therapy for patients affected by high prevalence, high morbidity, high cost conditions such as HF

  17. More people shouted, obviously all the members of the Skeleton Race had identified the hostile relationship with the Demon Race Dense tissue blocks x rays and therefore shows up as white on a mammogram

  18. Others veered away from the docket to address whether military and intelligence agents were spying on supposedly confidential attorney client discussions, an issue that is still unresolved

  19. Treatments directly aimed at DTC by critical cell survival and proliferation pathways e Use in Premenopausal Women Advise patients that exemestane is not for use for the treatment of breast cancer in premenopausal women see Warnings and Precautions 5

  20. The process occurs when an endogenous ribonuclease cleaves the longer dsRNA into shorter, 21 or 22 nucleotide long RNAs, termed small interfering RNAs or siRNAs Int J Cancer 127 1021 7, 2010

网站地图