当python遇到authentication

当python遇到authentication

编写参考Basic Authentication authentication with python:
http://www.voidspace.org.uk/python/articles/authentication.shtml

  • 扫描tomcat弱口令——遇到Basic Authentication

tomcat登录验证

这里写图片描述
如果tomcat开启了后台管理,访问ip+/manager/html时会弹出验证框

截包分析

1.截包证明tomcat的登录验证是针对HTTP中的authentication项进行的

2.并且authentication项又进行了basic项加密

部分实现代码

basic编码:

import base64 as bs
"""
对指定字符串编码
"""
def b64encode_str(str_):
    return bs.b64encode(str_)
"""
对指定字符串解码
"""
def b64decode_str(str_):
    return bs.b64decode(str_)'''

在HTTP请求中加入Authorization

theurl="http://XXXX.com/manager/html"
username=xxx
password=xxx
req = urllib2.Request(theurl)
base64string = base64.encodestring(
                '%s:%s' % (username, password))[:-1]
authheader =  "Basic %s" % base64string
req.add_header("Authorization", authheader)

源码下载地址
http://cl0wn.sinaapp.com/tomcat_scan.py
http://pan.baidu.com/s/1sjkbLoT

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值