Get the App
SLTechnology News&Howtos  ›  Network Security  › 

How to implement Code Audit with python

Shulou Source: shulou.com Published: 2022-06-01 00:29:32 11月24日 Update

This article is about how python implements code auditing. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Python Code Audit-Command execution vulnerability (self-written code) 0x00 source code def execute (request): context = {} ip= request.POST.get ("ip") username= request.POST.get ("username") password= request.POST.get ("password") idnex= int (request.POST.get ("index")) current_time=request.POST.get ("time") context = {"ip": ip, "username": username, "password": password "result": False} ippattern= "(25 [0-5] | 2 [0-4]\ d | [0-1]\ d {2} | [1-9]?\ d)\. (25 [0-5] | 2 [0-4]\ d | [0-1]\ d | [1-9]?\ d)\. (25 [0-5] | 2 [0-4]\ d | [0-1]\ d {2} | [1-9]?\ d)\ . (25 [0-5] | 2 [0-4]\ d | [0-1]\ d {2} | [1-9]?\ d) "if (re.match (ippattern) Ip): pass else: context ['error'] = "ip incorrectly formatted" log ("error", "[-]% s ip is error"% (ip)) print ("[-]% s ip malformed"% (ip)) # return render (request,' test.html', context) return HttpResponse (json.dumps (context)) try: length Scripts=executeScript.getScriptNums () if (idnex > length or idnex)

Tags: Code command audit format loophole input content beginning more article index script error good legal practical function foreground cause analysis Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information Linux Redmi Shulou Technology