1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import requests
    
def main():
    id = input("id 입력 : ")
    pw = input("pw 입력 : ")
 
    #로그인 세션 받기
    cookie = login(id, pw)
 
    query = 'http://webhacking.kr/challenge/codeing/code5.html?hit={0}'.format(id)
 
    for i in range(1,100):
        try:
            # 쿼리를 날린다.
            result = requests.get(query, cookies=cookie)
 
            # 응답 결과가 200인지 확인
            if result.text.find("200"!= -1:
                print("Error !")
 
            # 응답 결과가 200일 때 10번 째 쿼리마다 출력을 해줌
            else:
                if(i % 10 == 0):
                    print("{0} 번째 쿼리 전송 !".format(i))
        except:
            print("Error !")
            exit()
 
 
    print("Complete !")
 
def login(id, pw):
    form = {'id':id,'pw':pw}
    print(form)
 
    # post 로 로그인
    result = requests.post('http://webhacking.kr', data=form)
 
    # 로그인 실패 시에 나오는 특정 문자열을 검색
    if(result.text.find("==========================================="!= -1):
        print("Login Fail !")
        exit()
 
    # 로그인 성공 시 cookies 를 반환
    else:
        cookie = result.headers.get('set-cookie')
        print('id : '+form['id']+'\tLogin Success !');
        max = cookie.index('=',0)
 
        # 세션이름 : 세션값 의 형태로 cookies 에 저장
        cookies = {cookie[0:max]:cookie[max+1:]}
        return cookies
 
if __name__ == "__main__":
    main()
 
 
 
cs


'Programing > Example_Code' 카테고리의 다른 글

320 악성코드  (0) 2015.11.20
MultiPort Listening Tool .. for Webhacking.kr - 31번 ( C )  (0) 2015.11.18
k4n3 Keygen  (0) 2015.10.31
Reversing.kr - Easy KeygenMe  (0) 2015.10.31
Zip Password Cracker ( Webhacking.kr 42번 문제용 )  (0) 2015.09.22

+ Recent posts