파이썬 오픈소스 오류 질문입니다

조회수 444회

import requests,sys,time,os, argparse

def main(): os.system(clear)

parser = argparse.ArgumentParser()

parser.add_argument('-d', help='path to file of domain list', nargs=1, dest='domain', required=True)
parser.add_argument('-w', help='payload wordlist', nargs=1, dest='payload', required=True)

args = parser.parse_args()


file = args.domain[0]

payloads = args.payload[0]


with open(file) as f:

    print ("test")
    time.sleep(4)


    for line in f:
        with open(payloads) as p:
            for payload in p:
                try:
                    line2 = line.strip()

                    line3 = ('https://') + line2 + payload

                    print (line3)

                    response = requests.get(line3, verify=True)

                    print (response)
                    try:
                        if response.history:

                            print ("It has been was redirected")

                            for resp in response.history:

                                print ("|")

                                print (resp.status_code, resp.url)

                                print ("Final destination:")

                                print ("+")

                                print (response.status_code, response.url)

                            else:
                                print ("Request was not redirected")
                    except:
                                print ("Error")
                    except:

                        print ("Exit")
                    try:
                            main()

                    except IndexError:
                        print(" Usage: python "+sys.argv[0]+" [subdomains.file] [redirect.payload]\n")
                        print(" Example python "+sys.argv[0]+"uber.list '//yahoo.com/%2F..'\n")

코드는 이거인데 오류로 unexpected EOF while parsing 라는 오류가 나옵니다. 해결방법이 있나요??

  • (•́ ✖ •̀)
    알 수 없는 사용자

1 답변

  • import requests,sys,time,os, argparse
    
    def main():
        os.system('clear')
    
        parser = argparse.ArgumentParser()
        parser.add_argument('-d', help='path to file of domain list', nargs=1, dest='domain', required=True)
        parser.add_argument('-w', help='payload wordlist', nargs=1, dest='payload', required=True)
    
        args = parser.parse_args()
        file = args.domain[0]
        payloads = args.payload[0]
        with open(file) as f:
            print ("test")
            time.sleep(4)
            for line in f:
                with open(payloads) as p:
                    for payload in p:
                        try:
                            line2 = line.strip()
                            line3 = ('https://') + line2 + payload
                            print (line3)
                            response = requests.get(line3, verify=True)
                            print (response)
                            try:
                                if response.history:
                                    print ("It has been was redirected")
                                    for resp in response.history:
                                        print ("|")
                                        print (resp.status_code, resp.url)
                                        print ("Final destination:")
                                        print ("+")
                                        print (response.status_code, response.url)
                                    else:
                                        print ("Request was not redirected")
                            except:
                                        print ("Error")
                        except:
                            print ("Exit")
    try:
        main()
    except IndexError:
        print(" Usage: python "+sys.argv[0]+" [subdomains.file] [redirect.payload]\n")
        print(" Example python "+sys.argv[0]+"uber.list '//yahoo.com/%2F..'\n")
    

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)